public class GridTableModel extends TableModel
To use this you do the following:
import ewe.ui.*; import ewe.util.*; //################################################################## public class TestGridTableModel extends Editor{ //################################################################## //=================================================================== public TestGridTableModel() //=================================================================== { TableControl t = new TableControl(); // // Create the data Grid and header Vector. // Grid g = new Grid(); Vector headers = new Vector(); // for (int row = -1; row != 10; row++){ for (int col = 0; col != 5; col++){ if (row == -1) headers.add("Header: "+col); else g.add("Cell("+row+", "+col+")",false); } g.endRow(); } // // Create the GridTableModel. // GridTableModel gtm = new GridTableModel(); // // Set the data and the headers. // We won't use row headers in our example. // gtm.setDataAndHeaders(g,headers,null); // // Call this to correctly calculate the size of the each cell // given the Font that you intend to use. // If you intend to use the default font of this Editor then // you can use this.getFontMetrics() instead of t.getFontMetrics(). // t.font = mApp.findFont("fixed",true); gtm.calculateSizes(t.getFontMetrics()); // // If this is not true the Table will not have a preferred size // and will be initially displayed very small. // gtm.hasPreferredSize = true; // t.setTableModel(gtm); addLast(new ScrollBarPanel(t)); } //################################################################## } //##################################################################
TableModel.CellControl, TableModel.ControlProxy
Modifier and Type | Field and Description |
---|---|
protected Vector |
columnHeaders
The column headers if any.
|
protected Grid |
data
The data to be displayed.
|
protected int[] |
heights |
protected Vector |
rowHeaders
The row headers if any.
|
protected int[] |
widths
The widths of the cells as used by calculateColWidth().
|
activeCellControl, allColumnsSameSize, allRowsSameSize, canHScroll, canMoveColumnHeaders, canVScroll, cellInsets, charHeight, charWidth, clipData, colAdjustments, controlProxy, cursorSize, fillToEqualHeights, fillToEqualWidths, gap, hasColumnHeaders, hasPreferredSize, hasRowHeaders, hasSpanningColumns, hasSpanningRows, horizontalScrollUnit, keepSIP, mouseIsOverCell, numCols, numRows, preferredCols, preferredRows, selectRowWhenEditing, shadeAlternateRows, shadeColor, table, verticalScrollUnit
BDR_DOTTED, BDR_INNER, BDR_NOBORDER, BDR_OUTER, BDR_OUTLINE, BDR_RAISEDINNER, BDR_RAISEDOUTER, BDR_SUNKENINNER, BDR_SUNKENOUTER, BF_ABUT_ANY, BF_ABUT_BOTTOM, BF_ABUT_LEFT, BF_ABUT_RIGHT, BF_ABUT_TOP, 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
ALWAYS_STRETCHABLE, BOTTOM, CELLFLAG, CELLMASK, CENTER, CONTROLMASK, DONTCHANGE, DONTFILL, DONTSTRETCH, EAST, FILL, GROW, HCENTER, HCONTRACT, HEXPAND, HFILL, HGROW, HSHRINK, HSTRETCH, INITIALLY_CLOSED, INITIALLY_HIDDEN, INITIALLY_MINIMIZED, INITIALLY_PREFERRED_SIZE, INSETS, LEFT, MAXIMUMSIZE, MINIMUMSIZE, NORTH, NORTHEAST, NORTHWEST, PREFERREDSIZE, RECT, RIGHT, SHRINK, SOUTH, SOUTHEAST, SOUTHWEST, SPAN, STRETCH, TAG_BACKGROUND_IMAGE, TAG_BUSY_DISPLAY, TAG_COLORS, TAG_CONTROL_PAINTER, TAG_EXPOSE_GROUP, TAG_FIXEDSIZE, TAG_GRAY_BACKGROUND, TAG_HIDE_CONTROL_OBJECT, TAG_HIDE_PARENT, TAG_INNER_TEXT_INSETS, TAG_INPUT_STACK_PARENT, TAG_INSETS, TAG_MAKE_VISIBLE, TAG_MAXIMUMSIZE, TAG_MINIMUMSIZE, TAG_PAINT_CONTROL_LIST, TAG_PREFERRED_TEXT_SIZE, TAG_PREFERRED_TEXT_SIZE_HEIGHT, TAG_PREFERRED_TEXT_SIZE_WIDTH, TAG_PREFERREDSIZE, TAG_RECT, TAG_SHADOW_INSETS, TAG_SPAN, TAG_SWIPER, TAG_TEMPORARY_ERROR, TAG_TEXT_INSETS, TAG_TEXTSIZE, TEXTSIZE, TOP, VCENTER, VCONTRACT, VEXPAND, VFILL, VGROW, VSHRINK, VSTRETCH, WEST
All, AlwaysEnabled, AlwaysRecalculateSizes, ByDeferredMouse, ByDeferredPen, ByFrameChange, ByKeyboard, ByMouse, ByPen, ByRequest, CalculatedSizes, ContainerDontPaintChildren, Disabled, DisablePopupMenu, DisplayOnly, DontBuffer, Down, DrawFlat, Flag, ForceResize, HasData, Invisible, KeepImage, KeepSIP, Left, MakeMenuAtLeastAsWide, Maximize, Minimize, ModifiersInheritedFromWindow, MouseSensitive, NoFocus, NotAnEditor, NotEditable, PaintDataOnly, PaintOutsideOnly, PenTransparent, PreferredSizeOnly, Right, SendUpUIEvents, ShowSIP, ShrinkToNothing, SmallControl, TakeChildUIEvents, TakeControlEvents, TakesKeyFocus, Transparent, Up, WantDrag, WantHoldDown
Constructor and Description |
---|
GridTableModel() |
Modifier and Type | Method and Description |
---|---|
int |
calculateColWidth(int col)
Returns the column width.
|
int |
calculateRowHeight(int row)
Returns the row height.
|
void |
calculateSizes(FontMetrics fm)
This calculates the correct sizes for the rows and columns.
|
protected void |
checkCellSize(FontMetrics fm,
int row,
int col,
Dimension d)
This calculates the size of cell given the FontMetrics.
|
Object |
getCellData(int row,
int col)
This returns the data in the grid and columnHeaders/rowHeaders unmodified.
|
Dimension |
getCellPreferredSize(int row,
int col,
FontMetrics fm,
Dimension dest) |
void |
setDataAndHeaders(Grid data,
Vector columnHeaders,
Vector rowHeaders)
Set the data and the headers.
|
void |
updateData(boolean updateTable)
Call this method if you have changed any data in the grid for
the TableModel.
|
acceptColumnMoved, calculatePreferredColWidth, calculatePreferredRowHeight, calculatePreferredSize, calculateSizes, calculateTextCharsInColumn, calculateTextLinesInRow, canScreenScroll, canSelect, checkControlFor, clearCellAdjustments, clearColumnWidthAdjustments, clearSelectionOnClick, closeActiveControl, columnMoved, deferPaintTableCell, doHotKey, editNow, editNow, endEditing, findCellsInArea, fixBorder, freezeUpdate, getCellAttributes, getCellControlFor, getCellInsets, getCellRect, getCellText, getCellText, getColWidth, getColXPointInTable, getControlFor, getLock, getMaxColWidth, getMaxRowHeight, getMenuFor, getMenuOutsideCells, getMinColWidth, getMinRowHeight, getPreferredSize, getRowHeight, getRowYPointInTable, getTable, getToolTip, handleEvent, hasActiveControls, hasCellControlFor, inset, isActiveCellControl, made, makeActiveControlVisible, mouseMoving, mouseOverChanged, notifyDataChange, onEvent, onKeyEvent, paintTableCell, paintTableCell, paintTableCellData, paintTableCellText, penClicked, penPressed, popupMenuEvent, positionCellControl, remapColumns, resized, restoreColumnWidthAdjustments, saveColumnWidthAdjustments, scrolled, scrollTo, select, setColAdjust, setColWidth, show, showingMenuFor, sizeColumnToFitData, startedEditing, updateControls
protected Grid data
protected Vector columnHeaders
protected Vector rowHeaders
protected int[] widths
protected int[] heights
public void setDataAndHeaders(Grid data, Vector columnHeaders, Vector rowHeaders)
public Object getCellData(int row, int col)
getCellData
in class TableModel
protected void checkCellSize(FontMetrics fm, int row, int col, Dimension d)
public int calculateRowHeight(int row)
calculateRowHeight
in class TableModel
public int calculateColWidth(int col)
calculateColWidth
in class TableModel
public void calculateSizes(FontMetrics fm)
public Dimension getCellPreferredSize(int row, int col, FontMetrics fm, Dimension dest)
getCellPreferredSize
in class TableModel
public void updateData(boolean updateTable)
updateTable
- if this is true then a call to update(true) will be made
on the containing TableControl.