ewe.ui
Class IconTableModel

java.lang.Object
  extended byewe.ui.TableModel
      extended byewe.ui.IconTableModel
All Implemented Interfaces:
CellConstants, ControlConstants, EventListener, UIConstants

public class IconTableModel
extends TableModel

This is a table model that displays an icon with associated text below it. The display is actually treated as a list that scrolls either vertically or horizontally. All you need to do is set the minHeight/minWidth values and then override getIconCount(), getIconText() and getIconImage().


Nested Class Summary
 
Nested classes inherited from class ewe.ui.TableModel
TableModel.CellControl, TableModel.ControlProxy
 
Field Summary
 boolean dontAutoSelectScrollMode
          This is false by default and tells the table model to not automatically select the scrolling mode (vertical or horizontal) appropriate for the size of the table.
 int minHeight
          The minimum height for each cell.
 int minWidth
          The minimum width for each cell.
 boolean vmode
          If this is true then the table will scroll vertically only.
 
Fields inherited from class ewe.ui.TableModel
activeCellControl, allColumnsSameSize, allRowsSameSize, canHScroll, canVScroll, cellInsets, charHeight, charWidth, clipData, controlProxy, cursorSize, fillToEqualHeights, fillToEqualWidths, gap, hasColumnHeaders, hasPreferredSize, hasRowHeaders, hasSpanningColumns, hasSpanningRows, horizontalScrollUnit, insets, numCols, numRows, preferredCols, preferredRows, rect, selectRowWhenEditing, shadeAlternateRows, table, tca, verticalScrollUnit
 
Fields inherited from interface ewe.ui.UIConstants
BDR_DOTTED, BDR_INNER, BDR_NOBORDER, BDR_OUTER, BDR_OUTLINE, BDR_RAISEDINNER, BDR_RAISEDOUTER, BDR_SUNKENINNER, BDR_SUNKENOUTER, BF_BOTTOM, BF_BOTTOMLEFT, BF_BOTTOMRIGHT, BF_BUTTON, BF_DIAGONAL, BF_DIAGONAL_ENDBOTTOMLEFT, BF_DIAGONAL_ENDBOTTOMRIGHT, BF_DIAGONAL_ENDTOPLEFT, BF_DIAGONAL_ENDTOPRIGHT, BF_EXACT, BF_FLAT, BF_LEFT, BF_MIDDLE, BF_MONO, BF_PALM, BF_RECT, BF_RIGHT, BF_SOFT, BF_SQUARE, BF_TOP, BF_TOPLEFT, BF_TOPRIGHT, EDGE_BUMP, EDGE_ETCHED, EDGE_RAISED, EDGE_SUNKEN
 
Fields inherited from interface ewe.ui.CellConstants
BORDER, BOTTOM, CELLFLAG, CELLMASK, CENTER, CONTROLMASK, DONTCHANGE, DONTFILL, DONTSTRETCH, EAST, FILL, FIXEDSIZE, GROW, HCENTER, HCONTRACT, HEXPAND, HFILL, HGROW, HSHRINK, HSTRETCH, INITIALLY_CLOSED, INITIALLY_MINIMIZED, INITIALLY_PREFERRED_SIZE, INSETS, LEFT, MAXIMUMSIZE, MINIMUMSIZE, NORTH, NORTHEAST, NORTHWEST, PREFERREDSIZE, RECT, RIGHT, SHRINK, SOUTH, SOUTHEAST, SOUTHWEST, SPAN, STRETCH, TEXTSIZE, TOP, VCENTER, VCONTRACT, VEXPAND, VFILL, VGROW, VSHRINK, VSTRETCH, WEST
 
Fields inherited from interface ewe.ui.ControlConstants
All, AlwaysEnabled, AlwaysRecalculateSizes, ByDeferredMouse, ByDeferredPen, ByFrameChange, ByKeyboard, ByMouse, ByPen, ByRequest, CalculatedSizes, Disabled, DisablePopupMenu, DisplayOnly, Down, DrawFlat, Flag, ForceResize, HasData, Invisible, KeepImage, KeepSIP, Left, MakeMenuAtLeastAsWide, Maximize, Minimize, MouseSensitive, NoFocus, NotAnEditor, NotEditable, PaintDataOnly, PaintOutsideOnly, PenTransparent, PreferredSizeOnly, Right, SendUpKeyEvents, SendUpPenEvents, ShowSIP, ShrinkToNothing, SmallControl, SpecialBackground, TakeControlEvents, TakesKeyFocus, Transparent, Up, WantDrag, WantHoldDown
 
Constructor Summary
IconTableModel()
           
 
Method Summary
 int calculateColWidth(int col)
          This returns the full width of the column.
protected  void calculateRC()
          Calculate the rows and columns based on the size of the table.
 int calculateRowHeight(int row)
          This returns the full height of the row.
 boolean canSelect(int row, int col)
          This should return whether or not a particular cell may be selected.
 TableCellAttributes getCellAttributes(int row, int col, boolean isSelected, TableCellAttributes tca)
          Get the attributes for a cell.
 int getIconCount()
          This should return the number of icons.
 IImage getIconImage(int iconIndex)
          Get the image for the specified icon.
 String getIconText(int iconIndex)
          Get the text for the specified icon.
 Object getIconToolTip(int index)
          Get the tooltip for the icon at the specified index.
 Object getToolTip(int x, int y)
          Return a Tool Tip for the x,y position (in pixels) on the table.
 void iconClicked(int index)
          If an icon in the table returned by makeTable() is clicked, this method is called.
 void iconSelected(int index)
          If an icon in the table returned by makeTable() is selected with the arrow keys, this method is called.
 void made()
          This is called after the TableControl has been made.
 TableControl makeTable()
           
 void onEvent(Event ev)
           
 void resized(int width, int height)
          This is called after the TableControl has been resized.
 void setVMode(boolean vmode)
           
 boolean toCell(int index, Point where)
          Get the row and column of the icon at the specified index.
 int toIconIndex(int row, int col)
          Get the index of the icon given the row and column.
 void updateDisplay()
          Update the table display after any changes.
 
