/** * @file XTPMarkupGrid.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(__XTPMARKUPGRID_H__) # define __XTPMARKUPGRID_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPMarkupBuilder; class CXTPMarkupUIElement; class CXTPMarkupDefinitionBase; class CXTPMarkupColumnDefinitionCollection; class CXTPMarkupRowDefinitionCollection; /** * @brief * CXTPMarkupDefinitionCollection is the base class for CXTPMarkupDefinitionCollection * and CXTPMarkupDefinitionCollection. It implements the RowDefinition XAML Tag. */ class _XTP_EXT_CLASS CXTPMarkupDefinitionCollection : public CXTPMarkupCollection { /** @cond */ DECLARE_MARKUPCLASS(CXTPMarkupDefinitionCollection); /** @endcond */ public: /** * @brief * Constructs a CXTPMarkupDefinitionCollection object. */ CXTPMarkupDefinitionCollection(); public: /** * @brief * Retrieves a CXTPMarkupDefinitionBase object by its index. * @param nIndex Index of the CXTPMarkupDefinitionBase object to retrieve. * @return * A CXTPMarkupDefinitionBase object. */ CXTPMarkupDefinitionBase* GetItem(int nIndex) const; /** @cond */ public: DECLARE_DISPATCH_MAP() # ifdef _XTP_ACTIVEX DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPMarkupDefinitionCollection); # endif DECLARE_ENUM_VARIANT(CXTPMarkupDefinitionCollection) long OleGetItemCount(); LPDISPATCH OleGetItem(long nIndex); void OleAdd(LPDISPATCH lpElementDisp); void OleInsert(long Index, LPDISPATCH lpElementDisp); /** @endcond */ }; /** * @brief * CXTPMarkupGrid is a CXTPMarkupPanel derived class. * It implements the Grid XAML Tag. */ class _XTP_EXT_CLASS CXTPMarkupGrid : public CXTPMarkupPanel { private: enum LayoutTimeSizeType { sizeTypeNone = 0, sizeTypePixel = 1, sizeTypeAuto = 2, sizeTypeStar = 4 }; private: struct CELLCACHE { int nColumnIndex; int nRowIndex; int nColumnSpan; int nRowSpan; int nSizeTypeU; int nSizeTypeV; int nNext; public: BOOL IsStarU() const; BOOL IsAutoU() const; BOOL IsStarV() const; BOOL IsAutoV() const; }; struct SPANKEY { int nCount; int nStart; BOOL bU; int nValue; }; private: /** @cond */ DECLARE_MARKUPCLASS(CXTPMarkupGrid) /** @endcond */ protected: /** * @brief * Constructs a CXTPMarkupGrid object. */ CXTPMarkupGrid(); /** * @brief * Destroys a CXTPMarkupGrid object, handles cleanup and deallocation. */ virtual ~CXTPMarkupGrid(); public: /** * @brief * Retrieves the collection of constraints and definitions for grid columns. * @return * A pointer to the collection of CXTPMarkupColumnDefinition classes. */ CXTPMarkupColumnDefinitionCollection* GetColumnDefinitions() const; /** * @brief * Retrieves the collection of constraints and definitions for grid rows. * @return * A pointer to the collection of CXTPMarkupRowDefinition classes. */ CXTPMarkupRowDefinitionCollection* GetRowDefinitions() const; /** * @brief * Sets a column index for a grid child element. * @param pElement Grid child element. * @param nColumn Column index to set for pElement. * @return */ static void AFX_CDECL SetColumn(CXTPMarkupUIElement* pElement, int nColumn); /** * @brief * Retrieves the column index of a grid child element. * @param pElement Grid child element whose column index must be retrieved. * @return * The column index of the grid child element. */ static int AFX_CDECL GetColumn(CXTPMarkupUIElement* pElement); /** * @brief * Sets the row index for a grid child element. * @param pElement Grid child element. * @param nRow Row index to set for pElement. * @return */ static void AFX_CDECL SetRow(CXTPMarkupUIElement* pElement, int nRow); /** * @brief * Retrieves the row index of a grid child element. * @param pElement Grid child element whose row index must be retrieved. * @return * The row index of the grid child element. */ static int AFX_CDECL GetRow(CXTPMarkupUIElement* pElement); /** * @brief * Sets the total number of columns that child content spans within a grid. * @param pElement Pointer to a child element of the grid. * @param nColumnSpan Number of columns that the child content should span. * @return */ static void AFX_CDECL SetColumnSpan(CXTPMarkupUIElement* pElement, int nColumnSpan); /** * @brief * Gets the total number of columns that child content spans within a grid. * @param pElement Pointer to a child element of the grid to check. * @return * The total number of columns that child content spans within the grid. */ static int AFX_CDECL GetColumnSpan(CXTPMarkupUIElement* pElement); /** * @brief * Sets the total number of rows that child content spans within a grid. * @param pElement Pointer to a child element of the grid. * @param nRowSpan Number of rows that the child content should span. * @return */ static void AFX_CDECL SetRowSpan(CXTPMarkupUIElement* pElement, int nRowSpan); /** * @brief * Gets the total number of rows that child content spans within a grid. * @param pElement Pointer to a child element of the grid to check. * @return * The total number of rows that child content spans within the grid. */ static int AFX_CDECL GetRowSpan(CXTPMarkupUIElement* pElement); /** @cond */ // Implementation protected: CSize MeasureOverride(CXTPMarkupDrawingContext* pDC, CSize availableSize); CSize ArrangeOverride(CSize arrangeSize); void SetPropertyObject(CXTPMarkupBuilder* pBuilder, CXTPMarkupDependencyProperty* pProperty, CXTPMarkupObject* pValue); private: void ValidateDefinitionsLayout(CXTPMarkupDefinitionCollection* pDefinitions, BOOL bTreatStarAsAuto); void ValidateCells(); void ValidateDefinitions(); int GetLengthTypeForRange(CXTPMarkupDefinitionCollection* pDefinitions, int start, int count); void MeasureCellsGroup(CXTPMarkupDrawingContext* pDC, int cellsHead, CSize referenceSize, BOOL ignoreDesiredSizeU, BOOL forceInfinityV); void MeasureCell(CXTPMarkupDrawingContext* pDC, int cell, BOOL forceInfinityV); int GetMeasureSizeForRange(CXTPMarkupDefinitionCollection* pDefinitions, int start, int count); int CalculateDesiredSize(CXTPMarkupDefinitionCollection* pDefinitions); void ResolveStar(CXTPMarkupDefinitionCollection* pDefinitions, double availableSize); int GetFinalSizeForRange(CXTPMarkupDefinitionCollection* pDefinitions, int start, int count); void SetFinalSize(CXTPMarkupDefinitionCollection* pDefinitions, int finalSize); void EnsureMinSizeInDefinitionRange(CXTPMarkupDefinitionCollection* definitions, int start, int count, int requestedSize); static int AFX_CDECL DistributionOrderComparer(const void* arg1, const void* arg2); static int AFX_CDECL StarDistributionOrderComparer(const void* arg1, const void* arg2); static int AFX_CDECL SpanMaxDistributionOrderComparer(const void* arg1, const void* arg2); static int AFX_CDECL SpanPreferredDistributionOrderComparer(const void* arg1, const void* arg2); static void AFX_CDECL OnCellAttachedPropertyChanged(CXTPMarkupObject* d, CXTPMarkupPropertyChangedEventArgs* e); protected: CXTPMarkupRowDefinitionCollection* m_pRowDefinitions; CXTPMarkupColumnDefinitionCollection* m_pColumnDefinitions; public: static CXTPMarkupDependencyProperty* m_pColumnDefinitionsProperty; static CXTPMarkupDependencyProperty* m_pRowDefinitionsProperty; static CXTPMarkupDependencyProperty* m_pRowProperty; static CXTPMarkupDependencyProperty* m_pColumnProperty; static CXTPMarkupDependencyProperty* m_pColumnSpanProperty; static CXTPMarkupDependencyProperty* m_pRowSpanProperty; private: CELLCACHE* m_pCellCachesCollection; int m_nCellGroup[4]; BOOL m_bHasStarCellsU; BOOL m_bHasStarCellsV; BOOL m_bHasGroup2CellsInAutoRows; CXTPMarkupDefinitionCollection* m_pDefinitionsU; CXTPMarkupDefinitionCollection* m_pDefinitionsV; friend struct CELLCACHE; friend class CXTPMarkupDefinitionBase; /** @endcond */ /** @cond */ public: DECLARE_DISPATCH_MAP() # ifdef _XTP_ACTIVEX DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPMarkupGrid); # endif afx_msg int OleGetRow(LPDISPATCH lpElementDisp); afx_msg void OleSetRow(LPDISPATCH lpElementDisp, int nValue); afx_msg int OleGetRowSpan(LPDISPATCH lpElementDisp); afx_msg void OleSetRowSpan(LPDISPATCH lpElementDisp, int nValue); afx_msg int OleGetColumn(LPDISPATCH lpElementDisp); afx_msg void OleSetColumn(LPDISPATCH lpElementDisp, int nValue); afx_msg int OleGetColumnSpan(LPDISPATCH lpElementDisp); afx_msg void OleSetColumnSpan(LPDISPATCH lpElementDisp, int nValue); afx_msg LPDISPATCH OleGetColumnDefinitions(); afx_msg LPDISPATCH OleGetRowDefinitions(); /** @endcond */ }; AFX_INLINE CXTPMarkupColumnDefinitionCollection* CXTPMarkupGrid::GetColumnDefinitions() const { return m_pColumnDefinitions; } AFX_INLINE CXTPMarkupRowDefinitionCollection* CXTPMarkupGrid::GetRowDefinitions() const { return m_pRowDefinitions; } AFX_INLINE CXTPMarkupDefinitionBase* CXTPMarkupDefinitionCollection::GetItem(int nIndex) const { return nIndex >= 0 && nIndex < m_arrItems.GetSize() ? (CXTPMarkupDefinitionBase*)m_arrItems[nIndex] : NULL; } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPMARKUPGRID_H__) /** @endcond */