Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Grid User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

2.3 Drawing and Updating

The MFC document/view architecture upon which the grid is built takes care of getting paint messages from Windows to Objective Grid via the CView::OnDraw() routine. When the grid object draws, it first calculates the range of cells that need to be drawn. Then it creates a style object for each cell in that range and initializes the cell styles with ComposeStyleRowCol(). After all the style information has been gathered, the inactive cells are drawn by the grid object and then the active cell control draws itself.

In addition to drawing in response to standard Windows paint messages, the grid object also has to keep the document and views synchronized. The MFC document/view model handles most of the updating work for the grid.

CGXGridView can be used with a document or stand-alone. If the view is associated with a document, it is necessary to update all views in response to a change of the document data.

If the user interacts with the grid by typing text in a cell and moving the current cell, the view will call a command to change the value of the current cell. All associated views have to update this cell.

To provide maximum flexibility, the grid provides three overridable functions for each command in the update path. The overridable functions are marked in Figure 4 with M1, M2, and M3.

Figure 4: How Objective Grid updates are implemented

The developer can intercept updates at the command stage, the storing stage, and even the update stage. For example, changing the value of a cell is done by calling SetStyleRange(). This method calls StoreStyleRowCol() to store the cell contents and UpdateStyleRange() to redraw the cell. The three member functions are all virtual and the member function that reads the grid's data is also virtual.

By leveraging the document/view architecture and making sure that the programmer can override the functions involved in updating at every critical stage, the uses of Objective Grid have no limit.

2.3.1 CGXGridCore - Commands Interface

The CGXGridCore class provides the following commands. These commands are all associated with a Store-method and an Update-Method as explained above.

HideCols()
HideRows()
InsertCols()
InsertRows()
MoveCols()
MoveRows()
RemoveCols()
RemoveRows()
MoveCells()
CopyCells()
SelectRange()
SetColCount()
SetColWidth()
SetDefaultColWidth()
SetDefaultRowHeight()
SetFrozenCols()
SetFrozenRows()
SetReadOnly()
SetRowCount()
SetRowHeight()
SetStyleRange()
SetZoom()

2.3.2 Accessor Methods

The following methods encapsulate the access to data and you can easily override them when needed:

GetColCount()
GetColWidth()
GetDefaultColWidth()
GetDefaultRowHeight()
GetFrozenCols()
GetFrozenRows()
GetHeaderCols()
GetHeaderRows()
GetRowCount()
GetRowHeight()
GetStyleRowCol()
GetZoom()
IsReadOnly()
StoreColWidth()
StoreDefaultColWidth()
StoreDefaultRowHeight()
StoreHideCol()
StoreHideRow()
StoreInsertCols()
StoreInsertRows()
StoreMoveCols()
StoreMoveRows()
StoreMoveCells()
StoreCopyCells()
StoreReadOnly()
StoreRemoveCols()
StoreRemoveRows()
StoreRowHeight()
StoreStyleRowCol()
StoreZoom()

2.3.3 CGXGridCore - Drawing Overridables

OnGridDraw()
OnDrawTopLeftBottomRight()
OnDrawItem()


Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.