/** * @file XTPPropertyGridItemSize.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(__XTPPROPERTYGRIDITEMSIZE_H__) # define __XTPPROPERTYGRIDITEMSIZE_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** * @brief * CXTPPropertyGridItemSize is a CXTPPropertyGridItem derived class. * It is used to create a size value item in a Property Grid control. */ class _XTP_EXT_CLASS CXTPPropertyGridItemSize : public CXTPPropertyGridItem { public: /** * @brief * Constructs a CXTPPropertyGridItemSize object. * @param strCaption Caption of the item. * @param size Initial size value of the item. * @param pBindSize If not NULL, then the value of the item * is bound the value of this variable. * @details * Class CXTPPropertyGridItemSize has no default constructor. * * When using the second constructor, the Identifier (nID) of the * second constructor can be linked with a STRINGTABLE resource * with the same ID in such form "Caption\\nDescription". * * BINDING: * Variables can be bound to an item in two ways, the first is * to pass in a variable at the time of creation, the second allows * variables to be bound to an item after creation with the * BindToSize member. * * Bound variables store the values of the property grid items * and can be accessed without using the property grid methods * and properties. Bound variables allow the property grid to * store data in variables. When the value of a PropertyGridItem * is changed, the value of the bound variable will be changed to * the PropertyGridItem value. The advantage of binding is that * the variable can be used and manipulated without using * PropertyGridItem methods and properties. * * NOTE: If the value of the variable is changed without using * the PropertyGrid, the PropertyGridItem value will not be * updated until you call CXTPPropertyGrid::Refresh. * @see * BindToSize */ CXTPPropertyGridItemSize(LPCTSTR strCaption, CSize size = 0, CSize* pBindSize = NULL); /** * @brief * Constructs a CXTPPropertyGridItemSize object. * @param nID Identifier of the item. * @param size Initial size value of the item. * @param pBindSize If not NULL, then the value of the item * is bound the value of this variable. * @details * Class CXTPPropertyGridItemSize has no default constructor. * * When using the second constructor, the Identifier (nID) of the * second constructor can be linked with a STRINGTABLE resource * with the same ID in such form "Caption\\nDescription". * * BINDING: * Variables can be bound to an item in two ways, the first is * to pass in a variable at the time of creation, the second allows * variables to be bound to an item after creation with the * BindToSize member. * * Bound variables store the values of the property grid items * and can be accessed without using the property grid methods * and properties. Bound variables allow the property grid to * store data in variables. When the value of a PropertyGridItem * is changed, the value of the bound variable will be changed to * the PropertyGridItem value. The advantage of binding is that * the variable can be used and manipulated without using * PropertyGridItem methods and properties. * * NOTE: If the value of the variable is changed without using * the PropertyGrid, the PropertyGridItem value will not be * updated until you call CXTPPropertyGrid::Refresh. * @see * BindToSize */ CXTPPropertyGridItemSize(UINT nID, CSize size = 0, CSize* pBindSize = NULL); /** * @brief * Destroys a CXTPPropertyGridItemSize object. */ virtual ~CXTPPropertyGridItemSize(); public: /** * @brief * Sets the size value for the item. * @param size size value to be set. */ virtual void SetSize(CSize size); /** * @brief * Gets the size value of the item. * @return * The size value of the item. */ virtual CSize GetSize() const; /** * @brief * Binds the item to a specified CSize object. * @param pBindSize Pointer to a CSize object. * @details * Variables can be bound to an item in two ways, the first is * to pass in a variable at the time of creation, the second allows * variables to be bound to an item after creation with the * BindToSize member. * * Bound variables store the values of the property grid items * and can be accessed without using the property grid methods * and properties. Bound variables allow the property grid to * store data in variables. When the value of a PropertyGridItem * is changed, the value of the bound variable will be changed to * the PropertyGridItem value. The advantage of binding is that * the variable can be used and manipulated without using * PropertyGridItem methods and properties. * * NOTE: If the value of the variable is changed without using * the PropertyGrid, the PropertyGridItem value will not be * updated until you call CXTPPropertyGrid::Refresh. */ virtual void BindToSize(CSize* pBindSize); protected: /** * @brief * This method is called before the item becomes visible in the * property grid. * @details * Before the item is inserted, it is first checked to see if it * is bound to a variable. If it is, then the value of the item * is updated with the value stored in the bound variable. * * OnBeforeInsert is called when an item is inserted, * when a category is inserted, when a category or item is expanded, * and when the sort property has changed. */ virtual void OnBeforeInsert(); private: void SetWidth(LPCTSTR strWidth); void SetHeight(LPCTSTR strHeight); CString SizeToString(CSize size); CSize StringToSize(LPCTSTR str); virtual void OnAddChildItem(); virtual void SetValue(CString strValue); void UpdateChilds(); private: class CXTPPropertyGridItemSizeWidth; class CXTPPropertyGridItemSizeHeight; CSize m_szValue; CXTPPropertyGridItemSizeWidth* m_pItemWidth; CXTPPropertyGridItemSizeHeight* m_pItemHeight; CSize* m_pBindSize; private: DECLARE_DYNAMIC(CXTPPropertyGridItemSize) friend class CXTPPropertyGridItemSizeWidth; friend class CXTPPropertyGridItemSizeHeight; }; /** * @brief * CXTPPropertyGridItemPoint is a CXTPPropertyGridItem derived class. * It is used to create a point value item in a Property Grid control. */ class _XTP_EXT_CLASS CXTPPropertyGridItemPoint : public CXTPPropertyGridItem { public: /** * @brief * Constructs a CXTPPropertyGridItemPoint object. * @param strCaption Caption of the item. * @param pt Initial point value of item. * @param pBindPoint If not NULL, then the value of this item * is bound the value of this variable. * @details * Class CXTPPropertyGridItemPoint has no default constructor. * * When using the second constructor, the Identifier (nID) of the * second constructor can be linked with a STRINGTABLE resource * with the same id in such form "Caption\\nDescription". * * BINDING: * Variables can be bound to an item in two ways, the first is * to pass in a variable at the time of creation, the second allows * variables to be bound to an item after creation with the * BindToPoint member. * * Bound variables store the values of the property grid items * and can be accessed without using the property grid methods * and properties. Bound variables allow the property grid to * store data in variables. When the value of a PropertyGridItem * is changed, the value of the bound variable will be changed to * the PropertyGridItem value. The advantage of binding is that * the variable can be used and manipulated without using * PropertyGridItem methods and properties. * * NOTE: If the value of the variable is changed without using * the PropertyGrid, the PropertyGridItem value will not be * updated until you call CXTPPropertyGrid::Refresh. * @see * BindToPoint */ CXTPPropertyGridItemPoint(LPCTSTR strCaption, CPoint pt = 0, CPoint* pBindPoint = NULL); /** * @brief * Constructs a CXTPPropertyGridItemPoint object. * @param nID Identifier of the item. * @param pt Initial point value of item. * @param pBindPoint If not NULL, then the value of this item * is bound the value of this variable. * @details * Class CXTPPropertyGridItemPoint has no default constructor. * * When using the second constructor, the Identifier (nID) of the * second constructor can be linked with a STRINGTABLE resource * with the same id in such form "Caption\\nDescription". * * BINDING: * Variables can be bound to an item in two ways, the first is * to pass in a variable at the time of creation, the second allows * variables to be bound to an item after creation with the * BindToPoint member. * * Bound variables store the values of the property grid items * and can be accessed without using the property grid methods * and properties. Bound variables allow the property grid to * store data in variables. When the value of a PropertyGridItem * is changed, the value of the bound variable will be changed to * the PropertyGridItem value. The advantage of binding is that * the variable can be used and manipulated without using * PropertyGridItem methods and properties. * * NOTE: If the value of the variable is changed without using * the PropertyGrid, the PropertyGridItem value will not be * updated until you call CXTPPropertyGrid::Refresh. * @see * BindToPoint */ CXTPPropertyGridItemPoint(UINT nID, CPoint pt = 0, CPoint* pBindPoint = NULL); /** * @brief * Destroys a CXTPPropertyGridItemPoint object. */ virtual ~CXTPPropertyGridItemPoint(); public: /** * @brief * Sets the point value for the item. * @param pt Point value to be set. */ virtual void SetPoint(CPoint pt); /** * @brief * Gets the point value of the item. * @return * The point value of the item. */ virtual CPoint GetPoint() const; /** * @brief * Binds the item to a specified CPoint object. * @param pBindPoint Pointer to a CPoint object. * @details * Variables can be bound to an item in two ways, the first is * to pass in a variable at the time of creation, the second allows * variables to be bound to an item after creation with the * BindToPoint member. * * Bound variables store the values of the property grid items * and can be accessed without using the property grid methods * and properties. Bound variables allow the property grid to * store data in variables. When the value of a PropertyGridItem * is changed, the value of the bound variable will be changed to * the PropertyGridItem value. The advantage of binding is that * the variable can be used and manipulated without using * PropertyGridItem methods and properties. * * NOTE: If the value of the variable is changed without using * the PropertyGrid, the PropertyGridItem value will not be * updated until you call CXTPPropertyGrid::Refresh. */ virtual void BindToPoint(CPoint* pBindPoint); protected: /** * @brief * This method is called before the item becomes visible in the * property grid. * @details * Before the item is inserted, it is first checked to see if it * is bound to a variable. If it is, then the value of the item * is updated with the value stored in the bound variable. * * OnBeforeInsert is called when an item is inserted, * when a category is inserted, when a category or item is expanded, * and when the sort property has changed. */ virtual void OnBeforeInsert(); private: void SetX(LPCTSTR sx); void SetY(LPCTSTR sy); CString PointToString(CPoint pt); CPoint StringToPoint(LPCTSTR str); virtual void OnAddChildItem(); virtual void SetValue(CString strValue); void UpdateChilds(); private: class CItemX; class CItemY; CPoint m_ptValue; CItemX* m_pItemX; CItemY* m_pItemY; CPoint* m_pBindPoint; private: DECLARE_DYNAMIC(CXTPPropertyGridItemPoint) friend class CItemX; friend class CItemY; }; ////////////////////////////////////////////////////////////////////// AFX_INLINE CSize CXTPPropertyGridItemSize::GetSize() const { return m_szValue; } AFX_INLINE CPoint CXTPPropertyGridItemPoint::GetPoint() const { return m_ptValue; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // #if !defined(__XTPPROPERTYGRIDITEMSIZE_H__) /** @endcond */