/** * @file XTPPropertyGridItemOption.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(__XTPPROPERTYGRIDITEMOPTION_H__) # define __XTPPROPERTYGRIDITEMOPTION_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** * @brief * CXTPPropertyGridItemOption is a CXTPPropertyGridItem derived class. */ class _XTP_EXT_CLASS CXTPPropertyGridItemOption : public CXTPPropertyGridItem { /** @cond */ DECLARE_DYNAMIC(CXTPPropertyGridItemOption) /** @endcond */ public: /** * @brief * Constructs a CXTPPropertyGridItemOption object. * @param strCaption Caption of the item. * @param nValue Initial value of the item. * @param pBindOption If not NULL, then the value of the item * is bound the value of this variable. * @details * Class CXTPPropertyGridItemOption 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 * BindToOption 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 * BindToOption */ CXTPPropertyGridItemOption(LPCTSTR strCaption, int nValue = 0, int* pBindOption = NULL); /** * @brief * Constructs a CXTPPropertyGridItemOption object. * @param nID Identifier of the item. * @param nValue Initial value of the item. * @param pBindOption If not NULL, then the value of the item * is bound the value of this variable. * @details * Class CXTPPropertyGridItemOption 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 * BindToOption 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 * BindToOption */ CXTPPropertyGridItemOption(UINT nID, int nValue = 0, int* pBindOption = NULL); /** * @brief * Destroys a CXTPPropertyGridItemOption object. */ virtual ~CXTPPropertyGridItemOption(); public: /** * @brief * Sets the integer value of the item. * @param nValue Integer value to be set. */ void SetOption(int nValue); /** * @brief * Binds the item to a specified integer value. * @param pBindOption Pointer to an integer 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. */ void BindToOption(int* pBindOption); /** * @brief * Gets the integer value of the item. * @return * The integer value of the item. */ int GetOption() const; /** * @brief * Specifies if the item should be drawn * as a checkbox or as an option/radio button. * @param bCheckBoxStyle TRUE if the item should be drawn as a checkbox, * FALSE if the item should be drawn as an option/radio button. */ void SetCheckBoxStyle(BOOL bCheckBoxStyle = TRUE); /** * @brief * Determines if the item is drawn * as a checkbox or as an option/radio button. * @return * TRUE if the item is drawn as a checkbox, * FALSE if the item is drawn as an option/radio button. */ BOOL IsCheckBoxStyle() const; 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. */ void OnBeforeInsert(); /** * @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. */ void SetValue(CString strValue); /** * @brief * Override this method and fill in a specified MEASUREITEMSTRUCT structure * to inform Windows of the list-box dimensions. * @param lpMeasureItemStruct Long pointer to a MEASUREITEMSTRUCT structure. */ void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct); /** * @brief * This method is called when an item is drawn. * Override this method if needed. * @param dc Reference to the device context to be used * for rendering an image of the item. * @param rcValue Bounding rectangle of the item. * @return * TRUE if the item is self-drawn. */ BOOL OnDrawItemValue(CDC& dc, CRect rcValue); /** * @brief * This method is called when the user double-clicks the * left mouse button on the item. * @param nFlags Indicates whether various virtual keys are down * (see Visual C++ documentation). * @param point Specifies the x- and y- coordinates of the cursor. */ void OnLButtonDblClk(UINT nFlags, CPoint point); /** * @brief * This method is called when the user presses the * left mouse button on the item. * @param nFlags Indicates whether various virtual keys are down * (see Visual C++ documentation). * @param point Specifies the x- and y- coordinates of the cursor. * @return * TRUE if the message was processed, otherwise FALSE. */ BOOL OnLButtonDown(UINT nFlags, CPoint point); /** * @brief * This method is called by the property grid to set focus to * an in-place child window. * @param bForward TRUE if the user moves focus forward (with Tab), * FALSE if the user moves focus backword (with Shift+Tab). * @return * TRUE if successful, otherwise FALSE. */ BOOL OnInpaceControlFocus(BOOL bForward); /** * @brief * This method is called when an item is de-selected. */ void OnDeselect(); /** * @brief * This method is called when a non-system key is pressed. * @param nChar Specifies the virtual-key code of the given key. * @return True when non-system key is pressed, false otherwise */ BOOL OnKeyDown(UINT nChar); /** * @brief * Toggles the value of the option button. * @param nIndex Index of the option in the options list to be checked. */ void ToggleConstraint(int nIndex); private: void _Init(int nValue); protected: int m_nValue; /**< Value of the item. This will contain the value of the selected constraint (not the text). */ int* m_pBindOption; /**< Pointer to the variable bound to this item. */ BOOL m_bCheckBoxStyle; /**< TRUE if the option button will be displayed as a check box, FALSE if the option button will be displayed as an option/radio button. */ # 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(CXTPPropertyGridItemBool) void BindDispatch(); /** @endcond */ # endif }; AFX_INLINE int CXTPPropertyGridItemOption::GetOption() const { return m_nValue; } AFX_INLINE void CXTPPropertyGridItemOption::SetCheckBoxStyle(BOOL bCheckBoxStyle /*= TRUE*/) { m_bCheckBoxStyle = bCheckBoxStyle; } AFX_INLINE BOOL CXTPPropertyGridItemOption::IsCheckBoxStyle() const { return m_bCheckBoxStyle; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPPROPERTYGRIDITEMOPTION_H__) /** @endcond */