<< Return to Main Index

< Return to Class Index

CGXControl Class Members

Construction

CGXControl Constructs a control object.

User Attributes

AddUserAttributes Call this static method to register user attributes with the styles-map. Registered user attributes will be displayed in the CGXStyleSheet and can be modified by the user with the style sheet.

Overridable Extrinsic State Operations

Drawing

Draw Draws the cell.

Find and Replace

FindText Finds text in the cell’s data.
ReplaceAll Replaces all found patterns in the cell’s data.

Cell Rectangle

AddBorders Adds space reserved for margins and borders to the size of the cell rectangle, e.g., with a combo box it adds space for drawing the pushbutton. AddBorders will be called from CalcSize.
CalcSize Calculates the optimal size for the control depending on its data. This method is called when row-heights or column-widths should be automatically resized.
GetCellRect Returns the interior rectangle for the cell, e.g., in a combo box the rectangle for the text (without the area needed for the pushbutton).

Display Text

GetControlText Called to convert the value from the style object into plain text as it should be displayed in the cell. Override this method if you want to display the value in a certain formatting in the cell (e.g., date, currency or numeric).
SetControlText Converts the display text and calls SetValueRange with the value that should be stored in the grid. For example, SetControlText will be called when you paste text into the grid. The actual text conversion is done by calling ConvertControlTextToValue.
ConvertControlTextToValue This method converts the display text into the value that should be stored in the grid. You might add validation into this routine and also adjust the text before it gets stored in the grid (e.g., remove literals like the ‘$’ or ‘/’ from currency or date values). ConvertControlTextToValue will be called from SetControlText.

Style Information

LoadStyle This method determines the cell-specific style information. By default, the style will not be changed, but the new RTF cell will extract font and alignment from the style value (RTF string) and return them as real style attributes.
StoreStyle StoreStyle will be called from SetStyleRange and allows you to adjust the cell’s style object before it is stored in the grid by calling StoreStyleRowCol.

Sorting

GetSortKey This method is called to return the sort key for a given cell.

Merge and Floating Cells

CanFloatCell Objective Grid calls this method to check if it is possible to float a cell, or to hide a cell by flooding it from another floating cell.
CanMergeCell Objective Grid calls this method to check if it is possible to merge a cell in the specified direction (vertical or horizontal).

Overridable Intrinsic State Operations

Display Text

GetCurrentText Returns the text as displayed in the cell (e.g., if the control is associated with a CWnd, like CGXEditControl, it determines the text with GetWindowText).
GetSelectedText Override this method to return the selected text (e.g., in an edit window the highlighted text).
SetCurrentText Override this method to set the window text of the current cell. If your control is associated with a CWnd for example, you should override this method and call SetWindowText.
ValidateString Called after the user has pressed a key and before it is accepted. If you return FALSE, the new character will be discarded. Will also be called from OnValidate and from SetCurrentText before the text is displayed in the cell.

Value

GetValue Reads out the window text and converts it into the plain value as it will be stored in the style object. Override this method if you have formatted the text that is displayed in the cell (e.g., date format entry).
SetValue Converts the value that should be stored in the style object to the text which should be displayed in the cell and displays it in the active current cell.

State

GetModify Returns the modified-state.
IsActive Returns the state of the active-flag. The base-class version of this method returns FALSE.
IsInit Returns TRUE if control is used as current cell, i.e., CGXControl::Init has been called and intrinsic state is initialized; it returns FALSE if control is not used as current cell.
IsReadOnly Determines whether the cell is read-only or if the user can change the cell.
SetActive Specifies the active-flag. Controls associated with a CWnd (like CGXEditControl) should override this method when focus should be set to the CWnd.
SetModify Specifies the modified-state.

Cell Tips

NeedShowCellTip Called to determine if a cell tip window needs to be shown.
GetCellTipID Returns the appropriate cell tip window ID.
InitializeCellTip Initializes the cell tip window.

Operations

Hide If the control is associated with a CWnd, this method hides the associated window. This method is overridden in CGXEditControl, CGXListBox and CGXWndWrapper to hide the window object. The active-flag stays unchanged.
InvertBorders Highlights the current cell by inverting the cell’s border or drawing a thick border. Override this method if you don’t want the default highlighting of your cell.
Refresh This method is called to refresh the cell.
ReplaceSel Override this method to replace the currently selected text.
Store Stores the cell’s data, resets the modified-flag and redraws the cell.

Initialization

Init Initializes the intrinsic state (e.g., row, column, style) of the control for the current cell. This method is called when the current cell has moved. The operations that follow all depend on the intrinsic state of the control.
Reset Resets the intrinsic state of the control. This method is called when the current cell is moving.

Keyboard

KeyPressed Called when the user has pressed a key and the active-flag is FALSE (the grid-parent has the focus).
OnGridChar KeyPressed will call this overridable for WM_CHAR messages.
OnGridDeadChar KeyPressed will call this overridable for WM_DEADCHAR messages.
OnGridDoubleByteChar KeyPressed will call this overridable for WM_CHAR messages.
OnGridKeyDown KeyPressed will call this overridable for WM_KEYDOWN messages.
OnGridKeyUp KeyPressed will call this overridable for WM_KEYUP messages.
OnGridSysChar KeyPressed will call this overridable for WM_SYSCHAR messages.
OnGridSysDeadChar KeyPressed will call this overridable for WM_SYSDEADCHAR messages.
OnGridSysKeyDown KeyPressed will call this overridable for WM_SYSKEYDOWN messages.
OnGridSysKeyUp KeyPressed will call this overridable for WM_SYSKEYUP messages.

Mouse messages

