/** * @file XTPPropertyGridItemNumber.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(__XTPPROPERTYGRIDITEMNUMBER_H__) # define __XTPPROPERTYGRIDITEMNUMBER_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** * @brief * CXTPPropertyGridItemNumber is a CXTPPropertyGridItem derived class. * It is used to create an integer value item in a Property Grid control. */ class _XTP_EXT_CLASS CXTPPropertyGridItemNumber : public CXTPPropertyGridItem { public: /** * @brief * Constructs a CXTPPropertyGridItemNumber object * @param strCaption Caption of the item. * @param nValue Initial long value of the item. * @param pBindNumber If not NULL, then the value of the item * is bound the value of this variable. * @details * Class CXTPPropertyGridItemNumber 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 * BindToNumber 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 * BindToNumber */ CXTPPropertyGridItemNumber(LPCTSTR strCaption, long nValue = 0, long* pBindNumber = NULL); /** * @brief * Constructs a CXTPPropertyGridItemNumber object * @param nID Identifier of the item. * @param nValue Initial long value of the item. * @param pBindNumber If not NULL, then the value of the item * is bound the value of this variable. * @details * Class CXTPPropertyGridItemNumber 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 * BindToNumber 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 * BindToNumber */ CXTPPropertyGridItemNumber(UINT nID, long nValue = 0, long* pBindNumber = NULL); /** * @brief * Destroys a CXTPPropertyGridItemNumber object. */ virtual ~CXTPPropertyGridItemNumber(); public: /** * @brief * Sets the long value for the item. * @param nValue Long value to be set. */ virtual void SetNumber(long nValue); /** * @brief * Gets the long value of the item. * @return * The long value of the item. */ virtual long GetNumber() const; /** * @brief * Binds the item to a specified long value. * @param pBindNumber Pointer to a long value. * @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 * BindToNumber 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 BindToNumber(long* pBindNumber); protected: /** * @brief * Sets the value of the item. * Override this method to add new functionality. You should call * the base class version of this function from your override. * @param strValue Value to be set. */ virtual void SetValue(CString strValue); /** * @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(); protected: long m_nValue; /**< Value of the item. */ long* m_pBindNumber; /**< Pointer to the variable bound to this item. */ private: # ifdef _XTP_ACTIVEX /** @cond */ afx_msg void OleSetValue(const VARIANT* varValue); afx_msg const VARIANT OleGetValue(); void BindDispatch(); /** @endcond */ # endif DECLARE_DYNAMIC(CXTPPropertyGridItemNumber) }; /** * @brief * CXTPPropertyGridItemDouble is a CXTPPropertyGridItem derived class. * It is used to create a double value item in a Property Grid control. */ class _XTP_EXT_CLASS CXTPPropertyGridItemDouble : public CXTPPropertyGridItem { public: /** * @brief * Constructs a CXTPPropertyGridItemDouble object. * @param strCaption Caption of the item. * @param fValue Initial double value of the item. * @param strFormat The number of digits after the decimal point. * For example, "%0.5f" would display * five digits after the decimal point. * @param pBindNumber If not NULL, then the value of this item * is bound the value of this variable. * @details * Class CXTPPropertyGridItemDouble 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 * BindToDouble 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 * BindToDouble */ CXTPPropertyGridItemDouble(LPCTSTR strCaption, double fValue = 0, LPCTSTR strFormat = NULL, double* pBindNumber = NULL); /** * @brief * Constructs a CXTPPropertyGridItemDouble object. * @param nID Identifier of the item. * @param fValue Initial double value of the item. * @param strFormat The number of digits after the decimal point. * For example, "%0.5f" would display * five digits after the decimal point. * @param pBindNumber If not NULL, then the value of this item * is bound the value of this variable. * @details * Class CXTPPropertyGridItemDouble 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 * BindToDouble 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 * BindToDouble */ CXTPPropertyGridItemDouble(UINT nID, double fValue = 0, LPCTSTR strFormat = NULL, double* pBindNumber = NULL); /** * @brief * Destroys a CXTPPropertyGridItemDouble object. */ virtual ~CXTPPropertyGridItemDouble(); public: /** * @brief * Sets the double value for the item. * @param fValue Double value to be set. */ virtual void SetDouble(double fValue); /** * @brief * Gets the double value of the item. * @return * The double value of the item. */ virtual double GetDouble() const; /** * @brief * Binds the item to a specified double value. * @param pBindDouble Pointer to a double value. * @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 * BindToDouble 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 BindToDouble(double* pBindDouble); /** * @brief * Specifies which type of symbol should be used to divide * the whole and decimal parts of numbers. * @param bUseSystemDecimalSymbol TRUE to use the system defined decimal symbol, * FALSE to always use a decimal point ".". * @details * Setting bUseSystemDecimalSymbol to FALSE causes the decimal point "." * to always be used to separate the whole and decimal parts of numbers. * * Setting bUseSystemDecimalSymbol to TRUE causes the system defined symbol * to be used to separate the whole and decimal parts of numbers. * For example, if bUseSystemDecimalSymbol is set to TRUE, then a comma "," * will be used in Europe to separate the whole and decimal parts of numbers. */ void UseSystemDecimalSymbol(BOOL bUseSystemDecimalSymbol); protected: /** * @brief * Sets the value of the item. * Override this method to add new functionality. You should call * the base class version of this function from your override. * @param strValue Value to be set. */ virtual void SetValue(CString strValue); /** * @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(); protected: /** * @brief * Converts a specified string to a double. * @param lpszValue String to be converted. * @return * The converted double. * @see * DoubleToString */ virtual double StringToDouble(LPCTSTR lpszValue); /** * @brief * Converts a specified double to a string. * @param dValue Double to be converted. * @return * The converted string. * @see * StringToDouble */ virtual CString DoubleToString(double dValue); protected: double m_fValue; /**< Double value of the item. */ double* m_pBindDouble; /**< Pointer to the variable bound to this item. */ BOOL m_bUseSystemDecimalSymbol; /**< TRUE to use the system defined decimal symbol, FALSE to always use a decimal point ".". */ private: DECLARE_DYNAMIC(CXTPPropertyGridItemDouble) # ifdef _XTP_ACTIVEX /** @cond */ afx_msg void OleSetValue(const VARIANT* varValue); afx_msg const VARIANT OleGetValue(); DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPPropertyGridItemDouble) void BindDispatch(); /** @endcond */ # endif }; ////////////////////////////////////////////////////////////////////// AFX_INLINE long CXTPPropertyGridItemNumber::GetNumber() const { return m_nValue; } ////////////////////////////////////////////////////////////////////// AFX_INLINE double CXTPPropertyGridItemDouble::GetDouble() const { return m_fValue; } AFX_INLINE void CXTPPropertyGridItemDouble::UseSystemDecimalSymbol(BOOL bUseSystemDecimalSymbol) { m_bUseSystemDecimalSymbol = bUseSystemDecimalSymbol; m_strValue = DoubleToString(m_fValue); } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // #if !defined(__XTPPROPERTYGRIDITEMNUMBER_H__) /** @endcond */