/** * @file XTPGridSections.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(__XTPGRIDSECTIONS_H__) # define __XTPGRIDSECTIONS_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPGridControl; class CXTPGridSection; class CXTPMarkupContext; /** * @brief * Defines a grid section. */ enum XTPGridSection { xtpGridSectionHeader = 0, /**< Index of header section. */ xtpGridSectionBody = 1, /**< Index of body section. */ xtpGridSectionFooter = 2, /**< Index of footer section. */ xtpGridSectionCount = 3 /**< Number of default sections. */ }; /** * @brief * Collection of sections. */ class _XTP_EXT_CLASS CXTPGridSections : public CXTPCmdTarget { public: /** * @brief * Constructs the collection and default sections. * @param pControl Pointer to the grid control. */ CXTPGridSections(CXTPGridControl* pControl); /** * @brief * Destructs the collection and sections. */ ~CXTPGridSections(); public: int Add(CXTPGridSection* pSection) { return (int)m_arrSections.Add(pSection); } CXTPGridSection* GetAt(int nIndex) const { CXTPGridSection* pSection = NULL; if (GetSize() > nIndex) // Valid index { pSection = m_arrSections.GetAt(nIndex); } return pSection; } int GetSize() const { return int(m_arrSections.GetSize()); } void RemoveAll() { m_arrSections.RemoveAll(); } public: /** * @brief * Ensures that a Grid control row is at least partially visible. * @param pDC Pointer to a valid device context. * @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. * @return * TRUE if successful, otherwise FALSE. * @see * MoveDown, MoveUp, MovePageDown, MovePageUp, MoveFirst, MoveLast */ virtual BOOL EnsureVisible(CDC* pDC, CXTPGridRow* pRow); /** * @brief * Gets the currently focused row in the Grid control's view. * @return * A pointer to the currently focused row in the * Grid control's view if successful, otherwise NULL. */ CXTPGridRow* GetFocusedRow() const; /** * @brief * Retrieves the current rectangle for the sections. * @return * A CRect containing the current rectangle for the sections. */ CRect GetRect() const; /** * @brief * Determines which section, if any, is at a specified point. * @param pt Point to test. * @return * A pointer to the section at the specified point, if any, * otherwise NULL. */ CXTPGridSection* HitTest(CPoint pt) const; /** * @brief * Draws the sections to the device context. * @param pDC Pointer to the used device context. */ virtual void Draw(CDC* pDC); /** * @brief * Adjusts section areas depending on the current control size. * @param pDC Target device context pointer. * @param rcSections Target sections rectangle. */ virtual void AdjustLayout(CDC* pDC, CRect rcSections); /** * @brief * Sets the markup context. * @param pMarkupContext Pointer to the markup context to be set. */ void SetMarkupContext(CXTPMarkupContext* pMarkupContext); /** * @brief * Re-sorts the rows for all sections. */ virtual void ReSortRows(); /** * @brief * Recalculates the indices of all rows. * @param bAdjustLayout TRUE to adjust the layout. */ virtual void RefreshIndexes(BOOL bAdjustLayout); virtual void ResetContent(); protected: CXTPGridSection* FindSection(CXTPGridRow* pRow) const; protected: CArray m_arrSections; CRect m_rcSections; /**< Sections rectangle. */ CXTPGridControl* m_pControl; /**< Parent control. */ private: # ifdef _XTP_ACTIVEX DECLARE_OLETYPELIB_EX(CXTPGridSections); DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() int OleGetCount() const { return GetSize(); } LPDISPATCH OleGetSection(int nIndex) const; # endif // _XTP_ACTIVEX }; /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPGRIDSECTIONS_H__) /** @endcond */