/** * @file XTPPropertyGridInplaceEdit.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(__XTPPROPERTYGRIDINPLACEEDIT_H__) # define __XTPPROPERTYGRIDINPLACEEDIT_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" // class forwards. class CXTPPropertyGridView; class CXTPPropertyGridItem; /** * @brief * CXTPPropertyGridInplaceEdit is a CEdit derived class. * It is an internal class used by the property grid control. */ class _XTP_EXT_CLASS CXTPPropertyGridInplaceEdit : public CXTPMaskEditT { /** @cond */ DECLARE_DYNAMIC(CXTPPropertyGridInplaceEdit) /** @endcond */ public: /** * @brief * Constructs a CXTPPropertyGridInplaceEdit object. */ CXTPPropertyGridInplaceEdit(); /** * @brief * Destroys a CXTPPropertyGridInplaceEdit object, handles cleanup * and deallocation. */ virtual ~CXTPPropertyGridInplaceEdit(); /** * @brief * Sets the value for the edit text. * @param strValue Value to be set. */ virtual void SetValue(LPCTSTR strValue); /** * @brief * Hides the in-place edit control. */ virtual void HideWindow(); /** * @brief * Creates the in-place edit control. * @param pItem Pointer to a CXTPPropertyGridItem object. * @param rect Specifies the size and position of the item. */ virtual void Create(CXTPPropertyGridItem* pItem, CRect rect); /** * @brief * This method is called when the parent item is destroyed. */ virtual void DestroyItem(); /** * @brief * Gets the current item. * @return * A pointer to the current item. */ CXTPPropertyGridItem* GetItem(); /** * @brief * Selects the next constraint value in the specified direction * within the edit control. * @param nDirection Direction for the constraint search. * @param bCycle TRUE to enable starting from the opposite end * of the constraint list in case either * the beginning or end of the constraint list * is reached in the specified direction. * @return * TRUE if successful, otherwise FALSE. */ virtual BOOL SelectConstraint(int nDirection, BOOL bCycle); protected: CString m_strValue; /**< Previous item value. */ CXTPBrush m_xtpBrushBack; /**< Background brush. */ XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED(CBrush, m_brBack, m_xtpBrushBack, GetBackBrushHandle); COLORREF m_clrBack; /**< Background color. */ CXTPPropertyGridView* m_pGrid; /**< Parent grid view. */ CXTPPropertyGridItem* m_pItem; /**< Current item. */ BOOL m_bDelayCreate; /**< TRUE to create Edit after activate. */ BOOL m_bCreated; /**< TRUE if the Create method was executed. */ BOOL m_bEditMode; /**< TRUE after edit first receive focus. */ BOOL m_bCancel; /**< User cancel edit with Escape. */ BOOL m_bCheckAutoComplete; /**< Check auto-complete. */ BOOL m_bIgnoreEditChanged; /**< TRUE to ignore edit changed notification. */ protected: /** @cond */ //{{AFX_VIRTUAL(CXTPPropertyGridInplaceEdit) virtual BOOL PreTranslateMessage(MSG* pMsg); //}}AFX_VIRTUAL //{{AFX_MSG(CXTPPropertyGridInplaceEdit) afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); afx_msg void OnEnKillfocus(); afx_msg void OnEnSetfocus(); afx_msg void OnEnChange(); afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg UINT OnGetDlgCode(); afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct); afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); afx_msg void OnDestroy(); //}}AFX_MSG /** @endcond */ private: BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID); DECLARE_MESSAGE_MAP() friend class CXTPPropertyGridItem; friend class CXTPPropertyGrid; }; /** * @brief * CXTPPropertyGridInplaceControl is a CWnd derived class that represents * the base class for all items with in-place controls. */ class _XTP_EXT_CLASS CXTPPropertyGridInplaceControl : public CWnd { /** @cond */ DECLARE_DYNAMIC(CXTPPropertyGridInplaceControl) /** @endcond */ public: /** * @brief * Constructs a CXTPPropertyGridInplaceControl object. * @param pItem Pointer to the parent CXTPPropertyGridItem object. */ CXTPPropertyGridInplaceControl(CXTPPropertyGridItem* pItem); public: /** * @brief * This method is called when an item creates its in-place control. * @param rcValue Reference to the bounding rectangle of the control. * @see * OnDestroyWindow */ virtual void OnCreateWindow(CRect& rcValue) = 0; /** * @brief * This method is called when an item destroys its in-place control. * @see * OnCreateWindow */ virtual void OnDestroyWindow(); /** * @brief * This method is called when an item adjusts the rectangle of its value part. * @param rcValue Reference to the bounding rectangle of the value part. * @see * OnCreateWindow */ virtual void OnAdjustValueRect(CRect& rcValue) = 0; /** * @brief * This method is called when the value of the parent item is changed. */ virtual void OnValueChanged(); /** * @brief * This method is called when the user rolls the mouse wheel while * in an edit control. * @param pEdit Pointer to the currently selected edit control. * @param zDelta Mouse wheel delta. * @return * TRUE if successful, otherwise FALSE. */ virtual BOOL OnEditMouseWheel(CEdit* pEdit, short zDelta); protected: /** @cond */ DECLARE_MESSAGE_MAP() virtual void OnFinalRelease(); //{{AFX_MSG(CXTPPropertyGridInplaceControl) afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg UINT OnGetDlgCode(); afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); //}}AFX_MSG /** @endcond */ protected: CXTPPropertyGridItem* m_pItem; /**< Parent item pointer */ int m_nWidth; /**< Width of in-place item */ }; /** * @brief * CXTPPropertyGridInplaceSlider is a CXTPPropertyGridInplaceControl derived class. * It represents the in-place slider of an item. * Call the CXTPPropertyGridItem::AddSliderControl() method to add a slider * to a property grid item. */ class _XTP_EXT_CLASS CXTPPropertyGridInplaceSlider : public CXTPPropertyGridInplaceControl { /** @cond */ DECLARE_DYNAMIC(CXTPPropertyGridInplaceSlider) /** @endcond */ public: /** * @brief * Constructs a CXTPPropertyGridInplaceSlider object. * @param pItem Pointer to the parent CXTPPropertyGridItem object. */ CXTPPropertyGridInplaceSlider(CXTPPropertyGridItem* pItem); public: /** * @brief * This method is called when an item creates its in-place control. * @param rcValue Reference to the bounding rectangle of the control. * @see * OnDestroyWindow */ virtual void OnCreateWindow(CRect& rcValue); /** * @brief * This method is called when an item adjusts the rectangle of its value part. * @param rcValue Reference to the bounding rectangle of the value part. * @see * OnCreateWindow */ virtual void OnAdjustValueRect(CRect& rcValue); /** * @brief * This method is called when the value of the parent item is changed. */ virtual void OnValueChanged(); /** * @brief * Gets the slider control. * @return * A pointer to the slider control. */ CSliderCtrl* GetSliderCtrl() const; /** * @brief * Sets the lower range for the slider control. * @param nMin Lower range to be set. * @see * SetMax */ void SetMin(int nMin); /** * @brief * Sets the upper range for the slider control. * @param nMax Upper range to be set. * @see * SetMin */ void SetMax(int nMax); /** * @brief * Gets the lower range of the slider control. * @return * The lower range of the slider control. */ int GetMin() const; /** * @brief * Gets the upper range of the slider control. * @return * The upper range of the slider control. */ int GetMax() const; /** * @brief * This method is called when the user rolls the mouse wheel while * in an edit control. * @param pEdit Pointer to the currently selected edit control. * @param zDelta Mouse wheel delta. * @return * TRUE if successful, otherwise FALSE. */ virtual BOOL OnEditMouseWheel(CEdit* pEdit, short zDelta); protected: /** * @brief * This method is called when the slider is moved by the user. * @param nSBCode Slider code that indicates the user's scrolling request. * @param nPos Current slider position. */ virtual void OnScroll(UINT nSBCode, UINT nPos); protected: /** @cond */ DECLARE_MESSAGE_MAP() int CalcualteEditWidth(); //{{AFX_MSG(CXTPPropertyGridInplaceSlider) afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); afx_msg void HScroll(UINT nSBCode, UINT nPos); afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); afx_msg UINT OnGetDlgCode(); //}}AFX_MSG /** @endcond */ # ifdef _XTP_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() XTP_DECLARE_CMDTARGETPROVIDER_INTERFACE() DECLARE_OLETYPELIB_EX(CXTPPropertyGridInplaceSlider); /** @endcond */ # endif protected: int m_nMin; /**< Lower range. */ int m_nMax; /**< Upper range. */ int m_nValue; /**< Value of the slider. */ private: COLORREF m_clrBack; CXTPBrush m_xtpBrushBack; }; AFX_INLINE CSliderCtrl* CXTPPropertyGridInplaceSlider::GetSliderCtrl() const { return (CSliderCtrl*)this; } AFX_INLINE void CXTPPropertyGridInplaceSlider::SetMin(int nMin) { m_nMin = nMin; } AFX_INLINE void CXTPPropertyGridInplaceSlider::SetMax(int nMax) { m_nMax = nMax; } AFX_INLINE int CXTPPropertyGridInplaceSlider::GetMin() const { return m_nMin; } AFX_INLINE int CXTPPropertyGridInplaceSlider::GetMax() const { return m_nMax; } /** * @brief * CXTPPropertyGridInplaceSpinButton is a CXTPPropertyGridInplaceControl derived class. * It represents the in-place spin button of an item. * Call the CXTPPropertyGridItem::AddSpinButton() method to add a spin button * to a property grid item. */ class _XTP_EXT_CLASS CXTPPropertyGridInplaceSpinButton : public CXTPPropertyGridInplaceControl { /** @cond */ DECLARE_DYNAMIC(CXTPPropertyGridInplaceSpinButton) /** @endcond */ public: /** * @brief * Constructs a CXTPPropertyGridInplaceSpinButton object. * @param pItem Pointer to the parent CXTPPropertyGridItem object. */ CXTPPropertyGridInplaceSpinButton(CXTPPropertyGridItem* pItem); public: /** * @brief * This method is called when an item creates its in-place control. * @param rcValue Reference to the bounding rectangle of the control. * @see * OnDestroyWindow */ virtual void OnCreateWindow(CRect& rcValue); /** * @brief * This method is called when an item adjusts the rectangle of its value part. * @param rcValue Reference to the bounding rectangle of the value part. * @see * OnCreateWindow */ virtual void OnAdjustValueRect(CRect& rcValue); /** * @brief * This method is called when the value of the parent item is changed. */ virtual void OnValueChanged(); /** * @brief * Gets the spin button control. * @return * A pointer to the spin button control. */ CSpinButtonCtrl* GetSpinButtonCtrl() const; /** * @brief * Sets the lower range for the spin button control. * @param nMin Lower range to be set. * @see * SetMax */ void SetMin(int nMin); /** * @brief * Sets the upper range for the spin button control. * @param nMax Upper range to be set. * @see * SetMin */ void SetMax(int nMax); /** * @brief * Gets the lower range of the spin button control. * @return * The lower range of the spin button control. */ int GetMin() const; /** * @brief * Gets the upper range of the spin button control. * @return * The upper range of the spin button control. */ int GetMax() const; /** * @brief * This method is called when the user rolls the mouse wheel while * in an edit control. * @param pEdit Pointer to the currently selected edit control. * @param zDelta Mouse wheel delta. * @return * TRUE if successful, otherwise FALSE. */ virtual BOOL OnEditMouseWheel(CEdit* pEdit, short zDelta); protected: /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_MSG(CXTPPropertyGridInplaceSpinButton) afx_msg void OnDeltapos(NMHDR* pNMHDR, LRESULT* pResult); afx_msg UINT OnGetDlgCode(); //}}AFX_MSG /** @endcond */ # ifdef _XTP_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() XTP_DECLARE_CMDTARGETPROVIDER_INTERFACE() DECLARE_OLETYPELIB_EX(CXTPPropertyGridInplaceSpinButton); /** @endcond */ # endif protected: int m_nMin; /**< Lower range. */ int m_nMax; /**< Upper range. */ }; AFX_INLINE CSpinButtonCtrl* CXTPPropertyGridInplaceSpinButton::GetSpinButtonCtrl() const { return (CSpinButtonCtrl*)this; } AFX_INLINE void CXTPPropertyGridInplaceSpinButton::SetMin(int nMin) { m_nMin = nMin; } AFX_INLINE void CXTPPropertyGridInplaceSpinButton::SetMax(int nMax) { m_nMax = nMax; } AFX_INLINE int CXTPPropertyGridInplaceSpinButton::GetMin() const { return m_nMin; } AFX_INLINE int CXTPPropertyGridInplaceSpinButton::GetMax() const { return m_nMax; } /** * @brief * CXTPPropertyGridInplaceControls is a standalone class that represents * a collection of CXTPPropertyGridInplaceControl classes. */ class _XTP_EXT_CLASS CXTPPropertyGridInplaceControls { public: /** * @brief * Constructs a CXTPPropertyGridInplaceControls object. */ CXTPPropertyGridInplaceControls(); /** * @brief * Destroys a CXTPPropertyGridInplaceControls object, handles * cleanup and deallocation. */ ~CXTPPropertyGridInplaceControls(); public: /** * @brief * Removes all in-place controls from the collection. * @see * Add */ void RemoveAll(); /** * @brief * Gets the number of controls in the collection. * @return * The number of controls in the collection. * @see * GetAt */ int GetCount() const; /** * @brief * Adds an in-place control to the collection. * @param pWindow Pointer to the in-place control to add. * @see * GetAt */ void Add(CXTPPropertyGridInplaceControl* pWindow); /** * @brief * Retrieves the in-place control at a specified index in the collection. * @param nIndex Index of the control to retrieve. * @return * A pointer to the in-place control at the specified index in the collection. * @see * GetCount, Add */ CXTPPropertyGridInplaceControl* GetAt(int nIndex); protected: CArray m_arrControls; /**< Array of controls. */ }; AFX_INLINE CXTPPropertyGridItem* CXTPPropertyGridInplaceEdit::GetItem() { return m_pItem; } AFX_INLINE BOOL CXTPPropertyGridInplaceEdit::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext); } AFX_INLINE BOOL CXTPPropertyGridInplaceEdit::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID) { return CEdit::Create(dwStyle, rect, pParentWnd, nID); } AFX_INLINE BOOL CXTPPropertyGridInplaceControl::OnEditMouseWheel(CEdit* /*pEdit*/, short /*zDelta*/) { return FALSE; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // #if !defined(__XTPPROPERTYGRIDINPLACEEDIT_H__) /** @endcond */