Methods inherited from class ewe.ui.TableModel
calculateTextCharsInColumn, calculateTextLinesInRow, canScreenScroll, checkControlFor, clearCellAdjustments, closeActiveControl, deferPaintTableCell, doHotKey, findCellsInArea, fixBorder, getCellControlFor, getCellData, getCellInsets, getCellPreferredSize, getCellRect, getCellText, getColWidth, getControlFor, getLinesFor, getMaxColWidth, getMaxRowHeight, getMenuFor, getMenuOutsideCells, getMinColWidth, getMinRowHeight, getPreferredSize, getRowHeight, hasActiveControls, inset, isActiveCellControl, notifyDataChange, onKeyEvent, paintTableCell, paintTableCell, paintTableCellData, paintTableCellText, penPressed, popupMenuEvent, remapColumns, scrollTo, select, show, startedEditing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

minWidth

public int minWidth
The minimum width for each cell.


minHeight

public int minHeight
The minimum height for each cell.


vmode

public boolean vmode
If this is true then the table will scroll vertically only. If it is false it will scroll horizontally only. Use setVMode() to change.


dontAutoSelectScrollMode

public boolean dontAutoSelectScrollMode
This is false by default and tells the table model to not automatically select the scrolling mode (vertical or horizontal) appropriate for the size of the table.

Constructor Detail

IconTableModel

public IconTableModel()
Method Detail

getIconCount

public int getIconCount()
This should return the number of icons.


getIconText

public String getIconText(int iconIndex)
Get the text for the specified icon.

Parameters:
iconIndex - The index of the icon.
Returns:
the text for the specified icon.

getIconImage

public IImage getIconImage(int iconIndex)
Get the image for the specified icon.

Parameters:
iconIndex - The index of the icon.
Returns:
the image for the specified icon.

updateDisplay

public void updateDisplay()
Update the table display after any changes.


calculateColWidth

public int calculateColWidth(int col)
Description copied from class: TableModel
This returns the full width of the column. If the requested col is -1 (header col) and there are no row headers it should return 0.

Overrides:
calculateColWidth in class TableModel

calculateRowHeight

public int calculateRowHeight(int row)
Description copied from class: TableModel
This returns the full height of the row. If the requested row is -1 (header row) and there are no column headers it should return 0.

Overrides:
calculateRowHeight in class TableModel

calculateRC

protected void calculateRC()
Calculate the rows and columns based on the size of the table.


resized

public void resized(int width,
                    int height)
Description copied from class: TableModel
This is called after the TableControl has been resized.

Overrides:
resized in class TableModel

setVMode

public void setVMode(boolean vmode)

getToolTip

public Object getToolTip(int x,
                         int y)
Description copied from class: TableModel
Return a Tool Tip for the x,y position (in pixels) on the table. In this method you can do:
        Point cell = table.cellAtPoint(x,y,null);
        if (cell == null) return null; //Not on a cell.
        // Now cell.x will have the column and cell.y will have the row
        // of the cell the mouse is over and you can then display a tool tip for that cell.
        

Overrides:
getToolTip in class TableModel
Parameters:
x - The x co-ordinate in pixels of the mouse.
y - The y co-ordinate in pixels of the mouse.
Returns:
An acceptable ToolTip object.

getIconToolTip

public Object getIconToolTip(int index)
Get the tooltip for the icon at the specified index. By default it returns the text of the icon.


toIconIndex

public int toIconIndex(int row,
                       int col)
Get the index of the icon given the row and column. Returns -1 if it is out of range.


toCell

public boolean toCell(int index,
                      Point where)
Get the row and column of the icon at the specified index.

Parameters:
index - The index of the icon.
where - A Point to store the x (column) and y (row) location of its cell. This parameter may be null, in which case the return value will simply indicate if the index is valid or not.
Returns:
true if the index is within range, false if not.

getCellAttributes

public TableCellAttributes getCellAttributes(int row,
                                             int col,
                                             boolean isSelected,
                                             TableCellAttributes tca)
Description copied from class: TableModel
Get the attributes for a cell. Note that even though a TableCellAttributes is passed to the method, for effeciency a completely different one may be returned. You should therefore not attempt to modify or reuse the one that is returned.

Overrides:
getCellAttributes in class TableModel

canSelect

public boolean canSelect(int row,
                         int col)
Description copied from class: TableModel
This should return whether or not a particular cell may be selected. Note that selecting a column or row header (row == -1 or col == -1) results in the entire row/column being selected.

Overrides:
canSelect in class TableModel

made

public void made()
Description copied from class: TableModel
This is called after the TableControl has been made.

Overrides:
made in class TableModel

makeTable

public TableControl makeTable()

iconClicked

public void iconClicked(int index)
If an icon in the table returned by makeTable() is clicked, this method is called. by default it does nothing, override it to do something useful.

Parameters:
index - The index of the icon that was clicked.

iconSelected

public void iconSelected(int index)
If an icon in the table returned by makeTable() is selected with the arrow keys, this method is called. by default it does nothing, override it to do something useful.

Parameters:
index - The index of the icon that was clicked.

onEvent

public void onEvent(Event ev)
Specified by:
onEvent in interface EventListener
Overrides:
onEvent in class TableModel