/** * @file XTPPropertyGridInplaceButton.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(__XTPPROPERTYGRIDINPLACEBUTTON_H__) # define __XTPPROPERTYGRIDINPLACEBUTTON_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" // class forwards class CXTPPropertyGridView; class CXTPPropertyGridItem; class CXTPImageManagerIcon; const UINT XTP_ID_PROPERTYGRID_EXPANDBUTTON = 100; /**< @see CXTPPropertyGridInplaceButton::CXTPPropertyGridInplaceButton(UINT) */ const UINT XTP_ID_PROPERTYGRID_COMBOBUTTON = 101; /**< @see CXTPPropertyGridInplaceButton::CXTPPropertyGridInplaceButton(UINT) */ /** * @brief * CXTPPropertyGridInplaceButton is a CXTPCmdTarget derived class. * It represents an in-place button in the property grid control. */ class _XTP_EXT_CLASS CXTPPropertyGridInplaceButton : public CXTPCmdTarget { public: /** * @brief * Constructs a CXTPPropertyGridInplaceButton object. * @param nID Identifier of the button. */ CXTPPropertyGridInplaceButton(UINT nID); /** * @brief * Destroys a CXTPPropertyGridInplaceButton object, handles cleanup * and deallocation. */ virtual ~CXTPPropertyGridInplaceButton(); /** * @brief * Gets the width of the button. * @return * The width of the button. * @see * SetWidth */ int GetWidth(); /** * @brief * Sets the width for the button. * @param nWidth Width to be set. * @see * GetWidth */ void SetWidth(int nWidth); /** * @brief * Gets the caption text of the button. * @return * The caption text of the button. * @see * SetCaption */ CString GetCaption() const; /** * @brief * Sets the caption text for the button. * @param lpszCaption Caption text to be set. * @see * GetCaption */ void SetCaption(LPCTSTR lpszCaption); /** * @brief * Gets the image index of the button. * @return * The image index of the button. * @see * SetIconIndex */ int GetIconIndex() const; /** * @brief * Sets the tooltip text for the item. * @param lpstrTooltip Tooltip text to be set. * @details * The tooltip text is displayed when the mouse cursor is over the item. */ void SetTooltip(LPCTSTR lpstrTooltip); /** * @brief * Gets the tooltip text of the item. * @details * The tooltip text is displayed when the mouse cursor is over the item. * @return * The tooltip text of the item. */ CString GetTooltip() const; /** * @brief * Sets the icon index for the button. * @param nIconIndex Icon index to be set. * @details * Icons should be added to the image manager of the property grid * prior to using this method. * @see * GetImage, GetIconIndex, CXTPPropertyGrid::GetImageManager */ void SetIconIndex(int nIconIndex); /** * @brief * Gets the icon of the button. * @return * A pointer to the icon of the button. * @see * SetIconIndex, CXTPPropertyGrid::GetImageManager */ virtual CXTPImageManagerIcon* GetImage() const; /** * @brief * Gets the parent property grid item. * @return * A pointer to the parent property grid item. */ CXTPPropertyGridItem* GetItem() const; /** * @brief * Gets the identifier of the button. * @details * The default identifier for the expand button is XTP_ID_PROPERTYGRID_EXPANDBUTTON. * The default identifier for the combo button is XTP_ID_PROPERTYGRID_COMBOBUTTON. * @return * The indentifier of the button. */ UINT GetID() const; /** * @brief * Gets the bounding rectangle of the button. * @return * The bounding rectangle of the button. */ CRect GetRect() const; /** * @brief * Determines if the button has focus. * @return * TRUE if the button has focus, otherwise FALSE. */ BOOL IsFocused() const; /** * @brief * Determines if the button is hot (i.e. currently highlighted). * @return * TRUE if the button is hot, otherwise FALSE. */ BOOL IsHot() const; /** * @brief * Determines if the button is pressed. * @return * TRUE if the button is pressed, otherwise FALSE. */ BOOL IsPressed() const; /** * @brief * Gets the index of this button within the collection of * in-place buttons of the parent item. * @return * The index of this button within the collection of * in-place buttons of the parent item. */ int GetIndex() const; /** * @brief * Draws the button. Override this method to draw a custom button. * @param pDC Pointer to a valid device context. * @param rc Bounding rectangle of the button. */ virtual void OnDraw(CDC* pDC, CRect rc); /** * @brief * This method is called when the user presses the * left mouse button on the button. * @param nFlags Indicates whether various virtual keys are down * (see Visual C++ documentation). * @param point Specifies the x- and y- coordinates of the cursor. */ virtual void OnLButtonDown(UINT nFlags, CPoint point); /** * @brief * This method is called when the user presses a key * while the button has focus. * @param nChar Specifies the virtual-key code of the given key. */ virtual void OnKeyDown(UINT nChar); /** * @brief * Gets the parent property grid view. * @return * A pointer to the parent property grid view. */ CXTPPropertyGridView* GetGrid() const; /** * @brief * Determines if the button is enabled/disabled. * @return * TRUE if the button is enabled, FALSE if the button is disabled. */ BOOL GetEnabled() const; /** * @brief * Enables/disables the button. * @param bEnabled TRUE to enable the button, FALSE to disable the button. */ void SetEnabled(BOOL bEnabled); /** * @brief * Determines if the button acts as a hyperlink. * @return * TRUE if the button acts as a hyperlink, otherwise FALSE. */ BOOL IsHyperlink() const; /** * @brief * Specifies if the button should act as a hyperlink. * @param bHyperlink TRUE to set the button to act as a hyperlink, * FALSE to prevent the button from acting as a hyperlink. */ void SetHyperlink(BOOL bHyperlink = TRUE); /** * @brief * Determines if the button is always shown. * @return * TRUE if the button is always shown, * FALSE if the button is only shown when the item is selected. * @see * SetShowAlways */ BOOL GetShowAlways() const; /** * @brief * Specifies if the button should always be shown. * @param bShowAlways TRUE to always show the button, * FALSE to only show the button when the item is selected. * @see * GetShowAlways */ void SetShowAlways(BOOL bShowAlways); /** * @brief * Gets the alignment of the button. * @return * The alignment of the button. */ int GetAlignment() const; /** * @brief * Sets the alignment for the button. * @param nAlignment Alignment to be set (DT_LEFT or DT_RIGHT). */ void SetAlignment(int nAlignment); /** * @brief * Specifies if the button is a tab stop * (i.e. if the user can use the TAB key to move focus to the button). * @return * TRUE if the button is a tab stop, otherwise FALSE. */ BOOL GetTabStop() const; protected: /** @cond */ BOOL m_bPressed; /**< TRUE if the button is pressed. */ int m_nIndex; CXTPPropertyGridView* m_pGrid; CXTPPropertyGridItem* m_pItem; UINT m_nID; CRect m_rcButton; int m_nWidth; CString m_strCaption; int m_nIconIndex; BOOL m_bEnabled; CString m_strTooltip; BOOL m_bHyperlink; BOOL m_bShowAlways; BOOL m_bTabStop; int m_nAlignment; /** @endcond */ protected: # ifdef _XTP_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPPropertyGridInplaceButton); LPDISPATCH OleGetItem(); BSTR OleGetCaption(); /** @endcond */ # endif private: friend class CXTPPropertyGridItem; friend class CXTPPropertyGridItems; friend class CXTPPropertyGridInplaceButtons; }; /** * @brief * CXTPPropertyGridInplaceButtons is a CXTPCmdTarget derived class. * It represents a collection of in-place buttons for a specified grid item. */ class _XTP_EXT_CLASS CXTPPropertyGridInplaceButtons : public CXTPCmdTarget { public: /** * @brief * Constructs a CXTPPropertyGridInplaceButtons object * @param pItem Pointer to the parent CXTPPropertyGridItem object. */ CXTPPropertyGridInplaceButtons(CXTPPropertyGridItem* pItem); /** * @brief * Destroys a CXTPPropertyGridInplaceButtons object, * handles cleanup and deallocation. */ ~CXTPPropertyGridInplaceButtons(); public: /** * @brief * Adds a standard combo button to the collection. */ void AddComboButton(); /** * @brief * Adds a standard expand button to the collection. */ void AddExpandButton(); /** * @brief * Adds a custom button to the collection. * @param pButton Pointer to the button to add. * @return * A pointer to the newly added CXTPPropertyGridInplaceButton object. * * Example: *
pItem->GetInplaceButtons()->AddButton(new CXTPPropertyGridInplaceButton(1));*/ CXTPPropertyGridInplaceButton* AddButton(CXTPPropertyGridInplaceButton* pButton); public: /** * @brief * Gets the number of buttons in the collection. * @return * The number of buttons in the collection. */ int GetCount() const; /** * @brief * Retrieves the button at a specified index within the collection. * @param nIndex Index of the button to retrieve. * @return * A pointer to the CXTPPropertyGridInplaceButton object at the specified index * if successful, otherwise NULL. */ CXTPPropertyGridInplaceButton* GetAt(int nIndex) const; /** * @brief * Removes all buttons from the collection. */ void RemoveAll(); /** * @brief * Removes a specified button from the collection. * @param pButton Pointer to the button to remove. */ void Remove(CXTPPropertyGridInplaceButton* pButton); /** * @brief * Removes the button with a specified identifier from the collection. * @param nID Identifier of the button to remove. */ void Remove(UINT nID); /** * @brief * Removes the button at a specified index within the collection. * @param nIndex Index of the button to remove. */ void RemoveAt(long nIndex); /** * @brief * Determines which button, if any, is at a specified position. * @param point Point to be tested. * @return * A pointer to the button at the specified position, if any, otherwise NULL. */ CXTPPropertyGridInplaceButton* HitTest(CPoint point) const; /** * @brief * Retrieves the button with a specified identifier within the collection. * @param nID Identifier of the button to retrieve. * @return * A pointer to the CXTPPropertyGridInplaceButton object with the * specified identifier if successful, otherwise NULL. */ CXTPPropertyGridInplaceButton* Find(UINT nID) const; protected: /** * @brief * This method is called when a button is removed. * @param pButton Pointer to the button being removed. * @details * This method removes the possible reference from the property grid * to the button in this collection. */ virtual void OnButtonRemoved(CXTPPropertyGridInplaceButton* pButton); private: void UpdateIndexes(); private: CArray