/** * @file XTPGridSubListControl.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(__XTPGRIDSUBLISTCONTROL_H__) # define __XTPGRIDSUBLISTCONTROL_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPGridHeaderDragWnd; class CXTPGridControl; class CXTPGridColumn; /** * @brief * Field chooser list box control. * This control allows the user to move column names from an associated * CXTPGridControl object to and from its header. * @details * To use a field chooser in an existing dialog box of your application, * add a standard list box to your dialog template using the dialog * editor and then initialize your CXTPGridSubListControl object * inside the OnInitialUpdate dialog handler. See example below: * * Example: *
* // CXTPGridSubListControl m_wndSubList; * wndSubList.SubclassDlgItem(IDC_COLUMNLIST, &pFieldChooserDialog); * // CXTPGridControl wndGrid; * wndGrid.GetGridHeader()->SetSubListCtrl(&wndSubList); ** * @see * CDragListBox, CXTPGridControl, CXTPGridHeader, * CXTPGridHeaderDragWnd, GridControl sample application */ class _XTP_EXT_CLASS CXTPGridSubListControl : public CListBox { /** @cond */ DECLARE_DYNAMIC(CXTPGridSubListControl) /** @endcond */ public: /** * @brief * Constructs a CXTPGridSubListControl object. * @details * You construct a CXTPGridSubListControl object in two steps. * First, call the constructor CXTPGridSubListControl. * Second, call CListBox::Create. This initializes the Windows list box * and attaches it to the CXTPGridSubListControl. * * Example: *
* // Declare a local CXTPGridSubListControl object. * CXTPGridSubListControl mySubList; * * // Declare a dynamic CXTPGridSubListControl object. * CXTPGridSubListControl* pMySubList = new CXTPGridSubListControl; ** * @see * CListBox, CXTPGridSubListControl::SetGridCtrl, * CXTPGridHeader::SetSubListCtrl */ CXTPGridSubListControl(); /** * @brief * Destroys a CXTPGridSubListControl object, * handles cleanup and deallocation. */ ~CXTPGridSubListControl(); public: /** * @brief * Sets the associated Grid control. * @param pGridCtrl Pointer to the associated Grid control to be set. * @details * Usually this method should not be called by the user. Instead * the user should call CXTPGridHeader::SetSubListCtrl. * @return * TRUE if the associated Grid control was set successfully, * otherwise FALSE. * @see * CXTPGridHeader::SetSubListCtrl, GetGridCtrl */ BOOL SetGridCtrl(CXTPGridControl* pGridCtrl); /** @cond */ _XTP_DEPRECATED_IN_FAVOR(SetGridCtrl) BOOL SetReportCtrl(CXTPGridControl* pGridCtrl); /** @endcond */ /** * @brief * Gets the associated Grid control. * @return * A pointer to the associated Grid control. * @see * CXTPGridHeader::SetSubListCtrl, SetGridCtrl */ CXTPGridControl* GetGridCtrl(); /** @cond */ _XTP_DEPRECATED_IN_FAVOR(GetGridCtrl) CXTPGridControl* GetReportCtrl(); /** @endcond */ public: /** * @brief * Updates columns list data in the field chooser. * @details * Reloads the column list from the associated CXTPGridControl object, * deletes all visible column items from the internal list, * and adds the rest of the invisible items. * * Example: *
wndSubList.UpdateList();* @return * TRUE if the update was successful, otherwise FALSE. */ BOOL UpdateList(); /** * @brief * Not used currently. * @param iSubItem Sub-item number for including. * @return * Nonzero if successful, otherwise 0. */ virtual BOOL Include(int iSubItem); /** * @brief * Not used currently. * @param iSubItem Sub-item number for disabling. * @return * Nonzero if successful, otherwise 0. */ virtual BOOL Disable(int iSubItem); /** * @brief * Specifies if the list should be sorted in ascending order. * @param bSort TRUE to sort the list in ascending order. */ void SortAscending(BOOL bSort); /** * @brief * Retrieves the caption of an item by its index. * @param nIndex Index of the item with the caption to retrieve. * @return * The caption of the item. */ CString GetItemCaption(int nIndex); /** * @brief * Retrieves the column object of an item by its index. * @param nIndex Index of the item with the column object to retrieve. * @return * A pointer to the CXTPGridColumn object of the item. */ CXTPGridColumn* GetItemColumn(int nIndex); protected: /** * @brief * Retrieves the index of an item by its data. * @param nItemData Data of the item with the index to retrieve. * @return * The index of the item if successful, otherwise a value of -1. */ int FindItemData(int nItemData); /** * @brief * Called by the framework when a drag operation starts. * @param nItem Item being dragged. * @details * Override this function if you want to control what happens when * a drag operation begins. This implementation captures the mouse, * creates a CXTPGridHeaderDragWnd and stays in drag mode until * the user clicks the left or right mouse button or presses ESC, * at which time the drag operation is canceled. * @return * Nonzero if dragging is allowed, otherwise 0. * @see * CDragListBox::BeginDrag */ BOOL BeginDrag(int nItem); /** * @brief * Called by the framework when an item is being dragged within the * CDragListBox object. * @param pt CPoint object that contains the x- and y- screen coordinates * of the cursor. * @details * This implementation allows dropping items only on the control itself * and associated Grid control header. * Override this function if you want to provide additional functionality. * @return * The resource ID of the cursor to be displayed. * The following values are possible: * DL_COPYCURSOR: Indicates that the item will be copied. * DL_MOVECURSOR: Indicates that the item will be moved. * DL_STOPCURSOR: Indicates that the current drop target * is not acceptable. * @see * CDragListBox::Dragging */ UINT Dragging(CPoint pt); /** * @brief * Called by the framework when a drag operation has been canceled. * @details * Destroys the dragging CXTPGridHeaderDragWnd window and resets * the associated Grid control mouse mode. * @see * CDragListBox::CancelDrag */ void CancelDrag(); /** * @brief * Called by the framework when an item is dropped within a * CDragListBox object. * @param pt CPoint object that contains the coordinates of the drop site. * @details * Destroys the dragging CXTPGridHeaderDragWnd window and returns * control to the caller. * @see * CDragListBox::Dropped */ void Dropped(CPoint pt); protected: /** @cond */ DECLARE_MESSAGE_MAP() void ParentNotify_SelChangd(); //{{AFX_VIRTUAL(CXTPGridSubListControl) public: virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); protected: virtual void PreSubclassWindow(); virtual void MeasureItem(LPMEASUREITEMSTRUCT) { } //}}AFX_VIRTUAL //{{AFX_MSG(CXTPGridSubListControl) afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnPaint(); afx_msg LRESULT OnPrintClient(WPARAM wParam, LPARAM lParam); //}}AFX_MSG /** @endcond */ protected: CXTPGridControl* m_pGridCtrl; /**< Pointer to the parent Grid control. */ CXTPGridHeaderDragWnd* m_pDragWnd; /**< Pointer to the associated dragging window. */ CRect m_rcDragWnd; /**< Coordinates of the associated dragging window. */ CRect m_rcDropTarget1; /**< First drop target - the list window itself. */ CRect m_rcDropTarget2; /**< Second drop target - the grid header. */ int m_nDropIndex; /**< Drop item index. */ BOOL m_bSortAscending; /**< TRUE to sort items ascending in the list. */ }; /** @cond */ AFX_INLINE BOOL CXTPGridSubListControl::SetReportCtrl(CXTPGridControl* pGridCtrl) { return SetGridCtrl(pGridCtrl); } AFX_INLINE CXTPGridControl* CXTPGridSubListControl::GetReportCtrl() { return GetGridCtrl(); } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPGRIDSUBLISTCONTROL_H__) /** @endcond */