This class if for presenting data in a tabular format.
|
Public Types |
| enum | TableControlEvents {
TableCellClickedEvent = CUSTOM_EVENT_TYPES + 32131,
FixedRowClickedEvent,
FixedColumnClickedEvent,
SelectingEvent,
TableSelectionChangingEvent,
TableSelectionChangedEvent,
TableCellCreatingEvent
} |
| enum | DrawGridLines { dglNone = 0,
dglDrawVerticalLines = 1,
dglDrawHorizontalLines = 2,
dglDrawBoth = 3
} |
| enum | AutoSizeOption { asoDefault = 0,
asoHeader = 1,
asoData = 2,
asoBoth
} |
Public Member Functions |
| | TableControl (TableModel *model=NULL) |
| virtual | ~TableControl () |
| virtual void | paint (GraphicsContext *context) |
| | Paints the control.
|
| void | init () |
| uint32 | getDefaultRowHeight () |
| void | setDefaultRowHeight (const uint32 &defaultRowHeight) |
| uint32 | getDefaultColumnWidth () |
| void | setDefaultColumnWidth (const uint32 &defaultColumnWidth) |
| void | setColumnWidth (const uint32 &column, const uint32 &width) |
| void | setRowHeight (const uint32 &row, const uint32 &height) |
| double | getRowHeight (uint32 row) |
| double | getColumnWidth (uint32 col) |
| TableModel * | getTableModel () |
| virtual void | modelChanged (Model *oldModel, Model *newModel) |
| void | setColumnCount (const uint32 &colCount) |
| void | setRowCount (const uint32 &rowCount) |
| virtual void | mouseDown (MouseEvent *event) |
| | Called when one (or more) of the mouse buttons are held down.
|
| virtual void | mouseMove (MouseEvent *event) |
| | Called when the mouse moves over the control.
|
| virtual void | mouseUp (MouseEvent *event) |
| | Called when one (or more) of the mouse buttons are released.
|
| virtual void | mouseClick (MouseEvent *event) |
| | Called when one or mouse buttons are held down and immediately released ( a "mouse click" ).
|
| void | setAutoResizeColumns (const bool &autoResizeColumns) |
| bool | getAutoResizeColumns () |
| virtual void | handleEvent (Event *e) |
| | This gets called by the ControlPeer for any windowing system mouse events, as well as for any windowing system keyboard events and for any windowing system events like size changes, position changes, etc.
|
| DrawGridLines | getDrawGridLinesStyle () |
| void | setDrawGridLinesStyle (DrawGridLines val) |
| virtual bool | canBeginDragDrop (Point *point) |
| | We'll always return false, so that we can control when to start the drag-drop operation.
|
| bool | getAllowColumnResizing () |
| void | setAllowColumnResizing (bool val) |
| bool | getAllowRowResizing () |
| void | setAllowRowResizing (bool val) |
| bool | getListMode () |
| void | setListMode (bool val) |
| bool | getAllowColumnHide () |
| void | setAllowColumnHide (bool val) |
| bool | getAllowRowHide () |
| void | setAllowRowHide (bool val) |
| bool | getEnableSelection () |
| void | setEnableSelection (bool val) |
| bool | getAllowSingleColumnSelection () |
| void | setAllowSingleColumnSelection (bool val) |
| bool | getAllowSingleRowSelection () |
| void | setAllowSingleRowSelection (bool val) |
| bool | getAllowFixedColumnSelection () |
| void | setAllowFixedColumnSelection (bool val) |
| bool | getAllowFixedRowSelection () |
| void | setAllowFixedRowSelection (bool val) |
| virtual void | keyDown (KeyboardEvent *e) |
| | called when the user presses the key down
|
| void | resizeColumnWidths () |
| void | resizeRowHeights () |
| void | resizeColumnRowDimensions () |
| bool | autoSizeColumn (int column, AutoSizeOption autoSizeStyle=asoDefault, bool resetScroll=true) |
| | autosize the specified column's width to its text
|
| bool | autoSizeRow (int row, bool resetScroll=true) |
| | autosize the specified row's heigth to its text
|
| Color * | getDefaultTableCellColor () |
| void | setDefaultTableCellColor (Color *color) |
| Font * | getDefaultTableCellFont () |
| void | setDefaultTableCellFont (Font *font) |
| TableCellItem * | setSelectedCell (const bool &val, const uint32 &row, const uint32 &column) |
| void | setSelectedRange (const bool &val, const uint32 &startRow, const uint32 &startColumn, const uint32 &endRow, const uint32 &endColumn) |
| void | setFocusedCell (const uint32 &row, const uint32 &column) |
| TableCellItem * | getFocusedCell () |
| void | clearSelection () |
| Enumerator< TableCellItem * > * | getSelectedCells () |
| CellID | getCellIDForItem (TableCellItem *item) |
| TableCellItem * | getItem (const CellID &cell) |
| TableCellItem * | getItem (const uint32 &row, const uint32 &column) |
| void | setItem (const uint32 &row, const uint32 &column, TableCellItem *cell) |
Public Attributes |
| VCF::Delegate | TableCellDelegate |
| TableCellClicked VCF::Delegate | TableCellDelegate |
| TableCellDblClicked VCF::Delegate | TableCellDelegate |
| TableCellDown VCF::Delegate | TableCellDelegate |
| TableCellFinishedEditing VCF::Delegate | TableCellDelegate |
| FixedRowClicked VCF::Delegate | TableCellDelegate |
| FixedColumnClicked VCF::Delegate | TableCellDelegate |
| TableSelecting VCF::Delegate | TableCellDelegate |
| TableSelectionChanging VCF::Delegate | EventDelegate |
| TableSelectionChanged VCF::Delegate | TableModelDelegate |
| | TableCellsSelected |
| VCF::Delegate | CreateTableCellDelegate |
| | TableCellCreating |
Protected Types |
| enum | MouseState {
msNone = 0,
msPrepareForEdit,
msPrepareForDrag,
msPrepareToSelect,
msPrepareColResize,
msColResizing,
msPrepareRowResize,
msRowResizing,
msSelectAll,
msSelectColumn,
msSelectRow,
msSelectCells
} |
Protected Member Functions |
| Rect | getBoundsForCell (const CellID &cell) |
| Rect | getBoundsForItem (TableCellItem *item) |
| double | getFixedColumnWidth () |
| double | getFixedRowHeight () |
| void | onTableModelChanged (TableModelEvent *event) |
| void | onTableCellItemSelected (ItemEvent *event) |
| void | onTableModelEmptied (ModelEvent *e) |
| void | onEditingControlKeyPressed (KeyboardEvent *event) |
| void | finishEditing () |
| void | cancelEditing () |
| void | onFocusLost (FocusEvent *e) |
| void | onFinishEditing (Event *e) |
| CellID | getCellIDFromPoint (const Point &pt, bool allowFixedCellCheck=true) |
| CellID | setFocusedCell (const CellID &cell) |
| bool | columnResizeAreaHitTest (const Point &pt) |
| bool | rowResizeAreaHitTest (const Point &pt) |
| bool | getCellOrigin (const CellID &cell, Point &pt) |
| | returns false if the cell is not visible, otherwise pt will be set to the top left coordinates of the item represented by the row/col of cell
|
| CellID | getTopLeftNonFixedCell (const bool &recalc=false) |
| CellRange | getVisibleNonFixedCellRange (Rect *rect=NULL, bool forceRecalculation=false) |
| Point | getClickedPoint (const CellID &cell, const Point &pt) |
| void | clearSelectionRange () |
| void | doSelection (const CellID &cell) |
| void | selectAllCells () |
| void | selectColumns (CellID currentCell, bool forceRedraw=false, bool selectCells=true) |
| void | selectRows (CellID currentCell, bool forceRedraw=false, bool selectCells=true) |
| void | selectCells (CellID currentCell, bool forceRedraw=false, bool selectCells=true) |
| void | fixedRowClicked (CellID cell) |
| void | fixedColumnClicked (CellID cell) |
| void | recalcScrollBars () |
| void | onVerticalScrolling (Event *e) |
| void | onHorizontalScrolling (Event *e) |
| double | getTotalRowHeight () |
| double | getTotalColumnWidth () |
| void | editCell (const CellID &cell, const Point &pt) |
| Rect | getEditCellRect (const CellID &editCellID) |
| virtual TableCellItem * | createCell (const uint32 &row, const uint32 &column) |
| virtual void | paintItem (GraphicsContext *ctx, const Rect &itemRect, const CellID &cell, const DrawUIState &state) |
Protected Attributes |
| TableCellItem * | selectedCellItem_ |
| TableCellItem * | focusedCell_ |
| Control * | currentEditingControl_ |
| TableItemEditor * | currentItemEditor_ |
| bool | autoResizeColumns_ |
| bool | allowColumnResizing_ |
| bool | allowRowResizing_ |
| bool | hiddenColumnUnhide_ |
| bool | hiddenRowUnhide_ |
| bool | listMode_ |
| bool | allowColumnHide_ |
| bool | allowRowHide_ |
| bool | enableSelection_ |
| bool | allowSingleColumnSelection_ |
| bool | allowSingleRowSelection_ |
| bool | allowFixedColumnSelection_ |
| bool | allowFixedRowSelection_ |
| bool | allowLiveResizing_ |
| int | resizeCaptureRange_ |
| Point | resizeDragPt_ |
| Point | lastMousePoint_ |
| Point | leftClickPoint_ |
| CellID | clickCell_ |
| CellID | selectionStartCell_ |
| CellID | currentCell_ |
| CellID | topLeftCell_ |
| uint32 | dragColumnWidth_ |
| double | totalRowHeight_ |
| MouseState | mouseState_ |
| DrawGridLines | drawGridLinesStyle_ |
| AutoSizeOption | autoSizeStyle_ |
| uint32 | defaultColumnWidth_ |
| uint32 | defaultRowHeight_ |
| std::vector< uint32 > | columnWidths_ |
| std::vector< uint32 > | rowHeights_ |
| Map< uint32, TableCellItem * > | selectionMap_ |
| std::map< CellID, TableCellItem * > | previouslySelectedCellMap_ |
| Color * | defaultCellColor_ |
| Font * | defaultCellFont_ |
| std::vector< TableCellItem * > | tableItems_ |
This class if for presenting data in a tabular format.
You can adjust the number of rows and columns, as well as various formatting features. You can also have custom editors for editing individual cells.
Originally started as a basic table control, I quickly realized what an ordeal this was going to turn into, and I began looking at Chris Maunder's excellent CGridCtrl class. At this point, much of the original code that I wrote has been completely dismantled, and in it's place I have ported over most of the basic design/layout/algorithms from the CGridCtrl.
The original CGridCtrl was written for MFC, and has a number of very Win32-ish designs implicit in it. These have been heavily changed to fit within the VCF way of doing things. For example, the original TableControl made use of a TableModel with TableCellItem's to represent an individual cell. This is still the case and in migrating over to Chris's code, I had to make allowances for this, since his control doesn't separate the model/data from the control itself (though he does use a CGridCell class for the cell items). In addition most of the enumerations and all of the function names have been changed, again to fit in with the VCF's coding standards.