/** * @file XTPGridControl.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(__XTPGRIDCONTROL_H__) # define __XTPGRIDCONTROL_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPCompatibleDC; class CXTPPropExchange; class CXTPToolTipContext; class CXTPImageManager; class CXTPMarkupContext; struct XTP_GRIDRECORDITEM_DRAWARGS; struct XTP_GRIDRECORDITEM_METRICS; struct XTP_GRIDRECORDITEM_ARGS; struct XTP_NM_GRIDTOOLTIPINFO; class CXTPGridRecords; class CXTPGridRecordItem; class CXTPGridColumns; class CXTPGridGroups; class CXTPGridColumn; class CXTPGridRecord; class CXTPGridRows; class CXTPGridRow; class CXTPGridPaintManager; class CXTPGridColumnOrder; class CXTPGridInplaceEdit; class CXTPGridInplaceButtons; class CXTPGridInplaceList; class CXTPGridNavigator; class CXTPGridIconNavigator; class CXTPGridRecordItemConstraint; class CXTPGridDataManager; class CXTPGridHyperlink; class CXTPGridRecordItemRange; class CXTPGridSelectedRows; class CXTPGridBehavior; class CXTPGridBehaviorRowMouseButton; class CXTPGridTip; class CXTPGridSection; class CXTPGridSections; class CXTPGridBorder; class CXTPGridHitTestInfo; /** * @brief * This structure is sent to the Main window in a WM_NOTIFY message from * Item and provides all parameters required by the Main window to process * control specific notifications. * * Example: * *
* BEGIN_MESSAGE_MAP(CGridSampleView, CXTPGridView)
* ON_NOTIFY(XTP_NM_GRID_GETITEMMETRICS, XTP_ID_GRID_CONTROL, OnGridGetItemMetrics)
* END_MESSAGE_MAP()
*
* void CGridSampleView::OnGridGetItemMetrics(NMHDR* pNotifyStruct, LRESULT* result)
* {
* XTP_NM_GRIDITEMMETRICS* pItemNotify = (XTP_NM_GRIDITEMMETRICS*)pNotifyStruct;
*
* _ASSERTE(pItemNotify->pDrawArgs);
* _ASSERTE(pItemNotify->pDrawArgs->pControl);
* _ASSERTE(pItemNotify->pDrawArgs->pRow);
*
* // pItemNotify->pDrawArgs->pColumn - may be NULL (for a group row)
* // pItemNotify->pDrawArgs->pItem - may be NULL (for a group row)
*
* _ASSERTE(pItemNotify->pItemMetrics);
*
* // NTcustomize members of pItemNotify->pItemMetrics.
* }
*
*
* @see
* CXTPGridControl, CXTPGridControl::GetItemMetrics(),
* XTP_NM_GRID_GETITEMMETRICS
*/
struct XTP_NM_GRIDITEMMETRICS
{
NMHDR hdr; /**< Standard structure; contains information about a notification message. */
XTP_GRIDRECORDITEM_DRAWARGS* pDrawArgs; /**< Pointer to an XTP_GRIDRECORDITEM_DRAWARGS
structure. */
XTP_GRIDRECORDITEM_METRICS* pItemMetrics; /**< Pointer to an XTP_GRIDRECORDITEM_METRICS
structure to be filled. */
};
/**
* @brief
* This structure is sent to the Main window in a WM_NOTIFY message from
* Grid Control to determine if records are dragged or dropped.
*
* Example:
*
* BEGIN_MESSAGE_MAP(CGridSampleView, CXTPGridView)
* ON_NOTIFY(XTP_NM_GRID_BEGINDRAG, XTP_ID_GRID_CONTROL, OnGridBeginDrag)
* END_MESSAGE_MAP()
*
* void CGridSampleView::OnGridBeginDrag(NMHDR* pNotifyStruct, LRESULT* result)
* {
* XTP_NM_GRIDDRAGDROP* pItemNotify = (XTP_NM_GRIDDRAGDROP*)pNotifyStruct;
*
* _ASSERTE(pItemNotify->pRecords);
* }
*
* @see
* XTP_NM_GRID_DROP, XTP_NM_GRID_BEGINDRAG, CXTPGridControl::EnableDragDrop
*/
struct XTP_NM_GRIDDRAGDROP
{
NMHDR hdr; /**< Standard structure; contains information about a notification message. */
CXTPGridRecords* pRecords; /**< Records will be dragged/dropped. */
CXTPGridRecord* pTargetRecord; /**< Target record (if any). */
int nTargetRow; /**< Index of target row. */
BOOL bAbove; /**< Where to insert (relative to the target record). */
DROPEFFECT dropEffect; /**< DropEffect flags. */
CPoint pt; /**< Current location of the cursor in client coordinates. */
int nState; /**< Transition state (0 - enter, 1 - leave, 2 - over). */
DWORD dwKeyState; /**< Key state. */
COleDataSource* pDataSource; /**< Data Source - issue 22675. */
COleDataObject* pDataObject; /**< Data Object - required for drag over and drop. */
BOOL bReturnValue; /**< TRUE to accept dropEffect, FALSE to not accept dropEffect. */
};
/**
* @brief
* This structure is sent to the Main window in a WM_NOTIFY message before
* processing the OnKeyDown event.
* @see
* CXTPGridControl::OnPreviewKeyDown, XTP_NM_GRID_PREVIEWKEYDOWN,
* CXTPGridControl::OnKeyDown, CWnd::OnKeyDown.
*/
struct XTP_NM_GRIDPREVIEWKEYDOWN
{
NMHDR hdr; /**< Standard structure; contains information about a notification message. OnKeyDown
parameters */
UINT nChar; /**< [in/out] Specifies the virtual key code of the given key. */
UINT nRepCnt; /**< [in] Repeat count. */
UINT nFlags; /**< [in] Specifies the scan code, key-transition code, previous key state, and
context code. */
BOOL bCancel; /**< [out] TRUE to cancel processing key, FALSE to continue. */
};
/**
* @brief
* Enumeration of operational mouse modes.
* @details
* GridControl has several mouse states handled by the control.
* This enumeration helps to clearly identify each of these:
* Sends Notifications.
* Sends Messages.
* @see
* CXTPGridControl::SetMouseMode, CXTPGridControl::GetMouseMode,
* xtpGridMouseNothing, xtpGridMouseOverColumnDivide, xtpGridMousePrepareDragColumn,
* xtpGridMouseDraggingColumn
*/
enum XTPGridMouseMode
{
xtpGridMouseNothing, /**< User is just watching to the list.*/
xtpGridMouseOverColumnDivide, /**< User watching, but mouse is under column divider.*/
xtpGridMousePrepareDragColumn, /**< User holds mouse button pressed on the column header.*/
xtpGridMouseDraggingColumn, /**< User is dragging column header.*/
xtpGridMouseOverRowDivide, /**< User watching, but mouse is under row divider.*/
};
/**
* @brief
* Enumeration of drag and drop flags.
* @details
* Call CXTPGridControl::EnableDragDrop to allow drag/drop operations.
*
* Example:
* m_wndGrid.EnableDragDrop("MyApplication", xtpGridAllowDrop |
* xtpGridAllowDrag);
* @see
* CXTPGridControl::EnableDragDrop
*/
enum XTPGridDragDrop
{
xtpGridAllowDrop = 1, /**< Allow drop records to grid. */
xtpGridAllowDragCopy = 2, /**< Allow copy records from grid. */
xtpGridAllowDragMove = 4, /**< Allow move records from grid. */
xtpGridAllowDrag = 6, /**< Allow copy and move records from grid.*/
xtpGridDontDropAsText = 8 /**< Do not drag record as plain text. */
};
/**
* @brief
* Enumeration describes the drop marker.
*/
enum XTPGridDropMarker
{
xtpGridDropBetween = 1, /**< Drop the row between two rows.*/
xtpGridDropSelect = 2, /**< Drop the selected rows.*/
};
/**
* @brief
* Enumeration of watermark alignment flags.
* @details
* Call CXTPGridControl::SetWatermarkAlignment to modify watermark alignment.
*
* Example:
* m_wndGrid.SetWatermarkAlignment(xtpWatermarkCenter | xtpWatermarkBottom);* @see * CXTPGridControl::SetWatermarkAlignment, GetWatermarkAlignment */ enum XTPGridWatermarkAlignment { xtpGridWatermarkUnknown = 0, /**< Unknown (empty) value.*/ xtpGridWatermarkLeft = 0x0001, /**< Horizontal alignment: left side of Grid control client rect. */ xtpGridWatermarkCenter = 0x0002, /**< Horizontal alignment: center of Grid control client rect. */ xtpGridWatermarkRight = 0x0004, /**< Horizontal alignment: right side of Grid control client rect. */ xtpGridWatermarkHmask = 0x000F, /**< A mask for horizontal alignment flags.*/ xtpGridWatermarkTop = 0x0010, /**< Vertical alignment: top side of Grid control client rect.*/ xtpGridWatermarkVCenter = 0x0020, /**< Vertical alignment: center of Grid control client rect.*/ xtpGridWatermarkBottom = 0x0040, /**< Vertical alignment: bottom side of Grid control client rect. */ xtpGridWatermarkVmask = 0x00F0, /**< A mask for vertical alignment flags.*/ xtpGridWatermarkStretch = 0x0100, /**< Stretch watermark to entire Grid control client rect.*/ xtpGridWatermarkEnlargeOnly = 0x0200, /**< Watermark can be enlarged only, shrinking is disabled. */ xtpGridWatermarkShrinkOnly = 0x0400, /**< Watermark can be shrinked only, enlarging is disabled.*/ xtpGridWatermarkPreserveRatio = 0x0800, /**< Watermark aspect ratio is preserved.*/ }; /** * @brief * Enumeration of GetElementRect flags. * @details * Call CXTPGridControl::GetElementRect to get grid element rectangle. * * Example: *
CRect rcElement = m_wndGrid.GetElementRect(xtpGridRectGroupByArea);* @see * CXTPGridControl::GetElementRect */ enum XTPGridElementRect { xtpGridElementRectGridArea = 0, /**< The area occupied by the records. */ xtpGridElementRectGroupByArea, /**< The area occupied by Group By item. */ xtpGridElementRectHeaderArea, /**< The area occupied by the header. */ xtpGridElementRectFooterArea, /**< The area occupied by the footer. */ xtpGridElementRectHeaderRecordsArea, /**< The area occupied by the header records. */ xtpGridElementRectFooterRecordsArea, /**< The area occupied by the footer records. */ xtpGridElementRectHeaderRecordsDividerArea, /**< The area occupied by the header records divider. */ xtpGridElementRectFooterRecordsDividerArea, /**< The area occupied by the footer records divider. */ }; /** * @brief * Enumeration of options for the SetRecordsTreeFilterMode method. * @details * Call CXTPGridControl::SetRecordsTreeFilterMode to set options for the filtering tree. * * Example: *
m_wndGrid.SetRecordsTreeFilterMode(xtpGridFilterTreeSimple);* @see * CXTPGridControl::SetRecordsTreeFilterMode */ enum XTPGridFilterMode { xtpGridFilterTreeSimple = 0, /**< Specifies a simple tree grid filter mode */ xtpGridFilterTreeByParentAndChildren = 1, /**< Specifies a parent-children tree grid filter mode */ xtpGridFilterTreeByEndChildrenOnly = 2 /**< Specifies a end children only tree grid filter mode */ }; /** * @brief * Enumeration of scroll update modes. */ enum XTPGridScrollUpdateMode { xtpGridScrollUpdateModeImmediate, /**< Immediately updates the scroll position.*/ xtpGridScrollUpdateModeDeferred /**< Updates the scroll position deferred.*/ }; /** * @brief * Enumeration of scroll modes. */ enum XTPGridScrollMode { xtpGridScrollModeNone = 0, /**< No scrolling.*/ xtpGridScrollModeBlockCount = 1, /**< Scrolls an entire row or column.*/ xtpGridScrollModeBlockSize = 3, /**< Scrolls an entire row or column.*/ xtpGridScrollModeSmooth = 2, /**< Smooth scrolling. */ // Deprecated xtpGridScrollModeBlock = xtpGridScrollModeBlockCount, /**< Deprecated, same as xtpGridScrollModeBlockCount */ }; /** * @brief * Stores the mouse and key states. */ struct XTPGridInputState { XTPGridInputState() : ptMouse(-1, -1) , bKeyControl(FALSE) , bKeyShift(FALSE) , nRow(-1) , bSelected(FALSE) { // Nothing. } CPoint ptMouse; /**< Mouse position. */ BOOL bKeyControl; /**< Control key state. */ BOOL bKeyShift; /**< Shift key state. */ int nRow; /**< Clicked row index. */ BOOL bSelected; /**< Clicked row selection state. */ }; /** * @brief * The CXTPGridControl class provides an implementation of * the Grid control. * * @details * A "Grid control" is a window that displays a hierarchical list * of items, such as emails in the inbox. Each item is called a CXTPGridRow * and consists of its properties and corresponding CXTPGridRecord, * which contains all the corresponding data (mostly text). * Each Row item (as well as Record) can have a list of sub-items * associated with it. By clicking a Row item, the user can expand and * collapse the associated list of sub-items. * * The CXTPGridRecords collection holds all the CXTPGridRecord objects * that are assigned to the Grid control. It could be accessible via * the GetRecords() method. The records in this collection * are referred to as the root records. Any record that is subsequently * added to a root record is referred to as a child record. Because each * CXTPGridRecord can contain a collection of other CXTPGridRecord * objects, you might find it difficult to determine your location in the * tree structure when you iterate through the collection. * * Record nodes can be expanded to display the next level of child records. * The user can expand the CXTPGridRecord by clicking the plus-sign (+) * button, if one is displayed, or you can expand the CXTPGridRecord by * calling the CXTPGridRecord::SetExpanded method. * To expand all the child records, call the ExpandAll method. * You can collapse the child CXTPGridRecord level by calling the * CXTPGridRecord::SetExpanded(FALSE) method, or the user can press * the minus-sign (-) button, if one is displayed. You can also call * CollapseAll method to collapse all child records. * * Each record contains an array of record items which are implemented * with CXTPGridRecordItem and its descendants. You can create your own * types of items simply by inheriting from the base record item class. * * Each record item has an association with a corresponding CXTPGridColumn * item. The item will be shown below the corresponding column header * depending on its position in Grid control columns array. If a column * does not have an associated item in the record, there will be an empty item * shown in the corresponding cell. * * Columns array is represented by the CXTPGridColumns collection and could * be accessed via the GetColumns() method. * * As a finalization of adding data to the Grid control, which means * adding columns and records, the Populate() method should be called. It * performs population of control rows with data - creates a rows tree if * necessary, rebuilds groups if grouping if enabled, and sorts rows * on a specified manner. See Also an example below. * * Handling notification messages sent by the control to the parent * window is allowed with the ON_NOTIFY handler. The control uses the * SendMessageToParent function to send notifications. See below for * the example of how messages could be handled in a parent window: * *
* ON_NOTIFY(NM_CLICK, ID_GRID_CONTROL, OnGridItemClick) * ON_NOTIFY(NM_RCLICK, ID_GRID_CONTROL, OnGridItemRClick) * ON_NOTIFY(NM_DBLCLK, ID_GRID_CONTROL, OnGridItemDblClick) * ON_NOTIFY(XTP_NM_SHOWFIELDCHOOSER, ID_GRID_CONTROL, OnShowFieldChooser) * ON_NOTIFY(XTP_NM_HEADER_RCLICK, ID_GRID_CONTROL, OnGridColumnRClick) * ON_NOTIFY(NM_KEYDOWN, ID_GRID_CONTROL, OnGridKeyDown) ** * You can also change the appearance of the CXTPGridControl control * by setting some of its display and style properties. * * Also Grid control has an ability to store and restore its * settings, which includes all columns with their settings, and some * required control's settings. It is implemented via standard MFC and XTP * serialization and is available with the member functions * SerializeState(CArchive& ar), DoPropExchange(CXTPPropExchange* pPX); * * Grid control supports Copy/Paste clipboard operations. * See methods: CanCut(), CanCopy(), CanPaste(), Cut(), Copy(), Paste(). * There are 2 clipboard formats that are supported: * Binary - contains all record(s) data; * Text - contains visible columns texts. * * To support binary format the XTP serialization is used - * DoPropExchange() methods are implemented for CXTPGridRecord, * CXTPGridRecordItem and derived CXTPGridRecordItemXXX classes. * Also some part of standard MFC serialization is used * (see DECLARE_SERIAL macro) to automatically create classes when * loading from the data source. * * If you are creating custom records and records items classes, you have * to use DECLARE_SERIAL macro and may need to override DoPropExchange() * methods to serialize custom data as well as standard records data. * * Storing records is simple: the CXTPGridRecord (or derived class) * is stored first, then record items (CXTPGridRecordItemXXX classes) * are stored one by one. * The class information, which allows for creating object instances when * loading, is stored for all classes. See CArchive::WriteClass(), * CArchive::ReadClass() and other CArchive members for more details * about this idea. * * When Grid control loads records from the data source, * the record class is created automatically (using stored * class information). * Then the items collection is cleared and record items are created * automatically and added to the items collection. * For example see GridSample project: CMessageRecord class. * * We support text format with '\\t' dividers for record items and * "\\r\\n" dividers for records (simple tab-separated text). * Such format is also supported by Excel and some other applications. * * There are a few methods and corresponding notifications which allow * for the customization of copy/paste operations: * OnBeforeCopyToText(); OnBeforePasteFromText(); OnBeforePaste(); * * @see * CXTPGridView, CXTPGridHeader, CXTPGridRow, CXTPGridRecord, * CXTPGridColumn, * CXTPGridRecords, CXTPGridRows, CXTPGridColumns, * CXTPGridSubListControl, CXTPGridFilterEditControl */ class _XTP_EXT_CLASS CXTPGridControl : public CWnd , public CXTPAccessible { /** @cond */ DECLARE_DYNCREATE(CXTPGridControl) DECLARE_INTERFACE_MAP() XTP_DECLARE_CMDTARGETPROVIDER_INTERFACE() friend class CXTPGridSubListControl; friend class CXTPGridRow; friend class CXTPGridGroupRow; friend class CXTPGridHeader; friend class CXTPGridNavigator; friend class CXTPGridInplaceEdit; friend class CXTPGridHeaderDragWnd; friend class CXTPGridInplaceList; friend class CXTPGridColumn; friend class CXTPGridView; class CGridDropTarget; /** @endcond */ public: /** * @brief * Internal grid update helper. */ class _XTP_EXT_CLASS CUpdateContext { public: /** * @brief * Constructs a CUpdateContext object. * @param pControl Pointer to a Grid Control object. */ CUpdateContext(CXTPGridControl* pControl) { m_pControl = pControl; pControl->BeginUpdate(); } /** * @brief * Destroys a CUpdateContext object, * handles cleanup and deallocation. */ ~CUpdateContext() { m_pControl->EndUpdate(); } protected: CXTPGridControl* m_pControl; /**< Updated Grid control pointer. */ }; public: /** * @brief * Call this function to use the custom heap feature. * @details * If it is enabled, grid data will be allocated in custom (separate) * heap instead of standard application heap. This optimize memory * using (fragmentation) for big amount of data. * For custom heap used for classes derived from CXTPHeapObjectT template, * like CXTPGridRecord, CXTPGridRecordItem, CXTPGridRow and so others. * This template just overrides operators new and delete. * It must be called on initialization before any allocations of classes * which use custom heap. OnInitInstance is a fine place for this. * @return * TRUE if custom heap feature is enabled for all grid allocators, * FALSE otherwise. */ static BOOL AFX_CDECL UseGridCustomHeap(); /** * @brief * Call this function to enable the batch allocation feature for grid rows. * @details * Batch allocation means that memory allocated not for one object only, * but for many objects at one time (for 1024 objects by default). * Next allocations take memory from this big block. New blocks allocated * when necessary. This increase performance and reduce heap fragmentation. * Batch allocation mechanism responsible for allocation/deallocation * blocks of memory from heap and internally organize free/busy lists of * memory pieces. When object deleted, its memory stored in free list and * used for new objects. * When all memory pieces from block free, it may be deallocated from * heap automatically (this depends on options in _TBatchAllocData) * or by FreeExtraData call, * It must be called on initialization before any allocations of classes * which use batch allocation. OnInitInstance is a fine place for this. * @return * TRUE if batch allocation feature is enabled for grid rows, * FALSE otherwise. */ static BOOL AFX_CDECL UseRowBatchAllocation(); /** * @brief * This function is used when row batch allocation is enabled to both check * all allocated blocks and deallocate any blocks which are completely free. * @return * @see * UseRowBatchAllocation, CXTPBatchAllocObjT */ static void AFX_CDECL FreeRowBatchExtraData(); /** * @brief * Constructs a CXTPGridControl object. * @details * You construct a CXTPGridControl object in two steps. * First, call the constructor CXTPGridControl and then call * the Create method. This initializes the window. * * * Example: *
* // Declare a local CXTPGridControl object.
* CXTPGridControl myGrid;
*
* // Declare a dynamic CXTPGridControl object.
* CXTPGridControl* pMyGrid = new CXTPGridControl();
*
* if (!myGrid.Create(WS_CHILD | WS_TABSTOP | WS_VISIBLE | WM_VSCROLL, CRect(0, 0, 0, 0),
* this, ID_GRID_CONTROL))
* {
* TRACE(_T("Failed to create view window\n"));
* }
*
* @see
* Create
*/
CXTPGridControl();
/**
* @brief
* Destroys a CXTPGridControl object, handles cleanup and deallocation.
*/
virtual ~CXTPGridControl();
/**
* @brief
* This method is called to create a Grid control.
* @param dwStyle Specifies the window style attributes
* (this could be a combination of standard window styles).
* @param rect Size and position of the window,
* in client coordinates of pParentWnd.
* @param pParentWnd Specifies the Grid control parent window.
* @param nID Specifies the Grid control identifier.
* @param pContext The create context of the window.
* @details
* You construct a CXTPGridControl object in two steps.
* First, call the constructor CXTPGridControl and then call
* the Create method. This initializes the window.
*
* Example:
* See the example for CXTPGridControl::CXTPGridControl.
* @return
* Nonzero if successful, otherwise 0.
* @see
* CXTPGridControl::CXTPGridControl
*/
BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID,
CCreateContext* pContext = NULL);
/**
* @brief
* (Re)Stores control configuration to/from the provided archive stream.
* @param ar Archive stream for serializing.
*/
virtual void SerializeState(CArchive& ar);
/**
* @brief
* Reads/writes configuration to/from the provided data source.
* @param pPX Pointer to a CXTPPropExchange object to serialize to/from.
*/
virtual void DoPropExchange(CXTPPropExchange* pPX);
/**
* @brief
* Adds a specified column to the end of the columns array.
* @param pColumn Pointer to a CXTPGridColumn object to add.
* @details
* Call this member function if you want to add a specified column to the
* Grid control. It will be added to the end of the columns array.
* @return
* A pointer to the newly added column.
*
* Example:
*
* // this function adds a column with "Subject" caption and 250 pixels initial width
* void AddSubjectColumn(CXTPGridControl* pGridCtrl)
* {
* pGridCtrl->AddColumn(new CXTPGridColumn(1, _T("Subject"), 250));
* }
*
* @see
* CXTPGridColumn overview
*/
CXTPGridColumn* AddColumn(CXTPGridColumn* pColumn);
/**
* @brief
* Adds a specified data record to the records collection.
* @param pRecord Pointer to a CXTPGridRecord object to add.
* @details
* Call this member function if you want to add a specified
* data record to the Grid control's internal storage.
* @return
* A pointer to the newly added data record.
*
* Example:
*
* // this function adds 2 empty records to a Grid control
* void Add2Empties(CXTPGridControl* pGridCtrl)
* {
* pGridCtrl->AddRecord(new CXTPGridRecord());
* pGridCtrl->AddRecord(new CXTPGridRecord());
* }
*
* @return
* Pointer to the recently added record object.
* @see
* CXTPGridRecord overview, GetRecords
*/
virtual CXTPGridRecord* AddRecord(CXTPGridRecord* pRecord);
/**
* @brief
* Adds a specified data record to the records collection and
* associates a row with it.
* @param pRecord Pointer to a CXTPGridRecord object to add.
* @param pParentRecord Pointer to a parent CXTPGridRecord object
* for pRecord to be added to.
* @param nRowChildIndex Child index for a row to be inserted at in case the
* index is not defined by other conditions (or -1).
* @param nRecordChildIndex Child index for a record to be inserted at (or -1).
* @details
* Call this member function if you want to add a data record to the
* Grid control's internal storage and associate a row with it.
*
* Example:
*
* // this function adds 2 empty records to a Grid control
* void Add2Empties(CXTPGridControl* pGridCtrl)
* {
* pGridCtrl->AddRecordEx(new CXTPGridRecord());
* pGridCtrl->AddRecordEx(new CXTPGridRecord());
* }
*
* @see
* CXTPGridRecord overview, GetRecords, RemoveRecordEx, RemoveRowEx, UpdateRecord
*/
virtual void AddRecordEx(CXTPGridRecord* pRecord, CXTPGridRecord* pParentRecord = NULL,
int nRowChildIndex = -1, int nRecordChildIndex = -1);
/**
* @brief
* Removes a specified record, the row associated with the specified record,
* and all child records and rows.
* @param pRecord Pointer to a CXTPGridRecord object to remove.
* @param bAdjustLayout TRUE to call the AdjustLayout method.
* @param bRemoveFromParent TRUE to remove the record from its parent.
* @details
* Call this member function if you want to remove a record and row on the fly
* without calling the Populate method.
* @return
* TRUE if the operation was successful, otherwise FALSE.
* @see
* RemoveRowEx, AddRecordEx, CXTPGridRecords::RemoveRecord, UpdateRecord
*/
virtual BOOL RemoveRecordEx(CXTPGridRecord* pRecord, BOOL bAdjustLayout = TRUE,
BOOL bRemoveFromParent = TRUE);
/**
* @brief
* Removes a specified row, the record associated with the specified row,
* and all child rows and records.
* @param pRow Pointer to a CXTPGridRow object to remove.
* @param bAdjustLayout TRUE to call the AdjustLayout method.
* @details
* Call this member function if you want to remove a row and record on the fly
* without calling the Populate method.
* @return
* TRUE if the operation was successful, otherwise FALSE.
* @see
* RemoveRecordEx, AddRecordEx, CXTPGridRecords::RemoveRecord, UpdateRecord
*/
virtual BOOL RemoveRowEx(CXTPGridRow* pRow, BOOL bAdjustLayout = TRUE);
/**
* @brief
* Updates a specified record.
* @param pRecord Pointer to a CXTPGridRecord object to update.
* @param bUpdateChildren TRUE to update the children of pRecord.
* @details
* Call this member function if you modified a record and want it
* to be updated according to the current grouping and sorting.
* @see
* CXTPGridRecord overview, GetRecords
*/
virtual void UpdateRecord(CXTPGridRecord* pRecord, BOOL bUpdateChildren);
/**
* @brief
* Prevents the Grid control from being redrawn until the EndUpdate
* method is called.
* @details
* If you want to add items one at a time using the AddRecord method, or
* if you want to perform other operations in a single sequence, then
* you can use the BeginUpdate method to prevent the control from repainting
* the CXTPGridControl each time an item is added. Once you have
* completed the task of adding items to the control, call the EndUpdate
* method to enable the CXTPGridControl to repaint. This way of
* adding items can prevent flickered drawing of the CXTPGridControl when
* a large number of items are being added to the control.
*
* Example:
*
* // This function collapses all rows for the specified Grid control
* void CollapseAll(CXTPGridControl* pGridCtrl)
* {
* pGridCtrl->BeginUpdate();
* for (int i = pGridCtrl->GetRows()->GetCount() - 1; i >= 0; i --)
* pGridCtrl->GetRows()->GetAt(i)->SetExpanded(FALSE);
*
* pGridCtrl->EndUpdate();
* }
*
* @see
* EndUpdate, RedrawControl, AddRecord
*/
void BeginUpdate();
/**
* @brief
* Deletes all rows and records from the Grid control.
* @param bUpdateControl TRUE to redraw the control, FALSE otherwise.
*/
void ResetContent(BOOL bUpdateControl = TRUE);
/**
* @brief
* Resumes drawing of the Grid control after drawing has been suspended
* by the BeginUpdate method.
* @details
* If you want to add items one at a time using the AddRecord method, or
* if you want to perform other operations in a single sequence, then
* you can use the BeginUpdate method to prevent the control from repainting
* the CXTPGridControl each time an item is added. Once you have
* completed the task of adding items to the control, call the EndUpdate
* method to enable the CXTPGridControl to repaint. This way of
* adding items can prevent flickered drawing of the CXTPGridControl when
* a large number of items are being added to the control.
*
* Example:
* See example for CXTPGridControl::BeginUpdate method.
* @see
* BeginUpdate, RedrawControl
*/
void EndUpdate();
/**
* @return
* Gets the number of update locks.
* @details
* The number of update locks.
*/
int GetLockUpdateCount() const;
/**
* @brief
* Initiates Grid control redrawing.
* @details
* Call this member function if you want to initialize
* Grid control redrawing. The control will be redrawn
* taking into account its latest state.
* @see
* BeginUpdate, EndUpdate
*/
void RedrawControl();
/**
* @brief
* Gets the tooltip context.
* @return
* A pointer to the tooltip context.
*/
CXTPToolTipContext* GetToolTipContext() const;
/**
* @brief
* Call this method to enable built in drag and drop operations
* @param lpszClipboardFormat Name of the clipboard format to be used
* for the Grid control.
* @param dwFlags Combination of XTPGridDragDrop flags;
* can be one or more of following:
* xtpGridAllowDrop: Allow drop records to grid.
* xtpGridAllowDragCopy: Allow copy records from grid.
* xtpGridAllowDragMove: Allow move records from grid.
* xtpGridAllowDrag: Allow copy and move records from grid.
* @param dwDropMarkerFlags Combination of required bits specified by
* the XTPGridDropMarker enumeration.
* @return
* Clipboard format that will be used with Grid Control
* @see
* XTPGridDragDrop
*/
CLIPFORMAT EnableDragDrop(LPCTSTR lpszClipboardFormat, DWORD dwFlags,
DWORD dwDropMarkerFlags = xtpGridDropBetween);
/**
* @brief
* Sets the drop marker flags.
*
* @param dwDropMarkerFlags Drop marker flags.
*/
void SetDropMarkerFlags(DWORD dwDropMarkerFlags);
/**
* @brief
* Gets the drop marker flags.
* @return
* The drop marker flags.
*/
DWORD GetDropMarkerFlags() const;
/**
* @brief
* Sets the grid drawing style.
* @param orientation Determines the grid style to set; must be one of the
* values defined by the XTPGridOrientation enumeration;
* xtpGridOrientationVertical to set the vertical grid style,
* xtpGridOrientationHorizontal to set the horizontal grid style.
* @param gridStyle Grid style to be set; must be one of the values
* defined by the XTPGridGridStyle enumeration.
* @details
* Call this member function if you want to set the
* grid line drawing style for the Grid control.
*
* Possible grid line drawing styles are the following:
* xtpGridGridNoLines: Empty line.
* xtpGridGridSmallDots: Line drawn by small dots.
* xtpGridGridLargeDots: Line drawn by large dots.
* xtpGridGridDashes: Line drawn by dashes.
* xtpGridGridSolid: Draws solid line.
* @see
* XTPGridGridStyle overview, GetGridStyle, SetGridColor
*/
void SetGridStyle(XTPGridOrientation orientation, XTPGridGridStyle gridStyle);
/** @cond */
_XTP_DEPRECATED_IN_FAVOR(SetGridStyle)
void SetReportStyle(XTPGridOrientation orientation, XTPGridGridStyle gridStyle);
/** @endcond */
/**
* @brief
* Gets the grid drawing style.
* @param orientation Determines the grid style to get; must be one of the
* values defined by the XTPGridOrientation enumeration;
* xtpGridOrientationVertical to get the vertical grid style,
* xtpGridOrientationHorizontal to get the horizontal grid style.
* @details
* Call this member function if you want to get the
* grid line drawing style for the Grid control.
* @return
* The grid drawing style; one of the values defined by
* the XTPGridGridStyle enumeration.
* @see
* XTPGridGridStyle overview, SetGridStyle, SetGridColor
*/
XTPGridGridStyle GetGridStyle(XTPGridOrientation orientation) const;
/** @cond */
_XTP_DEPRECATED_IN_FAVOR(GetGridStyle)
XTPGridGridStyle GetReportStyle(XTPGridOrientation orientation) const;
/** @endcond */
/**
* @brief
* Sets the grid line color.
* @param clrGridLine Grid line color to be set.
* @details
* Call this member function if you want to change the color of
* Grid control grid lines.
* @return
* The previous grid line color.
* @see
* SetGridStyle, GetGridStyle
*/
COLORREF SetGridColor(COLORREF clrGridLine);
/** @cond */
_XTP_DEPRECATED_IN_FAVOR(SetGridColor)
COLORREF SetReportColor(COLORREF clrGridLine);
/** @endcond */
/**
* @brief
* Gets the collection of grid columns.
* @return
* A pointer to the collection of grid columns.
*
* Example:
*
* // this function adds a column with "Subject" caption and 250 pixels initial width
* void AddSubjectColumn(CXTPGridControl* pGridCtrl)
* {
* pGridCtrl->GetColumns()->Add(new CXTPGridColumn(1, _T("Subject"), 250));
* }
*
* @see
* CXTPGridColumns overview
*/
CXTPGridColumns* GetColumns() const;
/**
* @brief
* Gets the paint manager object used to draw the Grid control window.
* @return
* A pointer to the paint manager object.
* @see
* CXTPGridPaintManager overview
*/
CXTPGridPaintManager* GetPaintManager() const;
/**
* @brief
* Sets the paint manager object used to draw the Grid control window.
* @param pPaintManager Pointer to a CXTPGridPaintManager object.
*/
void SetPaintManager(CXTPGridPaintManager* pPaintManager);
/**
* @brief
* Gets the navigator object used for cell navigation by the Grid control.
* @return
* A pointer to the navigator object.
* @see
* CXTPGridNavigator overview
*/
CXTPGridNavigator* GetNavigator() const;
/**
* @brief
* Performs control population, creating a view from the data.
* @details
* Call this member function to populate control's rows collection
* with the data containing in the records collection.
* This method automatically creates Tree View references if
* necessary (e.g. in Grouping mode).
* This method is the main function which should be called for
* (re)populating all data changes made in the records collection.
* @see
* CXTPGridPaintManager overview
*/
virtual void Populate();
/**
* @brief
* Performs control's header rows population, creating a view from the data.
* @details
* Call this member function to populate control's header rows collection
* with the data contained in the header records collection.
* This method is useful when main rows are controlled through the use of
* the AddRecordEx/RemoveRecordEx/UpdateRecord methods.
* @see
* Populate, PopulateFooterRows, AddRecordEx, RemoveRecordEx, UpdateRecord
*/
virtual void PopulateHeaderRows();
/**
* @brief
* Performs control's footer rows population, creating a view from the data.
* @details
* Call this member function to populate control's footer rows collection
* with the data contained in the footer records collection.
* This method is useful when main rows are controlled through the use of
* the AddRecordEx/RemoveRecordEx/UpdateRecord methods.
* @see
* Populate, PopulateHeaderRows, AddRecordEx, RemoveRecordEx, UpdateRecord
*/
virtual void PopulateFooterRows();
/**
* @brief
* Ensures that a Grid control row is at least partially visible.
* @param pRow Pointer to the CXTPGridRow object whose
* visibility must be checked.
* @details
* Ensures that a grid row item is at least partially visible.
* The list view control is scrolled if necessary.
* @see
* MoveDown, MoveUp, MovePageDown, MovePageUp, MoveFirst, MoveLast
*/
void EnsureVisible(CXTPGridRow* pRow);
/**
* @brief
* Ensures that a Grid control column is at least partially visible.
* @param pCheckColumn Pointer to the CXTPGridColumn object whose
* visibility must be checked.
* @details
* Ensures that a grid column item is at least partially visible.
* The list view control is scrolled if necessary.
* @see
* MoveRight, MoveLeft, MoveToColumn, MoveFirstColumn, MoveLastColumn
*/
void EnsureVisible(CXTPGridColumn* pCheckColumn);
/**
* @brief
* Determines which grid part is at a specified point.
* @param pt Point to be tested.
* @param pInfo Pointer to a CXTPGridHitTestInfo object that will
* receive the returned information.
* @return
* TRUE if the method was successful, otherwise FALSE.
*/
virtual BOOL HitTest(CPoint pt, CXTPGridHitTestInfo* pInfo) const;
/**
* @brief
* Determines which grid row is at a specified point, if any.
* @param pt Point to be tested.
* @return
* A pointer to the CXTPGridRow object at the specified point, if any,
* otherwise NULL.
*/
CXTPGridRow* HitTest(CPoint pt) const;
/**
* @brief
* Gets the collection of selected rows.
* @details
* Use this member function to retrieve access to the collection
* of currently selected grid rows.
* @return
* A pointer to the collection of selected rows.
* @see
* CXTPGridSelectedRows overview.
*/
CXTPGridSelectedRows* GetSelectedRows() const;
/**
* @brief
* Gets the currently focused row in the Grid control's view.
* @return
* A pointer to the currently focused row if successful, otherwise NULL.
*/
CXTPGridRow* GetFocusedRow() const;
/**
* @brief
* Sets the currently focused row in the Grid control's view.
* @param pRow Pointer to a CXTPGridRow object.
* @param bControlKey TRUE to select a new focused row.
* @return
* TRUE if the specified row has been focused, otherwise FALSE.
*/
BOOL SetFocusedRow(CXTPGridRow* pRow, BOOL bControlKey = FALSE);
/**
* @brief
* Sets the currently focused row in the Grid control's view.
* @param pRow Pointer to a CXTPGridRow object.
* @param bControlKey TRUE to select a new focused row.
* @param bShiftKey TRUE to select rows up to the new focused row.
* @return
* TRUE if the specified row has been focused, otherwise FALSE.
*/
BOOL SetFocusedRow(CXTPGridRow* pRow, BOOL bShiftKey, BOOL bControlKey);
/**
* @brief
* Sets the currently focused row in the Grid control's view.
* @param bEnsureVisible TRUE to ensure that the row will be visible.
* @param pRow Pointer to a CXTPGridRow object.
* @param bControlKey TRUE to select a new focused row.
* @param bShiftKey TRUE to select rows up to the new focused row.
* @return
* TRUE if the specified row has been focused, otherwise FALSE.
*/
BOOL SetFocusedRow(BOOL bEnsureVisible, CXTPGridRow* pRow, BOOL bShiftKey, BOOL bControlKey);
/**
* @brief
* Calculates the number of visible rows between a specified row
* and the bottom/top of the current view.
* @param nStartRow Index of the row to begin calculating from.
* @param bMoveDown TRUE to down, FALSE to move up.
* @return
* The number of visible rows between the specified row
* and the bottom/top of the current view.
* @see
* MovePageDown, MovePageUp
*/
int GetGridAreaRows(int nStartRow, BOOL bMoveDown);
/** @cond */
_XTP_DEPRECATED_IN_FAVOR(GetGridAreaRows)
int GetReportAreaRows(int nStartRow, BOOL bMoveDown);
/** @endcond */
/**
* @brief
* Sets the top row of the Grid control view.
* @param nIndex Index of the row to be set.
* @details
* The system scrolls the Grid control view upward until either
* the row specified by nIndex is at the top of the view
* or the maximum scroll range is reached.
* @see
* GetGridAreaRows, EnsureVisible
*/
void SetTopRow(int nIndex);
/**
* @brief
* Gets the index of the top row of the Grid control view.
* @return
* The index of the top row of the Grid control view.
* @see
* SetTopRow
*/
int GetTopRowIndex() const;
/**
* @brief
* Sets the horizontal scroll position.
* @param nOffset Horizontal scroll position to be set.
* @details
* This method only takes effect when auto-column sizing is disabled.
* @see
* CXTPGridHeader::SetAutoColumnSizing
*/
void SetScrollOffsetH(int nOffset);
/**
* @brief
* Sets the vertical scroll position.
* @param nOffset Vertical scroll position to be set.
*/
void SetScrollOffsetV(int nOffset);
/**
* @brief
* Sets right-to-left (RTL) mode.
* @param bRightToLeft TRUE to set right-to-left (RTL) reading-order properties.
*/
void SetLayoutRTL(BOOL bRightToLeft);
/**
* @brief
* Determines if right-to-left (RTL) mode was set.
* @return
* TRUE if the layout is right-to-left (RTL), otherwise FALSE.
*/
BOOL IsLayoutRTL();
/**
* @brief
* Enables/disables preview mode for the control.
* @param bIsPreviewMode TRUE to enable preview mode,
* FALSE to disable preview mode.
* @details
* Preview mode has two states: enabled and disabled. When preview mode is
* enabled, the control tries to show additional bands with preview text.
* @see
* IsPreviewMode
*/
void EnablePreviewMode(BOOL bIsPreviewMode);
/**
* @brief
* Determines if preview mode is enabled/disabled for the control.
* @return
* TRUE if preview mode is enabled, FALSE if preview mode is disabled.
* @see
* EnablePreviewMode
*/
BOOL IsPreviewMode() const;
/**
* @brief
* Sets the visible state of the Group By area.
* @param bEnable TRUE to show the Group By area
* FALSE to hide the Group By area.
* @details
* Call this member function if you want to show/hide the
* Group By area in the grid header.
* @see
* IsGroupByVisible
*/
void ShowGroupBy(BOOL bEnable = TRUE);
/**
* @brief
* Gets the visible state of the Group By area.
* @details
* Call this member function if you want to determine if the
* Group By area in the grid header is shown or not.
* @return
* TRUE if the Group By area is shown,
* FALSE if the Group By area is hidden.
* @see
* ShowGroupBy
*/
BOOL IsGroupByVisible() const;
/**
* @brief
* Sets the visible state of column headers.
* @param bShow TRUE to show column headers,
* FALSE to hide column headers.
* @see
* IsHeaderVisible, ShowFooter
*/
void ShowHeader(BOOL bShow = TRUE);
/**
* @brief
* Gets the visible state of column headers.
* @return
* TRUE if column headers are shown,
* FALSE if column headers are hidden.
* @see
* ShowHeader
*/
BOOL IsHeaderVisible() const;
/**
* @brief
* Sets the visible state of column footers.
* @param bShow TRUE to show column footers,
* FALSE to hide column footers.
* @see
* IsFooterVisible, ShowHeader
*/
void ShowFooter(BOOL bShow = TRUE);
/**
* @brief
* Gets the visible state of column footers.
* @return
* TRUE if column footers are shown,
* FALSE if column footers are hidden.
* @see
* ShowHeader
*/
BOOL IsFooterVisible() const;
/**
* @brief
* Enables/disables group items shading.
* @param bEnable TRUE to enable group items shading,
* FALSE to disable group items shading.
* @details
* Call this member function if you want to show/hide
* group rows' headings.
* @see
* IsShadeGroupHeadingsEnabled, IsGroupRowsBold, SetGroupRowsBold,
* GetItemMetrics
*/
void ShadeGroupHeadings(BOOL bEnable = TRUE);
/**
* @brief
* Determines if group items shading is enabled/disabled.
* @details
* Call this member function if you want to determine whether
* group rows' headings are enabled or not.
* @return
* TRUE if group items shading is enabled,
* FALSE if group items shading is disabled.
* @see
* ShadeGroupHeadings, IsGroupRowsBold, SetGroupRowsBold,
* GetItemMetrics
*/
BOOL IsShadeGroupHeadingsEnabled() const;
/**
* @brief
* Sets the group rows text style: bold or normal.
* @param bBold TRUE for bold text style,
* FALSE for normal text style.
* @see
* IsGroupRowsBold, ShadeGroupHeadings, IsShadeGroupHeadingsEnabled,
* GetItemMetrics
*/
void SetGroupRowsBold(BOOL bBold = TRUE);
/**
* @brief
* Gets the group rows text style: bold or normal.
* @return
* TRUE if group rows text style is bold,
* FALSE if group rows text style is normal.
* @see
* SetGroupRowsBold, ShadeGroupHeadings, IsShadeGroupHeadingsEnabled,
* GetItemMetrics
*/
BOOL IsGroupRowsBold() const;
/**
* @brief
* Gets the number of frozen columns starting from the left hand side.
* @return
* The number of the frozen columns.
*/
int GetFreezeColumnsCount() const;
/**
* @brief
* Gets the number of frozen columns starting from the left hand side.
* @param nLastIndex Reference to an int to receive
* the index of the rightmost frozen column.
* @return
* The number of the frozen columns.
*/
int GetFreezeColumnsCount(int& nLastIndex) const;
/**
* @brief
* Gets the index of the rightmost frozen column.
* @return
* The index of the rightmost frozen column.
*/
int GetFreezeColumnsIndex() const;
/**
* @brief
* Sets the number of frozen columns.
* @param nCount Number of frozen columns to be set
* (e.g. 1 would make only one leftmost column frozen).
* @param bReserved TRUE for reserved.
*/
void SetFreezeColumnsCount(int nCount, BOOL bReserved = FALSE);
/**
* @brief
* Gets the number of columns at the left side where reordering is disabled.
* @return
* The number of columns at the left side.
*/
int GetDisableReorderColumnsCount() const;
/**
* @brief
* Sets the number of columns at the left side where reordering is disabled.
* @param nCount Number of columns to be set.
*/
void SetDisableReorderColumnsCount(int nCount);
/**
* @brief
* Gets the horizontal scrolling mode.
* @return
* TRUE if full columns scrolling mode is set,
* FALSE if horizontal scrolling by pixels mode is set.
* @see
* SetFullColumnScrolling
*/
BOOL IsFullColumnScrolling() const;
/**
* @brief
* Sets the horizontal scrolling mode.
* @param bSet TRUE to set full columns scrolling mode,
* FALSE to set horizontal scrolling by pixels mode.
* @see
* IsFullColumnScrolling
*/
void SetFullColumnScrolling(BOOL bSet);
/**
* @brief
* Call this method to remove all items and column in specified position.
* @param nIndex Index of item to remove.
*/
void ReleaseItem(int nIndex);
/**
* @brief
* Specifies if footer records are pinned to the last body row.
* @param bPin TRUE to pin footer records to the last body row,
* FALSE to dock footer records to the footer.
* @details
* By default, footer records are docked to the footer.
* @see
* IsFooterRowsVisible, ShowFooterRows
*/
void PinFooterRows(BOOL bPin = FALSE);
/**
* @brief
* Determines if footer records are pinned to the last body row.
* @return
* TRUE if footer records are pinned to the last body row,
* FALSE if footer records are docked to the footer.
* @see
* PinFooterRows
*/
BOOL IsFooterRowsPinned() const;
/**
* @brief
* Specifies if footer records are pinned to the last body row.
* This method is used only in printing mode.
* @param bPin TRUE to pin footer records to the last body row,
* FALSE to dock footer records to the footer.
* @details
* By default, footer records are docked to the footer.
* @see
* IsFooterRowsVisible, ShowFooterRows
*/
void PinFooterRowsPrinted(BOOL bPin = FALSE);
/**
* @brief
* Determines if footer records are pinned to the last body row.
* This method is used only in printing mode.
* @return
* TRUE if footer records are pinned to the last body row,
* FALSE if footer records are docked to the footer.
* @see
* PinFooterRows
*/
BOOL IsFooterRowsPinnedPrinted() const;
/**
* @brief
* Call this method to enable Markup for records.
* @param bEnable TRUE to enable Markup.
*/
void EnableMarkup(BOOL bEnable = TRUE);
/**
* @brief
* Gets the Markup context.
* @return
* A pointer to the Markup context.
*/
CXTPMarkupContext* GetMarkupContext() const;
/**
* @brief
* Gets the image manager of the Grid control.
* @return
* A pointer to the image manager of the Grid control.
* @see
* SetImageManager
*/
CXTPImageManager* GetImageManager() const;
/**
* @brief
* Sets the image manager for the Grid control.
* @param pImageManager Image manager to be set
*
* Example:
* * CXTPImageManager* pImageManager = new CXTPImageManager(); * pImageManager->SetIcons(IDR_MAINFRAME); * m_wndGrid.SetImageManager(pImageManager); ** @see * GetImageManager */ void SetImageManager(CXTPImageManager* pImageManager); /** * @brief * Sets the image list for the paint manager. * @param pImageList Pointer to a CImageList object. * @details * Use this function to set up your own image list * with set bitmaps that represent various states * of rows and depict any other information. * Note: * Recommended to use the SetImageManager/GetImageManager methods instead. * * Example: *
* CImageList listIcons; * listIcons.Create(16, 16, ILC_COLOR24 | ILC_MASK, 0, 1)); * CBitmap bmp; * // load bitmap by id * bmp.LoadBitmap(IDB_BMGRID); * ilIcons.Add(&bmp, RGB(255, 0, 255)); * m_wndGrid.SetImageList(&lIcons); ** @see * GetImageManager */ void SetImageList(CImageList* pImageList); /** * @brief * Gets the associated grid header object. * @details * Call this member function if you want to retrieve access * to the grid header object properties and methods. * @return * A pointer to the associated grid header object. * @see * CXTPGridHeader overview */ CXTPGridHeader* GetGridHeader() const; /** @cond */ _XTP_DEPRECATED_IN_FAVOR(GetGridHeader) CXTPGridHeader* GetReportHeader() const; /** @endcond */ /** * @brief * Sets the associated grid header object. * @param pGridHeader Pointer to the grid header to be set. * * Example: *
m_wndGrid.SetGridHeader(new CMyGridHeader());* @see * CXTPGridHeader overview */ void SetGridHeader(CXTPGridHeader* pGridHeader); /** @cond */ _XTP_DEPRECATED_IN_FAVOR(SetGridHeader) void SetReportHeader(CXTPGridHeader* pGridHeader); /** @endcond */ /** * @brief * Calculates the indentation, in pixels, for a tree view row * of a specified depth level. * @param nLevel Tree depth level. * @return * The indentation, in pixels, for a tree view row * of the specified depth level. * @see * Populate */ int GetIndent(int nLevel) const; /** * @brief * Notifies the parent control about an event that occurred. * @param pRow Pointer to the row of the event if used. * @param pItem Pointer to the item of the event if used. * @param pColumn Pointer to the column of the event if used. * @param nMessage Message to be sent to the parent window. * @param pPoint Pointer to the point where the message * was sent from in client coordinates. * @param nHyperlink Hyperlink order number where the message was sent from * (or -1 if the message was not send from a hyperlink). * @details * Sends a message to the parent control in the form of a * WM_NOTIFY message with a specific structure attached. * @return * The result of the message processing; its value depends * on the message that was sent (see CWnd::SendMessage). * @see * CXTPGridControl overview, SendNotifyMessage */ LRESULT SendMessageToParent(CXTPGridRow* pRow, CXTPGridRecordItem* pItem, CXTPGridColumn* pColumn, UINT nMessage, CPoint* pPoint, int nHyperlink = -1) const; /** * @brief * Sends a specified message to the window. * @param nMessage Message to be sent. * @param pNMHDR Notify header. * @return * Nonzero if successful, otherwise zero. */ LRESULT SendNotifyMessage(UINT nMessage, NMHDR* pNMHDR = NULL) const; /** * @brief * Collapses all rows. * @details * The CollapseAll method collapses all CXTPGridRow objects, * including child rows, that are in the Grid control. * @see * ExpandAll, CXTPGridRow::SetExpanded */ void CollapseAll(); /** * @brief * Expands all rows. * @param bRecursive TRUE to recursively expand all levels of child rows, * FALSE to only expand one level of child rows. * @details * The ExpandAll method expands all CXTPGridRow objects, * including child rows, that are in the Grid control. * @see * CollapseAll, CXTPGridRow::SetExpanded */ void ExpandAll(BOOL bRecursive = FALSE); /** * @brief * Determines if multiple selections is enabled/disabled for the Grid control. * @return * TRUE if multiple selections is enabled for the Grid control, * FALSE if multiple selections is disabled for the Grid control. * @see * SetMultipleSelection, GetSelectedRows */ BOOL IsMultipleSelection() const; /** * @brief * Enables/disables multiple selections for the Grid control. * @param bMultipleSelection TRUE to enable multiple selections, * FALSE to disable multiple selections. * @see * IsMultipleSelection, GetSelectedRows */ void SetMultipleSelection(BOOL bMultipleSelection); /** * @brief * Determines if multi-selection mode is enabled/disabled for the Grid control. * @return * TRUE if multi-selection mode is enabled for the control, * FALSE if multi-selection mode is disabled for the control. * @details * If multi-selection mode is enabled, then VK_CTRL is always ON. * @see * SetMultiSelectionMode */ BOOL IsMultiSelectionMode() const; /** * @brief * Enables/disables multi-selection mode for the Grid control. * @param bMultiSelectionMode TRUE to enable multi-selection mode, * FALSE to disable multi-selection mode. * @details * If multi-selection mode is enabled, then VK_CTRL is always ON. * @see * IsMultiSelectionMode */ void SetMultiSelectionMode(BOOL bMultiSelectionMode); /** * @brief * Enables/disables showing tooltips for the Grid control window. * @param bEnable TRUE to enable showing tooltips, * FALSE to disable showing tooltips. */ void EnableToolTips(BOOL bEnable); /** * @brief * Specifies if groups are skipped when navigating the Grid control * by using the Up and Down keys. * @param bSkipFocus TRUE to skip group headings and select the next non-group * heading row when navigating the Grid control by using * the Up and Down keys, * FALSE to cause all rows to be selected (including group * headings) when navigating the Grid control by using * the Up and Down keys. */ void SkipGroupsFocus(BOOL bSkipFocus); /** * @brief * Determines if groups are skipped when navigating the Grid control * by using the Up and Down keys. * @return * TRUE if group headings are skipped and the next non-group heading row is * selected when navigating the Grid control by using the Up and Down keys, * FALSE if all rows are selected (including group headings) when navigating * the Grid control by using the Up and Down keys. */ BOOL IsSkipGroupsFocusEnabled() const; /** * @brief * Gets the indentation of the header. * @return * The indentation of the header. */ int GetHeaderIndent() const; /** * @brief * Adjusts scrollbars depending on currently visible rows. */ virtual void AdjustScrollBars(); /** * @brief * Adjusts main control areas depending on current control size. */ virtual void AdjustLayout(); /** * @brief * Gets the selected column. * @return * A pointer to the selected column. */ CXTPGridColumn* GetFocusedColumn() const; /** * @brief * Sets the selected column. * @param pColumn Column to be selected. * @return * TRUE if the specified column was selected, otherwise FALSE. */ BOOL SetFocusedColumn(CXTPGridColumn* pColumn); /** * @brief * Sets the selection state of a row. * @param index Index of the row. * @param state Integer value denoting the state of the checkbox; must be one * of the values defined by the XTPGridCheckState enumeration. */ void SetSelectionState(int index, int state); /** * @brief * Specifies if the visibility of focused rows should be ensured. * @param bEnsureFocusedRowVisible TRUE to ensure the visibility of the entire * row when a record item is focused. * @see * IsEnsureFocusedRowVisible */ void EnsureFocusedRowVisible(BOOL bEnsureFocusedRowVisible); /** * @brief * Determines if the visibility of focused rows is ensured. * @return * TRUE if the visibility of focused rows is ensured, otherwise FALSE. */ BOOL IsEnsureFocusedRowVisible() const; /** * @brief * Specifies if each individual record item in a row should receive focus * when an item in the row is clicked. * @param bFocusSubItems TRUE to highlight the entire row when a record item * is clicked excluding the item that was clicked, * FALSE to highlight the entire row when a record item * is clicked including the item that was clicked. * @see * IsFocusSubItems */ void FocusSubItems(BOOL bFocusSubItems); /** * @brief * Determines if each individual record item in a row receives focus * when an item in the row is clicked. * @return * TRUE if the entire row is highlighted when a record item is clicked * excluding the item that was clicked, * FALSE if the entire row is highlighted when a record item is clicked * including the item that was clicked. * @see * FocusSubItems */ BOOL IsFocusSubItems() const; /** * @brief * Specifies if a CXTPGridRecordItem should become editable after * being single-clicked. * @param bEditOnClick TRUE to allow a CXTPGridRecordItem to become * editable after being single-clicked. * @details * The entire Grid control and/or the specific CXTPGridRecordItem * must also be set to editable in order for a CXTPGridRecordItem * to become editable after being single-clicked. * @see * AllowEdit, IsAllowEdit, IsEditOnClick */ void EditOnClick(BOOL bEditOnClick); /** * @brief * Determines if a CXTPGridRecordItem becomes editable after * being single-clicked. * @return * TRUE if a CXTPGridRecordItem becomes editable after * being single-clicked. * @details * The entire Grid control and/or the specific CXTPGridRecordItem * must also be set to editable in order for a CXTPGridRecordItem * to become editable after being single-clicked. * @see * AllowEdit, IsAllowEdit, EditOnClick */ BOOL IsEditOnClick() const; /** * @brief * Enables/disables the Delay Click Edit feature. * @param bEditOnDelayClick TRUE to enable the Delay Click Edit feature, * FALSE to disable the Delay Click Edit feature. */ void EditOnDelayClick(BOOL bEditOnDelayClick); /** * @brief * Determines if the Delay Click Edit feature is enabled/disabled. * @return * TRUE if the Delay Click Edit feature is enabled, * FALSE if the Delay Click Edit feature is disabled. */ BOOL IsEditOnDelayClick() const; /** * @brief * Specifies if a CXTPGridRecordItem should become editable after * being double-clicked. * @param bEditOnClick TRUE to allow a CXTPGridRecordItem to become * editable after being double-clicked. * @details * The entire Grid control and/or the specific CXTPGridRecordItem * must also be set to editable in order for a CXTPGridRecordItem * to become editable after being double-clicked. * @see * AllowEdit, IsAllowEdit, IsEditOnDoubleClick */ void EditOnDoubleClick(BOOL bEditOnClick); /** * @brief * Determines if a CXTPGridRecordItem becomes editable after * being double-clicked. * @return * TRUE if a CXTPGridRecordItem becomes editable after * being double-clicked. * @details * The entire Grid control and/or the specific CXTPGridRecordItem * must also be set to editable in order for a CXTPGridRecordItem * to become editable after being double-clicked. * @see * AllowEdit, IsAllowEdit, EditOnDoubleClick */ BOOL IsEditOnDoubleClick() const; /** * @brief * Gets the index of the most recent row that was requested for editing. * @return * The index of the most recent row that was requested for editing. */ int GetLastRqstEditRow() const; /** * @brief * Gets the index of the most recent column that was requested for editing. * @return * The index of the most recent column that was requested for editing. */ int GetLastRqstEditCol() const; /** * @brief * Sets an arbitrary index for both the most recent row and most recent column * that was requested for editing. * @param iRqstEditRow Index to be set for the most recent row. * @param iRqstEditCol Index to be set for the most recent column. */ void SetLastRqstEdit(int iRqstEditRow, int iRqstEditCol); /** * @brief * Stops the last request timer used for delay edit. */ void EnsureStopLastRqstTimer(); /** * @brief * Starts the last request timer used for delay edit. */ void StartLastRqstTimer(); /** * @brief * Gets the ID of the delay edit timer. * @return * The ID of the delay edit timer. */ UINT_PTR GetDelayEditTimer() const; /** * @brief * Stops the delay edit timer. */ void EnsureStopDelayEditTimer(); /** * @brief * Starts the delay edit timer. */ void StartDelayEditTimer(); /** * @brief * Enables/disables auto-check mode for checkbox items. * @param bAutoCheck TRUE to enable auto-check mode, FALSE to disable auto-check mode. * @details * If auto-check mode is enabled, then the checkbox will become * checked/unchecked automatically when the user clicks on the checkbox. * @see * IsAutoCheckItems, CXTPGridRecordItem::OnClick, CXTPGridRecordItem::OnChar */ void SetAutoCheckItems(BOOL bAutoCheck); /** * @brief * Determines if auto-check mode is enabled/disabled for checkbox items. * @details * If auto-check mode is enabled, then the checkbox will become * checked/unchecked automatically when the user clicks on the checkbox. * @return * TRUE if auto-check mode is enabled, FALSE if auto-check mode is disabled. * @see * SetAutoCheckItems, CXTPGridRecordItem::OnClick, CXTPGridRecordItem::OnChar */ BOOL IsAutoCheckItems() const; /** * @brief * Edits a grid cell by focusing the specified cell and starting * in-place editing for the control specified there. * @param pItemArgs Pointer to an XTP_GRIDRECORDITEM_ARGS structure * containing item arguments of the item to be edited. * @details * All editing options should be enabled in order for this method * to be executed successfully. * Call this method with NULL as its parameter to stop item edit. * @see * AllowEdit, CXTPGridColumn::SetEditable */ void EditItem(XTP_GRIDRECORDITEM_ARGS* pItemArgs); /** * @brief * Gets the in-place edit control. * @return * A pointer to the in-place edit control. */ CXTPGridInplaceEdit* GetInplaceEdit() const; /** * @brief * Gets the collection of in-place buttons of the Grid control. * @return * A pointer to the collection of in-place buttons of the Grid control. */ CXTPGridInplaceButtons* GetInplaceButtons() const; /** * @brief * Gets the in-place list of Grid controls. * @return * A pointer to the in-place list of Grid controls. */ CXTPGridInplaceList* GetInplaceList() const; /** * @brief * Determines if the Grid control has focus. * @return * TRUE if the Grid control has focus, otherwise FALSE. */ BOOL HasFocus() const; /** * @brief * Gets the active item (i.e. the item that has focus in edit mode). * @return * A pointer to the active item if in edit mode, otherwise NULL. */ CXTPGridRecordItem* GetActiveItem() const; /** * @brief * Gets the focused item. * @return * A pointer to the focused item. */ CXTPGridRecordItem* GetFocusedRecordItem() const; /** * @brief * Sets the indentation before the text of each child node in a * hierarchical tree structure. * @param nIndent Indentation to be set. */ void SetTreeIndent(int nIndent); /** * @brief * Call this method to enable virtual mode of the control * @param pVirtualRecord record to be used as virtual for all rows. * @param nCount Count of virtual records. * @param nFields number of fields to assign); * * Example: *
* class CVirtualRecord : public CXTPGridRecord
* {
* public:
* CVirtualRecord()
* {
* AddItem(new CXTPGridRecordItem());
* AddItem(new CXTPGridRecordItem());
* AddItem(new CXTPGridRecordItem());
* }
*
* void GetItemMetrics (XTP_GRIDRECORDITEM_DRAWARGS* pDrawArgs,
* XTP_GRIDRECORDITEM_METRICS* pItemMetrics)
* {
* // Draw virtual record
* }
* }
* ...
* m_wndGrid.SetVirtualMode(new CVirtualRecord(), 540);
*
* @see
* IsVirtualMode
*/
void SetVirtualMode(CXTPGridRecord* pVirtualRecord, int nCount, int nFields = 0);
/**
* @brief
* Determines if virtual mode is enabled/disabled.
*
* @return TRUE if virtual mode is enabled, FALSE if virtual mode is disabled.
* @see
* SetVirtualMode
*/
BOOL IsVirtualMode() const;
/**
* @brief
* Gets the filter text of the control.
* @return
* The filter text of the control.
* @see
* SetFilterText
*/
virtual CString GetFilterText();
/**
* @brief
* Sets the filter text for the control.
* @param strFilterText Filter text to be set.
* @details
* You must call the Populate method to update rows.
* @see
* GetFilterText, Populate
*/
virtual void SetFilterText(LPCTSTR strFilterText);
/**
* @brief
* Determines if search filter text is enabled/disabled in hidden columns.
* @details
* This option is disabled by default.
* @return
* TRUE if search filter text is enabled in hidden columns,
* FALSE if search filter text is disabled in hidden columns.
* @see
* SetFilterHiddenColumns, GetFilterText, SetFilterText
*/
virtual BOOL IsFilterHiddenColumns() const;
/**
* @brief
* Enables/disables search filter text in hidden columns.
* @param bFilterHidden TRUE to enable search filter text in hidden columns,
* FALSE to disable search filter text in hidden columns.
* @details
* This option is disabled by default.
* You must call the Populate method to update rows.
* @see
* IsFilterHiddenColumns, GetFilterText, SetFilterText, Populate
*/
virtual void SetFilterHiddenColumns(BOOL bFilterHidden);
/**
* @brief
* Sets the filtering mode for the record tree.
* @param nMode Filtering mode to be set; must be one of the values
* defined by the XTPGridFilterMode enumeration.
* @see
* GetRecordsTreeFilterMode, XTPGridFilterMode
*/
void SetRecordsTreeFilterMode(int nMode);
/**
* @brief
* Gets the filtering mode of the record tree.
* @return
* The filtering mode of the record tree; one of the values
* defined by the XTPGridFilterMode enumeration.
* @see
* SetRecordsTreeFilterMode, XTPGridFilterMode
*/
int GetRecordsTreeFilterMode() const;
/**
* @brief
* Registers the window class if it has not already been registered.
* @param hInstance Instance of the resource where the control is located.
* @return
* TRUE if the window class was successfully registered.
*/
BOOL RegisterWindowClass(HINSTANCE hInstance = NULL);
/**
* @brief
* Determines if the Cut operation is possible in the current context
* (i.e. one or more records are selected).
* @return
* TRUE if the Cut operation is possible in the current context, otherwise FALSE.
* @see
* CanPaste, Cut, Copy, Paste.
*/
virtual BOOL CanCut();
/**
* @brief
* Determines if the Copy operation is posssible in the current context
* (i.e. one or more records are selected).
* @return
* TRUE if the Copy operation is possible in the current context, otherwise FALSE.
* @see
* CanPaste, Cut, Copy, Paste.
*/
virtual BOOL CanCopy();
/**
* @brief
* Determines if the Paste operation is possible in the current context
* (i.e. binary and/or text data exists in the clipboard).
* @return
* TRUE if the Paste operation is possible in the current context, otherwise FALSE.
* @see
* CanCut, CanCopy, Cut, Copy, Paste.
*/
virtual BOOL CanPaste();
/**
* @brief
* Copies the selected record data (in the binary and/or text data formats)
* to the clipboard and deletes the selected record data.
* @see
* CanCut, CanCopy, CanPaste, Copy, Paste,
* OnBeforeCopyToText, OnBeforePasteFromText, OnBeforePaste.
*/
virtual void Cut();
/**
* @brief
* Copies the selected record data (in the binary and/or text data formats)
* to the clipboard.
* @see
* CanCut, CanCopy, CanPaste, Cut, Paste,
* OnBeforeCopyToText, OnBeforePasteFromText, OnBeforePaste.
*/
virtual void Copy();
/**
* @brief
* Reads records from the clipboard and adds them to the records collection
* (the binary data format is used rather than the text data format).
* @see
* CanCut, CanCopy, CanPaste, Cut, Copy,
* OnBeforeCopyToText, OnBeforePasteFromText, OnBeforePaste.
*/
virtual void Paste();
/**
* @brief
* Determines if the in-place edit control is active (i.e. visible and focused).
* @return
* TRUE if the in-place edit control is active, otherwise FALSE.
* @see
* GetInplaceEdit.
*/
virtual BOOL IsEditMode();
/**
* @brief
* Sets the compare function used to compare (and sort) rows.
* @param pCompareFunc XTPGridRowsCompareFunc function pointer to be used
* to compare rows, or NULL to use the default function.
* @details
* This method uses Visual C++ run-time library (MSVCRT)
* implementation of the quick-sort function, qsort, for sorting
* stored CXTPGridRow objects.
* If pCompareFunc = NULL, then the default compare function is used.
* Call the Populate() method to re-sort items.
* @see
* SortRows, CXTPGridRows::SortEx, CXTPGridRows::Sort,
* CXTPGridRows::XTPGridRowsCompareFunc
*/
virtual void SetRowsCompareFunc(XTPGridRowsCompareFunc pCompareFunc);
/**
* @brief
* Determines if the sort order is applied to record children.
* @return
* TRUE if the sort order is applied to record children, otherwise FALSE.
*/
BOOL IsSortRecordChilds() const;
/**
* @brief
* Specifies if the sort order should be applied to record children.
* @param bSortRecordChildren TRUE to apply the sort order to record children,
* FALSE otherwise.
*/
void SetSortRecordChilds(BOOL bSortRecordChildren);
/**
* @brief
* Gets the horizontal scrolling step.
* @return
* The horizontal scrolling step, in pixels.
*/
int GetHScrollStep() const;
/**
* @brief
* Sets the horizontal scrolling step.
* @param nStep Horizontal scrolling step to be set, in pixels.
*/
void SetHScrollStep(int nStep);
/**
* @brief
* Gets the vertical scrolling timer resolution.
* @return
* The vertical scrolling timer resolution, in milliseconds.
*/
UINT GetAutoVScrollTimerResolution() const;
/**
* @brief
* Sets the vertical scrolling timer resolution.
* @param nNewTimerResolution Vertical scrolling timer resolution, in milliseconds.
* @see
* CWnd::SetTimer
*/
void SetAutoVScrollTimerResolution(UINT nNewTimerResolution);
/**
* @brief
* Determines if preview editing is enabled/disabled.
* @return
* TRUE if preview editing is enabled, FALSE if preview editing is disabled.
*/
BOOL IsPreviewAllowEdit() const;
/**
* @brief
* Enables/disables preview editing.
*
* @param bAllowEdit TRUE to enable preview editing, FALSE to disable preview editing.
*/
void PreviewAllowEdit(BOOL bAllowEdit);
/**
* @brief
* Determines if the user's ability to collapse/expand rows is locked.
* @return
* TRUE if the user's ability to collapse/expand rows is locked.
*/
BOOL IsLockExpand() const;
/**
* @brief
* Specifies if the user's ability to collapse/expand rows should be locked.
*
* @param bLockExpand TRUE to lock the user's ability to collapse/expand rows.
*/
void LockExpand(BOOL bLockExpand);
/**
* @brief
* Recalculates and redraws rows.
*
* @param bAll TRUE to recalculate and redraw all rows,
* FALSE to recalculate and redraw only the focused row.
*/
void Recalc(BOOL bAll = FALSE);
/**
* @brief
* Enables/disables double-buffering.
*
* @param bEnable TRUE to enable double-buffering, FALSE to disable double-buffering.
*/
void EnableDoubleBuffering(BOOL bEnable);
/**
* @brief
* Determines if double-buffering is enabled/disabled.
* @return
* TRUE if double buffering is enabled, FALSE if double-buffering is disabled.
* @see
* EnableDoubleBuffering
*/
BOOL IsDoubleBuffering() const;
/**
* @brief
* Determines if initial selection is enabled/disabled.
* @details
* If initial selection is enabled, then the first row in the grid
* will become selected when the grid is populated.
* @return
* TRUE if initial selection is enabled, FALSE if initial selection is disabled.
* @see
* SelectionEnable
*/
BOOL IsInitialSelectionEnabled() const;
/**
* @brief
* Enables/disables initial selection.
* @param bEnable TRUE to enable initial selection,
* FALSE to disable initial selection.
* @details
* If initial selection is enabled, then the first row in the grid
* will become selected when the grid is populated.
* @see
* IsSelectionEnabled
*/
void InitialSelectionEnable(BOOL bEnable);
/**
* @brief
* Determines if row focus is shown.
* @return
* TRUE if row focus is shown, otherwise FALSE.
* @see
* ShowRowFocus
*/
BOOL IsRowFocusVisible() const;
/**
* @brief
* Specifies if row focus should be shown.
* @param bShow TRUE to show row focus, FALSE otherwise.
* @see
* IsRowFocusVisible
*/
void ShowRowFocus(BOOL bShow);
/**
* @brief
* Gets the watermark alignment.
* @return
* The watermark alignment; one of the values defined
* by the XTPGridWatermarkAlignment enumeration.
* @see
* XTPGridWatermarkAlignment, SetWatermarkAlignment.
*/
int GetWatermarkAlignment() const;
/**
* @brief
* Sets the watermark alignment.
* @param nWatermarkAlignment Watermark alignment to be set; must be one of the values
* defined by the XTPGridWatermarkAlignment enumeration.
* @see
* XTPGridWatermarkAlignment, GetWatermarkAlignment.
*/
void SetWatermarkAlignment(int nWatermarkAlignment);
/**
* @brief
* Draws a watermark.
* @param pDC Pointer to the device context.
* @param rcWatermark Rectangular bounds of the watermark.
* @param rcClient Rectangular bounds of the client area.
*/
void DrawWatermark(CDC* pDC, CRect rcWatermark, CRect rcClient);
/**
* @brief
* Retrieves a specified grid element rectangle.
* @param nElement Grid element rectangle to retrieve; must be one of
* the values defined by the XTPGridElementRect enumeration.
* @return
* The specified grid element rectangle.
* @see
* XTPGridElementRect
*/
CRect GetElementRect(XTPGridElementRect nElement) const;
/** @cond */
_XTP_DEPRECATED_IN_FAVOR_("GetElementRect with XTPGridElementRect")
CRect GetElementRect(int nElement) const;
/** @endcond */
/**
* @brief
* Gets the grid data manager.
* @return
* A pointer to the grid data manager.
*/
CXTPGridDataManager* GetDataManager();
/**
* @brief
* Sets the control mouse mode.
* @param nMode Mouse mode to be set; must be one of the values
* defined by the XTPGridMouseMode enumeration.
* @see
* XTPGridMouseMode overview, GetMouseMode
*/
void SetMouseMode(XTPGridMouseMode nMode);
/**
* @brief
* Gets the control mouse mode.
* @return
* The control mouse mode; one of the values defined
* by the XTPGridMouseMode enumeration.
* @see
* XTPGridMouseMode overview, SetMouseMode
*/
XTPGridMouseMode GetMouseMode() const;
/**
* @brief
* Gets the watermark bitmap to be shown in the Grid control background.
* @return
* The handle of the watermark bitmap.
*/
virtual HBITMAP GetWatermarkBitmap() const;
/**
* @brief
* Sets the watermark bitmap to be shown in the Grid control background.
* @param hBitmap Handle of the watermark bitmap.
* @param Transparency Transparency value.
* @return
* TRUE if successful, otherwise FALSE.
*/
virtual BOOL SetWatermarkBitmap(HBITMAP hBitmap, BYTE Transparency);
/**
* @brief
* Sets the watermark bitmap to be shown in the Grid control background.
* @param szPath Path to the bitmap file of the watermark bitmap.
* @param Transparency Transparency value.
* @return
* TRUE if successful, otherwise FALSE.
*/
virtual BOOL SetWatermarkBitmap(LPCTSTR szPath, BYTE Transparency);
/**
* @brief
* Gets the next focusable column.
* @param pRow Pointer to a CXTPGridRow object.
* @param nColumnIndex Column index.
* @param nDirection Positive integer to get the next focusable column
* to the right of nColumnIndex,
* Negative integer to get the next focusable column
* to the left of nColumnIndex.
* @return
* A pointer to the next focusable column.
*/
virtual CXTPGridColumn* GetNextFocusableColumn(CXTPGridRow* pRow, int nColumnIndex,
int nDirection);
CXTPGridBehavior* GetBehavior() const;
/**
* @brief
* Specifies if item icons should be shown while the item is being edited.
* @param bShow TRUE to show item icons, FALSE otherwise.
*/
void ShowIconWhenEditing(BOOL bShow);
/**
* @brief
* Determines if item icons are shown while the item is being edited.
* @return
* TRUE if item icons are shown while the item is being edited, otherwise FALSE.
*/
BOOL IsShowIconWhenEditing();
/**
* @brief
* Enables/disables Fast Deselect mode (like in Windows Explorer).
* @param bFastDeselect TRUE to enable Fast Deselect mode,
* FALSE to disable Fast Deselect mode.
*/
void SetFastDeselectMode(BOOL bFastDeselect = TRUE);
/**
* @brief
* Sets a column to be an icon view column.
* @param pColumn Pointer to a CXTPGridColumn object.
*/
void SetIconColumn(CXTPGridColumn* pColumn);
/**
* @brief
* Creates a column as an icon view column and specifies if the
* column may be reused as a number column in the grid view.
* @param bUseColumnForNum TRUE to reuse the column as a
* number column in the grid view.
* @param nWidth Width for the number column.
*/
void CreateIconColumn(BOOL bUseColumnForNum = FALSE, int nWidth = 40);
/**
* @brief
* Creates a column as an icon view column and specifies if the
* column may be reused as a number column in the grid view.
* @param nCol Column index to use as the icon column property.
* @param nIcon Icon index to use in icon view.
* @param bUseColumnForNum TRUE to reuse the column as a
* number column in the grid view.
* @param nWidth Width for the number column.
* @details
* This can be used for non-virtual mode.
*/
void AssignIconViewPropNumAndIconNum(int nCol = 0, int nIcon = 0, BOOL bUseColumnForNum = FALSE,
int nWidth = 20);
/**
* @brief
* Toggles between Icon View mode and Grid View mode.
* @param bIconView TRUE for Icon View mode,
* FALSE for Grid View mode.
*/
void SetIconView(BOOL bIconView = TRUE);
/**
* @brief
* Determines if Icon View mode is active.
* @return
* TRUE if Icon View mode is active.
*/
BOOL IsIconView() const;
/**
* @brief
* Gets the number of rows per line.
* @return
* The number of rows per line.
*/
int GetRowsPerLine() const;
/**
* @brief
* Gets the number of rows on a line of abitrary width.
* @param iTotalWidth Width of the line.
* @return
* The number of rows on the line.
*/
int GetNumRowsOnLine(int iTotalWidth) const;
/**
* @brief
* Sets the grid navigator.
* @param pNavigator Pointer to the grid navigator to be set.
*/
void SetNavigator(CXTPGridNavigator* pNavigator);
/**
* @brief
* Specifies if the row number should be shown.
* @param bSet TRUE to show the row number, FALSE otherwise.
*/
void ShowRowNumber(BOOL bSet);
/**
* @brief
* Determines if the row number is shown.
* @return
* TRUE if the row number is shown, otherwise FALSE.
*/
BOOL IsShowRowNumber();
/**
* @brief
* Sets the text for a specified cell.
* @param row Row index.
* @param col Column index.
* @param sText Text string to be set.
* @return
* TRUE if successful, otherwise FALSE.
*/
BOOL SetCellText(int row, int col, CString sText);
/**
* @brief
* Sets the formula for a specified cell.
* @param row Row index.
* @param col Column index.
* @param sFormula Formula to be set.
* @return
* TRUE if successful, otherwise FALSE.
*/
BOOL SetCellFormula(int row, int col, CString sFormula);
/**
* @brief
* Deselects all group rows.
*/
void UnselectGroupRows();
/**
* @brief
* Releases all sorted items and clears memory.
*/
void ReleaseSorted();
/**
* @brief
* Gets the horizontal scroll position.
* @return
* The horizontal scroll position.
*/
int GetLeftOffset() const;
/**
* assessors for m_bDragMode
* @brief
* Determines if Grid control items are in drag mode.
* @return
* TRUE if Grid control items are in drag mode, otherwise FALSE.
*/
BOOL IsDragMode() const;
/**
* @brief
* Gets the horizontal sensitivity of Drag'n'Drop operations.
* @return
* The horizontal sensitivity of Drag'n'Drop operations, in pixels.
* @see
* SetDragSensitivityX, GetDragSensitivityY, SetDragSensitivityY
*/
int GetDragSensitivityX() const;
/**
* @brief
* Sets the horizontal sensitivity of Drag'n'Drop operations.
* @param nDragSensitivityX Horizontal sensitivity for Drag'n'Drop operations,
* in pixels. The value must not be scaled to DPI
* and must be in the range of 1-10000.
* @see
* GetDragSensitivityX, GetDragSensitivityY, SetDragSensitivityY
*/
void SetDragSensitivityX(int nDragSensitivityX);
/**
* @brief
* Gets the vertical sensitivity of Drag'n'Drop operations.
* @return
* The vertical sensitivity of Drag'n'Drop operations, in pixels.
* @see
* GetDragSensitivityX, SetDragSensitivityX, SetDragSensitivityY
*/
int GetDragSensitivityY() const;
/**
* @brief
* Sets the vertical sensitivity of Drag'n'Drop operation.
* @param nDragSensitivityY Vertical sensitivity for Drag'n'Drop operations,
* in pixels. The value must not be scaled to DPI
* and must be in the range of 1-10000.
* @see
* GetDragSensitivityX, SetDragSensitivityX, GetDragSensitivityY
*/
void SetDragSensitivityY(int nDragSensitivityY);
/**
* @brief
* Resets the icon view column to its default values.
* @details
* This method should be called in the event that the
* icon view column is destroyed.
*/
void SetIconViewToDefaults();
/**
* @brief
* Gets the scroll mode.
* @param orientation Orientation of the scroll mode to get; must be one of the
* values defined by the XTPGridOrientation enumeration.
* @return
* The scroll mode; one of the values defined by the
* XTPGridScrollMode enumeration.
*/
XTPGridScrollMode GetScrollMode(XTPGridOrientation orientation) const;
/**
* @brief
* Sets the scroll mode.
* @param orientation Orientation of the scroll mode to set; must be one of the
* values defined by the XTPGridOrientation enumeration.
* @param scrollMode Scroll mode to be set; must be one of the
* values defined by the XTPGridScrollMode enumeration.
*/
void SetScrollMode(XTPGridOrientation orientation, XTPGridScrollMode scrollMode);
/**
* @brief
* Gets the sections collection.
* @return
* A pointer to the sections collection.
*/
CXTPGridSections* GetSections() const;
/**
* @brief
* Determines if cell merging is allowed.
* @return
* TRUE if cell merging is allowed, otherwise FALSE.
*/
virtual BOOL IsCellMergingAllowed() const;
# if XTP_GRID_DEPRECATED()
/**
* @brief
* Gets the grid drawing style.
* @param bvertical Determines the grid drawing style to get;
* TRUE to get the vertical grid drawing style,
* FALSE to get the horizontal grid drawing style.
* @return
* The grid drawing style; one of the values defined by the
* XTPGridLineStyle enumeration.
* @see
* XTPGridGridStyle overview, SetGridStyle, SetGridColor
*/
XTPGridGridStyle GetGridStyle(BOOL bVertical) const;
/** @cond */
_XTP_DEPRECATED_IN_FAVOR(GetGridStyle)
XTPGridGridStyle GetReportStyle(BOOL bVertical) const;
/** @endcond */
/**
* @brief
* Sets the grid drawing style.
* @param bvertical Determines the grid drawing style to set;
* TRUE to get the vertical grid drawing style,
* FALSE to get the horizontal grid drawing style.
* @param gridStyle Grid style to be set; can be
* any of the values listed in the Remarks section.
* @details
* Grid drawing style can be one of the following:
* xtpGridGridNoLines: Empty line.
* xtpGridGridSmallDots: Line drawn by small dots.
* xtpGridGridLargeDots: Line drawn by large dots.
* xtpGridGridDashes: Line drawn by dashes.
* xtpGridGridSolid: Draws solid line.
*
* @see
* XTPGridGridStyle overview, GetGridStyle, SetGridColor
*/
void SetGridStyle(BOOL bVertical, XTPGridGridStyle gridStyle);
/** @cond */
_XTP_DEPRECATED_IN_FAVOR(SetGridStyle)
void SetReportStyle(BOOL bVertical, XTPGridGridStyle gridStyle);
/** @endcond */
/**
* @brief
* Gets the collection of data records.
* @return
* A pointer to the collection of data records.
* @details
* Use this member function to retrieve access to the collection
* of grid data records. You may then perform standard operations
* on the collection (e.g. adding, removing, etc.).
* @see
* CXTPGridRecords overview, AddRecord
*/
CXTPGridRecords* GetRecords() const;
/**
* @brief
* Gets the collection of header records.
* @return
* A pointer to the collection of header records.
* @details
* Use this member function to retrieve access to the collection
* of grid header records. You may then perform standard operations
* on the collection (e.g. adding, removing, etc.).
* @see
* CXTPGridRecords overview, AddRecord
*/
CXTPGridRecords* GetHeaderRecords() const;
/**
* @brief
* Gets the collection of footer records.
* @return
* A pointer to the collection of footer records.
* @details
* Use this member function to retrieve access to the collection
* of grid footer records. You may then perform standard operations
* on the collection (e.g. adding, removing, etc.).
* @see
* CXTPGridRecords overview, AddRecord
*/
CXTPGridRecords* GetFooterRecords() const;
/**
* @brief
* Gets the collection of grid rows.
* @details
* Use this member function to retrieve access to the collection
* of grid rows, representing the current control view.
* Note that the rows collection could be rebuilt automatically
* by executing the Populate method.
* @return
* A pointer to the collection of grid rows.
*
* Example:
* See example for the CXTPGridControl::BeginUpdate method.
* @see
* CXTPGridRows overview, Populate
*/
CXTPGridRows* GetRows() const;
/**
* @brief
* Gets the collection of grid header rows.
* @details
* Use this member function to retrieve access to the collection
* of grid header rows, representing the current control view.
* Note that the rows collection could be rebuilt automatically
* by executing the Populate method.
* @return
* A pointer to the collection of grid header rows.
* @see
* CXTPGridRows overview, Populate
*/
CXTPGridRows* GetHeaderRows() const;
/**
* @brief
* Gets the collection of grid footer rows.
* @details
* Use this member function to retrieve access to the collection
* of grid footer rows, representing the current control view.
* Note that the rows collection could be rebuilt automatically
* by executing the Populate method.
* @return
* A pointer to the collection of grid footer rows.
* @see
* CXTPGridRows overview, Populate
*/
CXTPGridRows* GetFooterRows() const;
/**
* @brief
* Gets the grid bounding rectangle.
* @return
* The grid bounding rectangle.
*/
CRect GetGridRectangle() const;
/** @cond */
_XTP_DEPRECATED_IN_FAVOR(GetGridRectangle)
CRect GetReportRectangle() const;
/** @endcond */
/**
* @brief
* Gets the header records bounding rectangle.
* @return
* The header records bounding rectangle.
*/
CRect GetHeaderRowsRect() const;
/**
* @brief
* Gets the footer records bounding rectangle.
* @return
* The footer records bounding rectangle.
*/
CRect GetFooterRowsRect() const;
/**
* @brief
* Specifies if the user is allowed to move the selection to header rows.
* @param bAllowAccess TRUE to allow the user to move the selection to header rows,
* FALSE otherwise.
* @see
* IsHeaderRowsAllowAccess
*/
void HeaderRowsAllowAccess(BOOL bAllowAccess);
/**
* @brief
* Specifies if the user is allowed to move the selection to footer rows.
* @param bAllowAccess TRUE to allow the user to move the selection to footer rows,
* FALSE otherwise.
* @see
* IsFooterRowsAllowAccess
*/
void FooterRowsAllowAccess(BOOL bAllowAccess);
/**
* @brief
* Determines if the user is allowed to move the selection to header rows.
* @return
* TRUE if the user is allowed to move the selection to header rows,
* otherwise FALSE.
* @see
* HeaderRowsAllowAccess.
*/
BOOL IsHeaderRowsAllowAccess() const;
/**
* @brief
* Determines if the user is allowed to move the selection to footer rows.
* @return
* TRUE if the user is allowed to move the selection to footer rows,
* otherwise FALSE.
* @see
* FooterRowsAllowAccess.
*/
BOOL IsFooterRowsAllowAccess() const;
/**
* @brief
* Determines if rows selection is enabled/disabled.
* @return
* TRUE if rows selection is enabled, FALSE if rows selection is disabled.
* @see
* SelectionEnable
*/
BOOL IsSelectionEnabled() const;
/**
* @brief
* Enables/disables rows selection.
* @param bEnable TRUE to enable rows selection, FALSE to disable rows selection.
* @see
* IsSelectionEnabled
*/
void SelectionEnable(BOOL bEnable);
/**
* @brief
* Enables/disables header rows selection.
* @param bEnable TRUE to enable header rows selection,
* FALSE to disable header rows selection.
* @see
* IsHeaderRowsSelectionEnabled
*/
void HeaderRowsEnableSelection(BOOL bEnable);
/**
* @brief
* Determines if header rows selection is enabled/disabled.
* @return
* TRUE if header rows selection is enabled,
* FALSE if header rows selection is disabled.
* @see
* HeaderRowsEnableSelection.
*/
BOOL IsHeaderRowsSelectionEnabled() const;
/**
* @brief
* Enables/disables footer rows selection.
* @param bEnable TRUE to enable footer rows selection,
* FALSE to disable footer rows selection.
* @see
* IsFooterRowsSelectionEnabled
*/
void FooterRowsEnableSelection(BOOL bEnable);
/**
* @brief
* Determines if footer rows selection is enabled/disabled.
* @return
* TRUE if footer rows selection is enabled,
* FALSE if footer rows selection is disabled.
* @see
* FooterRowsEnableSelection.
*/
BOOL IsFooterRowsSelectionEnabled() const;
/**
* @brief
* Specifies if the text in all CXTPGridRecordItem(s) can be edited.
* @param bAllowEdit TRUE to allow the text in CXTPGridRecordItem(s)
* to be edited, FALSE otherwise.
* @details
* If bAllowEdit is set to TRUE, then an edit box will be added that
* allows for CXTPGridRecordItem(s) to be editable.
* If bAllowEdit is set to FALSE, then the edit box that allows for
* CXTPGridRecordItem(s) to be editable will be removed.
* @see
* IsAllowEdit, EditOnClick, IsEditOnClick
*/
void AllowEdit(BOOL bAllowEdit);
/**
* @brief
* Determines if the text in all CXTPGridRecordItem(s) can be edited.
* @return
* TRUE if the text in all CXTPGridRecordItem(s) can be edited,
* otherwise FALSE.
* @see
* AllowEdit, EditOnClick, IsEditOnClick
*/
BOOL IsAllowEdit() const;
/**
* @brief
* Specifies if the text in all CXTPGridRecordItem(s) can be edited
* (for header records only).
* @param bAllowEdit TRUE to allow the text in CXTPGridRecordItem(s)
* to be edited, FALSE otherwise.
* @details
* If bAllowEdit is set to TRUE, then an edit box will be added that
* allows for CXTPGridRecordItem(s) to be editable.
* If bAllowEdit is set to FALSE, then the edit box that allows for
* CXTPGridRecordItem(s) to be editable will be removed.
* @see
* IsHeaderRowsAllowEdit, EditOnClick, IsEditOnClick
*/
void HeaderRowsAllowEdit(BOOL bAllowEdit);
/**
* @brief
* Determines if the text in all CXTPGridRecordItem(s) can be edited
* (for header records only).
* @return
* TRUE if the text in all CXTPGridRecordItem(s) can be edited,
* otherwise FALSE.
* @see
* HeaderRowsAllowEdit, EditOnClick, IsEditOnClick
*/
BOOL IsHeaderRowsAllowEdit() const;
/**
* @brief
* Specifies if the text in all CXTPGridRecordItem(s) can be edited
* (for footer records only).
* @param bAllowEdit TRUE to allow the text in CXTPGridRecordItem(s)
* to be edited, FALSE otherwise.
* @details
* If bAllowEdit is set to TRUE, then an edit box will be added that
* allows for CXTPGridRecordItem(s) to be editable.
* If bAllowEdit is set to FALSE, then the edit box that allows for
* CXTPGridRecordItem(s) to be editable will be removed.
* @see
* IsFooterRowsAllowEdit, EditOnClick, IsEditOnClick
*/
void FooterRowsAllowEdit(BOOL bAllowEdit);
/**
* @brief
* Determines if the text in all CXTPGridRecordItem(s) can be edited
* (for footer records only).
* @return
* TRUE if the text in all CXTPGridRecordItem(s) can be edited,
* otherwise FALSE.
* @see
* FooterRowsAllowEdit, EditOnClick, IsEditOnClick
*/
BOOL IsFooterRowsAllowEdit() const;
//////////////////////////////////////////////////////////////////////////
// Allow Group
//////////////////////////////////////////////////////////////////////////
/**
* @brief
* Enables/disables row grouping.
* @param bAllowGroup TRUE to enable row grouping,
* FALSE to disable row grouping.
* @see
* IsAllowGroup
*/
void AllowGroup(BOOL bAllowGroup);
/**
* @brief
* Determines if row grouping is enabled/disabled.
* @return
* TRUE if row grouping is enabled, otherwise FALSE.
* @see
* AllowGroup
*/
BOOL IsAllowGroup() const;
/**
* @brief
* Enables/disables header row grouping.
* @param bAllowGroup TRUE to enable header row grouping,
* FALSE to disable header row grouping.
* @see
* IsHeaderRowsAllowGroup
*/
void HeaderRowsAllowGroup(BOOL bAllowGroup);
/**
* @brief
* Determines if header row grouping is enabled/disabled.
* @return
* TRUE if header row grouping is enabled, otherwise FALSE.
* @see
* HeaderRowsAllowGroup
*/
BOOL IsHeaderRowsAllowGroup() const;
/**
* @brief
* Enables/disables footer row grouping.
* @param bAllowGroup TRUE to enable footer row grouping,
* FALSE to disable footer row grouping.
* @see
* IsFooterRowsAllowGroup
*/
void FooterRowsAllowGroup(BOOL bAllowGroup);
/**
* @brief
* Determines if footer row grouping is enabled/disabled.
* @return
* TRUE if footer row grouping is enabled, otherwise FALSE.
* @see
* FooterRowsAllowGroup
*/
BOOL IsFooterRowsAllowGroup() const;
//////////////////////////////////////////////////////////////////////////
// Allow Sort
//////////////////////////////////////////////////////////////////////////
/**
* @brief
* Enables/disables row sorting.
* @param bAllowSort TRUE to enable row sorting,
* FALSE to disable row sorting.
* @see
* IsAllowSort
*/
void AllowSort(BOOL bAllowSort);
/**
* @brief
* Determines if row sorting is enabled/disabled.
* @return
* TRUE if row sorting is enabled, otherwise FALSE.
* @see
* AllowSort
*/
BOOL IsAllowSort() const;
/**
* @brief
* Enables/disables header row sorting.
* @param bAllowSort TRUE to enable header row sorting,
* FALSE to disable header row sorting.
* @see
* IsHeaderRowsAllowSort
*/
void HeaderRowsAllowSort(BOOL bAllowSort);
/**
* @brief
* Determines if header row sorting is enabled/disabled.
* @return
* TRUE if header row sorting is enabled, otherwise FALSE.
* @see
* HeaderRowsAllowSort
*/
BOOL IsHeaderRowsAllowSort() const;
/**
* @brief
* Enables/disables footer row sorting.
* @param bAllowSort TRUE to enable footer row sorting,
* FALSE to disable footer row sorting.
* @see
* IsFooterRowsAllowSort
*/
void FooterRowsAllowSort(BOOL bAllowSort);
/**
* @brief
* Determines if footer row sorting is enabled/disabled.
* @return
* TRUE if footer row sorting is enabled, otherwise FALSE.
* @see
* FooterRowsAllowSort
*/
BOOL IsFooterRowsAllowSort() const;
//////////////////////////////////////////////////////////////////////////
// Show Rows
//////////////////////////////////////////////////////////////////////////
/**
* @brief
* Specifies the visible state of header records.
* @param bShow TRUE to show header records,
* FALSE to hide header records.
* @see
* IsHeaderRowsVisible, ShowFooterRows
*/
void ShowHeaderRows(BOOL bShow = TRUE);
/**
* @brief
* Determines the visible state of header records.
* @return
* TRUE if header records are shown, FALSE if header records are hidden.
* @see
* ShowHeaderRows
*/
BOOL IsHeaderRowsVisible() const;
/**
* @brief
* Specifies the visible state of footer records.
* @param bShow TRUE to show footer records,
* FALSE to hide footer records.
* @see
* IsFooterRowsVisible, ShowHeaderRows
*/
void ShowFooterRows(BOOL bShow = TRUE);
/**
* @brief
* Determines the visible state of footer records.
* @return
* TRUE if footer records are shown, FALSE if footer records are hidden.
* @see
* ShowFooterRows
*/
BOOL IsFooterRowsVisible() const;
/**
* @brief
* Sets the Grid control theme.
* @param paintTheme Grid control theme; must be one of the values
* listed in the Remarks section.
* @param bEnableMetrics TRUE to allow the theme to override control metrics.
* @details
* paintTheme can be one of the following values:
* xtpGridThemeDefault: Enables default theme.
* xtpGridThemeOfficeXP: Enables Office XP style theme.
* xtpGridThemeOffice2003: Enables Office 2003 style theme.
* xtpGridThemeOffice2007: Enables Office 2007 style theme.
* xtpGridThemeOffice2010: Enables Office 2010 style theme.
* xtpGridThemeOffice2013: Enables Office 2013 style theme.
* xtpGridThemeVisualStudio2005: Enables Visual Studio 2005 style theme.
* xtpGridThemeVisualStudio2010: Enables Visual Studio 2010 style theme.
* xtpGridThemeVisualStudio2012Light: Enables VS 2012 Light style
* Property Grid theme.
* xtpGridThemeVisualStudio2012Dark: Enables VS 2012 Dark style
* Property Grid theme.
* xtpGridThemeResource: Enables visual style theme.
*/
void SetTheme(XTPGridPaintTheme paintTheme, BOOL bEnableMetrics = FALSE);
/**
* @brief
* Gets the Grid control theme.
* @return
* The Grid control theme; one of the values defined
* by the XTPGridPaintTheme enumeration.
*/
XTPGridPaintTheme GetCurrentTheme() const;
# endif // XTP_GRID_DEPRECATED()
protected:
int GetPageRowCount(CDC* pDC) const;
void AdjustScrollBarH(BOOL bUpdate, UINT nMask); /* Adjusts the horizontal scrollbar. */
void AdjustScrollBarV(BOOL bUpdate, UINT nMask); /* Adjusts the vertical scrollbar. */
void UpdateScrollBarV();
void Paint(CDC* pDC);
/**
* @brief
* Performs all drawing logic.
* @param pDC Provided device context to draw control image with.
*/
virtual void OnDraw(CDC* pDC);
/**
* @brief
* Draws all rows in the provided device context.
* @param pDC Provided device context to draw rows image with.
* @param rcClient Reference to a rectangle to draw rows image into.
* @param pRows Rows collection to draw.
* @param nTopRow Index of the topmost visible row of the rows collection.
* @param nColumnFrom Index of the first column to draw from.
* @param nColumnTo Index of the last column to draw to.
* @param pnHeight Pointer to an integer to receive the total height
* of the drawn rows; can be NULL.
* @param y Distance from the top.
* @return
* The index of the last printed row.
*/
virtual int DrawRows(CDC* pDC, CRect& rcClient, int y, CXTPGridRows* pRows, int nTopRow,
int nColumnFrom, int nColumnTo, int* pnHeight = NULL);
virtual void DrawIconView(CDC* pDC, CRect& rcClient);
/**
* @brief
* Draws the 'NoItems' text in the provided device conext.
* @param pDC Provided device context to draw text with.
* @param rcClient Rectangle to draw text into.
*/
virtual void DrawNoItems(CDC* pDC, const CRect& rcClient);
/**
* @brief
* Determines if the internal control state was changed since the last drawing.
* @details
* This method is used for caching control image drawing.
* @return
* TRUE if the internal control state was changed since last drawing,
* otherwise FALSE.
*/
BOOL IsChanged() const;
/**
* @brief
* Specifies if the internal control state was changed since the last drawing.
* @param bChanged TRUE if the internal control state was changed since
* the last drawing and the control must be republished.
* @details
* This method is used for caching control image drawing.
*/
void SetChanged(BOOL bChanged = TRUE);
/**
* @brief
* Re-sorts the rows tree according to the sort order for columns.
* @details
* This method works faster than Populate.
*/
virtual void ReSortRows();
/**
* @brief
* Updates the field chooser control with its content.
*/
void UpdateSubList();
/**
* @brief
* Inserts a specified row at a specified index in the rows array.
* @param nIndex Integer index to insert the row at.
* @param pRow Row to be inserted.
* @details
* This method inserts the specified row to the rows array at
* the specified index with all its children expanded.
* Use _DoExpand() to expand all child items.
* @return
* The number of inserted rows.
*/
virtual int InsertRow(int nIndex, CXTPGridRow* pRow);
/**
* @brief
* Checks a record for filter text.
* @param pRecord A record to apply filter to.
* @param strFilterText Filter string text.
* @param bIncludePreview Include preview item in filtering or not.
* @details
* This member function represents filter functionality. First, it parses
* the input text of a filter string by tokens; second it enumerates all visible
* columns to find text matching to the filter string. Returns TRUE if
* matching found, FALSE otherwise
* @return
* TRUE if record is filtered with the specified filter,
* FALSE otherwise.
*/
virtual BOOL ApplyFilter(CXTPGridRecord* pRecord, CString strFilterText, BOOL bIncludePreview);
/**
* @brief
* This member function is called after a user selects a row or a column.
* @details
* After the user selects a row or column, the Grid control sends a
* notification to the parent window by calling OnSelectionChanged().
* @see
* XTP_NM_GRID_SELCHANGED, SendNotifyMessage()
*/
virtual void OnSelectionChanged();
/**
* @brief
* This member function is called before the focus changes.
* @param pNewRow Pointer to the newly focused row object.
* @param pNewCol Pointer to the newly focused column object.
* @details
* Before the user changes the focused row or column, the Grid control
* sends a notification to the parent window by calling OnFocusChanging().
* @return
* TRUE if the operation will continue, FALSE if the operation will be canceled.
* @see
* XTP_NM_GRID_FOCUS_CHANGING, SendNotifyMessage(), OnFocusChanged
*/
virtual BOOL OnFocusChanging(CXTPGridRow* pNewRow, CXTPGridColumn* pNewCol);
/**
* @brief
* Calculates metrics for a row.
* @param pDrawArgs Pointer to an XTP_GRIDRECORDITEM_DRAWARGS
* structure used to calculate metrics.
* @param pItemMetrics Pointer to an XTP_GRIDRECORDITEM_METRICS
* structure to fill with values.
*/
virtual void GetItemMetrics(XTP_GRIDRECORDITEM_DRAWARGS* pDrawArgs,
XTP_GRIDRECORDITEM_METRICS* pItemMetrics);
/**
* @brief
* Creates a CXTPGridRow object.
* Overwrite it to use the derived CXTPGridRow class.
* @return
* A pointer to the newly created CXTPGridRow object.
*/
virtual CXTPGridRow* CreateRow();
/**
* @brief
* Creates a CXTPGridGroupRow object.
* Overwrite it to use the derived CXTPGridGroupRow class.
* @return
* A pointer to the newly created CXTPGridGroupRow object.
*/
virtual CXTPGridGroupRow* CreateGroupRow();
/**
* @brief
* Creates a CXTPGridRow object for header/footer rows.
* Overwrite it to use the derived CXTPGridRow class.
* @return
* A pointer to the newly created CXTPGridRow object.
*/
virtual CXTPGridRow* CreateHeaderFooterRow();
/**
* @brief
* This method is called when the user begins dragging a row.
* @param point Drag point.
* @details
* You can override this method or catch a LVN_BEGINDRAG message to
* proceed with drag operations.
* OnBeginDrag will not know which mouse button is used for the
* drag unless you pass nFlags.
*/
virtual void OnBeginDrag(CPoint point);
/**
* @brief
* This method is called when the user begins dragging a row.
* @param point Drag point.
* @param nFlags Flags for various mouse button states.
* @details
* You can override this method or catch a LVN_BEGINDRAG message to
* proceed with drag operations.
* OnBeginDrag will not know which mouse button is used for the
* drag unless you pass nFlags.
*/
virtual void OnBeginDrag(CPoint point, UINT nFlags);
/**
* @brief
* This method is called before a record is copied to the clipboard in text format.
* @param pRecord [in] Pointer to the source record.
* @param rarStrings [in/out] Reference to an array of strings with record item
* values. By default, this array contains visible item captions.
* @details
* If you would like to customize text data for the clipboard, then
* you can change rarStrings as needed.
*
* Default implementation sends an XTP_NM_GRID_BEFORE_COPY_TOTEXT
* notification.
* @return
* TRUE if the operation will be canceled, FALSE if the operation will continue.
* @see
* OnBeforePasteFromText, OnBeforePaste, Cut, Copy, Paste.
*/
virtual BOOL OnBeforeCopyToText(CXTPGridRecord* pRecord, CStringArray& rarStrings);
/**
* @brief
* This method is called before creating a new record using text data
* from the clipboard.
* @param arStrings [in] Array of strings with record items values.
* @param ppRecord [out] Double pointer to the new record.
* @details
* If you would like to customize creating a new record from text data, then
* you must create a new record object with record items and fill them
* using the default values and strings provided by the arStrings parameter.
*
* If the new record will not be set to the ppRecord parameter, then the
* control will create a CXTPGridRecord object with
* CXTPGridRecordItemVariant items and fill the visible items using
* the strings provided by the arStrings parameter.
*
* Default implementation sends an XTP_NM_GRID_BEFORE_PASTE_FROMTEXT
* notification.
* @return
* TRUE if the operation will be canceled, FALSE if the operation will continue.
* @see
* OnBeforeCopyToText, OnBeforePaste, Cut, Copy, Paste.
*/
virtual BOOL OnBeforePasteFromText(CStringArray& arStrings, CXTPGridRecord** ppRecord);
/**
* @brief
* This method is called after creating a new record using binary data
* from the clipboard, but before adding it to records collection.
* @param ppRecord [in/out] Double pointer to the new record.
* @details
* If you would like to customize the new record created from binary data,
* then you may either create a new record or change the provided record
* by using the ppRecord parameter.
*
* Default implementation sends an XTP_NM_GRID_BEFORE_PASTE
* notification.
* @return
* TRUE if the operation will be canceled, FALSE if the operation will continue.
* @see
* OnBeforeCopyToText, OnBeforePasteFromText, Cut, Copy, Paste.
*/
virtual BOOL OnBeforePaste(CXTPGridRecord** ppRecord);
/**
* @brief
* This method is called before processing the OnKeyDown event.
* @param rnChar [in/out] Reference to a variable that specifies
* the virtual key code of the given key. For a list
* of standard virtual key codes, see Winuser.h.
* @param nRepCnt [in] Repeat count (the number of times that the keystroke
* is repeated as a result of the user holding down the key).
* @param nFlags [in] Specifies the scan code, key-transition code,
* previous key state, and context code.
* @details
* If you would like to customize keyboard behavior, then you can either
* change the rnChar parameter value or perform your logic and then
* return FALSE to disable default processing.
*
* Default implementation sends an XTP_NM_GRID_PREVIEWKEYDOWN
* notification.
* @return
* TRUE if the operation will continue, FALSE if the operation will be canceled.
* @see
* OnKeyDown, CWnd::OnKeyDown, XTP_NM_GRID_PREVIEWKEYDOWN.
*/
virtual BOOL OnPreviewKeyDown(UINT& rnChar, UINT nRepCnt, UINT nFlags);
/**
* @brief
* This method is used by the Grid control to calculate
* the best-fit column width.
* @param pColumn Pointer to a column for width calculation.
* @return
* The best-fit column width if successful, otherwise a value of 0.
*/
virtual int OnGetColumnDataBestFitWidth(CXTPGridColumn* pColumn);
/**
* @brief
* This method is used by the Grid control to calculate
* the items captions maximum width.
* @param pDC Pointer to a valid device context.
* @param pRows Pointer to a rows collection.
* @param pColumn Pointer to a column for width calculation.
* @param nStartRow Index of the row to begin calculating from.
* @param nRowsCount Number of rows to include within the calculation
* (i.e. the rows specified by this parameter includes both
* nStartRow and the rows that immediately follow nStartRow).
* @return
* The items captions maximum width.
*/
virtual int OnGetItemsCaptionMaxWidth(CDC* pDC, CXTPGridRows* pRows, CXTPGridColumn* pColumn,
int nStartRow = 0, int nRowsCount = -1);
/**
* @brief
* This method is used to start monitoring mouse position for
* automatic vertical scrolling.
* @details
* Used when dragging records.
* @see
* EnsureStopAutoVertScroll, DoAutoVertScrollIfNeed
*/
virtual void EnsureStartAutoVertScroll();
/**
* @brief
* This method is used to stop monitoring mouse position for
* automatic vertical scrolling.
* @details
* Used when dragging records.
* @see
* EnsureStartAutoVertScroll, DoAutoVertScrollIfNeed
*/
virtual void EnsureStopAutoVertScroll();
/**
* @brief
* This method is used to monitor mouse position. If the mouse
* is moved to 20 pixels before either the top or bottom
* grid borders, then the control will be scrolled vertically.
* @param ptClick Coordinates of the initial click (or mouse down).
* @param pt Current mouse position.
* @details
* Used when dragging records.
* @see
* EnsureStartAutoVertScroll, EnsureStopAutoVertScroll
*/
virtual void DoAutoVertScrollIfNeed(CPoint ptClick, CPoint pt);
/**
* @brief
* Calculates the combined height of all rows within a specified rows collection.
* @param pRows Pointer to the rows collection to calculate
* the combined height of all rows within.
* @param nTotalWidth Width of the row.
* @param nMaxHeight Should the calculated height exceed the value of this
* parameter, then the calculation will end. Set this
* parameter to -1 to calculate the height of all rows.
* @return
* The combined height of all rows within the specified rows collection.
*/
virtual int GetRowsHeight(CXTPGridRows* pRows, int nTotalWidth, int nMaxHeight = -1);
/**
* @brief
* This method is used to notify about changes to the constraint selection.
* @param pRow Pointer to the current row object.
* @param pItem Pointer to the current record item object.
* @param pColumn Pointer to the current column object.
* @param pConstraint Pointer to the hot selected constraint.
* @details
* Sent for every selection change before the new selection is applied or canceled.
* @return
* TRUE if the notification was sent successfully, otherwise FALSE.
*/
virtual BOOL OnConstraintSelecting(CXTPGridRow* pRow, CXTPGridRecordItem* pItem,
CXTPGridColumn* pColumn,
CXTPGridRecordItemConstraint* pConstraint);
/**
* @brief
* This method is called to get the tooltip text for the current record item.
* @param pRow Pointer to the current row object.
* @param pItem Pointer to the current record item object.
* @param rstrToolTipText Reference to a CString object to customize the
* tooltip text. It contains default tooltip text.
* @details
* If rstrToolTipText is set to empty, then the default tooltip will be shown
* when there is not enough space to draw item text.
* If rstrToolTipText is set to a single space (" "), then no tooltip will be shown.
* @return
* A reference to an XTP_NM_GRIDTOOLTIPINFO structure.
*/
virtual const XTP_NM_GRIDTOOLTIPINFO& OnGetToolTipInfo(CXTPGridRow* pRow,
CXTPGridRecordItem* pItem,
CString& rstrToolTipText);
/**
* @brief
* Adjusts control indentation properties depending on the current tree depth.
* @see
* GetIndent
*/
void AdjustIndentation();
/**
* @brief
* This member is called when an item is dragged over the Grid control.
* @param pDataObject Pointer to the COleDataObject being dragged over the drop target.
* @param dwKeyState State of keys on the keyboard (including modifier keys).
* This is a combination of any number of the following: MK_CONTROL,
* MK_SHIFT, MK_ALT, MK_LBUTTON, MK_MBUTTON, and MK_RBUTTON.
* @param point Current mouse position relative to the Grid control.
* @param nState Transition state (0 enter, 1 leave, 2 over).
* @return
* A value from the DROPEFFECT enumerated type which indicates the type
* of drop that would occur if the user dropped the object at this position.
* The type of drop often depends on the current key state as indicated
* by dwKeyState. A standard mapping of key states to DROPEFFECT values is:
* DROPEFFECT_NONE: The data object cannot be dropped in this window.
* DROPEFFECT_COPY for MK_CONTROL: Creates a copy of
* the dropped object.
* DROPEFFECT_MOVE for MK_ALT: Creates a copy of the dropped
* object and deletes the original
* object. This is typically the
* default drop effect when the
* view can accept the data object.
*/
virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point,
int nState);
/**
* @brief
* This member is called when an item has been dropped into the Grid control.
* @param pDataObject Pointer to the COleDataObject dropped into the drop target.
* @param dropEffect Drop effect requested by the user; can be any
* of the values listed in the Remarks section.
* @param point Current mouse position relative to the Grid control.
* @details
* The dropEffect parameter can be one of the following values:
* DROPEFFECT_COPY: Creates a copy of the data object being dropped.
* DROPEFFECT_MOVE: Moves the data object to the current mouse location.
* @return
* TRUE if the drop was successful, otherwise FALSE.
*/
virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
/**
* @brief
* Relays a tooltip event.
*
* @param message Windows message.
*/
virtual void RelayToolTipEvent(UINT message);
/**
* @brief
* Gets the number of rows per mouse scroll.
* @return
* The number of rows per mouse scroll.
*/
static UINT AFX_CDECL GetMouseScrollLines();
/** @cond */
virtual CString _GetSelectedRowsVisibleColsText();
BOOL _GetSelectedRows(CXTPGridRecords* pRecords,
CXTPInternalCollectionT