|
#include <Dapfor/GUI/Grid.h>
Serialization | |
| virtual void | Serialize (CArchive &ar) |
| Saves a state and settings to the archive and restores them from it. | |
| static int | GetSerializeVertion () |
| Gets a current grid version that is used for compatibility with the archives made by the previous grid versions. | |
Public Member Functions | |
Addition, deleting, positioning, enumeration | |
| HITEM | Add (Common::CDataObject *pDO, HITEM hParent=GI_SCROLLABLE_ROOT, HITEM hInsertAfter=GI_LAST) |
| Adds a data object to the grid. | |
| bool | Delete (HITEM hItem) |
| Deletes an item from the grid. | |
| int | Delete (const Common::CDataObject *pDO) |
| Deletes all corresponding to a given data object lines from the grid. | |
| bool | Delete (int nRow, ContextType contextType=ScrollableContext) |
| Deletes a visible line from a given data context. | |
| void | DeleteAll (ContextType contextType=AllContexts) |
| Deletes all data from a given context. | |
| Handles | GetHandles (const Common::CDataObject *pDO, bool visibleOnly, ContextType contextType=AllContexts) const |
| Gets all corresponding to a given data object handles. | |
| Handles | GetHandles (ContextType contextType=AllContexts) const |
| Get a copy of all handles, inserted into the grid. | |
| bool | Attach (HITEM hItem, HITEM hParent, HITEM hInsertAfter=GI_LAST) |
| The function permits to attach a given hItem to the grid. | |
| bool | Detach (HITEM hItem) |
| Detaches the handle inserted by Add() function from the grid. | |
| bool | Exists (HITEM hItem) const |
| Checks whether a given handle is attached to the grid. | |
| bool | Exists (const Common::CDataObject *pDO) const |
| Checks whether a given data object is inserted into the grid. One data object can be inserted several times into one grid. At each insertion a unique handle is created which allows to uniquely define the object position and status in the grid. | |
| unsigned int | GetRowCount (ContextType contextType=ScrollableContext) const |
| Gets a number of visible grid lines (not filtered and not hidden by parents). | |
| void | ForEach (IForEach &functional, HITEM startFrom=GI_FIRST) |
| Conducts a search and passes all found handles with data objects to the object of functional. | |
| void | ForEachVisible (IForEach &functional, HITEM startFrom=GI_FIRST) |
| Conducts a search and passes all found visible handles with data objects to the object of functional. | |
| bool | MoveBefore (HITEM movingItem, HITEM parentPosition, HITEM position) |
| Moves a given handle with all hierarchy before a given position for a given parent. | |
| bool | MoveAfter (HITEM movingItem, HITEM parentPosition, HITEM position) |
| Moves a given handle with all hierarchy after a given position for a given parent. | |
Getting and setting formatted and non-formatted data | |
| Common::CValue | GetValue (HITEM hItem, Common::FID fid) const |
| The function allows to get corresponding to the 'fid' unformatted value of a data object. | |
| bool | SetValue (HITEM hItem, Common::FID fid, const Common::CValue &value) |
| Sets new value into the data object. | |
| TString | GetFormattedStlString (HITEM hItem, Common::FID fid, const Common::CFormat *format=0) const |
| Gets a formatted string from a data object by its field identifier. | |
| bool | SetFormattedStlString (HITEM hItem, Common::FID fid, const TString &str, const Common::CFormat *format=0) |
| Sets new value into the data object using a formatted string. | |
| CString | GetFormattedMfcString (HITEM hItem, Common::FID fid, const Common::CFormat *format=0) const |
| bool | SetFormattedMfcString (HITEM hItem, Common::FID fid, const CString &str, const Common::CFormat *format=0) |
Functions to work with hierarchy | |
| bool | IsExpanded (HITEM hItem) const |
| Gets the value pointing whether a line is expanded. | |
| Handles | GetChildren (HITEM hItem, bool visibleOnly) const |
| Gets handles of all the children of a given parent. | |
| bool | HasChildren (HITEM hItem) const |
| Gets the value pointing whether a given handle has at least one child. | |
| int | GetHierarchicalLevel (HITEM hItem) const |
| Gets a hierarchical level of a given line. | |
| HITEM | GetParent (HITEM hItem) const |
| Gets the parent to which a line is attached. | |
| void | Expand (HITEM hItem, bool withChildren) |
| Expands a line. | |
| void | Expand (const Common::CDataObject *pDO, bool withChildren) |
| Expands the line which handle is associated with the data object. | |
| void | Collapse (HITEM hItem, bool withChildren) |
| Collapses a line. | |
| void | Collapse (const Common::CDataObject *pDO, bool withChildren) |
| Collapses the line which handle is associated with the data object. | |
Data objects and lines search in the grid | |
| int | GetRow (HITEM hItem) const |
| Gets an index of a visible grid line for a given handle. | |
| int | GetRow (const Common::CDataObject *pDO) const |
| Searches for the grid line corresponding to the first met handle of a given data object. | |
| ContextType | GetContextType (HITEM hItem) const |
| Gets the grid context to which a given handle belongs. | |
| ContextType | GetContextType (const Common::CDataObject *pDO) const |
| Gets the grid context into which the first met handle corresponding to a given data object is inserted. | |
| HITEM | GetItem (int nRow, ContextType contextType=ScrollableContext) const |
| Gets a line's handle by its absolute location in the grid context. | |
| HITEM | GetItem (const Common::CDataObject *pDO) const |
| Gets the first met handle for a given data object. | |
| HITEM | GetItem (CPoint point) const |
| Gets a handle of the grid line located within given x, y coordinates. | |
| HITEM | GetPreviousItem (HITEM hItem, bool jumpBetweenContexts=true) const |
| Gets a handle of the previous visible line located before a given handle. | |
| HITEM | GetNextItem (HITEM hItem, bool jumpBetweenContexts=true) const |
| Gets a handle of the next visible line located after a given handle. | |
| Common::CDataObject * | GetDataObject (HITEM hItem) |
| Gets the data object corresponding to a given handle. | |
| const Common::CDataObject * | GetDataObject (HITEM hItem) const |
| Gets the data object corresponding to a given handle. Const version. | |
| Common::CDataObject * | GetDataObject (int nRow, ContextType contextType=ScrollableContext) |
| Gets the data object corresponding to the line located in a given grid context and at a given position. | |
| const Common::CDataObject * | GetDataObject (int nRow, ContextType contextType=ScrollableContext) const |
| Gets the data object corresponding to the line located in a given grid context and at a given position. Const version. | |
Visibility, placement and bounds | |
| int | GetFirstVisibleRow () const |
| Gets the first visible on the screen line in the scrollable context. | |
| int | GetLastVisibleRow (ContextType contextType=ScrollableContext) const |
| Gets the last visible on the screen line in a given context. | |
| void | SetFirstVisibleRow (int nRow) |
| Sets a given index as the first visible in the scrollable context. | |
| void | SetFirstVisibleItem (HITEM hItem) |
| Sets a given handle as the first visible in the scrollable context. | |
| void | SetFirstVisibleItem (const Common::CDataObject *pDO) |
| The first met line's handle in the scrollable context for a given data object is searched. | |
| void | EnsureVisible (int nRow) |
| Makes a given line visible in the scrollable context. | |
| void | EnsureVisible (HITEM hItem) |
| Makes a given handle visible in the scrollable context. | |
| void | EnsureVisible (const Common::CDataObject *pDO) |
| Makes the handle corresponding to the data object visible in the scrollable context. | |
| bool | IsVisible (HITEM hItem) const |
| Checks whether a given handle is visible in the grid. | |
| bool | IsVisible (const Common::CDataObject *pDO) const |
| Checks whether the first handle corresponding to the data object is visible in the grid. | |
| bool | IsInVisibleRect (HITEM hItem) |
| Checks whether at least a part of a given line is visible in the client's area of the grid. | |
| bool | IsInVisibleRect (const Common::CDataObject *pDO) |
| Checks whether at least a part of the given line corresponding to the data object is visible in the client's area of the grid. | |
| bool | IsInVisibleRect (int nRow, ContextType contextType) |
| Checks whether at least a part of the line located in a given grid context and at a given position is visible in the client's area of the grid. | |
| CRect | GetContextVisibleRect (ContextType contextType) const |
| Gets the visible rectangle occupied by a given grid context taking the size of the client's grid area and scrolling into consideration. | |
| CRect | GetContextVirtualRect (ContextType contextType) const |
| Gets the virtual rectangle occupied by a given grid context without taking the size of the client's grid area and scrolling into consideration. | |
| CRect | GetLineVisibleRect (HITEM hItem) const |
| Gets the visible rectangle occupied by the grid line corresponding to a given handle. | |
| CRect | GetLineVisibleRect (const Common::CDataObject *pDO) const |
| Gets the visible rectangle occupied by the grid line corresponding to the first found handle for a given data object. | |
| CRect | GetLineVirtualRect (HITEM hItem) const |
| Calculates the virtual rectangle occupied by the line corresponding to a given handle. | |
| CRect | GetLineVirtualRect (const Common::CDataObject *pDO) const |
| Gets the virtual rectangle occupied by the grid line corresponding to the first found handle for a given data object. | |
| CRect | GetCellVisibleRect (HITEM hItem, Common::FID fid) const |
| Gets a visible rectangle of the grid cell specified by a given handle and column identifier (identifier of a data object field). | |
| CRect | GetCellVisibleRect (const Common::CDataObject *pDO, Common::FID fid) const |
| Gets a visible rectangle of the grid cell specified by the first found handle for a given data object and column identifier (identifier of a data object field). | |
| CRect | GetCellVirtualRect (HITEM hItem, Common::FID fid) const |
| Gets a virtual rectangle of the grid cell specified by a given handle and column identifier (identifier of a data object field). | |
| CRect | GetCellVirtualRect (const Common::CDataObject *pDO, Common::FID fid) const |
| Gets a virtual size of the grid cell specified by the first found handle for a given data object and column identifier (identifier of the data object field) without taking the size of the visible grid area into consideration. | |
| int | GetLinesPerPage (bool forward=true) const |
| Calculates a quantity of wholly visible lines per page in the scrollable context of the grid. | |
| int | GetItemHeight (HITEM hItem) const |
| Gets a height of the corresponding to a given handle line. | |
Selection | |
| void | AllowSelection (bool bEnable) |
| Allows to perform selection in the grid. | |
| bool | CanSelect () const |
| Defines whether lines selection in the grid is allowed. | |
| void | AllowMultiSelection (bool bEnable) |
| Allows the possibility to select several lines in the grid. | |
| bool | CanMultiSelect () const |
| Defines whether lines multi selection is allowed in the grid. | |
| void | AllowSelectContext (ContextType contextType=AllContexts) |
| Sets the grid context where selection is allowed. | |
| bool | CanSelectContext (ContextType contextType) const |
| Defines whether lines selection is allowed in a given grid context. | |
| int | GetSelectedCount () const |
| Gets a total number of selected lines in the grid. | |
| bool | Select (int nRow, ContextType contextType, bool bSelect) |
| Changes selection of the line located in a given position in a given context. | |
| bool | Select (HITEM hItem, bool bSelect) |
| Allows to select a line by its handle. | |
| bool | Select (const Common::CDataObject *pDO, bool bSelect) |
| Changes selection for all the handles associated with a given data object in the grid. | |
| Selection | GetSelection (ContextType contextType) const |
| Gets a list of selected handles. | |
| bool | IsSelected (int nRow, ContextType contextType) const |
| Tests whether the line located in a given position in a given context is selected. | |
| bool | IsSelected (HITEM hItem) const |
| Tests whether the line with a specified handle is selected. | |
| bool | IsSelected (const Common::CDataObject *pDO) const |
| Tests whether the first line's handle corresponding to the data object is selected. | |
| void | SelectAll () |
| Selects all visible lines in the grid if selection is allowed. | |
| void | ClearSelection () |
| Selects out all lines in the grid. | |
| void | AllowMouseTrackSelection (bool bEnable) |
| Allows selection using the mouse. | |
| bool | CanMouseTrackSelection () const |
| Tests whether selection using the mouse is allowed. | |
Focus | |
| void | AllowFocusContext (ContextType contextType=AllContexts) |
| Allows to focus lines in a given context. | |
| bool | CanFocusContext (ContextType contextType) const |
| Checks if lines focusing is allowed in a given grid context. | |
| bool | SetFocusedRow (int nRow, ContextType contextType) |
| Sets a new focused line. | |
| int | GetFocusedRow () const |
| Gets an index of a focused line in a focused grid context. | |
| ContextType | GetFocusedContext () const |
| Gets a focused grid context. | |
Updating | |
| void | UpdateRow (int nRow, ContextType contextType, Common::FID fid) |
| Informs the grid about changing of a data object. | |
| void | UpdateItem (HITEM hItem, Common::FID fid) |
| Informs the grid that a given handle has been updated. | |
| void | UpdateDataObject (const Common::CDataObject *pDO, Common::FID fid) |
| Informs the grid that a data object has been updated. | |
| int | GetTimeElapsedSinceLastUpdate (int nRow, ContextType contextType, Common::FID fid) const |
| Returns (in milliseconds) the time passed from the moment of the last update of a grid cell. | |
| int | GetTimeElapsedSinceLastUpdate (HITEM hItem, Common::FID fid) const |
| Returns (in milliseconds) the time passed from the moment of the last update of a grid cell. | |
| void | InvalidateRow (int nRow, ContextType contextType, int spanTime=0) |
| Redraws a line in the grid. | |
| void | InvalidateRow (HITEM hItem, int spanTime=0) |
| Redraws the line corresponding to a given handle (if it is visible) in the grid. | |
| void | InvalidateRow (const Common::CDataObject *pDO, int spanTime=0) |
| Redraws all the visible lines corresponding to a given data object in the grid. | |
| void | InvalidateCell (int nRow, ContextType contextType, Common::FID fid, int spanTime=0) |
| Redraws the cell corresponding to a given line and column identifier in the grid. | |
| void | InvalidateCell (HITEM hItem, Common::FID fid, int spanTime=0) |
| Redraws the cell corresponding to a given handle (if it is visible) and column identifier in the grid. | |
| void | InvalidateCell (const Common::CDataObject *pDO, Common::FID fid, int spanTime=0) |
| Redraws all the visible cells corresponding to a given data object and column identifier in the grid. | |
Notifications | |
| void | AllowNotifications (bool bAllow) |
| The grid provides the possibility to deliver notifications to its owner by sending WM_NOTIFY messages. | |
| bool | IsNotificationsAllowed () const |
| Returns the value indicating whether the grid is allowed to deliver notifications by sending WM_NOTIFY message to its owner. | |
Appearance | |
| CAppearance & | GetAppearance () |
| Gets CAppearance type object where the basic visual grid characteristics such as text, background, vertical and horizontal lines colors and so on are collected. | |
| const CAppearance & | GetAppearance () const |
| Gets CAppearance type object where the basic visual grid characteristics such as text, background, vertical and horizontal lines colors and so on are collected. Const version. | |
| void | SetAppearance (const CAppearance &appearance) |
| Sets a new grid appearance. | |
| const CBackgroundImage & | GetBackgroundImage () const |
| Gets a background image of the grid. | |
| void | SetBackgroundImage (const CBackgroundImage &settings) |
| Sets a new background image into the grid. | |
| void | SetFont (CFont *font, BOOL bRedraw=TRUE) |
| Sets font attributes to be used for a text within the grid. Internally, the grid clones the font, and after this function has been called, you should to destroy it. | |
| CFont * | GetFont () const |
| Gets the current font used in the grid. | |
| CImageList * | SetImageList (CImageList *imageList, bool stretchImage=false) |
| Sets new ImageList to display icons within grid cells. | |
| CImageList * | GetImageList () const |
| Gets the current ImageList value used by the grid. | |
| void | AllowStretchImageInCell (bool stretch) |
| Sets the flag allowing to stretch icons in grid cells. | |
| bool | CanStretchImageInCell () const |
| Tests whether the flag allowing to stretch icons in grid cells is set. | |
| void | AllowDrawContextSeparator (bool bDraw) |
| Allows drawing of a separator between two grid contexts. | |
| bool | CanDrawContextSeparator () const |
| Tests whether drawing of a separator between two grid contexts is allowed. | |
| void | SetContextSeparatorHeight (int nHeight) |
| Sets two grid contexts separator's height. | |
| int | GetContextSeparatorHeight () const |
| Gets two grid contexts separator's height. | |
| void | AllowHighlight (bool bAllow) |
| Allows or forbids grid cells highlighting. | |
| bool | CanHighlight () const |
| Returns the value indicating if the grid can perform cells highlighting or not. | |
| const CHighlightSettings & | GetHighlightSettings () const |
| Gets the highlighting parameters collected in CHighlightSettings type object. Const version. | |
| CHighlightSettings & | GetHighlightSettings () |
| Gets the highlighting parameters collected in CHighlightSettings type object. | |
| void | SetHighlightSettings (const CHighlightSettings &settings) |
| Sets new parameters of highlighting in the grid. | |
| ICustomDraw * | SetCustomDraw (ICustomDraw *customDraw) |
| Sets a new interface to specify grid elements drawing. | |
| ICustomDraw * | GetCustomDraw () const |
| Gets current ICustomDraw interface. | |
| void | SetPaintFilter (UINT paintFilter=defaultPaintFilter) |
| Sets a new graphical filter. | |
| UINT | GetPaintFilter () const |
| Gets current value of the graphical filter. | |
| void | SetFlickerFreeDrawing (bool enable) |
| Allows to use the mechanism of double buffering in order to exclude the flicker effect at the moment of elements drawing. | |
| bool | GetFlickerFreeDrawing () const |
| Gets the value indicating whether a double buffering mode is allowed. | |
| int | GetOptimalRowHeight (ContextType contextType) const |
| Gets optimal value of lines height in a given grid context. | |
| int | GetOptimalCellWidth (int nRow, ContextType contextType, Common::FID fid) const |
| Gets optimal value of a given grid cell width. | |
| int | GetOptimalColumnWidth (ContextType contextType, Common::FID fid) const |
| Calculates the optimal grid column size based on the optimal sizes got for grid visible cells by GetOptimalCellWidth() function call. | |
Headers | |
| CHeader * | SetHeader (CHeader *newHeader) |
| Sets a new header. | |
| CHeader * | GetHeader () |
| Gets the current header used by the grid. | |
| const CHeader * | GetHeader () const |
| Gets the current header used by the grid. Const version. | |
| void | ShowHeader () |
| Makes the header visible. | |
| void | HideHeader () |
| Makes the header invisible. | |
| bool | IsHeaderVisible () const |
| Returns the value indicating whether the header is visible. | |
| virtual void | ShowHeaderDialog () |
| Shows the dialog allowing to configure columns of the header. | |
| const CColumn * | GetColumn (CPoint pt) const |
| Searches a column in the grid according to the coordinates counted off in the client's area of the grid. | |
| const CColumn * | GetNavigationColumn () const |
| Gets a navigation column. | |
| const CColumn * | GetHierarchicalColumn () const |
| Gets the column that manages the grid hierarchy. | |
| void | AdjustColumnByFid (Common::FID fid) |
| Performs column width optimization for visible grid lines. | |
| void | AdjustColumnByIndex (int index) |
| Performs column width optimization by its index. | |
| void | AdjustAllColumns () |
| Performs all grid columns width optimization. The columns width is adjusted in such a way that grid cells in a given column haven't got partly hidden data. | |
| int | GetOptimalHeaderHeight () const |
| Gets optimal header's height. | |
| void | EnsureColumnVisible (Common::FID fid) |
| The function makes a column wholly visible in the grid. | |
Tooltips | |
| void | EnableTooltip (bool enable=true) |
| Allows to display tooltips. | |
| bool | IsTooltipEnabled () const |
| Returns the value indicating whether tooltip displaying is allowed. | |
| const ITooltipCtrl * | GetTooltipCtrl () |
| Gets current ITooltipCtrl used by the grid. | |
| ITooltipCtrl * | SetTooltipCtrl (ITooltipCtrl *control) |
| Sets new ITooltipCtrl interface to control the tooltip window. | |
| const ITooltip * | GetTooltip () const |
| Gets the interface controlling the tooltip content. | |
| ITooltip * | SetTooltip (ITooltip *tooltip) |
| Set a new interface for defining the tooltip content. | |
| const CTooltipSettings & | GetTooltipSettings () const |
| Gets the tooltip settings collected in CTooltipSettings class object. Const version. | |
| CTooltipSettings & | GetTooltipSettings () |
| Gets the tooltip settings collected in CTooltipSettings class object. | |
| void | SetTooltipSettings (const CTooltipSettings &settings) |
| Sets new tooltip settings. | |
| void | EnableInPlaceTooltip (bool bEnable=true) |
| Allows to show the tooltip above grid cells when a cell size is not enough for displaying a text. | |
| bool | IsInPlaceTooltipEnabled () const |
| Returns the value indicating whether the grid can show the tooltip above the grid cells when a cell size is not enough for displaying a text. | |
| CTooltipSettings & | GetInPlaceTooltipSettings () |
| Gets the tooltip settings determinant how the grid should show the tooltip above the grid cells when a cell size is not enough for displaying a text. | |
| void | SetInPlaceTooltipSettings (const CTooltipSettings &settings) |
| Sets the new settings determinant how the grid should show the tooltip above the grid cells when a cell size is not enough for displaying a text. | |
| const ITooltipCtrl * | GetInPlaceTooltipCtrl () const |
| Gets the current tooltip control used by the grid when a cell size is not enough for displaying a text. | |
| ITooltipCtrl * | SetInPlaceTooltipCtrl (ITooltipCtrl *control) |
| Sets new ITooltipCtrl interface to control the 'embedded' tooltip window. | |
Copy/cut/paste | |
| bool | Copy () |
| Copies selection to the clipboard. | |
| bool | Cut () |
| Cuts selection to the clipboard. | |
| bool | Paste () |
| Inserts elements into the grid to the located after the focused line place. | |
| bool | Paste (HITEM hParent, HITEM hInsertAfter) |
| Pastes data from the clipboard to a given position. | |
| ICopyPaste * | SetCopyPaste (ICopyPaste *copyPaste) |
| Sets new ICopyPaste interface. | |
| ICopyPaste * | GetCopyPaste () const |
| Gets the current ICopyPaste interface used by the grid. | |
| const CCopyPasteSettings & | GetCopyPasteSettings () const |
| Gets the settings collected in CCopyPasteSettings type object and used by the grid at copy/paste operations. Const version. | |
| CCopyPasteSettings & | GetCopyPasteSettings () |
| Gets the settings collected in CCopyPasteSettings type object and used by the grid at copy/paste operations. | |
| void | SetCopyPasteSettings (const CCopyPasteSettings &settings) |
| Sets the new settings used by the grid at copy/paste operations. | |
| void | AllowCopyPaste (bool bAllow) |
| Allows or forbids to use copy/paste. | |
| bool | IsCopyPasteAllowed () const |
| Gets the value indicating whether copy/paste operations are allowed. | |
Drag and drop | |
| IDragDrop * | SetDragDrop (IDragDrop *dragDrop) |
| Sets new IDragDrop interface. At the same time the function returns the previous interface used by the grid. | |
| IDragDrop * | GetDragDrop () const |
| Gets the current IDragDrop interface used by the grid. | |
| const CDragDropSettings & | GetDragDropSettings () const |
| Gets the drag&drop settings collected in CDragDropSettings type object. Const version. | |
| CDragDropSettings & | GetDragDropSettings () |
| Gets the drag&drop settings collected in CDragDropSettings type object. | |
| void | SetDragDropSettings (const CDragDropSettings &settings) |
| Sets new drag&drop settings. | |
| void | AllowDragAndDrop (bool bAllow) |
| Allows or forbids drag&drop in the grid. | |
| bool | IsDragAndDropAllowed () const |
| Gets the value indicating whether drad&drop operations are allowed. | |
| CDragImage | CreateDragImage (const Handles &handles, ContextType contextType, const CHeader *header) const |
| Helper which allows to create an image while grid content dragging. | |
Sorting | |
| void | AllowSort (bool bEnable) |
| Allows or forbids sorting in the grid. | |
| bool | CanSort () const |
| Returns the value indicating whether sorting is allowed. | |
| void | AllowMultiSort (bool bEnable) |
| Allows multiple sorting in the grid. | |
| bool | CanMultiSort () const |
| Returns the value indicating whether multiple sorting is allowed. | |
| void | SetSortedContext (ContextType contextType=AllContexts) |
| Sets the grid context where sorting is allowed. | |
| ContextType | GetSortedContext () const |
| Gets the contexts where sorting is allowed. | |
| void | ResetSort (bool redraw=true) |
| Cancels sorting. | |
| void | SetSort (int level, CSortInfo sortInfo, bool applyImmediatelly=true) |
| Sets a sort for a given level. | |
| CSortInfo | GetSort (int level) const |
| Gets information about sorting for a given level. | |
| void | UpdateSort () |
| Carries out data sorting in the grid according to the sorting rules specified in a header. | |
| int | GetSortLevels () const |
| Returns current value of sorting levels quantity. | |
Data filtration | |
| IGridFilter * | SetFilter (IGridFilter *filter) |
| Sets a new filter. | |
| IGridFilter * | GetFilter () const |
| Gets the current filter set in the grid. | |
| void | UpdateFilter () |
| Calls checking of all grid lines on whether or not they are filtered. | |
Navigation and keyboard | |
| IKeyManager * | SetKeyManager (IKeyManager *keyManager) |
| Sets a new keyboard manager to control the grid. | |
| IKeyManager * | GetKeyManager () const |
| Gets the current keyboard manager used by the grid. | |
| void | AllowNavigation (ContextType contextType=AllContexts) |
| Allows to conduct navigation in given grid contexts. | |
| bool | CanNavigate (ContextType contextType) const |
| Returns the value, indicating whether navigation is possible in given grid context. | |
| void | NavigateUp (bool bShift, bool bCtrl) |
| Moves a focus up and scrolls down one line if it is necessary. | |
| void | NavigateDown (bool bShift, bool bCtrl) |
| Moves a focus down and scrolls up one line if it is necessary. | |
| void | NavigatePageUp (bool bShift, bool bCtrl) |
| Moves a focus up and scrolls down one page if it is necessary. | |
| void | NavigatePageDown (bool bShift, bool bCtrl) |
| Moves a focus down and scrolls up one page if it is necessary. | |
| void | NavigateHome (bool bShift, bool bCtrl) |
| Focuses the first line in the fixed or scrollable context according to navigation settings. | |
| void | NavigateEnd (bool bShift, bool bCtrl) |
| Focuses the last line in the fixed or scrollable context according to navigation settings. | |
| void | ResetScroll () |
| Conducts updating of vertical and horizontal scrollbars' positions. | |
Printing | |
| void | PrintPreview (const CPrintSettings &settings) |
| The function opens a print preview dialog where the user can specify printer settings, position and size of paper, choose zoom for the grid content displaying on the screen and zoom to enlarge a printed sheet on the screen. | |
| void | Print (const CPrintSettings &settings, CPrintInfo *printInfo=0) |
| Launches a printing process for a grid content. | |
Built in controls | |
| CEmbeddedControlAdapter * | AttachControl (CWnd *control, HITEM hItem, Common::FID fid, const CEmbeddedControlParams ¶ms=CEmbeddedControlParams()) |
| Attaches a control to a grid cell. | |
| bool | DetachControl (CWnd *control) |
| Looks for the cell where a specified control is attached and detaches it. | |
| bool | DetachControl (HITEM hItem, Common::FID fid, bool bDestroy) |
| Detaches a control from the grid cell specified by hItem and fid values. | |
| bool | HasControl (HITEM hItem, Common::FID fid) const |
| Checks whether MFC control is attached to a given cell. | |
| bool | HasControl (int nRow, ContextType contextType, Common::FID fid) const |
| Checks whether MFC control is attached to a given cell. | |
Edit in place | |
| IEditInPlace * | SetEditInPlace (IEditInPlace *editInPlace) |
| Sets new IEditInPlace interface. The function returns the previous value of the interface. | |
| IEditInPlace * | GetEditInPlace () const |
| Gets current IEditInPlace interface used by the grid. | |
| bool | CanStartEditInPlace (HITEM hItem, Common::FID fid, IEditInPlace::StartReason reason) const |
| Checks if it is possible to start 'edit in place' for a given cell. | |
| bool | StartEditInPlace (HITEM hItem, Common::FID fid, IEditInPlace::StartReason reason=IEditInPlace::ActivateOnUserStart) |
| Starts 'edit in place' process for a given grid cell. | |
| bool | StopEditInPlace (IEditInPlace::StopReason reason, bool postMessage=false) |
| Requests the grid to stop' edit in place' giving a reason (lost of focus, navigation, enter...). | |
| CWnd * | GetEditInPlaceControl () const |
| Gets a pointer to the control that at the present moment is participating in 'edit in place' operation. | |
| const CEditInPlaceSettings & | GetEditInPlaceSettings () const |
| Gets current 'edit in place' settings collected in CEditInPlaceSettings class object. Const version. | |
| CEditInPlaceSettings & | GetEditInPlaceSettings () |
| Gets current 'edit in place' settings collected in CEditInPlaceSettings class object. | |
| void | SetEditInPlaceSettings (const CEditInPlaceSettings &settings) |
| Sets new 'edit in place' settings. | |
The grid provides possibilities of automatic updating, sorting, highlighting and filtration of the objects at each values modification. To benefit this, it is recommended to implement Common::CDataOnject::ISink interface that can fire notifications to the grid.
The grid allows you to use simultaneously objects of different classes. The only condition is that types of the values returned by the functions should be the same. It is not so critical for data painting and highlighting but at sorting it is required to compare values of one type.
To display information in cells, the grid needs to retrieve values from your business objects. There are two thread-safe modes to do it:
Read What is a data object? article to get more information about binding.
The article How to install the MFC grid and compile the first application? will explain all steps how to install and compile your first application.
class CDemoView : public CView { ... afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnSize(UINT nType, int cx, int cy); private: Dapfor::GUI::CGrid m_Grid; }; int CDemoView::OnCreate(LPCREATESTRUCT lpCreateStruct) { ... //Initialize the grid m_Grid.Create(0, 0, WS_VISIBLE|WS_CHILD, CRect(), this, 1000); //Create a header: Dapfor::GUI::CHeader* header = new Dapfor::GUI::CHeader(true); //Add some columns to header. Field identifiers should be the same that declared in the data object //For more information see "How to install my first application" header->Add(new Dapfor::GUI::CColumn(CDemoClass::FidPrice, _T("Field1"), 190)); //Set the header to the grid m_Grid.SetHeader(header); ... return 0; } void CDemoView::OnSize(UINT nType, int cx, int cy) { CMDIChildWnd::OnSize(nType, cx, cy); //Fit the grid to the client's area CRect rc; GetClientRect(rc); m_Grid.MoveWindow(rc); } //Declaration of some C++ class: class CDemoClass : public Common::CDataObject { public: enum { FidPrice, }; ... double GetPrice() const; ... }; //This code adds C++ objects to the grid: CDemoClass* obj = new CDemoClass(); m_Grid.Add(obj);
| HITEM Add | ( | Common::CDataObject * | pDO, | |
| HITEM | hParent = GI_SCROLLABLE_ROOT, |
|||
| HITEM | hInsertAfter = GI_LAST | |||
| ) |
Adds a data object to the grid.
The grid has a hierarchical architecture. Scrolled (GI_SCROLLABLE_ROOT) or fixed (GI_FIXED_ROOT) contexts can be root value. They are not displayed in the grid. That's why when a data object is added to them visually it will be placed on the top level of the hierarchy. If the addition is successful then the handle, which uniquely determines the data object position in the grid and is unique for an application, is returned. The acquired handle can be used as a parent to add new objects. The hierarchy is usually built, when values are added but also can be changed later. The same data object can be inserted into the grid many times. A handle can be detached form the grid and attached to any other place or even to a different grid. It's significant that the grid doesn't control the data objects life. Data can be stored at any place according to the programmer's desire. The method of data objects keeping doesn't have to repeat the grid hierarchy at all. Moreover in other grids it is possible to built a completely different hierarchy using the same data objects. At data object realization it is strongly recommended to implement ISink interface that will allow to notify the grid about data modification. That makes it possible to use the services of automatic data updating, sorting, highlighting and filtration that will considerably simplify the application. Also it is significant that if sorting is switched on a data object will be added to hParent according to the sorting rules. In case if hParent is collapsed or filtered a data object will be added but not seen. In terms of productivity to add data to the end of the grid is several times more productive than to add them to the beginning.
| [in] | pDO | added data object | ||||||
| [in] | hParent | parent item to which a data object will be added. The following values are available:
| ||||||
| [in] | hInsertAfter | the value used to specify location of an insertion. If sorting is switched on then this parameter doesn't have any meaning because a data object will be inserted according to the sorting rules. If there is no sorting hInsertAfter can have the following values:
|
class CAuthor : public Dapfor::Common::CDataObject { ... CString GetFirstName() const; CString GetLastName() const; ... }; class CBook : public Dapfor::Common::CDataObject { ... CString GetAuthor() const; ... }; //Instantiate autor and his books CAuthor* author = new CAuthor(...); CBook* book1 = new CBook(...); CBook* book2 = new CBook(...); //Add author to the grid m_Grid.Add(author); //Attach books to the author in the hierarchical grid m_Grid.Add(book1, m_Grid.GetItem(author)); m_Grid.Add(book2, m_Grid.GetItem(author)); //The next code 'frezes' the autor i.e. adds the autor to the fixed context: m_Grid.Add(new CAuthor(...), Dapfor::GUI::GI_FIXED_ROOT);
| bool Delete | ( | HITEM | hItem | ) |
Deletes an item from the grid.
When the function is called corresponding to a given handle line is deleted together with all children. Deleting will be done even if the handle is filtered or collapsed by the parent. The grid doesn't hold a data object but only displays it on the screen through the system of formats. So when the handle is deleted the data object will not be physical destructed and if the data object is inserted several times into the same grid or into several grids then except for the deleted line in other places it will be displayed as before.
| [in] | hItem | handle that is to be deleted. |
//Add an object to the grid CSomeClass* someObject = new CSomeClass(...); Dapfor::GUI::HITEM hItem = m_Grid.Add(someObject); ... //Remove the row with all children from the grid. Note, that the call does not destroy the object of CSomeClass. //It just removes the corresponding row. m_Grid.Delete(hItem); someObject->DoSomething(...); //Ok, the object is alive.
| int Delete | ( | const Common::CDataObject * | pDO | ) |
Deletes all corresponding to a given data object lines from the grid.
This function can be useful in case of multiple insertion of a data object into the grid. When the data object is deleted from the grid it is not physically destroyed.
| [in] | pDO | pointer to the data object which should be deleted from the grid. |
//Add an object to the grid CSomeClass* someObject = new CSomeClass(...); m_Grid.Add(someObject); ... //Remove all rows with theirs children that correspond to the specified object from the grid. //The grid will look for all GUI::HITEM (one or more) with the given data object and remove them. //Note, that the call does not destroy the object of CSomeClass. m_Grid.Delete(someObject); someObject->DoSomething(...); //Ok, the object is alive.
| bool Delete | ( | int | nRow, | |
| ContextType | contextType = ScrollableContext | |||
| ) |
Deletes a visible line from a given data context.
If the line contains children (both visible and invisible) they all also will be deleted. The function doesn't delete data objects (doesn't call their destructors) but only deletes the reference to a found data object in the grid.
| [in] | nRow | index of a visible line which starts from 0. |
| [in] | contextType | type of a data context. Available values: FixedContext, ScrollableContext. In case of AllContexts the grid is trying to delete given line in every context. |
//Remove the first non-scrollable row (the indexes are started from 0) with all children. //Note, that the call does not destroy the data object. m_Grid.Delete(0, Dapfor::GUI::FixedContext);
| void DeleteAll | ( | ContextType | contextType = AllContexts |
) |
Deletes all data from a given context.
| [in] | contextType | type of a data context. Available values: FixedContext, ScrollableContext, AllContexts. |
//Remove all non-scrollable rows. m_Grid.DeleteAll(Dapfor::GUI::FixedContext); //Remove all scrollable & non-scrollable rows. m_Grid.DeleteAll(Dapfor::GUI::AllContexts);
| Handles GetHandles | ( | const Common::CDataObject * | pDO, | |
| bool | visibleOnly, | |||
| ContextType | contextType = AllContexts | |||
| ) | const |
Gets all corresponding to a given data object handles.
Let's mention that several handles can correspond to one data object. Part of the handles for one object might be filtered (lines will be invisible) or hidden by their parents.
| [in] | pDO | pointer to a data object. |
| [in] | visibleOnly | flag pointing that the returned handles will be visible in the grid, i.e. not hidden by the parents or filtered. |
| [in] | contextType | type of the context where handles will be searched. Available values: FixedContext, ScrollableContext, AllContexts. |
//Gets all visible in the grid rows (scrollable and non-scrollable) that correspond to the specified data object Dapfor::GUI::Handles& handles = m_Grid.GetHandles(root, true); //Gets all visible and invisible (filtered or collapsed) non-scrollable rows //that correspond to the specified data object Dapfor::GUI::Handles& handles = m_Grid.GetHandles(root, false, Dapfor::GUI::FixedContext);
| Handles GetHandles | ( | ContextType | contextType = AllContexts |
) | const |
Get a copy of all handles, inserted into the grid.
| [in] | contextType | type of the context where handles will be searched. Available values: FixedContext, ScrollableContext, AllContexts. |
| bool Attach | ( | HITEM | hItem, | |
| HITEM | hParent, | |||
| HITEM | hInsertAfter = GI_LAST | |||
| ) |
The function permits to attach a given hItem to the grid.
The possibility to attach/detach handles was implemented in order to be able to easily transfer hierarchical data inside one context, between different contexts and between different grids while keeping their hierarchy. This function is applicable only to the data previously detached from the grid. One handle can't be attached two times to one or several grids.
| [in] | hItem | Handle to be attached. | ||||||
| [in] | hParent | Parent to which the attachment can be done. Any got in Add() function value or one of the following contexts: GI_SCROLABLE_ROOT or GI_FIXED_ROOT can be a parent. | ||||||
| [in] | hInsertAfter | the value used to specify location of the insertion. If sorting is switched on then this parameter doesn't have any meaning because the data object will be inserted according to the sorting rules. If there is no sorting hInsertAfter can have the following values:
|
| bool Detach | ( | HITEM | hItem | ) |
Detaches the handle inserted by Add() function from the grid.
| [in] | hItem | Handle to be detached. |
| bool Exists | ( | HITEM | hItem | ) | const |
Checks whether a given handle is attached to the grid.
| [in] | hItem | Handle to be verified |
| bool Exists | ( | const Common::CDataObject * | pDO | ) | const |
Checks whether a given data object is inserted into the grid. One data object can be inserted several times into one grid. At each insertion a unique handle is created which allows to uniquely define the object position and status in the grid.
| [in] | pDO | data object to be verified |
| unsigned int GetRowCount | ( | ContextType | contextType = ScrollableContext |
) | const |
Gets a number of visible grid lines (not filtered and not hidden by parents).
The search can be carried out in one or both contexts.
| [in] | contextType | Type of the context where the search will be carried out. Available values: FixedContext, ScrollableContext, AllContexts. |
| void ForEach | ( | IForEach & | functional, | |
| HITEM | startFrom = GI_FIRST | |||
| ) |
Conducts a search and passes all found handles with data objects to the object of functional.
The search is carried out among visible and invisible lines. It can be started not only from the first line but from the position assigned by startFrom. The search can be interrupted if IForEach returns 'false'.
| [in] | functional | Functional where all found handles and data objects are handed over to. |
| [in] | startFrom | handle from which the search starts. Available values: GI_FIRST, GI_FIXED_ROOT, GI_SCROLLABLE_ROOT, any inserted onto the grid handle. If GI_FIRST is used then the search starts from the fixed context and if it has no elements then from the scrollable context. |
#include <Dapfor/GUI/IForEach.h> //The functor that counts visible and invisible rows in the grid class RowsCounter : public Dapfor::GUI::IForEach { public: int GetVisibleRows() const {return m_VisibleRows;} int GetInvisibleRows() const {return m_InvisibleRows;} virtual bool operator () (Dapfor::GUI::CGrid& grid, Dapfor::GUI::HITEM item, Dapfor::Common::CDataObject* pDO) { if(grid.IsVisible(item)) { //Increment count of visible rows m_VisibleRows++; } else { //Increment count of invisible rows m_InvisibleRows++; } //Continue iterations return true; } private: int m_VisibleRows; int m_InvisibleRows; }; //How to use: //the functor is applied for both visible and invisible items RowsCounter functor1; m_Grid.ForEach(functor1); //the functor is applied only for visible rows //functor2.GetInvisibleRows() will get zero. RowsCounter functor2; m_Grid.ForEachVisible(functor2);
| void ForEachVisible | ( | IForEach & | functional, | |
| HITEM | startFrom = GI_FIRST | |||
| ) |
Conducts a search and passes all found visible handles with data objects to the object of functional.
The search is carried out among visible lines. It can be started not only from the first line but from the position assigned by startFrom. The search can be interrupted if IForEach returns 'false'.
| [in] | functional | Functional where all found handles and data objects are handed over to. |
| [in] | startFrom | handle from which the search starts. Available values: GI_FIRST, GI_FIXED_ROOT, GI_SCROLLABLE_ROOT, any inserted onto the grid handle. If GI_FIRST is used then the search starts from the fixed context and if it has no elements then from the scrollable context. |
#include <Dapfor/GUI/IForEach.h> //The functor that counts visible and invisible rows in the grid class RowsCounter : public Dapfor::GUI::IForEach { public: int GetVisibleRows() const {return m_VisibleRows;} int GetInvisibleRows() const {return m_InvisibleRows;} virtual bool operator () (Dapfor::GUI::CGrid& grid, Dapfor::GUI::HITEM item, Dapfor::Common::CDataObject* pDO) { if(grid.IsVisible(item)) { //Increment count of visible rows m_VisibleRows++; } else { //Increment count of invisible rows m_InvisibleRows++; } //Continue iterations return true; } private: int m_VisibleRows; int m_InvisibleRows; }; //How to use: //the functor is applied for both visible and invisible items RowsCounter functor1; m_Grid.ForEach(functor1); //the functor is applied only for visible rows //functor2.GetInvisibleRows() will get zero. RowsCounter functor2; m_Grid.ForEachVisible(functor2);
| bool MoveBefore | ( | HITEM | movingItem, | |
| HITEM | parentPosition, | |||
| HITEM | position | |||
| ) |
Moves a given handle with all hierarchy before a given position for a given parent.
The moving is conducted by the consecutive handle detaching from the grid and then attaching to a new position.
| [in] | movingItem | Moved handle. | ||||||
| [in] | parentPosition | Parent to which the moved handle will be attached. The parent must not be a direct or indirect child of the moved handle. Available values:
| ||||||
| [in] | position | Position before which the handle will be inserted. Available values:
|
//Get a handle that corresponds to the specified data object Dapfor::Common::CDataObject* pDO = ...; Dapfor::GUI::HITEM hItem = m_Grid.GetItem(pDO); //'Freeze' the item. i.e. move to the fixed context m_Grid.MoveAfter(hItem, Dapfor::GUI::GI_FIXED_ROOT, Dapfor::GUI::GI_LAST);
| bool MoveAfter | ( | HITEM | movingItem, | |
| HITEM | parentPosition, | |||
| HITEM | position | |||
| ) |
Moves a given handle with all hierarchy after a given position for a given parent.
The moving is conducted by the consecutive handle detaching from the grid and then attaching to a new position.
| [in] | movingItem | Moved handle. | ||||||
| [in] | parentPosition | Parent to which the moved handle will be attached. The parent must not be a direct or indirect child of the moved handle. Available values:
| ||||||
| [in] | position | Position after which the handle will be inserted. Available values:
|
//Get a handle that corresponds to the specified data object Dapfor::Common::CDataObject* pDO = ...; Dapfor::GUI::HITEM hItem = m_Grid.GetItem(pDO); //'Freeze' the item. i.e. move to the fixed context m_Grid.MoveAfter(hItem, Dapfor::GUI::GI_FIXED_ROOT, Dapfor::GUI::GI_LAST);
| Common::CValue GetValue | ( | HITEM | hItem, | |
| Common::FID | fid | |||
| ) | const |
The function allows to get corresponding to the 'fid' unformatted value of a data object.
It is significant that during operating in CPreferences::MemoryBuffer mode data are got from the grid's cache but not from the data object. As a result access to the data object is not carried out. In case of CPreferences::DirectCall mode the value is requested directly from the data object.
| [in] | hItem | Line's handle in the grid. The line can be visible and invisible as well. |
| [in] | fid | Field's identifier. |
//Declaration of a data object class CTestClass : public Dapfor::Common::CDataObject { enum { FidPrice, }; double GetPrice() const {return ...;} void SetPrice(double newPrice) {...; NotifyUpdate(FidPrice);} }; DF_BEGIN_FIELD_MAP(CTestClass) DF_DOUBLE_ID(FidPrice, "Price", &CTestClass::GetPrice, &CTestClass::SetPrice, 0) DF_END_FIELD_MAP() //There are many ways to get the non-formatted value from the grid's cell //1. If you have a pointer to the object of your class CTestClass* testClass; double price = testClass->GetPrice(); //2. If you have a pointer to the data object and don't want to cast to the CTestClass type: Dapfor::Common::CDataObject* testClass = new CTestClass(); double price = testClass->GetDouble(CTestClass::FidPrice); //or double price = testClass->GetValue(CTestClass::FidPrice); //3. Get the value directly from the grid. Note, that you get the typed value! //For the Datfor::GUI::CPreferences::DirectCall mode the grid will get the data from the data object //by calling GetPrice() method. //For the Datfor::GUI::CPreferences::MemoryBuffer mode the grid will return value from the cache. double price = m_Grid.GetValue(hItem, CTestClass::FidPrice); //In the same way it is possible to get formatted values as MFC or STL strings Dapfor::Common::CDataObject* testClass = ...; CString mfcText = testClass->GetFormattedMfcString(CTestClass::FidPrice, 0); std::string stlText = testClass->GetFormattedStlString(CTestClass::FidPrice, 0); //Or from the grid: CString mfcText = m_Grid.GetFormattedMfcString(hItem, CTestClass::FidPrice); std::string stlText = m_Grid.GetFormattedStlString(hItem, CTestClass::FidPrice); //The preferred way to set a new value is to implement notifications mechanism //in the data object and call Set- method. CTestClass* testClass = new CTestClass(); test->SetPrice(...); //Of course, you can call m_Grid.SetValue(hItem, CTestClass::FidPrice, (double)1.23); testClass->SetValue(CTestClass::FidPrice, (double)1.23); //Or if you want to transform MFC/STL string to the value, you can use the next m_Grid.SetFormattedMfcString(hItem, CTestClass::FidPrice, "1.23"); testClass->SetFormattedMfcString(CTestClass::FidPrice, "1.23", 0);
| bool SetValue | ( | HITEM | hItem, | |
| Common::FID | fid, | |||
| const Common::CValue & | value | |||
| ) |
Sets new value into the data object.
| [in] | hItem | Line's handle in the grid. The line can be visible and invisible as well. |
| [in] | fid | Field's identifier. |
| [in] | value | New value which is set into the data object. |
//Declaration of a data object class CTestClass : public Dapfor::Common::CDataObject { enum { FidPrice, }; double GetPrice() const {return ...;} void SetPrice(double newPrice) {...; NotifyUpdate(FidPrice);} }; DF_BEGIN_FIELD_MAP(CTestClass) DF_DOUBLE_ID(FidPrice, "Price", &CTestClass::GetPrice, &CTestClass::SetPrice, 0) DF_END_FIELD_MAP() //There are many ways to get the non-formatted value from the grid's cell //1. If you have a pointer to the object of your class CTestClass* testClass; double price = testClass->GetPrice(); //2. If you have a pointer to the data object and don't want to cast to the CTestClass type: Dapfor::Common::CDataObject* testClass = new CTestClass(); double price = testClass->GetDouble(CTestClass::FidPrice); //or double price = testClass->GetValue(CTestClass::FidPrice); //3. Get the value directly from the grid. Note, that you get the typed value! //For the Datfor::GUI::CPreferences::DirectCall mode the grid will get the data from the data object //by calling GetPrice() method. //For the Datfor::GUI::CPreferences::MemoryBuffer mode the grid will return value from the cache. double price = m_Grid.GetValue(hItem, CTestClass::FidPrice); //In the same way it is possible to get formatted values as MFC or STL strings Dapfor::Common::CDataObject* testClass = ...; CString mfcText = testClass->GetFormattedMfcString(CTestClass::FidPrice, 0); std::string stlText = testClass->GetFormattedStlString(CTestClass::FidPrice, 0); //Or from the grid: CString mfcText = m_Grid.GetFormattedMfcString(hItem, CTestClass::FidPrice); std::string stlText = m_Grid.GetFormattedStlString(hItem, CTestClass::FidPrice); //The preferred way to set a new value is to implement notifications mechanism //in the data object and call Set- method. CTestClass* testClass = new CTestClass(); test->SetPrice(...); //Of course, you can call m_Grid.SetValue(hItem, CTestClass::FidPrice, (double)1.23); testClass->SetValue(CTestClass::FidPrice, (double)1.23); //Or if you want to transform MFC/STL string to the value, you can use the next m_Grid.SetFormattedMfcString(hItem, CTestClass::FidPrice, "1.23"); testClass->SetFormattedMfcString(CTestClass::FidPrice, "1.23", 0);
| TString GetFormattedStlString | ( | HITEM | hItem, | |
| Common::FID | fid, | |||
| const Common::CFormat * | format = 0 | |||
| ) | const |
Gets a formatted string from a data object by its field identifier.
In case of CPreferences::MemoryBuffer mode the string is taken from a cache, in case of CPreferences::DirectCall mode the value is requested from the data object and then is formatted into a string.
| [in] | hItem | Line's handle in the grid. The line can be visible and invisible as well. |
| [in] | fid | Field's identifier. |
| [in] | format | The format by which the value will be formatted into the string. If the format is not specified then its search will be conducted according to the following order: firstly the format is searched in object of CColumn class, if it has not been found the format is searched in data object Common::CFieldMap and if after that the format has not been defined then the default format returned by Common::CFormat::GetDefaultFormat() function is selected. |
//Declaration of a data object class CTestClass : public Dapfor::Common::CDataObject { enum { FidPrice, }; double GetPrice() const {return ...;} void SetPrice(double newPrice) {...; NotifyUpdate(FidPrice);} }; DF_BEGIN_FIELD_MAP(CTestClass) DF_DOUBLE_ID(FidPrice, "Price", &CTestClass::GetPrice, &CTestClass::SetPrice, 0) DF_END_FIELD_MAP() //There are many ways to get the non-formatted value from the grid's cell //1. If you have a pointer to the object of your class CTestClass* testClass; double price = testClass->GetPrice(); //2. If you have a pointer to the data object and don't want to cast to the CTestClass type: Dapfor::Common::CDataObject* testClass = new CTestClass(); double price = testClass->GetDouble(CTestClass::FidPrice); //or double price = testClass->GetValue(CTestClass::FidPrice); //3. Get the value directly from the grid. Note, that you get the typed value! //For the Datfor::GUI::CPreferences::DirectCall mode the grid will get the data from the data object //by calling GetPrice() method. //For the Datfor::GUI::CPreferences::MemoryBuffer mode the grid will return value from the cache. double price = m_Grid.GetValue(hItem, CTestClass::FidPrice); //In the same way it is possible to get formatted values as MFC or STL strings Dapfor::Common::CDataObject* testClass = ...; CString mfcText = testClass->GetFormattedMfcString(CTestClass::FidPrice, 0); std::string stlText = testClass->GetFormattedStlString(CTestClass::FidPrice, 0); //Or from the grid: CString mfcText = m_Grid.GetFormattedMfcString(hItem, CTestClass::FidPrice); std::string stlText = m_Grid.GetFormattedStlString(hItem, CTestClass::FidPrice); //The preferred way to set a new value is to implement notifications mechanism //in the data object and call Set- method. CTestClass* testClass = new CTestClass(); test->SetPrice(...); //Of course, you can call m_Grid.SetValue(hItem, CTestClass::FidPrice, (double)1.23); testClass->SetValue(CTestClass::FidPrice, (double)1.23); //Or if you want to transform MFC/STL string to the value, you can use the next m_Grid.SetFormattedMfcString(hItem, CTestClass::FidPrice, "1.23"); testClass->SetFormattedMfcString(CTestClass::FidPrice, "1.23", 0);
| bool SetFormattedStlString | ( | HITEM | hItem, | |
| Common::FID | fid, | |||
| const TString & | str, | |||
| const Common::CFormat * | format = 0 | |||
| ) |
Sets new value into the data object using a formatted string.
A formatted string cannot be directly set into the data object because it works with and keeps only unformatted values. A string is converted into unformatted value trough the format object.
| [in] | hItem | Line's handle in the grid. The line can be visible and invisible as well. |
| [in] | fid | Field's identifier. |
| [in] | str | Unformatted string. |
| [in] | format | The format to covert a formatted string into value |
//Declaration of a data object class CTestClass : public Dapfor::Common::CDataObject { enum { FidPrice, }; double GetPrice() const {return ...;} void SetPrice(double newPrice) {...; NotifyUpdate(FidPrice);} }; DF_BEGIN_FIELD_MAP(CTestClass) DF_DOUBLE_ID(FidPrice, "Price", &CTestClass::GetPrice, &CTestClass::SetPrice, 0) DF_END_FIELD_MAP() //There are many ways to get the non-formatted value from the grid's cell //1. If you have a pointer to the object of your class CTestClass* testClass; double price = testClass->GetPrice(); //2. If you have a pointer to the data object and don't want to cast to the CTestClass type: Dapfor::Common::CDataObject* testClass = new CTestClass(); double price = testClass->GetDouble(CTestClass::FidPrice); //or double price = testClass->GetValue(CTestClass::FidPrice); //3. Get the value directly from the grid. Note, that you get the typed value! //For the Datfor::GUI::CPreferences::DirectCall mode the grid will get the data from the data object //by calling GetPrice() method. //For the Datfor::GUI::CPreferences::MemoryBuffer mode the grid will return value from the cache. double price = m_Grid.GetValue(hItem, CTestClass::FidPrice); //In the same way it is possible to get formatted values as MFC or STL strings Dapfor::Common::CDataObject* testClass = ...; CString mfcText = testClass->GetFormattedMfcString(CTestClass::FidPrice, 0); std::string stlText = testClass->GetFormattedStlString(CTestClass::FidPrice, 0); //Or from the grid: CString mfcText = m_Grid.GetFormattedMfcString(hItem, CTestClass::FidPrice); std::string stlText = m_Grid.GetFormattedStlString(hItem, CTestClass::FidPrice); //The preferred way to set a new value is to implement notifications mechanism //in the data object and call Set- method. CTestClass* testClass = new CTestClass(); test->SetPrice(...); //Of course, you can call m_Grid.SetValue(hItem, CTestClass::FidPrice, (double)1.23); testClass->SetValue(CTestClass::FidPrice, (double)1.23); //Or if you want to transform MFC/STL string to the value, you can use the next m_Grid.SetFormattedMfcString(hItem, CTestClass::FidPrice, "1.23"); testClass->SetFormattedMfcString(CTestClass::FidPrice, "1.23", 0);
| bool IsExpanded | ( | HITEM | hItem | ) | const |
Gets the value pointing whether a line is expanded.
If the line is collapsed then all attached to the given line children will be invisible.
| [in] | hItem | line's handle in the grid. The line can be visible and invisible as well. |
| Handles GetChildren | ( | HITEM | hItem, | |
| bool | visibleOnly | |||
| ) | const |
Gets handles of all the children of a given parent.
Part of handles can be filtered (lines will be invisible.) or hidden by parents.
| [in] | hItem | line's handle in the grid. Available for handles values:
| ||||||
| [in] | visibleOnly | flag pointing that derivable handles will be visible on the screen. I.e. not hidden by parent and not filtered. |
| bool HasChildren | ( | HITEM | hItem | ) | const |
Gets the value pointing whether a given handle has at least one child.
Part of handles can be filtered (lines will be invisible.) or hidden by parents.
| [in] | hItem | line's handle in the grid. Available for handles values:
|
| int GetHierarchicalLevel | ( | HITEM | hItem | ) | const |
Gets a hierarchical level of a given line.
The value of pseudo-handles GI_SCROLLABLE_ROOT and GI_FIXED_ROOT are '-1'. The lines attached to any of these contexts will have level '0'. Next children will have level '1'. And so on. A number of levels is not limited.
| [in] | hItem | line's handle in the grid. The line can be visible and invisible as well. |
| HITEM GetParent | ( | HITEM | hItem | ) | const |
Gets the parent to which a line is attached.
| [in] | hItem | line's handle in the grid. The line can be visible and invisible as well. Any value got from Add function can be used as a parameter. |
| void Expand | ( | HITEM | hItem, | |
| bool | withChildren | |||
| ) |
Expands a line.
Attached to this line children become visible. Recursive expansion of all children is possible. In case of recursion if GI_SCROLLABLE_ROOT and GI_FIXED_ROOT are passed as an argument the grid will expand all lines in a given context.
| [in] | hItem | line handle in the grid. The line can be visible and invisible as well. GI_SCROLLABLE_ROOT and GI_FIXED_ROOT can be used as a parameter. Collapsing and expanding of the root item context don't have any effect but it can be useful in case of recursive data expansion when withChildren = true. |
| [in] | withChildren | indicates whether recursive data expansion should be done for all attached to a given line children. |
CMyClass* myObject = new CMyClass(...); Dapfor::GUI::HITEM hItem = m_Grid.Add(myObject); //We'll expand this node, so all children, added to this node will be visible m_Grid.Expand(hItem, false); //To expand all rows in the fixed or scrollable contexts, you can use a code like this: m_Grid.Expand(Dapfor::GUI::GI_SCROLLABLE_ROOT, true); //The same code you can use to collapse all rows m_Grid.Collapse(Dapfor::GUI::GI_SCROLLABLE_ROOT, true);
| void Expand | ( | const Common::CDataObject * | pDO, | |
| bool | withChildren | |||
| ) |
Expands the line which handle is associated with the data object.
If several handles are found in the grid then the operation will be applied to each of them.
| [in] | pDO | pointer to the data object. |
| [in] | withChildren | indicates whether recursive data expansion should be done for all attached to a given line children. |
CMyClass* myObject = new CMyClass(...); Dapfor::GUI::HITEM hItem = m_Grid.Add(myObject); //We'll expand this node, so all children, added to this node will be visible m_Grid.Expand(hItem, false); //To expand all rows in the fixed or scrollable contexts, you can use a code like this: m_Grid.Expand(Dapfor::GUI::GI_SCROLLABLE_ROOT, true); //The same code you can use to collapse all rows m_Grid.Collapse(Dapfor::GUI::GI_SCROLLABLE_ROOT, true);
| void Collapse | ( | HITEM | hItem, | |
| bool | withChildren | |||
| ) |
Collapses a line.
All attached to the line children become invisible.
| [in] | hItem | line handle in the grid. The line can be visible and invisible as well. GI_SCROLLABLE_ROOT and GI_FIXED_ROOT can be used as a parameter. Collapsing and expanding of the root item context don't have any effect but it can be useful in case of recursive data collapsing when withChildren = true. |
| [in] | withChildren | indicates whether recursive data collapsing should be done for all attached to a given line children. |
CMyClass* myObject = new CMyClass(...); Dapfor::GUI::HITEM hItem = m_Grid.Add(myObject); //We'll expand this node, so all children, added to this node will be visible m_Grid.Expand(hItem, false); //To expand all rows in the fixed or scrollable contexts, you can use a code like this: m_Grid.Expand(Dapfor::GUI::GI_SCROLLABLE_ROOT, true); //The same code you can use to collapse all rows m_Grid.Collapse(Dapfor::GUI::GI_SCROLLABLE_ROOT, true);
| void Collapse | ( | const Common::CDataObject * | pDO, | |
| bool | withChildren | |||
| ) |
Collapses the line which handle is associated with the data object.
If several handles are found in the grid then the operation will be applied to each of them.
| [in] | pDO | pointer to the data object. |
| [in] | withChildren | indicates whether recursive data collapsing should be done for all attached to a given line children. |
CMyClass* myObject = new CMyClass(...); Dapfor::GUI::HITEM hItem = m_Grid.Add(myObject); //We'll expand this node, so all children, added to this node will be visible m_Grid.Expand(hItem, false); //To expand all rows in the fixed or scrollable contexts, you can use a code like this: m_Grid.Expand(Dapfor::GUI::GI_SCROLLABLE_ROOT, true); //The same code you can use to collapse all rows m_Grid.Collapse(Dapfor::GUI::GI_SCROLLABLE_ROOT, true);
| int GetRow | ( | HITEM | hItem | ) | const |
Gets an index of a visible grid line for a given handle.
Counting out starts from '0' and is carried out from the beginning of the context, not from the beginning of the grid. I.e. the first line in the scrollable context will always have '0' index. And this index doesn't depend on a quantity of the lines in the fixed context.
| [in] | hItem | line's handle in the grid. |
| int GetRow | ( | const Common::CDataObject * | pDO | ) | const |
Searches for the grid line corresponding to the first met handle of a given data object.
The search starts from the fixed context and continues in the scrollable context. If the handle is filtered or hidden by its parents then '-1' will be returned.
| [in] | pDO | Pointer to the data object |
| ContextType GetContextType | ( | HITEM | hItem | ) | const |
Gets the grid context to which a given handle belongs.
| [in] | hItem | line's handle in the grid. The line can be visible and invisible as well. |
| ContextType GetContextType | ( | const Common::CDataObject * | pDO | ) | const |
Gets the grid context into which the first met handle corresponding to a given data object is inserted.
The search starts from the fixed context and continues in the scrollable context. If the handle is filtered or hidden by its parents then UndefinedContext will be returned.
| [in] | pDO | Pointer to the data object |
| HITEM GetItem | ( | int | nRow, | |
| ContextType | contextType = ScrollableContext | |||
| ) | const |
Gets a line's handle by its absolute location in the grid context.
| [in] | nRow | line's index in the grid context. |
| [in] | contextType | grid context. It can be ScrollableContext or FixedContext. |
| HITEM GetItem | ( | const Common::CDataObject * | pDO | ) | const |
Gets the first met handle for a given data object.
The search starts from the fixed context and continues in the scrollable context.
| [in] | pDO | Pointer to the data object |
| HITEM GetItem | ( | CPoint | point | ) | const |
Gets a handle of the grid line located within given x, y coordinates.
The coordinates are counted from the beginning of the client's area of the grid.
| [in] | point | the coordinates counted in client area of the grid. |
| HITEM GetPreviousItem | ( | HITEM | hItem, | |
| bool | jumpBetweenContexts = true | |||
| ) | const |
Gets a handle of the previous visible line located before a given handle.
To simplify navigation it is possible to jump from the scrollable context to the fixed one. In this case if hItem is pointing to the first visible line in the scrollable context then the previous line will be the last visible one in the fixed grid context.
| [in] | hItem | handle of a visible line (not filtered and not hidden by parents) in the grid. |
| [in] | jumpBetweenContexts | permits to search in the fixed context if hItem is pointing to the scrollable one. |
| HITEM GetNextItem | ( | HITEM | hItem, | |
| bool | jumpBetweenContexts = true | |||
| ) | const |
Gets a handle of the next visible line located after a given handle.
To simplify navigation it is possible to jump from the fixed context to the scrollable one. In this case if hItem is pointing to the last visible line in the fixed context then the next line will have '0' index in the scrollable grid context.
| [in] | hItem | handle of a visible line (not filtered and not hidden by parents) in the grid. |
| [in] | jumpBetweenContexts | permits to search in the scrollable context if hItem is pointing to the fixed one. |
| Common::CDataObject * GetDataObject | ( | HITEM | hItem | ) |
Gets the data object corresponding to a given handle.
| [in] | hItem | hItem line's handle in the grid. The line can be visible and invisible as well. |
| const Common::CDataObject * GetDataObject | ( | HITEM | hItem | ) | const |
Gets the data object corresponding to a given handle. Const version.
| [in] | hItem | hItem line's handle in the grid. The line can be visible and invisible as well. |
| Common::CDataObject * GetDataObject | ( | int | nRow, | |
| ContextType | contextType = ScrollableContext | |||
| ) |
Gets the data object corresponding to the line located in a given grid context and at a given position.
| [in] | nRow | index in the grid context. |
| [in] | contextType | grid context. |
| const Common::CDataObject * GetDataObject | ( | int | nRow, | |
| ContextType | contextType = ScrollableContext | |||
| ) | const |
Gets the data object corresponding to the line located in a given grid context and at a given position. Const version.
| [in] | nRow | index in the grid context. |
| [in] | contextType | grid context. |
| int GetFirstVisibleRow | ( | ) | const |
Gets the first visible on the screen line in the scrollable context.
| int GetLastVisibleRow | ( | ContextType | contextType = ScrollableContext |
) | const |
Gets the last visible on the screen line in a given context.
The index of the last line depends on the grid's size, quantity of inserted data objects and for scrollable context also from the position of vertical scrollbar.
| [in] | contextType | type of the context where the search is conducted. |
| void SetFirstVisibleRow | ( | int | nRow | ) |
Sets a given index as the first visible in the scrollable context.
| [in] | nRow | Index of the row in the scroolable area that is to be displaced. |
| void SetFirstVisibleItem | ( | HITEM | hItem | ) |
Sets a given handle as the first visible in the scrollable context.
If the given handle is located in the fixed context or invisible (filtered or hidden by the parents) then no action is taken.
| [in] | hItem | handle of a visible line in the scrollable context. |
| void SetFirstVisibleItem | ( | const Common::CDataObject * | pDO | ) |
The first met line's handle in the scrollable context for a given data object is searched.
If it is found and visible (not filtered or hidden by the parents) then corresponding to this handle line will be set as the first in the scrollable context of the grid.
| [in] | pDO | Pointer to the data object. |
| void EnsureVisible | ( | int | nRow | ) |
Makes a given line visible in the scrollable context.
| [in] | nRow | Index of the row in the scroollable area. |
| void EnsureVisible | ( | HITEM | hItem | ) |
Makes a given handle visible in the scrollable context.
The operation is not possible for filtered items. In the case of hierarchical items, the grid will expand all parents to show a specified handle.
| [in] | hItem | Handle that is to be visible |
| void EnsureVisible | ( | const Common::CDataObject * | pDO | ) |
Makes the handle corresponding to the data object visible in the scrollable context.
The operation is not possible if the specified handle is filtered. In the case of hierarchical items, the grid will expand all parents to show handle corresponding to the data object.
| [in] | pDO | Pointer to the data object. |
| bool IsVisible | ( | HITEM | hItem | ) | const |
Checks whether a given handle is visible in the grid.
Visibility is determined by the condition that the given handle and corresponding to it data object are not filtered in IGridFilter object. I.e. the operator () for this pair returns false. The second condition is that none of the direct or indirect parents of the given handle is not collapsed.
| [in] | hItem | line's handle in the grid. |
| bool IsVisible | ( | const Common::CDataObject * | pDO | ) | const |
Checks whether the first handle corresponding to the data object is visible in the grid.
Visibility is determined by the condition that given handle and corresponding to it data object are not filtered in the IGridFilter object. I.e. operator () for this pair returns false. The second condition is that none of direct or indirect parents of given handle is not collapsed.
| [in] | pDO | Pointer to the data object. |
| bool IsInVisibleRect | ( | HITEM | hItem | ) |
Checks whether at least a part of a given line is visible in the client's area of the grid.
| [in] | hItem | Handle that is to be checked |
| bool IsInVisibleRect | ( | const Common::CDataObject * | pDO | ) |
Checks whether at least a part of the given line corresponding to the data object is visible in the client's area of the grid.
| [in] | pDO | Pointer to the data object. |
| bool IsInVisibleRect | ( | int | nRow, | |
| ContextType | contextType | |||
| ) |
Checks whether at least a part of the line located in a given grid context and at a given position is visible in the client's area of the grid.
| [in] | nRow | index in the grid context. |
| [in] | contextType | grid context. |
| CRect GetContextVisibleRect | ( | ContextType | contextType | ) | const |
Gets the visible rectangle occupied by a given grid context taking the size of the client's grid area and scrolling into consideration.
| [in] | contextType | type of a grid context. Available values: FixedContext and ScrollableContext. |
| CRect GetContextVirtualRect | ( | ContextType | contextType | ) | const |
Gets the virtual rectangle occupied by a given grid context without taking the size of the client's grid area and scrolling into consideration.
| [in] | contextType | type of a grid context. Available values: FixedContext and ScrollableContext. |
| CRect GetLineVisibleRect | ( | HITEM | hItem | ) | const |
Gets the visible rectangle occupied by the grid line corresponding to a given handle.
| [in] | hItem | handle of a visible line in any context. |
| CRect GetLineVisibleRect | ( | const Common::CDataObject * | pDO | ) | const |
Gets the visible rectangle occupied by the grid line corresponding to the first found handle for a given data object.
| [in] | pDO | Pointer to the data object. |
| CRect GetLineVirtualRect | ( | HITEM | hItem | ) | const |
Calculates the virtual rectangle occupied by the line corresponding to a given handle.
The rectangle is calculated without taking the size of the visible grid area and scrolling into consideration.
| [in] | hItem | handle of a visible line in any context. |
| CRect GetLineVirtualRect | ( | const Common::CDataObject * | pDO | ) | const |
Gets the virtual rectangle occupied by the grid line corresponding to the first found handle for a given data object.
| [in] | pDO | Pointer to the data object. |
| CRect GetCellVisibleRect | ( | HITEM | hItem, | |
| Common::FID | fid | |||
| ) | const |
Gets a visible rectangle of the grid cell specified by a given handle and column identifier (identifier of a data object field).
The visible rectangle is bounded by the visible area of the grid context.
| [in] | hItem | handle of a visible line in any context. |
| [in] | fid | field's identifier. |
| CRect GetCellVisibleRect | ( | const Common::CDataObject * | pDO, | |
| Common::FID | fid | |||
| ) | const |
Gets a visible rectangle of the grid cell specified by the first found handle for a given data object and column identifier (identifier of a data object field).
The visible rectangle is bounded by the visible area of the grid context.
| [in] | pDO | Pointer to the data object. |
| [in] | fid | field's identifier. |
| CRect GetCellVirtualRect | ( | HITEM | hItem, | |
| Common::FID | fid | |||
| ) | const |
Gets a virtual rectangle of the grid cell specified by a given handle and column identifier (identifier of a data object field).
The visible rectangle is bounded by the visible area of the grid context.
| [in] | hItem | handle of a visible line in any context. |
| [in] | fid | field's identifier. |
| CRect GetCellVirtualRect | ( | const Common::CDataObject * | pDO, | |
| Common::FID | fid | |||
| ) | const |
Gets a virtual size of the grid cell specified by the first found handle for a given data object and column identifier (identifier of the data object field) without taking the size of the visible grid area into consideration.
The visible rectangle is bounded by the visible area of the grid context.
| [in] | pDO | Pointer to the data object. |
| [in] | fid | field's identifier. |
| int GetLinesPerPage | ( | bool | forward = true |
) | const |
Calculates a quantity of wholly visible lines per page in the scrollable context of the grid.
If indexes are increasing while counting (forward is equal to 'true') then the sum of derived value and the first visible index can't be more than the index of the last line in the scrollable context. And if indexes are reducing the difference between the first visible index and derived value can't be less than 0.
| [in] | forward | If the value is 'true' then calculation is conducted starting from the first visible index with index increase. Otherwise quantity of lines per page is calculated in direction of indexes reduction starting from the first visible line. |
| int GetItemHeight | ( | HITEM | hItem | ) | const |
Gets a height of the corresponding to a given handle line.
| [in] | hItem | line's handle in the grid. The line can be visible and invisible as well. |
| void AllowSelection | ( | bool | bEnable | ) |
Allows to perform selection in the grid.
| [in] | bEnable | Sets selection in the grid. True - selection is allowed, false - forbidden. |
| bool CanSelect | ( | ) | const |
Defines whether lines selection in the grid is allowed.
| void AllowMultiSelection | ( | bool | bEnable | ) |
Allows the possibility to select several lines in the grid.
| [in] | bEnable | If true then the grid allows to select several lines at once. Otherwise only one line can be selected. |
| bool CanMultiSelect | ( | ) | const |
Defines whether lines multi selection is allowed in the grid.
| void AllowSelectContext | ( | ContextType | contextType = AllContexts |
) |
Sets the grid context where selection is allowed.
The architecture of the grid sets two contexts: scrollable and fixed. In each of these contexts it is possible to allow a possibility of lines selection.
| [in] | contextType | grid context. Available values: UndefinedContext, FixedContext, ScrollableContext, AllContexts. |
| bool CanSelectContext | ( | ContextType | contextType | ) | const |
Defines whether lines selection is allowed in a given grid context.
| [in] | contextType | grid context. Available values: FixedContext, ScrollableContext. |
| int GetSelectedCount | ( | ) | const |
Gets a total number of selected lines in the grid.
| bool Select | ( | int | nRow, | |
| ContextType | contextType, | |||
| bool | bSelect | |||
| ) |
Changes selection of the line located in a given position in a given context.
| [in] | nRow | index of the line in the grid context. |
| [in] | contextType | grid context. |
| [in] | bSelect | points whether a given line should be selected or selection should be cancelled. In case of true the grid tries to do selection. |
| bool Select | ( | HITEM | hItem, | |
| bool | bSelect | |||
| ) |
Allows to select a line by its handle.
Selection can be done both for visible and for invisible (filtered or hidden by parents) grid lines.
| [in] | hItem | line's handle in the grid. |
| [in] | bSelect | points whether a given line should be selected or selection should be cancelled. In case of true the grid tries to do selection. |
| bool Select | ( | const Common::CDataObject * | pDO, | |
| bool | bSelect | |||
| ) |
Changes selection for all the handles associated with a given data object in the grid.
| [in] | pDO | Pointer to the data object. |
| [in] | bSelect | points whether a given line should be selected or selection should be cancelled. In case of true the grid tries to do selection. |
| Selection GetSelection | ( | ContextType | contextType | ) | const |
Gets a list of selected handles.
| [in] | contextType | The context where the search is conducted. Available values: FixedContext, ScrollableContext, AllContexts. |
| bool IsSelected | ( | int | nRow, | |
| ContextType | contextType | |||
| ) | const |
Tests whether the line located in a given position in a given context is selected.
| [in] | nRow | index of the line in the grid context. |
| [in] | contextType | grid context. |
| bool IsSelected | ( | HITEM | hItem | ) | const |
Tests whether the line with a specified handle is selected.
| [in] | hItem | line's handle in the grid. The line can be visible and invisible as well. |
| bool IsSelected | ( | const Common::CDataObject * | pDO | ) | const |
Tests whether the first line's handle corresponding to the data object is selected.
| [in] | pDO | Pointer to the data object. |
| void SelectAll | ( | ) |
Selects all visible lines in the grid if selection is allowed.
If multiselection is disabled, then only one line will be selected.
| void ClearSelection | ( | ) |
Selects out all lines in the grid.
| void AllowMouseTrackSelection | ( | bool | bEnable | ) |
Allows selection using the mouse.
With its help it is possible to select many grid lines at once. If the lines are located outside of the visible area there is a possibility of automatic data scrolling with their selection. And scrolling speed will change as the distance between the cursor and the grid increases.
| [in] | bEnable | True if enable. Otherwise false. |
| bool CanMouseTrackSelection | ( | ) | const |
Tests whether selection using the mouse is allowed.
| void AllowFocusContext | ( | ContextType | contextType = AllContexts |
) |
Allows to focus lines in a given context.
Lines focusing allows to perform navigation in the grid. Particularly at KeyUp, KeyDown ... keystroke the grid allows to focus a necessary line and ensure its visibility. The grid can have only one focused line.
| [in] | contextType | grid context. Available values: UndefinedContext, FixedContext, ScrollableContext, AllContexts. |
| bool CanFocusContext | ( | ContextType | contextType | ) | const |
Checks if lines focusing is allowed in a given grid context.
| [in] | contextType | grid context. Available values: FixedContext, ScrollableContext |
| bool SetFocusedRow | ( | int | nRow, | |
| ContextType | contextType | |||
| ) |
Sets a new focused line.
| [in] | nRow | index of a line in the grid context. -1 means that the focus will be dropped. |
| [in] | contextType | grid context. |
| int GetFocusedRow | ( | ) | const |
Gets an index of a focused line in a focused grid context.
| ContextType GetFocusedContext | ( | ) | const |
Gets a focused grid context.
| void UpdateRow | ( | int | nRow, | |
| ContextType | contextType, | |||
| Common::FID | fid | |||
| ) |
Informs the grid about changing of a data object.
When this function is called the grid checks line's location and in case of sorting moves it to the appropriate position. Moreover the grid checks whether a handle and a data object satisfy the filtration rules set in IGridFilter interface. If required the grid makes a line visible or hides it. The grid updates time stamp of the last updating for the handle corresponding to the data object what is used for automatic cell highlighting and finally redraws the cell. The same actions are made when a notification from Common::CDataObject::ISink interface has been received.
| [in] | nRow | index of the line in the grid context. |
| [in] | contextType | grid context. |
| [in] | fid | field's identifier. |
| void UpdateItem | ( | HITEM | hItem, | |
| Common::FID | fid | |||
| ) |
Informs the grid that a given handle has been updated.
Filtration check, moving in the grid in case of sorting and text updating will be performed only for one line corresponding to the given handle. Let's emphasize that notification of the grid from Common::CDataObject::ISink interface of the data object is a recommended solution.
| [in] | hItem | line's handle in the grid. |
| [in] | fid | field's identifier. |
| void UpdateDataObject | ( | const Common::CDataObject * | pDO, | |
| Common::FID | fid | |||
| ) |
Informs the grid that a data object has been updated.
The changes take place in all associated with a given data object handles. At the same time updates take place only in one grid. If one data object is inserted into several grids then the updates are not applied to other grids. That's why instead of direct call of UpdateRow(), UpdateItem() and UpdateDataObject() functions it is recommended to send notification through Common::CDataObject::ISink interface. Its thread safe asynchronous realization permits to exclude the risk of dead-lock between threads and automatically synchronize object presentation in all grids.
| [in] | pDO | Pointer to the data object. |
| [in] | fid | field's identifier. |
| int GetTimeElapsedSinceLastUpdate | ( | int | nRow, | |
| ContextType | contextType, | |||
| Common::FID | fid | |||
| ) | const |
Returns (in milliseconds) the time passed from the moment of the last update of a grid cell.
The time period is counted from the moment of UpdateRow(), UpdateItem() and UpdateDataObject() functions call or the moment when the notification from Common::CDataObject::ISink interface has been received.
| [in] | nRow | index of the line in the grid context. |
| [in] | contextType | grid context. |
| [in] | fid | field's identifier. |
| int GetTimeElapsedSinceLastUpdate | ( | HITEM | hItem, | |
| Common::FID | fid | |||
| ) | const |
Returns (in milliseconds) the time passed from the moment of the last update of a grid cell.
The time period is counted from the moment of UpdateRow(), UpdateItem() and UpdateDataObject() functions call or the moment when the notification from Common::CDataObject::ISink interface has been received.
| [in] | hItem | Line's handle in the grid. The line can be visible and invisible as well. |
| [in] | fid | field's identifier. |
| void InvalidateRow | ( | int | nRow, | |
| ContextType | contextType, | |||
| int | spanTime = 0 | |||
| ) |
Redraws a line in the grid.
The main difference from Update(...) functions is that the grid performs no manipulations with lines. spanTime parameter is an additional parameter of this function that indicates when line redrawing should be done. For example this function can be used during realizing line highlighting in the grid.
| [in] | nRow | index of the line in the grid context. |
| [in] | contextType | grid context. |
| [in] | spanTime | The time period in milliseconds after which line redrawing will be requested. If this value is equal to 0 then the request is sent immediately. |
| void InvalidateRow | ( | HITEM | hItem, | |
| int | spanTime = 0 | |||
| ) |
Redraws the line corresponding to a given handle (if it is visible) in the grid.
The main difference from Update(...) functions is that the grid performs no manipulations with lines. spanTime parameter is an additional parameter of this function that indicates when line redrawing should be done. For example this function can be used during realizing line highlighting in the grid.
| [in] | hItem | Line's handle in the grid. |
| [in] | spanTime | The time period in milliseconds after which line redrawing will be requested. If this value is equal to 0 then the request is sent immediately. |
| void InvalidateRow | ( | const Common::CDataObject * | pDO, | |
| int | spanTime = 0 | |||
| ) |
Redraws all the visible lines corresponding to a given data object in the grid.
The main difference from Update(...) functions is that the grid performs no manipulations with lines. spanTime parameter is an additional parameter of this function that indicates when line redrawing should be done. For example this function can be used during realizing line highlighting in the grid.
| [in] | pDO | Pointer to the data object. |
| [in] | spanTime | The time period in milliseconds after which line redrawing will be requested. If this value is equal to 0 then the request is sent immediately. |
| void InvalidateCell | ( | int | nRow, | |
| ContextType | contextType, | |||
| Common::FID | fid, | |||
| int | spanTime = 0 | |||
| ) |
Redraws the cell corresponding to a given line and column identifier in the grid.
| [in] | nRow | index of the line in the grid context. |
| [in] | contextType | grid context. |
| [in] | fid | field's identifier. |
| [in] | spanTime | The time period in milliseconds after which cell redrawing will be requested. If this value is equal to 0 then the request is sent immediately. |
| void InvalidateCell | ( | HITEM | hItem, | |
| Common::FID | fid, | |||
| int | spanTime = 0 | |||
| ) |
Redraws the cell corresponding to a given handle (if it is visible) and column identifier in the grid.
| [in] | hItem | Line's handle in the grid. |
| [in] | fid | field's identifier. |
| [in] | spanTime | The time period in milliseconds after which cell redrawing will be requested. If this value is equal to 0 then the request is sent immediately. |
| void InvalidateCell | ( | const Common::CDataObject * | pDO, | |
| Common::FID | fid, | |||
| int | spanTime = 0 | |||
| ) |
Redraws all the visible cells corresponding to a given data object and column identifier in the grid.
| [in] | pDO | Pointer to the data object. |
| [in] | fid | field's identifier. |
| [in] | spanTime | The time period in milliseconds after which cell redrawing will be requested. If this value is equal to 0 then the request is sent immediately. |
| void AllowNotifications | ( | bool | bAllow | ) |
The grid provides the possibility to deliver notifications to its owner by sending WM_NOTIFY messages.
In order to raise grid productivity this function permits to block the delivery of notifications. (For example when a large number of elements are inserted into the grid.)
| [in] | bAllow | Allows to send notifications. True - sending is allowed, false - forbidden. |
| bool IsNotificationsAllowed | ( | ) | const |
Returns the value indicating whether the grid is allowed to deliver notifications by sending WM_NOTIFY message to its owner.
| CAppearance & GetAppearance | ( | ) |
Gets CAppearance type object where the basic visual grid characteristics such as text, background, vertical and horizontal lines colors and so on are collected.
When values in the return object are modified CWnd::Invalidate() should be called in order the changes to be displayed on the screen.
| const CAppearance & GetAppearance | ( | ) | const |
Gets CAppearance type object where the basic visual grid characteristics such as text, background, vertical and horizontal lines colors and so on are collected. Const version.
When values in the return object are modified CWnd::Invalidate() should be called in order the changes to be displayed on the screen.
| void SetAppearance | ( | const CAppearance & | appearance | ) |
Sets a new grid appearance.
With its running completed the function automatically requests grid updating by calling CWind::Invalidate function.
| const CBackgroundImage & GetBackgroundImage | ( | ) | const |
Gets a background image of the grid.
It is possible to assign a picture with different transparency coefficients. Transparency rate is defined by mixing colors of the picture with the colors, specified in CAppearance object, returned by the GetAppearance() function.
| void SetBackgroundImage | ( | const CBackgroundImage & | image | ) |
Sets a new background image into the grid.
| [in] | image | A new background image |
| void SetFont | ( | CFont * | font, | |
| BOOL | bRedraw = TRUE | |||
| ) |
Sets font attributes to be used for a text within the grid. Internally, the grid clones the font, and after this function has been called, you should to destroy it.
| [in] | font | A new font. |
| [in] | bRedraw | value indicating that the grid should be redrawn. |
//File MyView.h class CMyView : public CView { ... protected: ... afx_msg void OnIncreaseFont(); afx_msg void OnDecreaseFont(); ... Dapfor::GUI::CGrid m_Grid; }; //File MyView.cpp BEGIN_MESSAGE_MAP(CMyView, CView) ... ON_COMMAND(ID_INCREASE_FONT, OnIncreaseFont) ON_COMMAND(ID_DECREASE_FONT, OnDecreaseFont) END_MESSAGE_MAP() ... void CMyView::OnIncreaseFont() { //Retrieve a font from the grid CFont* pfn = m_Grid.GetFont(); //If the grid doesn't have the font, we'll take a default one if(pfn == 0) pfn = Dapfor::GUI::CPreferences::GetFont(); //Default font can be obtained also with the next code: //pfn = CFont::FromHandle((HFONT)::GetStockObject(DEFAULT_GUI_FONT)); if(pfn != 0) { //Get the LOGFONT data LOGFONT logFont; pfn->GetLogFont(&logFont); //Increment the font's size if(CDC* pDC = m_Grid.GetDC()) { int fontSize = -MulDiv(logFont.lfHeight, 72, GetDeviceCaps(pDC->m_hDC, LOGPIXELSY)); if(fontSize < 24) { logFont.lfHeight = -MulDiv(fontSize + 1, GetDeviceCaps(pDC->m_hDC, LOGPIXELSY), 72); } m_Grid.ReleaseDC(pDC); } //Create a temporary font CFont font; font.CreateFontIndirect(&logFont); //Set this font to the grid m_Grid.SetFont(&font); //Destroy the temporary font font.DeleteObject(); } } void CMyView::OnDecreaseFont() { //Retrieve a font from the grid CFont* pfn = m_Grid.GetFont(); //If the grid doesn't have the font, we'll take a default one if(pfn == 0) pfn = Dapfor::GUI::CPreferences::GetFont(); //Default font can be obtained also with the next code: //pfn = CFont::FromHandle((HFONT)::GetStockObject(DEFAULT_GUI_FONT)); if(pfn != 0) { //Get the LOGFONT data LOGFONT logFont; pfn->GetLogFont(&logFont); //Decrease the font's size if(CDC* pDC = m_Grid.GetDC()) { int fontSize = -MulDiv(logFont.lfHeight, 72, GetDeviceCaps(pDC->m_hDC, LOGPIXELSY)); if(fontSize > 6) { logFont.lfHeight = -MulDiv(fontSize - 1, GetDeviceCaps(pDC->m_hDC, LOGPIXELSY), 72); } m_Grid.ReleaseDC(pDC); } //Create a temporary font CFont font; font.CreateFontIndirect(&logFont); //Set this font to the grid m_Grid.SetFont(&font); //Destroy the temporary font font.DeleteObject(); } }
| CFont * GetFont | ( | ) | const |
Gets the current font used in the grid.
| CImageList * SetImageList | ( | CImageList * | imageList, | |
| bool | stretch = false | |||
| ) |
Sets new ImageList to display icons within grid cells.
If an icon size doesn't fit to a cell height the icon can be stretched to be correctly placed in the grid. At data drawing given ImageList and icon's index are sent to ICustomDraw interface where the icon and whole ImageList can be changed.
| [in] | imageList | A new image list. |
| [in] | stretch | Indicates whether icons should be stretched to a cell height. |
| CImageList * GetImageList | ( | ) | const |
Gets the current ImageList value used by the grid.
| void AllowStretchImageInCell | ( | bool | stretch | ) |
Sets the flag allowing to stretch icons in grid cells.
| [in] | stretch | If true - permits to stretch icons in grid cells. |
| bool CanStretchImageInCell | ( | ) | const |
Tests whether the flag allowing to stretch icons in grid cells is set.
| void AllowDrawContextSeparator | ( | bool | bDraw | ) |
Allows drawing of a separator between two grid contexts.
| [in] | bDraw | True if the grid can draw a separator between two grid contexts |
| bool CanDrawContextSeparator | ( | ) | const |
Tests whether drawing of a separator between two grid contexts is allowed.
| void SetContextSeparatorHeight | ( | int | nHeight | ) |
Sets two grid contexts separator's height.
| [in] | nHeight | height of a separator between two contexts in pixels. |
| int GetContextSeparatorHeight | ( | ) | const |
Gets two grid contexts separator's height.
| void AllowHighlight | ( | bool | bAllow | ) |
Allows or forbids grid cells highlighting.
Highlighting is done during the time period specified in CHighlightSettings object and returned by GetHighlightSettings() function. Highlighting starts from the moment of receiving a notification from Common::CDataObject::ISink interface or from the moment of UpdateRow(), UpdateItem() or UpdateDataObject() functions call. The grid provides several possible highlighting types starting with simple colors inversion and ending with alpha blending on the background using a fading effect. All the information concerning highlighting is sent to ICustomDraw interface where it can be freely redefined, allowed or forbidden for a single cell.
| [in] | bAllow | Allows grid cells highlighting. True - highlighting is allowed, false - forbidden. |
//Turn on cells highlighting m_Grid.AllowHighlight(true); //Select the highlighting with a fading effect m_Grid.GetHighlightSettings().SetMode(Dapfor::GUI::FadingBackColor); m_Grid.GetHighlightSettings().SetBackColor(RGB(230, 10, 14));
| bool CanHighlight | ( | ) | const |
Returns the value indicating if the grid can perform cells highlighting or not.
//Turn on cells highlighting m_Grid.AllowHighlight(true); //Select the highlighting with a fading effect m_Grid.GetHighlightSettings().SetMode(Dapfor::GUI::FadingBackColor); m_Grid.GetHighlightSettings().SetBackColor(RGB(230, 10, 14));
| const CHighlightSettings & GetHighlightSettings | ( | ) | const |
Gets the highlighting parameters collected in CHighlightSettings type object. Const version.
Derived parameters include colors of the front and the rear background colors, highlighting a time period, mode...
//Turn on cells highlighting m_Grid.AllowHighlight(true); //Select the highlighting with a fading effect m_Grid.GetHighlightSettings().SetMode(Dapfor::GUI::FadingBackColor); m_Grid.GetHighlightSettings().SetBackColor(RGB(230, 10, 14));
| CHighlightSettings & GetHighlightSettings | ( | ) |
Gets the highlighting parameters collected in CHighlightSettings type object.
Derived parameters include colors of the front and the rear background colors, highlighting a time period, mode...
//Turn on cells highlighting m_Grid.AllowHighlight(true); //Select the highlighting with a fading effect m_Grid.GetHighlightSettings().SetMode(Dapfor::GUI::FadingBackColor); m_Grid.GetHighlightSettings().SetBackColor(RGB(230, 10, 14));
| void SetHighlightSettings | ( | const CHighlightSettings & | settings | ) |
Sets new parameters of highlighting in the grid.
| [in] | settings | New highlighting parameters. |
//Turn on cells highlighting m_Grid.AllowHighlight(true); //Select the highlighting with a fading effect m_Grid.GetHighlightSettings().SetMode(Dapfor::GUI::FadingBackColor); m_Grid.GetHighlightSettings().SetBackColor(RGB(230, 10, 14));
| ICustomDraw * SetCustomDraw | ( | ICustomDraw * | customDraw | ) |
Sets a new interface to specify grid elements drawing.
At grid realization all cells drawing, highlighting, navigation and so on were put to the external modules that totally define one or another functionality. Particularly during drawing all necessary parameters are gathered at one place and passed to ICustomDraw interface. If the interface is not assigned then the default realization got by calling Creferences::GetDefaultCustomDraw() is applied. The mission of the interface is to transmit parameters to the appropriate graphical format that directly conducts drawing. There are two types of formats: lines drawing format and cells drawing format. Default realization of the lines drawing format includes calculation of cells sizes and transmission of the parameters to the cells drawing format through ICustomDraw. Thus ICustomDraw is the central place through which all information at grid elements drawing is passed and this is the most convenient place for its redefining.
| [in] | customDraw | New interface to specify grid elements drawing. |
| ICustomDraw * GetCustomDraw | ( | ) | const |
Gets current ICustomDraw interface.
| void SetPaintFilter | ( | UINT | paintFilter = defaultPaintFilter |
) |
Sets a new graphical filter.
The filter is a list of PaintFilter type values and allows to conduct appropriate grid elements. The set filter at the moment of drawing is transmitted to ICustomDraw where it can be totally redefined. This permits to block highlighting or selection drawing for a separate grid cell.
| [in] | paintFilter | A new paint filter. Set of PaintFilter enumeration. |
//This filter is defined in the Dapfor/GUI/Types.h file enum PaintFilter { drawNothing = 0x00, //Draws nothing drawText = 0x01, //Draws the text in the grid drawImage = 0x02, //Draws an image in the cell drawHeaderImage = 0x04, //Draws an image in the columns drawBackground = 0x08, //Draws a background in the grid drawSelection = 0x10, //Blends selection with fore and back colors for selected lines. drawSelectionFrame = 0x20, //Draws a frame around selected lines drawColumnSort = 0x40, //Blends column sorting with fore and back colors. drawMouseTrackSelection = 0x80, //Draws an area, selected by mouse with pressed left button drawFocusedRow = 0x100, //Blends focus with fore and back colors for selected lines. drawFocusedRowFrame = 0x200, //Draws a frame around the focused line drawHighlight = 0x400, //Draws highlighting drawDropPosition = 0x800, //Draws indicators helping to drop a clipboard content drawDropParentPosition = 0x1000, //Draws an indicator helping to select a hierarchical level during drop operation drawHierarchy = 0x2000, //Draws a hierarchy. Each child is shifted relatively to its parent drawCollapseExpandIcon = 0x4000, //Draws collapse/expand icons drawHierarchicalLines = 0x8000, //Draws hierarchical lines drawHorizontalLines = 0x10000, //Draws horizontal lines between lines drawVerticalLines = 0x20000, //Draws vertical lines between columns drawEmbeddedControlBackground = 0x40000, //Forces an embedded MFC control to blend its background color with one of the cell drawEverything = drawText | drawImage | drawHeaderImage| drawBackground | //Text, Image & background drawSelection | drawSelectionFrame | //Selection drawMouseTrackSelection | //Mouse track selection drawFocusedRow | drawFocusedRowFrame | //Focus drawColumnSort | //Column sorting drawHighlight | //Highlighting drawDropPosition | drawDropParentPosition | //Drag & drop drawHierarchy |drawCollapseExpandIcon | drawHierarchicalLines | //Hierarchy drawHorizontalLines | drawVerticalLines | //Vertical & horizontal lines drawEmbeddedControlBackground | drawHorizontalLines | drawVerticalLines, //Vertical & horizontal lines defaultPaintFilter = drawEverything, }; //Using example: //This code prevent from drawing the selection. m_Grid.SetPaintFilter(m_Grid.GetPaintFilter() & ~(Dapfor::GUI::drawSelection|Dapfor::GUI::drawSelectionFrame)); //And this code prevent from drawing the focus. m_Grid.SetPaintFilter(m_Grid.GetPaintFilter() & ~(Dapfor::GUI::drawFocusedRow|Dapfor::GUI::drawFocusedRowFrame));
| UINT GetPaintFilter | ( | ) | const |
Gets current value of the graphical filter.
//This filter is defined in the Dapfor/GUI/Types.h file enum PaintFilter { drawNothing = 0x00, //Draws nothing drawText = 0x01, //Draws the text in the grid drawImage = 0x02, //Draws an image in the cell drawHeaderImage = 0x04, //Draws an image in the columns drawBackground = 0x08, //Draws a background in the grid drawSelection = 0x10, //Blends selection with fore and back colors for selected lines. drawSelectionFrame = 0x20, //Draws a frame around selected lines drawColumnSort = 0x40, //Blends column sorting with fore and back colors. drawMouseTrackSelection = 0x80, //Draws an area, selected by mouse with pressed left button drawFocusedRow = 0x100, //Blends focus with fore and back colors for selected lines. drawFocusedRowFrame = 0x200, //Draws a frame around the focused line drawHighlight = 0x400, //Draws highlighting drawDropPosition = 0x800, //Draws indicators helping to drop a clipboard content drawDropParentPosition = 0x1000, //Draws an indicator helping to select a hierarchical level during drop operation drawHierarchy = 0x2000, //Draws a hierarchy. Each child is shifted relatively to its parent drawCollapseExpandIcon = 0x4000, //Draws collapse/expand icons drawHierarchicalLines = 0x8000, //Draws hierarchical lines drawHorizontalLines = 0x10000, //Draws horizontal lines between lines drawVerticalLines = 0x20000, //Draws vertical lines between columns drawEmbeddedControlBackground = 0x40000, //Forces an embedded MFC control to blend its background color with one of the cell drawEverything = drawText | drawImage | drawHeaderImage| drawBackground | //Text, Image & background drawSelection | drawSelectionFrame | //Selection drawMouseTrackSelection | //Mouse track selection drawFocusedRow | drawFocusedRowFrame | //Focus drawColumnSort | //Column sorting drawHighlight | //Highlighting drawDropPosition | drawDropParentPosition | //Drag & drop drawHierarchy |drawCollapseExpandIcon | drawHierarchicalLines | //Hierarchy drawHorizontalLines | drawVerticalLines | //Vertical & horizontal lines drawEmbeddedControlBackground | drawHorizontalLines | drawVerticalLines, //Vertical & horizontal lines defaultPaintFilter = drawEverything, }; //Using example: //This code prevent from drawing the selection. m_Grid.SetPaintFilter(m_Grid.GetPaintFilter() & ~(Dapfor::GUI::drawSelection|Dapfor::GUI::drawSelectionFrame)); //And this code prevent from drawing the focus. m_Grid.SetPaintFilter(m_Grid.GetPaintFilter() & ~(Dapfor::GUI::drawFocusedRow|Dapfor::GUI::drawFocusedRowFrame));
| void SetFlickerFreeDrawing | ( | bool | enable | ) |
Allows to use the mechanism of double buffering in order to exclude the flicker effect at the moment of elements drawing.
However when this mode is set it can influence grid productivity. Usually it is not necessary to set this mode because an updated text practically doesn't flicker on the screen.
| [in] | enable | Allows to use the mechanism of double buffering. True - double buffering is allowed, false - forbidden. |
| bool GetFlickerFreeDrawing | ( | ) | const |
Gets the value indicating whether a double buffering mode is allowed.
| int GetOptimalRowHeight | ( | ContextType | contextType | ) | const |
Gets optimal value of lines height in a given grid context.
The height is calculated in ICustomDraw interface based on the font parameters and can be easily redefined.
| [in] | contextType | grid context. |
| int GetOptimalCellWidth | ( | int | nRow, | |
| ContextType | contextType, | |||
| Common::FID | fid | |||
| ) | const |
Gets optimal value of a given grid cell width.
The parameters for value calculation are passed to the graphical grid cells drawing format through ICustomDraw interface. Line position in the hierarchy and also icons, area for unrolling and rolling up children and current value of graphical filter presence are taken into consideration at calculation. ICustomDraw interface can influence the calculation of the derived value. The calculated value can be used for optimization of a column size in the grid.
| [in] | nRow | index of a line in the grid context. |
| [in] | contextType | grid context. Available values: FixedContext, ScrollableContext. |
| [in] | fid | field's identifier. |
| int GetOptimalColumnWidth | ( | ContextType | contextType, | |
| Common::FID | fid | |||
| ) | const |
Calculates the optimal grid column size based on the optimal sizes got for grid visible cells by GetOptimalCellWidth() function call.
| [in] | contextType | grid context. Available values: FixedContext, ScrollableContext, AllContexts. |
| [in] | fid | field's identifier. |
Sets a new header.
If sorting is set in a new header then all grid lines will be automatically sorted according to the sorting rules. Headers replacing allows to manage data objects presentation in the grid rather easy and effective. Particularly different headers can display different data objects fields or same fields but in different formats.
| [in] | newHeader | A new header. |
| CHeader * GetHeader | ( | ) |
Gets the current header used by the grid.
| const CHeader * GetHeader | ( | ) | const |
Gets the current header used by the grid. Const version.
| void ShowHeader | ( | ) |
Makes the header visible.
| void HideHeader | ( | ) |
Makes the header invisible.
| bool IsHeaderVisible | ( | ) | const |
Returns the value indicating whether the header is visible.
| void ShowHeaderDialog | ( | ) | [virtual] |
Shows the dialog allowing to configure columns of the header.
| const CColumn * GetColumn | ( | CPoint | pt | ) | const |
Searches a column in the grid according to the coordinates counted off in the client's area of the grid.
| [in] | pt | Location in the client's area of the grid. |
| const CColumn * GetNavigationColumn | ( | ) | const |
Gets a navigation column.
The grid allows to perform a quick line search according to the first letters typed by the user. During letters typing their comparison with the lines values in a navigation column is conducted and in case of coincidence scrolling to the first coincidence is done. The function gets the navigation column according to which the quick lines search can be performed.
| const CColumn * GetHierarchicalColumn | ( | ) | const |
Gets the column that manages the grid hierarchy.
In this column the icons allowing to unroll a line and show children items are displayed. Usually this column is the first visible column in a header.
| void AdjustColumnByFid | ( | Common::FID | fid | ) |
Performs column width optimization for visible grid lines.
A column width is adjusted in such a way that the grid cells in a given column haven't got partly hidden data. Data object field identifier is used to identify the column.
| [in] | fid | field's identifier. |
| void AdjustColumnByIndex | ( | int | index | ) |
Performs column width optimization by its index.
A column width is adjusted in such a way that the grid cells in given column haven't got partly hidden data.
| [in] | index | Zero-based column index. |
| void AdjustAllColumns | ( | ) |
Performs all grid columns width optimization. The columns width is adjusted in such a way that grid cells in a given column haven't got partly hidden data.
| int GetOptimalHeaderHeight | ( | ) | const |
Gets optimal header's height.
| void EnsureColumnVisible | ( | Common::FID | fid | ) |
The function makes a column wholly visible in the grid.
If a column is invisible or partly visible then the grid performs horizontal scrolling in order to make given column wholly visible.
| [in] | fid | field's identifier. |
| void EnableTooltip | ( | bool | bEnable = true |
) |
Allows to display tooltips.
| [in] | bEnable | True - tooltips are allowed, false - forbidden. |
| bool IsTooltipEnabled | ( | ) | const |
Returns the value indicating whether tooltip displaying is allowed.
| const ITooltipCtrl * GetTooltipCtrl | ( | ) |
Gets current ITooltipCtrl used by the grid.
This interface serves for managing a tooltip window.
| ITooltipCtrl * SetTooltipCtrl | ( | ITooltipCtrl * | control | ) |
Sets new ITooltipCtrl interface to control the tooltip window.
GUI library provides two realizations of the tooltip made in CTooltipCtrl and CHtmlTooltipCtrl classes. When a new tooltip is set the function returns the previous control.
| [in] | control | A new tooltip control |
| const ITooltip * GetTooltip | ( | ) | const |
Gets the interface controlling the tooltip content.
To display the tooltip it is not necessary to implement this interface because ITooltipCtrl provides default realization of this interface. If it is required to redefine an outputted text the programmer can give his version of this interface.
Set a new interface for defining the tooltip content.
| [in] | tooltip | New tooltip interface. |
| const CTooltipSettings & GetTooltipSettings | ( | ) | const |
Gets the tooltip settings collected in CTooltipSettings class object. Const version.
| CTooltipSettings & GetTooltipSettings | ( | ) |
Gets the tooltip settings collected in CTooltipSettings class object.
| void SetTooltipSettings | ( | const CTooltipSettings & | settings | ) |
Sets new tooltip settings.
| [in] | settings | New tooltip settings |
| void EnableInPlaceTooltip | ( | bool | bEnable = true |
) |
Allows to show the tooltip above grid cells when a cell size is not enough for displaying a text.
In case if a grid cell size is not enough for displaying a text then the 'embedded' tooltip allows to display a hidden text partly or wholly in the window located exactly above the grid cell keeping a size and style of the outputted text. This kind of tooltip is shown on the screen automatically in case of a invisible or partly visible text.
| [in] | bEnable | True - tooltips are allowed, false - forbidden. |
| bool IsInPlaceTooltipEnabled | ( | ) | const |
Returns the value indicating whether the grid can show the tooltip above the grid cells when a cell size is not enough for displaying a text.
| CTooltipSettings & GetInPlaceTooltipSettings | ( | ) |
Gets the tooltip settings determinant how the grid should show the tooltip above the grid cells when a cell size is not enough for displaying a text.
| void SetInPlaceTooltipSettings | ( | const CTooltipSettings & | settings | ) |
Sets the new settings determinant how the grid should show the tooltip above the grid cells when a cell size is not enough for displaying a text.
| [in] | settings | Settings collected in CTooltipSettings class object. |
| const ITooltipCtrl * GetInPlaceTooltipCtrl | ( | ) | const |
Gets the current tooltip control used by the grid when a cell size is not enough for displaying a text.
| ITooltipCtrl * SetInPlaceTooltipCtrl | ( | ITooltipCtrl * | control | ) |
Sets new ITooltipCtrl interface to control the 'embedded' tooltip window.
CInPlaceTooltipCtrl is the default realization used by the grid.
| [in] | control | A new tooltip control. |
| bool Copy | ( | ) |
Copies selection to the clipboard.
The copy process can be totally redefined in ICopyPaste interface.
| bool Cut | ( | ) |
Cuts selection to the clipboard.
The cut process can be totally redefined in ICopyPaste interface.
| bool Paste | ( | ) |
Inserts elements into the grid to the located after the focused line place.
If there is no focused line in the grid then the elements are pasted to the grid's end. If the elements are put to the clipboard by Cut() command then they are transfered from the previous position to a new one. This statement is true only for the grids running in one application. When data are intended to be transferred from grids running in different applications then if it is possible de-serialization and creation of corresponding types objects are conducted and then the reconstructed objects are pasted in the grid.
| bool Paste | ( | HITEM | hParent, | |
| HITEM | hInsertAfter | |||
| ) |
Pastes data from the clipboard to a given position.
| [in] | hParent | Parent to which the attachment can be done. Any got in Add() function value or one of the following contexts: GI_SCROLABLE_ROOT or GI_FIXED_ROOT can be a parent. | ||||||
| [in] | hInsertAfter | the value used to specify location of the insertion. If sorting is switched on then this parameter doesn't have any meaning because a data object will be inserted according to the sorting rules. If there is no sorting hInsertAfter can have the following values:
|
| ICopyPaste * SetCopyPaste | ( | ICopyPaste * | copyPaste | ) |
Sets new ICopyPaste interface.
| ICopyPaste * GetCopyPaste | ( | ) | const |
Gets the current ICopyPaste interface used by the grid.
| const CCopyPasteSettings & GetCopyPasteSettings | ( | ) | const |
Gets the settings collected in CCopyPasteSettings type object and used by the grid at copy/paste operations. Const version.
| CCopyPasteSettings & GetCopyPasteSettings | ( | ) |
Gets the settings collected in CCopyPasteSettings type object and used by the grid at copy/paste operations.
| void SetCopyPasteSettings | ( | const CCopyPasteSettings & | settings | ) |
Sets the new settings used by the grid at copy/paste operations.
| [in] | settings | New settings to be used at copy/paste operations. |
| void AllowCopyPaste | ( | bool | bAllow | ) |
Allows or forbids to use copy/paste.
| [in] | bAllow | Enables to use copy/paste. |
| bool IsCopyPasteAllowed | ( | ) | const |
Gets the value indicating whether copy/paste operations are allowed.
Sets new IDragDrop interface. At the same time the function returns the previous interface used by the grid.
| [in] | dragDrop | New IDragDrop interface. |
| IDragDrop * GetDragDrop | ( | ) | const |
Gets the current IDragDrop interface used by the grid.
| const CDragDropSettings & GetDragDropSettings | ( | ) | const |
Gets the drag&drop settings collected in CDragDropSettings type object. Const version.
| CDragDropSettings & GetDragDropSettings | ( | ) |
Gets the drag&drop settings collected in CDragDropSettings type object.
| void SetDragDropSettings | ( | const CDragDropSettings & | settings | ) |
Sets new drag&drop settings.
| [in] | settings | Settings collected in CDragDropSettings class object. |
| void AllowDragAndDrop | ( | bool | bAllow | ) |
Allows or forbids drag&drop in the grid.
| [in] | bAllow | Enables to use drag&drop. |
| bool IsDragAndDropAllowed | ( | ) | const |
Gets the value indicating whether drad&drop operations are allowed.
| CDragImage CreateDragImage | ( | const Handles & | handles, | |
| ContextType | contextType, | |||
| const CHeader * | header | |||
| ) | const |
Helper which allows to create an image while grid content dragging.
For more visualization the grid provides the possibility to use an image of transferred data. As a result the function returns CDragImage type object containing the image as CImageList object and the cursor's position counted from the left upper corner of the picture. With drop operation completed it is necessary to delete the image by calling CImageList::DeleteImageList() and then its destructor.
| [in] | handles | list of the handles participating in drag&drop operation. |
| [in] | contextType | Context type. |
| [in] | header | Current header used by the grid. |
| void AllowSort | ( | bool | bEnable | ) |
Allows or forbids sorting in the grid.
| [in] | bEnable | True - sorting is allowed, false - forbidden. |
| bool CanSort | ( | ) | const |
Returns the value indicating whether sorting is allowed.
| void AllowMultiSort | ( | bool | bEnable | ) |
Allows multiple sorting in the grid.
| [in] | bEnable | True - multiple sorting is allowed, false - forbidden. |
| bool CanMultiSort | ( | ) | const |
Returns the value indicating whether multiple sorting is allowed.
| void SetSortedContext | ( | ContextType | contextType = AllContexts |
) |
Sets the grid context where sorting is allowed.
| [in] | contextType | Grid context. Available values: UndefinedContext, FixedContext, ScrollableContext, AllContexts. If UndefinedContext is applied then sorting will be forbidden in both contexts. |
| ContextType GetSortedContext | ( | ) | const |
Gets the contexts where sorting is allowed.
| void ResetSort | ( | bool | redraw = true |
) |
Cancels sorting.
| [in] | redraw | If the redraw flag is set for true then the grid will be redrawn. |
| void SetSort | ( | int | level, | |
| CSortInfo | sortInfo, | |||
| bool | applyImmediatelly = true | |||
| ) |
Sets a sort for a given level.
The grid supports up to five levels of sorting. Level indexing starts from '0'. The function permits to set sorting for a given level. Levels of sorting must be set in order without leaps. There is a possibility to start the process after all levels of sorting have been set, not every time when a level is changed.
| [in] | level | sorting level. The first level starts from '0'. |
| [in] | sortInfo | information about sorting. Assigns the column on which sorting is conducted and its direction. |
| [in] | applyImmediatelly | Indicates whether it should apply for new sorting parameters immediatelly. |
| CSortInfo GetSort | ( | int | level | ) | const |
Gets information about sorting for a given level.
In case if sorting for a given level is not specified then the field identifier returned by CSortInfo::GetFid() will be equal to Common::fieldNotSpesified.
| void UpdateSort | ( | ) |
Carries out data sorting in the grid according to the sorting rules specified in a header.
| int GetSortLevels | ( | ) | const |
Returns current value of sorting levels quantity.
| IGridFilter * SetFilter | ( | IGridFilter * | filter | ) |
Sets a new filter.
At the same time the function returns the previous value of the filter. At filter setting all grid lines are checked on whether or not they are filtered.
| [in] | filter | New filter |
| IGridFilter * GetFilter | ( | ) | const |
Gets the current filter set in the grid.
| void UpdateFilter | ( | ) |
Calls checking of all grid lines on whether or not they are filtered.
| IKeyManager * SetKeyManager | ( | IKeyManager * | keyManager | ) |
Sets a new keyboard manager to control the grid.
At the same time the function returns the previous manager.
| [in] | keyManager | New keyboard manager. |
| IKeyManager * GetKeyManager | ( | ) | const |
Gets the current keyboard manager used by the grid.
| void AllowNavigation | ( | ContextType | contextType = AllContexts |
) |
Allows to conduct navigation in given grid contexts.
| [in] | contextType | Available values: UndefinedContex, FixedContext, ScrollableContext, AllContexts. If UndefinedContext is applied then navigation will be forbidden in both contexts. |
| bool CanNavigate | ( | ContextType | contextType | ) | const |
Returns the value, indicating whether navigation is possible in given grid context.
| void NavigateUp | ( | bool | bShift, | |
| bool | bCtrl | |||
| ) |
Moves a focus up and scrolls down one line if it is necessary.
The function hands over navigation parameters to the keyboard manager, which carries out movements of the grid lines focus and selection changing according to the specified values of bShift and bCtrl. In case if the keyboard manager is not set then the parameters are handed over to the default manager returned by CPreferences::GetDefaultKeyManager() function.
| [in] | bShift | Indicates whether the shift button is pressed |
| [in] | bCtrl | Indicates whether the control button is pressed |
| void NavigateDown | ( | bool | bShift, | |
| bool | bCtrl | |||
| ) |
Moves a focus down and scrolls up one line if it is necessary.
The function hands over navigation parameters to the keyboard manager, which carries out movements of the grid lines focus and selection changing according to the specified values of bShift and bCtrl. In case if the keyboard manager is not set then the parameters are handed over to the default manager returned by CPreferences::GetDefaultKeyManager() function.
| [in] | bShift | Indicates whether the shift button is pressed |
| [in] | bCtrl | Indicates whether the control button is pressed |
| void NavigatePageUp | ( | bool | bShift, | |
| bool | bCtrl | |||
| ) |
Moves a focus up and scrolls down one page if it is necessary.
The function hands over navigation parameters to the keyboard manager, which carries out movements of the grid lines focus and selection changing according to the specified values of bShift and bCtrl. In case if the keyboard manager is not set then the parameters are handed over to the default manager returned by CPreferences::GetDefaultKeyManager() function.
| [in] | bShift | Indicates whether the shift button is pressed |
| [in] | bCtrl | Indicates whether the control button is pressed |
| void NavigatePageDown | ( | bool | bShift, | |
| bool | bCtrl | |||
| ) |
Moves a focus down and scrolls up one page if it is necessary.
The function hands over navigation parameters to the keyboard manager, which carries out movements of the grid lines focus an