Objective Grid : PART II Programmer’s Guide : Chapter 12 Advanced Design Overview : Objective Grid Core Architecture In Brief
Objective Grid Core Architecture In Brief
A grid consists of cells that display information in the grid window. Each cell is identified through a unique row and column number pair. Cells have attributes associated with them such as text, font and borders. Attributes are stored in a cell data object. For Objective Grid, the cell data object is an instance of the CGXStyle class. The cell type itself is also an attribute of the cell. Some examples of cell types are edit box, static text, combo box, list box, radio button, push button and check box. In Objective Grid, each cell type is implemented through a class derived from CGXControl. CGXControl is an abstract base class that defines the interface between a grid object and a cell type object.
Objective Grid separates cell data from the cell type object. This means the programmer can change the attributes of a cell independent of the cell type. There is no need to get a pointer to the cell type object in order to change the content of a specific cell. This also implies that the cell type object does not store cell specific information. Objective Grid shares one cell type object among many cells. Responsibilities of the cell type object are drawing the cell and interpreting user input. If the user changes the cell text or value, all changes are stored in the cell data object for the cell.
Another interesting aspect in the interaction between cells and the grid object is that the cell attributes are determined at run time. The cell data objects are not persistent in memory. Whenever the grid object draws a specific cell, a cell data object is created for the cell and filled by calling virtual member functions. A programmer can override these virtual functions and specify the cell attributes at run time depending on the current context of the application. Because cell data objects are determined at run time, it is possible to implement a kind of cell attribute inheritance.
Suppose you want to change the font for a whole row of cells. Normally, you would have to loop through all cells in that row and change the font attribute, but with the cell attribute inheritance implemented in Objective Grid, you only have to change the font in the row style. All cells in the affected row will automatically inherit the font settings from the row style. Only cells that have already stored individual font settings in the cell data object will not be affected.
Cell attribute inheritance lets you group specific kinds of cells and make them have similar attributes. For example, all row headers can be changed through the "Row Header Style" and all column headers can be changed through the "Column Header Style". Default cell attributes can be changed through the "Standard Style". You can easily add your own base styles and let certain cells inherit their cell attributes from these base styles.
Objective Grid is composed of several groups of MFC extension classes which work together to provide the above features and design principles:
Drawing Classes - The Objective Grid drawing classes perform all of the drawing and updating of the grid cells. Both CWnd and CView derived grid classes are available for maximum flexibility.
Control Classes - Objective Grid cells can be a variety of control types. A control MFC extension class is provided for each type of control. An abstract base class is also included that helps the developer create new kinds of controls to supplement the existing controls.
Style Classes - A style refers to the attributes of a cell or group of cells. The Objective Grid style classes manage these attributes and provide a pre-built dialog for modifying them.
Browser Classes - The Objective Grid Browser classes let you easily browse any external data sources by overriding some virtual methods. Special derivatives of the Browser Classes let you connect to ODBC and ADO data sources.
Utility Classes - Objective Grid uses a variety of MFC extension classes for internal utility classes. These classes may be helpful in other parts of your applications. Examples of the utility classes are a long operation class that lets you monitor and cancel long operations, a tabbed window, and an Undo/Redo architecture.