|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--waba.ui.Control
|
+--waba.ui.Container
|
+--waba.ui.Grid
This is a common grid component. The features are:
Rect r = getClientRect();
String []gridCaptions = {" WPT "," HDG "," DST "," ETE "," FUEL "};
int gridWidths[] =
{
fm.getTextWidth(" ABCDE "),
fm.getTextWidth(" 000 "),
fm.getTextWidth(" 999.9 "),
fm.getTextWidth(" 99:99 "),
fm.getTextWidth(" 99.9 "),
};
int gridAligns[] = { LEFT, CENTER, RIGHT, CENTER, RIGHT };
grid = new Grid(gridCaptions, gridWidths, gridAligns, false);
add(grid);
grid.setRect(LEFT+3,TOP+3,r.width/2,r.height/2);
grid.secondStripeColor = new Color(235,235,235);
String[][] data = new String[][]
{
{"0AAAA","000","000.0","00:00","00.0"},
{"1BBBB","111","111.1","11:11","11.1"},
{"2CCCC","222","222.2","22:22","22.2"},
{"3DDDD","333","333.3","33:33","33.3"},
{"4EEEE","444","444.4","44:44","44.4"},
{"5FFFF","555","555.5","55:55","55.5"},
};
grid.setItems(data);
This will create a grid with the given captions, column widths, information alignment
and a check column.
Don't forget to take a look at superwaba.samples.ui.grid.GridTest.
Starting in version 5.7, it is possible to assign a DataSource to a Grid.
| Inner Class Summary | |
static class |
Grid.CellController
Abstract class that must be implemented if you want to get a fine control of each cell in the grid. |
static interface |
Grid.DataSource
Interface that can be used to fetch data on demmand. |
| Field Summary | |
static int |
ALL_CHECKED
When the user clicks on the header check to check all, a CHECK_CHANGED_EVENT is dispatched, and the row is set as ALL_CHECKED. |
static int |
ALL_UNCHECKED
When the user clicks on the header check, to uncheck all, a CHECK_CHANGED_EVENT is dispatched, and the row is set as ALL_UNCHECKED. |
boolean |
boldCheck
Set it to true to draw a bold check |
boolean |
canClickSelectAll
Set to false to disable the click on the check column of the captions to select all and unselect all |
java.lang.String[] |
captions
The column captions. |
Color |
captionsBackColor
Sets the captions box background color. |
Color |
checkColor
Default check color |
boolean |
disableSort
Set to true to disable sorting when clicking in the column header. |
boolean |
drawCheckBox
Set this to false if you dont want the check column to have the rect underneath the check mark |
boolean |
drawStripes
Set to false to don't draw the stripes |
boolean |
enableColumnResize
Set this to false if you dont want to let the user resize the columns |
int |
extraHorizScrollButtonHeight
The extra height of the horizontal scroll buttons. |
Color |
firstStripeColor
first stripe color. |
Color |
highlightColor
The color of the selected (highlighted) row |
protected int |
linesPerPage
How many lines fits in a page |
java.lang.String |
oldCellText
The text that was in the cell before the user had editted it. |
Color |
secondStripeColor
second stripe color. |
protected int |
selectedLine
The current selected line, or -1 if none. |
ToolTip |
tip
The tooltip used to display a column's text when it exceeds the column width |
static int |
VERT_DOT
used in the property verticalLineStyle |
static int |
VERT_LINE
used in the property verticalLineStyle |
static int |
VERT_NONE
used in the property verticalLineStyle |
int |
verticalLineStyle
Sets the vertical line style of the grid. |
| Fields inherited from class waba.ui.Container |
BORDER_LOWERED,
BORDER_NONE,
BORDER_RAISED,
BORDER_SIMPLE,
children,
lastH,
lastW,
lastX,
lastY,
parentWindow,
started,
tabOrder,
tail |
| Fields inherited from class waba.ui.Control |
AFTER,
appId,
appObj,
asContainer,
asWindow,
backColor,
backDis,
BEFORE,
BOTTOM,
CENTER,
clearValueInt,
clearValueStr,
enabled,
FILL,
FIT,
fm,
fmH,
focusLess,
focusTraversable,
font,
foreColor,
foreDis,
height,
highlightRectsCount,
isHighlighting,
LEFT,
parent,
PREFERRED,
RANGE,
RIGHT,
SAME,
TOP,
uiCE,
uiFlat,
uiPalm,
uiVista,
visible,
width,
x,
x2,
y,
y2 |
| Constructor Summary | |
Grid(java.lang.String[] captions,
boolean checkEnabled)
This will create a grid with the given captions and an optional multi-selection check column so that the user can select multiple lines of the grid. |
|
Grid(java.lang.String[] captions,
int[] widths,
int[] aligns,
boolean checkEnabled)
This will create a grid with the given captions, column widths, information alignment and an optional multi-selection check column so that the user can select multiple lines of the grid |
|
| Method Summary | |
void |
add(java.lang.String[] item)
Add a new line to the end of the grid. |
void |
add(java.lang.String[] item,
int row)
Add a new line at the given index position of the grid. |
void |
clear()
Clears the grid contents, leaving it blank. |
boolean |
del(int row)
Remove the given line index from the grid. |
java.lang.String |
getCellText(int row,
int col)
Returns the text's column of the given row number. |
java.lang.String |
getColumnText(int row,
int col)
Deprecated. Use getCellText instead. |
java.lang.String[] |
getItem(int row)
Returns the line corresponding to the given index. |
Vector |
getItemsVector()
Return a vector containing all information inside the grid. |
int |
getPreferredHeight()
Returns the preffered height of this control. |
int |
getPreferredWidth()
Returns the preffered width of this control. |
java.lang.String[] |
getSelectedItem()
Get the information on the currently selected line. |
int |
getSelectedLine()
Deprecated. Use getSelectedRow instead. |
int |
getSelectedRow()
Get the number of the currently selected row. |
boolean |
horizontalScroll(boolean toLeft)
Scrolls the grid horizontaly as needed |
boolean |
isChecked(int row)
Check if a given lineIndex is checked |
protected void |
onBoundsChanged()
Called after a setRect. |
protected void |
onColorsChanged(boolean colorsChanged)
Called after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container. |
void |
onEvent(Event e)
Called to process key, pen, control and other posted events. |
protected void |
onFontChanged()
Called after a setFont |
void |
onPaint(Graphics g)
Draws the border (if any). |
protected void |
onStart()
Called when this container can be initialized. |
void |
qsort(int col)
Performs a quicksort in the items of the given column. |
void |
replace(java.lang.String[] item,
int row)
Replace a given line by the specified by its index with the supplied one. |
void |
setCellController(Grid.CellController cc)
Sets the CellController instance for this grid. |
void |
setCellText(int row,
int col,
java.lang.String text)
Sets the text of a column. |
void |
setChecked(int row,
boolean check)
Checks or unchecks the given index based on the second argument. |
void |
setColumnChoices(int col,
java.lang.String[] choices)
Makes the given column ComboBox-like. |
Edit |
setColumnEditable(int col,
boolean editable)
Sets the given column as an editable one. |
void |
setColumnText(int row,
int col,
java.lang.String text)
Deprecated. Use setCellText instead. |
void |
setDataSource(Grid.DataSource ds,
int nrItems)
Sets the data source of this grid to be the given one. |
void |
setItems(java.lang.String[][] items)
Sets the grid items to be displayed, notice that it needs to be conforming to the numbers of columns that the grid currently have. |
void |
setSelectedLine(int row)
Deprecated. Use setSelectedRow instead. |
void |
setSelectedRow(int row)
Sets the selected line to the given one. |
int |
size()
Returns the number of lines in this grid |
| Methods inherited from class waba.ui.Container |
add,
add,
add,
broadcastEvent,
findChild,
getChildren,
getClientRect,
getClientRect,
onAdd,
onRemove,
paintChildren,
remove,
setBorderStyle,
setEnabled,
setHighlighting,
swapToTopmostWindow |
| Methods inherited from class waba.ui.Control |
addTimer,
changeHighlighted,
contains,
createGraphics,
drawHighlight,
getAbsoluteRect,
getBackColor,
getFont,
getFontMetrics,
getForeColor,
getNext,
getParent,
getParentWindow,
getPos,
getRect,
getSize,
isDisplayed,
isEnabled,
isVisible,
onWindowPaintFinished,
postEvent,
removeTimer,
repaint,
repaintNow,
requestFocus,
setBackColor,
setBackForeColors,
setFocusLess,
setFont,
setForeColor,
setRect,
setRect,
setRect,
setVisible,
translateFromOrigin,
uiStyleChanged |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
public static final int VERT_LINE
public static final int VERT_DOT
public static final int VERT_NONE
public static final int ALL_CHECKED
public static final int ALL_UNCHECKED
public boolean drawCheckBox
public Color checkColor
public boolean disableSort
public boolean enableColumnResize
public java.lang.String[] captions
setWidths
method.public boolean drawStripes
public Color firstStripeColor
public Color secondStripeColor
public Color highlightColor
public Color captionsBackColor
public int verticalLineStyle
protected int selectedLine
protected int linesPerPage
public java.lang.String oldCellText
public boolean canClickSelectAll
public boolean boldCheck
public ToolTip tip
public int extraHorizScrollButtonHeight
| Constructor Detail |
public Grid(java.lang.String[] captions,
int[] widths,
int[] aligns,
boolean checkEnabled)
captions - Captions for the columns. Cannot be null!widths - Widths of the columns. If the total width is less than the grid's width,
the last column will fill until the grid width. If null, the caption widths
will be computed and used as the row width.aligns - Alignment of information on the given column. If null, all aligns will be LEFT.checkEnabled - True if you want the multi-selection check column, false otherwise
public Grid(java.lang.String[] captions,
boolean checkEnabled)
captions - Captions for the columnscheckEnabled - True if you want the multi-selection check column, false otherwise| Method Detail |
public void setCellController(Grid.CellController cc)
public Edit setColumnEditable(int col,
boolean editable)
public void setColumnChoices(int col,
java.lang.String[] choices)
setCellController(waba.ui.Grid.CellController)protected void onFontChanged()
public void setItems(java.lang.String[][] items)
public void setDataSource(Grid.DataSource ds,
int nrItems)
public void add(java.lang.String[] item)
item - string containing the information on the row
public void add(java.lang.String[] item,
int row)
item - string containing the information on the rowrow - index position to insert the row in
public void replace(java.lang.String[] item,
int row)
item - string containing the information of the new linerow - index position to insert the row inpublic boolean del(int row)
public java.lang.String getColumnText(int row,
int col)
public java.lang.String getCellText(int row,
int col)
public java.lang.String[] getSelectedItem()
public int getSelectedLine()
public int getSelectedRow()
public void setChecked(int row,
boolean check)
public boolean isChecked(int row)
public Vector getItemsVector()
public java.lang.String[] getItem(int row)
protected void onColorsChanged(boolean colorsChanged)
public void onPaint(Graphics g)
super.onPaint(g);, or the border will not be drawn.g - the graphics object for drawingGraphicsprotected void onStart()
public int getPreferredWidth()
public int getPreferredHeight()
protected void onBoundsChanged()
public void clear()
public boolean horizontalScroll(boolean toLeft)
public void setColumnText(int row,
int col,
java.lang.String text)
public void setCellText(int row,
int col,
java.lang.String text)
public void onEvent(Event e)
event - the event to processEvent,
KeyEvent,
PenEventpublic void qsort(int col)
public void setSelectedLine(int row)
public void setSelectedRow(int row)
public int size()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||