/** * @file XTPGridRecordItemControls.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(__XTPGRIDRECORDITEMCONTROLS_H__) # define __XTPGRIDRECORDITEMCONTROLS_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" struct XTP_NM_GRIDRECORDITEM; struct XTP_GRIDRECORDITEM_CLICKARGS; class CXTPGridRecordItemControl; /** * @brief * This enum defines types for the item control. */ enum XTPGridItemControlType { xtpItemControlTypeUndefined = 0, /**< Undefined type.*/ xtpItemControlTypeButton = 1, /**< Button.*/ }; /** * @brief * This enum defines alignment styles for the item control. */ enum XTPGridItemControlAlignment { xtpItemControlUnknown = 0, /**< Unknown (empty) value.*/ xtpItemControlLeft = 0x001, /**< Aligns control to the left.*/ xtpItemControlRight = 0x002, /**< Aligns control to the right.*/ }; /** * @brief * This structure is sent to the Main window in a WM_NOTIFY message from * the item control and provides all parameters needed to process * control specific notifications by the main window. * @details * Use this structure to get the item control that produced the message. * @see * XTP_NM_GRID_ITEMBUTTONCLICK */ struct XTP_NM_GRIDITEMCONTROL : public XTP_NM_GRIDRECORDITEM { CXTPGridRecordItemControl* pItemControl; /**< Pointer to the item control. */ }; /** * @brief * This class represents a generic item control and handles control's * behaviour, common for all derived item controls. * You cannot use this class directly in the control. If you wish to add your * own item control, you must inherit it from CXTPGridRecordItemControl. * Some member functions in this class are virtual. * @see * CXTPGridRecordItemButton */ class _XTP_EXT_CLASS CXTPGridRecordItemControl : public CXTPCmdTarget { /** @cond */ DECLARE_SERIAL(CXTPGridRecordItemControl) /** @endcond */ public: /** * @brief * Creates a CXTPGridRecordItemControl object. * @param szCaption Item control caption. */ CXTPGridRecordItemControl(LPCTSTR szCaption = _T("")); /** * @brief * Destroys a CXTPGridRecordItemControl, handles cleanup and deallocation. */ virtual ~CXTPGridRecordItemControl(); /** * @brief * Call this member function to store/load a grid item control * using the specified data object. * @param pPX Source/destination CXTPPropExchange data object reference. */ virtual void DoPropExchange(CXTPPropExchange* pPX); /** * @brief * Gets the item control caption. * @return * The item control caption. * @see * SetCaption */ CString GetCaption() const; /** * @brief * Sets the item control caption. * @param szCaption Item control caption to be set. * @see * GetCaption */ void SetCaption(LPCTSTR szCaption); /** * @brief * Gets the item control type. * @return * The item control type. * @see * XTPGridItemControlType */ int GetType() const; /** * @brief * Gets the item control index. * @return * The item control index. */ int GetIndex() const; /** * @brief * Gets the font of the item control caption. * @return * A pointer to the font of the item control caption. * @see * SetFont */ CFont* GetFont(); /** * @brief * Sets the font for the item control caption. * @param pFont New font to be set. * @see * GetFont */ void SetFont(CFont* pFont); /** * @brief * Gets the color of the item control caption. * @return * The color of the item control caption. * @see * SetCaptionColor */ COLORREF GetCaptionColor() const; /** * @brief * Sets the color of the item control caption. * @param clrCaption New color to be set. * @see * GetCaptionColor */ void SetCaptionColor(COLORREF clrCaption); /** * @brief * Gets the item control size. * @return * The item control size. * @see * SetSize, GetWidth, SetWidth, GetHeight, SetHeight */ CSize GetSize() const; /** * @brief * Sets the item control size. * @param sizeControl Item control size to be set. * @details * If the item control size is set to (<=0, <=0), then the control will * occupy the rest of the cell. * @see * GetSize, GetWidth, SetWidth, GetHeight, SetHeight */ void SetSize(CSize sizeControl); /** * @brief * Gets the item control width. * @return * The item control width. * @see * GetSize, SetSize, SetWidth, GetHeight, SetHeight */ int GetWidth() const; /** * @brief * Sets the item control width. * @param nWidth Item control width to be set. * @details * If the width is set to less than 0, then the control will * occupy the rest of the cell width. * @see * GetSize, SetSize, GetWidth, GetHeight, SetHeight */ void SetWidth(int nWidth); /** * @brief * Gets the item control height. * @return * The item control height. * @see * GetSize, SetSize, GetWidth, SetWidth, SetHeight */ int GetHeight() const; /** * @brief * Sets the item control height. * @param nHeight Item control height to be set. * @details * If the height is set to less than 0, then the control height will * be the same as the cell height. * @see * GetSize, SetSize, GetWidth, SetWidth, GetHeight */ void SetHeight(int nHeight); /** * @brief * Gets the item control rectangle * (i.e. the rectangle occupied by the item control). * @return * The item control rectangle. */ CRect GetRect() const; /** * @brief * Gets the item control flags. * @return * The item control flags. * @see * SetFlags */ UINT GetFlags() const; /** * @brief * Sets the item control flags. * @param unFlags Item control flags to be set. * @see * GetFlags */ void SetFlags(UINT unFlags); /** * @brief * Gets the item control alignment. * @return * The item control alignment. * @see * XTPGridItemControlAlignment, SetAlignment */ int GetAlignment() const; /** * @brief * Sets the item control alignment. * @param nAlignment Item control alignment to be set. * @see * XTPGridItemControlAlignment, GetAlignment */ void SetAlignment(int nAlignment); /** * @brief * Determines if the item control is enabled/disabled. * @return * TRUE if the item control is enabled, * FALSE if the item control is disabled. * @see * SetEnable */ BOOL GetEnable() const; /** * @brief * Enables/disables the item control. * @param bEnable TRUE to enable the item control, * FALSE to disable the item control. * @details * If the control is disabled, then it is drawn as disabled and * will not react to user input. * @see * GetEnable */ void SetEnable(BOOL bEnable); /** * @brief * Gets the item control state. * @details * The item control state is control specific. * @return * The item control state. */ int GetState() const; /** * @brief * Sets the item control state. * @details * The item control state is control specific. * @param nNewState A new control specific state value. */ void SetState(int nNewState); /** * @brief * Specifies the themed state of the item control. * @param bThemed TRUE to set the item control to themed, FALSE otherwise. */ void SetThemed(BOOL bThemed); /** * @brief * Determines the themed state of the item control. * @return * TRUE if item control is themed, otherwise FALSE. */ BOOL GetThemed() const; /** * @brief * Sets the icon index for a specified control state. * @param nState Item control state. * @param nIconIndex Icon index for the specified state. * @details * The icon specified for the specified control state is drawn during * control drawing. * If no icon is specified for a certain state, then the icon for * state = 0 is drawn. * If no icon specified for any state, then no icon is drawn. * @see * GetIconIndex */ void SetIconIndex(int nState, int nIconIndex); /** * @brief * Retrieves the icon index of a specified item control state. * @param nState Item control state whose icon index must be retrieved. * @return * The icon index of the specified item control state. * @see * SetIconIndex */ int GetIconIndex(int nState) const; protected: /** * @brief * Sets the item control rectangle * (i.e. the rectangle occupied by the item control). * @param rcControl Item control rectangle to be set. * @see * GetRect */ void SetRect(CRect rcControl); public: /** * @brief * Processes mouse left button down clicks. * @param pClickArgs Pointer to an XTP_GRIDRECORDITEM_CLICKARGS * structure containing mouse click arguments. * @details * Usually this function is called by GridRecordItem's OnLButtonDown function. * @see * XTP_GRIDRECORDITEM_CLICKARGS */ virtual void OnLButtonDown(XTP_GRIDRECORDITEM_CLICKARGS* pClickArgs) { UNREFERENCED_PARAMETER(pClickArgs); } /** * @brief * Processes mouse left button up clicks. * @param pClickArgs Pointer to an XTP_GRIDRECORDITEM_CLICKARGS * structure containing mouse click arguments. * @details * Usually this function is called by GridRecordItem's OnLButtonUp function. * @see * XTP_GRIDRECORDITEM_CLICKARGS */ virtual void OnLButtonUp(XTP_GRIDRECORDITEM_CLICKARGS* pClickArgs) { UNREFERENCED_PARAMETER(pClickArgs); } /** * @brief * Notifies the item control that the mouse cursor has entered * the item control's area. * @param nFlags Additional flags. * @param point Mouse cursor position. * @details * Usually this function is called by GridRecordItem's OnMouseMove function. */ virtual void OnMouseEnter(UINT nFlags, CPoint point) { UNREFERENCED_PARAMETER(nFlags); UNREFERENCED_PARAMETER(point); } /** * @brief * Notifies the item control that the mouse cursor has left * the item control's area. * @param nFlags Additional flags. * @param point Mouse cursor position. * @details * Usually this function is called by GridRecordItem's OnMouseMove function. */ virtual void OnMouseLeave(UINT nFlags, CPoint point) { UNREFERENCED_PARAMETER(nFlags); UNREFERENCED_PARAMETER(point); } /** * @brief * Processes the move mouse event. * @param nFlags Additional flags. * @param point Mouse cursor position. * @details * Usually this function is called by GridRecordItem's OnMouseMove function. */ virtual void OnMouseMove(UINT nFlags, CPoint point) { UNREFERENCED_PARAMETER(nFlags); UNREFERENCED_PARAMETER(point); } protected: int m_nType; /**< Control type. See XTPGridItemControlType for details. */ int m_nIndex; /**< Control index. */ CString m_strCaption; /**< Control caption. */ CXTPFont m_xtpFontCaption; /**< Control caption font. */ XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED(CFont, m_fntCaption, m_xtpFontCaption, GetCaptionFontHandle); COLORREF m_clrCaption; /**< Control caption color. */ CSize m_sizeControl; /**< Control size. If size is (<=0, <=0), then the control occupies the entire cell. */ CRect m_rcControl; /**< Control rectangle. */ UINT m_unFlags; /**< Control flags. */ XTPGridItemControlAlignment m_Alignment; /**< Control alignment. See XTPGridItemControlAlignment for details. */ BOOL m_bEnabled; /**< Control enable flag. */ int m_nState; /**< Control state. Depends on control type. */ BOOL m_bThemed; /**< TRUE if control is themed, FALSE otherwise. */ CMap m_mapIcon; /**< Control icon map. */ # ifdef _XTP_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPGridRecordItemControl); afx_msg BSTR OleGetCaption(); afx_msg void OleSetCaption(LPCTSTR pcszCaption); LPFONTDISP OleGetFont(); void OleSetFont(LPFONTDISP pFontDisp); afx_msg void OleSetSize(long cx, long cy); afx_msg void OleGetRect(long* pnLeft, long* pnTop, long* pnRight, long* pnBottom); /** @endcond */ # endif friend class CXTPGridRecordItemControls; friend class CXTPGridRecordItemButton; friend class CXTPGridPaintManager; }; /** * @brief * This class represents an item button and inherits basic functionality * from the CXTPGridRecordItemControl class. * You create an item button simply by calling its constructor with one * parameter - a text string. * @see * CXTPGridRecordItemControl */ class _XTP_EXT_CLASS CXTPGridRecordItemButton : public CXTPGridRecordItemControl { /** @cond */ DECLARE_SERIAL(CXTPGridRecordItemButton) /** @endcond */ public: /** * @brief * Creates an item button. * @param szCaption Button caption. */ CXTPGridRecordItemButton(LPCTSTR szCaption = _T("")); /** * @brief * Call this member function to store/load a grid item button * using the specified data object. * @param pPX Source/destination CXTPPropExchange data object reference. */ virtual void DoPropExchange(CXTPPropExchange* pPX); /** * @brief * Processes mouse left button down clicks. * @param pClickArgs Pointer to an XTP_GRIDRECORDITEM_CLICKARGS * structure containing mouse click arguments. * @details * Usually this function is called by GridRecordItem's OnLButtonDown function. * @see * XTP_GRIDRECORDITEM_CLICKARGS */ virtual void OnLButtonDown(XTP_GRIDRECORDITEM_CLICKARGS* pClickArgs); /** * @brief * Processes mouse left button up clicks. * @param pClickArgs Pointer to an XTP_GRIDRECORDITEM_CLICKARGS * structure containing mouse click arguments. * @details * Usually this function is called by GridRecordItem's OnLButtonUp function. * @see * XTP_GRIDRECORDITEM_CLICKARGS */ virtual void OnLButtonUp(XTP_GRIDRECORDITEM_CLICKARGS* pClickArgs); /** * @brief * Notifies the item control that the mouse cursor has entered * the item button's area. * @param nFlags Additional flags. * @param point Mouse cursor position. * @details * Usually this function is called by GridRecordItem's OnMouseMove function. */ virtual void OnMouseEnter(UINT nFlags, CPoint point); /** * @brief * Notifies the item control that the mouse cursor has left * the item button's area. * @param nFlags Additional flags. * @param point Mouse cursor position. * @details * Usually this function is called by GridRecordItem's OnMouseMove function. */ virtual void OnMouseLeave(UINT nFlags, CPoint point); /** * @brief * Processes the move mouse event. * @param nFlags Additional flags. * @param point Mouse cursor position. * @details * Usually this function is called by GridRecordItem's OnMouseMove function. */ virtual void OnMouseMove(UINT nFlags, CPoint point); protected: int m_nSavedState; /**< Button state when the mouse cursor leaves the button area. */ # ifdef _XTP_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPGridRecordItemButton); /** @endcond */ # endif }; /** * @brief * This typedef is used to declare a base class for CXTPGridRecordItemControls. */ typedef CXTPArrayT CXTPGridRecordItemControls_base; /** * @brief * This class represents the inplace controls of a single item. * @brief * This class represents an array of pointers to CXTPGridRecordItemControl objects. * InternalRelease is called for each item in the array destructor. * Also serialization for array items is provided (see the DoPropExchange method). */ class _XTP_EXT_CLASS CXTPGridRecordItemControls : public CXTPGridRecordItemControls_base // class _XTP_EXT_CLASS CXTPGridRecordItemControls : public // CXTPHeapObjectT { /** @cond */ DECLARE_DYNAMIC(CXTPGridRecordItemControls) typedef CXTPGridRecordItemControls_base TBase; /** @endcond */ public: /** * @brief * Constructs a CXTPGridRecordItemControls object. */ CXTPGridRecordItemControls(); /** * @brief * Constructs a CXTPGridRecordItemControls object. * @param pRecordItem Pointer to the parent record item. */ CXTPGridRecordItemControls(CXTPGridRecordItem* pRecordItem); /** * @brief * Destroys a CXTPGridRecordItemControls object, * handles cleanup and deallocation */ ~CXTPGridRecordItemControls(); /** * @brief * Call this member function to store/load a grid item controls list * using the specified data object. * @param pPX Source/destination CXTPPropExchange data object reference. */ virtual void DoPropExchange(CXTPPropExchange* pPX); public: /** * @brief * Adds a new control to the controls list. * @param nType Type of control to be added. * @param nIndex Ordinal for position. * @return * A pointer to the newly added grid record item control object. */ CXTPGridRecordItemControl* AddControl(int nType, int nIndex = -1); /** * @brief * Adds a new control to the controls list. * @param pControl Pointer to the control to be added. * @param nIndex Ordinal for position * @return * A pointer to the newly added grid record item control object. */ CXTPGridRecordItemControl* AddControl(CXTPGridRecordItemControl* pControl, int nIndex = -1); /** * @brief * Removes all controls from the list. * void RemoveControls(); */ /** * @brief * Removes all controls from the list. */ virtual void RemoveAll(); /** * @brief * Removes a control from the list by its index. * @param nIndex Index of the control to remove. */ virtual void RemoveAt(int nIndex); /** * @brief * Removes a control from the list by its index. * @param nIndex Index of the control to remove. * @param nCount The number of elements to remove. */ virtual void RemoveAt(int nIndex, int nCount); /** * @brief * Copies all controls from a specified CXTPGridRecordItemControls object * to this CXTPGridRecordItemControls object. * @param pSrc Pointer to a CXTPGridRecordItemControls object to copy from. */ virtual void CopyFrom(CXTPGridRecordItemControls* pSrc); protected: /** * @brief * Recalculates the indices of all record item controls in the list * that appear at or after a specified index. * @param nIndexStart Specifies the zero-based index of the item before the first item */ virtual void RefreshIndexes(int nIndexStart = 0); public: CXTPGridRecordItem* m_pRecordItem; /**< Pointer to parent record item. */ # ifdef _XTP_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPGridRecordItemControls); DECLARE_ENUM_VARIANT(CXTPGridRecordItemControls) afx_msg int OleGetCount(); afx_msg LPDISPATCH OleAddButton(int nIndex); afx_msg void OleRemoveAt(int nIndex); // afx_msg LPDISPATCH OleGetButton(int nIndex); virtual LPDISPATCH OleGetItem(long nIndex); /** @endcond */ # endif }; /** * @brief * This class represents an item control hook window. * An instance of this window is created whenever the user presses the * left mouse button on an item control. Furthermore, all mouse input will * go to this window until the user releases the left mouse button. The * window hooks mouse events and redirects them to the grid record item. * @see * CXTPGridRecordItem, CXTPGridRecordItemControl */ class _XTP_EXT_CLASS CXTPGridRecordItemControlHookWnd : public CWnd { public: /** * @brief * Constructs a CXTPGridRecordItemControlHookWnd window. * @param pClickArgs Pointer to an XTP_GRIDRECORDITEM_CLICKARGS * structure containing the parameters of the cell. */ CXTPGridRecordItemControlHookWnd(XTP_GRIDRECORDITEM_CLICKARGS* pClickArgs); /** * @brief * Destroys a CXTPGridRecordItemControlHookWnd object, * handles cleanup and deallocation. */ ~CXTPGridRecordItemControlHookWnd(); protected: /** @cond */ DECLARE_MESSAGE_MAP() afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg void OnMouseMove(UINT nFlags, CPoint point); /** @endcond */ XTP_GRIDRECORDITEM_CLICKARGS m_ClickArgs; /**< Parameters of the cell. */ }; ////////////////////////////////////////////////////////////////////////// AFX_INLINE void CXTPGridRecordItemControl::SetCaption(LPCTSTR szCaption) { m_strCaption = szCaption; } AFX_INLINE CString CXTPGridRecordItemControl::GetCaption() const { return m_strCaption; } AFX_INLINE int CXTPGridRecordItemControl::GetType() const { return m_nType; } AFX_INLINE int CXTPGridRecordItemControl::GetIndex() const { return m_nIndex; } AFX_INLINE COLORREF CXTPGridRecordItemControl::GetCaptionColor() const { return m_clrCaption; } AFX_INLINE void CXTPGridRecordItemControl::SetCaptionColor(COLORREF clrCaption) { m_clrCaption = clrCaption; } AFX_INLINE CSize CXTPGridRecordItemControl::GetSize() const { return m_sizeControl; } AFX_INLINE void CXTPGridRecordItemControl::SetSize(CSize sizeControl) { m_sizeControl = sizeControl; } AFX_INLINE int CXTPGridRecordItemControl::GetWidth() const { return m_sizeControl.cx; } AFX_INLINE void CXTPGridRecordItemControl::SetWidth(int nWidth) { m_sizeControl.cx = nWidth; } AFX_INLINE int CXTPGridRecordItemControl::GetHeight() const { return m_sizeControl.cy; } AFX_INLINE void CXTPGridRecordItemControl::SetHeight(int nHeight) { m_sizeControl.cy = nHeight; } AFX_INLINE CRect CXTPGridRecordItemControl::GetRect() const { return m_rcControl; } AFX_INLINE void CXTPGridRecordItemControl::SetFlags(UINT unFlags) { m_unFlags = unFlags; } AFX_INLINE UINT CXTPGridRecordItemControl::GetFlags() const { return m_unFlags; } AFX_INLINE int CXTPGridRecordItemControl::GetAlignment() const { return m_Alignment; } AFX_INLINE void CXTPGridRecordItemControl::SetAlignment(int nAlignment) { m_Alignment = (XTPGridItemControlAlignment)nAlignment; } AFX_INLINE BOOL CXTPGridRecordItemControl::GetEnable() const { return m_bEnabled; } AFX_INLINE void CXTPGridRecordItemControl::SetEnable(BOOL bEnable) { m_bEnabled = bEnable; } AFX_INLINE int CXTPGridRecordItemControl::GetState() const { return m_nState; } AFX_INLINE void CXTPGridRecordItemControl::SetState(int nNewState) { m_nState = nNewState; } AFX_INLINE void CXTPGridRecordItemControl::SetThemed(BOOL bThemed) { m_bThemed = bThemed; } AFX_INLINE BOOL CXTPGridRecordItemControl::GetThemed() const { return m_bThemed; } AFX_INLINE void CXTPGridRecordItemControl::SetIconIndex(int nState, int nIconIndex) { m_mapIcon.SetAt(nState, nIconIndex); } AFX_INLINE void CXTPGridRecordItemControl::SetRect(CRect rcControl) { m_rcControl = rcControl; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPGRIDRECORDITEMCONTROLS_H__) /** @endcond */