LButtonDblClk Called when the user has double-clicked the left mouse button.
LButtonDown Called when the user has pressed the left mouse button.
LButtonUp Called when the user has released the left mouse button.
MButtonDblClk Called when the user has double-clicked the middle mouse button.
MButtonDown Called when the user has pressed the middle mouse button.
MButtonUp Called when the user has released the middle mouse button.
MouseMove Called when the user is moving the mouse with a clicked mouse button.
RButtonDblClk Called when the user has double-clicked the right mouse button.
RButtonDown Called when the user has pressed the right mouse button.
RButtonUp Called when the user has released the right mouse button.
MouseMoveOver Called when the user drags the mouse over the cell. You may change the cursor on the fly by overriding this method.

Notifications

OnCanceledEditing Called after the current cell’s content is canceled and the control has been reinitialized with the previous cell’s data.
OnCancelEditing Called when the user has pressed ESC.
OnDeleteCell Called when the user has pressed DEL and the active-flag is FALSE (the grid-parent has the focus).
OnEndEditing Called when the user accepts the cell’s data.
OnInvalidKeyPressed Called when the user has pressed an invalid key in the edit field which could not be accepted.
OnLeftCell Called after the current cell has been deactivated. Therefore, at the time this event is called, there is no current cell in the grid. Override this method if you want to hook into refreshing the current cell after being deactivated.
OnModifyCell Called when the user modifies cell contents (e.g., when a CEdit fires an EN_CHANGE event).
OnStartEditing Called when the user starts editing (pressed key or mouse into text).
OnValidate Checks if the cell’s data is valid.

Dispatched from the grid

OnCommand Called when the grid receives a WM_COMMAND message (e.g., CBN_SELCHANGE). The grid passes the attributes of the WM_COMMAND message to this method.
OnGridCtlColor Called when the grid receives a WM_CTLCOLOR message. The grid passes the attributes of the WM_CTLCOLOR message to this method.
OnGridPreTranslateMessage Called from CWnd::PreTranslateMessage for the current cell.
OnGridSysColorChange Called for every registered control in a grid when the grid receives a WM_SYSCOLORCHANGE message.
OnGridWinIniChange Called when the grid receives a WM_WININICHANGE message. The grid passes the attributes of the message to this method.

Clipboard

Copy Copies the selected text of the current cell to the clipboard. Override this method if you would like to supply additional clipboard formats. Note: This method will not be called when a range of cells is selected.
Paste Checks if the clipboard data should be pasted into the current cell. If this is the case, text will be pasted. Override this method if you want to handle special clipboard formats.
Cut Copies the selected text of the current cell to the clipboard and deletes the selected text.
CanCopy The default implementation returns TRUE if current cell can supply clipboard data. FALSE otherwise.
CanCut The default implementation returns TRUE if current cell can supply clipboard data and the current cell is active. FALSE otherwise.
CanPaste The default implementation returns TRUE if no range of cells is selected in the grid and the current cell is active. Override this method if you want to check for additional clipboard formats (e.g., the CGXRichEditCtrl overrides this method and checks for RTF clipboard format).
ValidatePaste Called when the user pastes text and the cell is active.  The default implementation returns TRUE.

Choice List Operations

GetChoiceListItem Reads out the choice list entry specified through a zero-based index from a given string.
FindStringInChoiceList Searches the choice list string for a specific entry and returns the zero-based index of the entry that matches the search criteria.

Overridable Child Operations

AddChild Adds a CGXChild to the control.
ChildWithFocus Returns a pointer to the focused CGXChild.
FocusOnChild Sets the focus to a child. LButtonDown, MButtonDown and RButtonDown call this method when a CGXChild was hit.
GetChild Returns a pointer to the CGXChild for the given index.
GetCount Returns the number of CGXChild objects.
OnClickedButton Called when the user has clicked a button (e.g., a pushbutton). The base-class version calls the grid’s OnClickedButtonRowCol method.
OnInitChildren Called to compute the rectangles for the CGXChild objects.

Protected Helper Operations

DrawBackground Draws the background and 3d-effects for the cell.
DrawFrame Draws only the 3d-effects for the cell without erasing the background.
ExcludeClipRect Calling this method is only necessary when using the gxDrawUsingMemDC drawing technique. After drawing a CWnd (with Invalidate( ) and UpdateWindow( ) ), you should call this method with the rectangle of the CWnd. This excludes the rectangle from the clipping rectangle and thus avoids overdrawing the CWnd.
GetMarkHeaderState Returns TRUE if this is a header cell and if the current cell is in the same row or column as the header cell; FALSE otherwise.
Grid Returns a pointer to the CGXGridCore object.
GridWnd Returns a pointer to the grid’s CWnd object.
OnKillFocus Sends a WM_KILLFOCUS message to the grid window. Call this method if your control receives a WM_KILLFOCUS message.
SelectFont Selects the font for the cell into the device context. If the font is the same as the standard font, no font will be selected into the device context.

Runtime Type Information

GetControlClass Returns the CGXControlClass structure corresponding to this object’s class.
GetRuntimeClass Returns the CWnd runtime class of the object. If the control is not derived from CWnd, it will return NULL.
GetWndPtr Returns a pointer to the CWnd object. If the control is not derived from CWnd, it will return NULL. Override this method if you have created a new control that is inherited multiply from CGXControl and CWnd.
IsKindOf Tests this object’s relationship to a given CWnd class.

Attributes

m_bRefreshOnSetCurrentCell If your control’s appearance depends on whether it is a current cell or not, you should set this attribute TRUE (default is FALSE).
m_nRow Holds the row id of the current cell.
m_nCol Holds the column id of the current cell.

CGXControl

Class Overview