/** * @file XTPControl.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(__XTPCONTROL_H__) # define __XTPCONTROL_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPControl; class CXTPControls; class CXTPCommandBar; class CXTPImageManager; class CXTPImageManagerIcon; class CXTPPaintManager; class CXTPPropExchange; class CXTPRibbonGroup; class CXTPCommandBarList; class CXTPCommandBars; struct XTP_COMMANDBARS_PROPEXCHANGE_PARAM; class CXTPControlActions; /** * @brief * CXTPControlAction is a CXTPCmdTarget derived class. * It represents the single action of controls. */ class _XTP_EXT_CLASS CXTPControlAction : public CXTPCmdTarget { /** @cond */ DECLARE_DYNAMIC(CXTPControlAction) /** @endcond */ protected: /** * @brief * Constructs a CXTPControlAction object. * @param pActions Owner actions collection. */ CXTPControlAction(CXTPControlActions* pActions); /** * @brief * Destroys a CXTPControlAction object, handles cleanup and deallocation. */ ~CXTPControlAction(); public: /** * @brief * Call this member to set the caption of the action. * @param lpszCaption Caption to be set. * @see * SetPrompt, SetDescription, SetTooltip */ void SetCaption(LPCTSTR lpszCaption); /** * @brief * Call this member to set the caption of the action. * @param nIDCaption Caption resource identifier. * @see * SetPrompt, SetDescription, SetTooltip */ void SetCaption(UINT nIDCaption); /** * @brief * Call this member to get the action's identifier. * @return * The identifier of the control. */ int GetID() const; /** * @brief * Call this member to get the action's caption. * @return * The caption of the control. */ CString GetCaption() const; /** * @brief * Call this member to set the description of the action. * @param lpszDescription Description to be set. * @see * SetCaption, SetPrompt, SetTooltip */ void SetDescription(LPCTSTR lpszDescription); /** * @brief * Call this member to load a string from a STRINGTABLE resource * to set the tooltip and description of a action. * @param lpszPrompt String from the resource file that contains the * tooltip and description of the item. The Caption * will be set to use the tooltip text. The tooltip * and description must be separated by "\n" if both * are included. You can omit the description and * both the tooltip and description will be set to * the same value. * @details * Resource strings are in the format "Description\nToolTip". * Note: The caption is set to the value of the tooltip when this * member is called. * @see * SetCaption, SetDescription, SetTooltip */ void SetPrompt(LPCTSTR lpszPrompt); /** * @brief * Call this member to get the action's description. * @return * The description of the control. */ CString GetDescription() const; /** * @brief * Call this member to set the action icon's identifier. * @param nId Icon's identifier to be set. */ void SetIconId(int nId); /** * @brief * Call this member to get the icon's identifier. * @return * An icon's identifier of the action. */ int GetIconId() const; /** * @brief * Call this member to set the action help identifier. * @param nId Help identifier to be set. */ void SetHelpId(int nId); /** * @brief * Call this member to get the help identifier. * @return * Help identifier of the action. */ int GetHelpId() const; /** * @brief * Call this member to enable or disable the action. * @param bEnabled TRUE to enable the action, FALSE to disable the action. * @see * GetEnabled, SetChecked */ void SetEnabled(BOOL bEnabled); /** * @brief * Call this member to get the state of the action. * @return * TRUE if the action is enabled; otherwise FALSE. */ BOOL GetEnabled() const; /** * @brief * Call this member to set the checked state of an action. * @param bChecked TRUE to set the action to checked. * @see * GetChecked, SetEnabled */ void SetChecked(BOOL bChecked); /** * @brief * Call this member to get the checked state of an action. * @return * TRUE if the action is checked; otherwise FALSE. */ BOOL GetChecked() const; /** * @brief * Call this member to get the visibility of an action. * @return * TRUE if the action is visible, FALSE otherwise. */ BOOL IsVisible() const; /** * @brief * Call this member to set the visibility of an action. * @param bVisible TRUE to set the action to visible. */ void SetVisible(BOOL bVisible); /** * @brief * This method sets the 32-bit value associated with the action. * @param dwTag The new 32-bit value to associate with the action. */ void SetTag(DWORD_PTR dwTag); /** * @brief * This method retrieves the application-supplied, 32-bit value * associated with the action. * @return * The 32-bit value associated with the action. */ DWORD_PTR GetTag() const; /** * @brief * Call this method to set the category of the action. * @param lpszCategory Category of the action. */ void SetCategory(LPCTSTR lpszCategory); /** * @brief * Call this method to retrieve the category of the action. * @return * Category of the action. */ CString GetCategory() const; /** * @brief * Call this member to set the tooltip of the action. * @param lpszTooltip Tooltip to be set. * @see * SetCaption, SetDescription, SetPrompt */ void SetTooltip(LPCTSTR lpszTooltip); /** * @brief * Call this member to get the action's tooltip. * @return * Tooltip of the control. */ CString GetTooltip() const; /** * @brief * Call this member to set the shortcut string to the action. * @param lpszShortcutText Shortcut to be set. */ void SetShortcutText(LPCTSTR lpszShortcutText); /** * @brief * Call this member to get the action's shortcut. * @return * The shortcut of the control. */ CString GetShortcutText() const; /** * @brief * Call this member to set the custom shortcut string to the action. * @param lpszCustomShortcutText Shortcut to be set. */ void SetCustomShortcutText(LPCTSTR lpszCustomShortcutText); /** * @brief * Call this member to get the action's custom shortcut text. * @return * The shortcut of the control. */ CString GetCustomShortcutText() const; /** * @brief * Call this member to set the keyboard tip to the action. * @param lpszKeyboardTip Keyboard tip to be set. */ void SetKeyboardTip(LPCTSTR lpszKeyboardTip); /** * @brief * Call this member to get the action's keyboard tip. * @return * The keyboard tip of the control. */ CString GetKeyboardTip() const; /** * @brief * Call this member to set the grayed-out text displayed in the edit and combo * controls which provides a helpful description of what the control is used for. * @param lpszEditHint Edit hint to be set. */ void SetEditHint(LPCTSTR lpszEditHint); /** * @brief * Call this member to get the grayed-out text displayed in the edit and combo * controls which provides a helpful description of what the control is used for. * @return * Edit hint of the control. */ CString GetEditHint() const; /** * @brief * "String" version of the ID given to a command in the CommandBars Designer * (For use with CommandBars designed in the CommandBars Designer Studio). * @param lpszKey "String" version of the ID to be given to a command * in the CommandBars Designer. * @details * The key is the "string" version of the ID given to a command * in the CommandBars Designer. "String" version refers to the * fact that a named constant is created in the designer, for * example ID_FILE_NEW, can also be referenced buy the actual * string "ID_FILE_NEW" which is stored in the key property. * Use GetKey to retrieve this key. * * This can be useful for developers who have older * applications that referenced controls by name rather than * by an ID. * * Steps needed to use the key: * * 1. In the Designer, add all actions you need to the * ActionLibrary pane (and Save them). * Note: The Actions Pane is a way to save and "Re-use" commands. * Always add controls to this library first so they can be * re-used in other xcb or xml files. * 2. Now you need to drag the actions from the ActionLibrary * pane to the Controls pane and then from the Controls pane * to the Toolbars and Menus. * 3. In your code use GetKey property instead of the GetId. * * @see * GetKey, m_strKey */ void SetKey(LPCTSTR lpszKey); /** * @brief * Gets the "string" version of the ID given to a command in the CommandBars Designer * (For use with CommandBars designed in the CommandBars Designer Studio). * @details * The key is the "string" version of the ID given to a command * in the CommandBars Designer. "String" version refers to the * fact that a named constant is created in the designer, for * example ID_FILE_NEW, can also be referenced buy the actual * string "ID_FILE_NEW" which is stored in the key property. * Use GetKey to retrieve this key. * * This can be useful for developers who have older * applications that referenced controls by name rather than * by an ID. * * Steps needed to use the key: * * 1. In the Designer add all actions you need to the * ActionLibrary pane (and Save them). * Note: The Actions Pane is a way to save and "Re-use" commands. * Always add controls to this library first so they can be * re-used in other xcb or xml files. * 2. Now you need to drag the actions from the ActionLibrary * pane to the Controls pane and then from the Controls pane * to the Toolbars and Menus. * 3. In your code use GetKey property instead of the GetId. * * @return * The "string" version of the ID given to a command in the * CommandBars Designer. * @see * SetKey */ CString GetKey() const; /** * @brief * Call this member to get a pointer to the owner CommandBars. * @return * The pointer to the CXTPCommandBars object. */ CXTPCommandBars* GetCommandBars() const; public: /** * @brief * Call this member to get a control associated with an action. * @param nIndex Index of the control to retrieve. * @return * Pointer to a CXTPControl object. */ CXTPControl* GetControl(int nIndex) const; /** * @brief * Call this member to get the number of controls associated with an action. * @return * Total number of controls associated with an action. */ int GetCount() const; public: /** * @brief * Call this member to redraw all controls associated with actions. */ void RedrawControls(); /** * @brief * Call this member to reposition all controls associated with actions. */ void RepositionControls(); public: /** * @brief * Either reads this object from or writes this object to an archive. * @param pPX A CXTPPropExchange object to serialize to or from. */ void DoPropExchange(CXTPPropExchange* pPX); protected: /** * @brief * This method is called when a new control is attached to an action. * @param pControl Control to be attached. * @see * RemoveControl */ void AddControl(CXTPControl* pControl); /** * @brief * This method is called to remove a control from the actions list. * @param pControl Control to be removed. * @see * AddControl */ void RemoveControl(CXTPControl* pControl); /** * @brief * This method is called before an action is removed. */ void OnRemoved(); /** * @brief * This method is called when the property of an action is changed. * @param nProperty Property identifier. * @see * OnChanging */ void OnChanged(int nProperty); /** * @brief * This method is called when the property of an action is about to be changed. * @param nProperty Property identifier. * @see * OnChanged */ void OnChanging(int nProperty); # ifdef _XTP_COMMANDBARS_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_OLETYPELIB_EX(CXTPControlAction); afx_msg void OleSetCaption(LPCTSTR lpszCaption); afx_msg BSTR OleGetCaption(); BSTR OleGetEditHint(); COleVariant m_oleTag; enum { dispidCaption = 4L, dispidDescriptionText = 5L, dispidId = 6L, dispidParameter = 8L, dispidShortcutText = 9L, dispidTooltipText = 10L, dispidVisible = 12L, dispidEnabled = 13L, dispidChecked = 14L, dispidIconId = 15L, dispidCategory = 19L, }; /** @endcond */ # endif public: CCmdTarget* m_pTarget; /**< Parameter of action. */ protected: DWORD_PTR m_nTag; /**< Action tag. */ int m_nId; /**< Identifier of the action. */ int m_nIconId; /**< Identifier of the action's image. */ int m_nHelpId; /**< Help identifier. */ BOOL m_bEnabled; /**< TRUE if the action is enabled. */ BOOL m_bChecked; /**< TRUE if the action is checked. */ BOOL m_bVisible; /**< TRUE if the action is visible. */ CString m_strCaption; /**< Caption of the action. */ CString m_strTooltipText; /**< Tooltip text. */ CString m_strDescriptionText; /**< Description text. */ CString m_strCategory; /**< Category of the action. */ CString m_strShortcutText; /**< Shortcut text. */ CString m_strEditHint; /**< Edit Hint for Combo and Edit Controls. */ CString m_strKeyboardTip; /**< Keyboard tip. */ CString m_strKey; /**< Key. */ CString m_strCustomShortcutText; /**< Custom Shortcut Text. */ CArray m_arrControls; /**< Associated controls. */ CXTPControlActions* m_pActions; /**< Parent actions object. */ private: friend class CXTPControl; friend class CXTPControls; friend class CXTPControlActions; }; AFX_INLINE void CXTPControlAction::SetShortcutText(LPCTSTR lpszShortcutText) { m_strShortcutText = lpszShortcutText; } AFX_INLINE CString CXTPControlAction::GetShortcutText() const { return m_strShortcutText; } AFX_INLINE void CXTPControlAction::SetCustomShortcutText(LPCTSTR lpszCustomShortcutText) { m_strCustomShortcutText = lpszCustomShortcutText; } AFX_INLINE CString CXTPControlAction::GetCustomShortcutText() const { return m_strCustomShortcutText; } AFX_INLINE void CXTPControlAction::SetDescription(LPCTSTR lpszDescription) { m_strDescriptionText = lpszDescription; } AFX_INLINE CString CXTPControlAction::GetDescription() const { return m_strDescriptionText; } AFX_INLINE CString CXTPControlAction::GetTooltip() const { return m_strTooltipText; } AFX_INLINE void CXTPControlAction::SetTooltip(LPCTSTR lpszTooltip) { m_strTooltipText = lpszTooltip; } AFX_INLINE CString CXTPControlAction::GetKey() const { return m_strKey; } AFX_INLINE void CXTPControlAction::SetKey(LPCTSTR lpszKey) { m_strKey = lpszKey; } AFX_INLINE CString CXTPControlAction::GetCaption() const { return m_strCaption.IsEmpty() ? m_strTooltipText : m_strCaption; } AFX_INLINE CString CXTPControlAction::GetEditHint() const { return m_strEditHint; } AFX_INLINE int CXTPControlAction::GetID() const { return m_nId; } AFX_INLINE void CXTPControlAction::SetIconId(int nId) { if (m_nIconId != nId) { m_nIconId = nId; RedrawControls(); } } AFX_INLINE int CXTPControlAction::GetIconId() const { return m_nIconId <= 0 ? m_nId : m_nIconId; } AFX_INLINE void CXTPControlAction::SetHelpId(int nId) { m_nHelpId = nId; } AFX_INLINE int CXTPControlAction::GetHelpId() const { return m_nHelpId <= 0 ? m_nId : m_nHelpId; } AFX_INLINE void CXTPControlAction::SetEnabled(BOOL bEnabled) { if (m_bEnabled != bEnabled) { m_bEnabled = bEnabled; OnChanged(0); RedrawControls(); } } AFX_INLINE BOOL CXTPControlAction::GetChecked() const { return m_bChecked; } AFX_INLINE void CXTPControlAction::SetChecked(BOOL bChecked) { if (m_bChecked != bChecked) { m_bChecked = bChecked; OnChanged(1); RedrawControls(); } } AFX_INLINE BOOL CXTPControlAction::IsVisible() const { return m_bVisible; } AFX_INLINE void CXTPControlAction::SetVisible(BOOL bVisible) { if (m_bVisible != bVisible) { m_bVisible = bVisible; OnChanged(2); RepositionControls(); } } AFX_INLINE void CXTPControlAction::SetCategory(LPCTSTR lpszCategory) { m_strCategory = lpszCategory; } AFX_INLINE CString CXTPControlAction::GetCategory() const { return m_strCategory; } AFX_INLINE void CXTPControlAction::SetTag(DWORD_PTR dwTag) { m_nTag = dwTag; } AFX_INLINE DWORD_PTR CXTPControlAction::GetTag() const { return m_nTag; } AFX_INLINE void CXTPControlAction::SetKeyboardTip(LPCTSTR lpszKeyboardTip) { m_strKeyboardTip = lpszKeyboardTip; } AFX_INLINE CString CXTPControlAction::GetKeyboardTip() const { return m_strKeyboardTip; } /** * @brief * CXTPControlActions is a CXTPCmdTarget derived class. * It represents a collection of actions. */ class _XTP_EXT_CLASS CXTPControlActions : public CXTPCmdTarget { protected: /** * @brief * Constructs a CXTPControlActions object. * @param pCommandBars Parent commandbars object. */ CXTPControlActions(CXTPCommandBars* pCommandBars); /** * @brief * Destroys a CXTPControlActions object, handles cleanup and deallocation. */ ~CXTPControlActions(); public: /** * @brief * Call this member to return the action at the specified index. * @param nIndex An integer index. * @return * The CXTPControlAction pointer currently at this index. */ CXTPControlAction* GetAt(int nIndex) const; /** * @brief * Call this member to get the count of the actions. * @return * The count of the actions. */ int GetCount() const; /** * @brief * Call this member to find the specified action. * @param nId The action's identifier. * @return * Pointer to the CXTPControlAction object if successful; otherwise returns NULL. */ CXTPControlAction* FindAction(int nId) const; /** * @brief * Call this member to add a new action. * @param nId Identifier of the control to be added. * @return * A pointer to the added action. */ CXTPControlAction* Add(int nId); /** * @brief * Call this member to add a new action. * @param nId Identifier of the control to be added. * @param pAction Action to add. * @return * A pointer to the added action. */ CXTPControlAction* Add(int nId, CXTPControlAction* pAction); /** * @brief * Either reads this object from or writes this object to an archive. * @param pPX A CXTPPropExchange object to serialize to or from. */ void DoPropExchange(CXTPPropExchange* pPX); /** * @brief * Call this member to remove all actions. */ void RemoveAll(); /** * @brief * Removes the action of a control by using the ID of the control. * @param nId Identifier of the control that has the action to be removed. */ void Remove(int nId); /** * @brief * Call this method to create actions using menu commands. * @param pMenu Menu pointer to convert from. */ void CreateFromMenu(CMenu* pMenu); protected: # ifdef _XTP_COMMANDBARS_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPControlActions); DECLARE_ENUM_VARIANT(CXTPControlActions); afx_msg long OleGetItemCount(); afx_msg LPDISPATCH OleGetItem(long nIndex); afx_msg LPDISPATCH OleAdd(int nId, LPCTSTR lpszCaption, LPCTSTR lpszTooltipText, LPCTSTR lpszDescriptionText, LPCTSTR lpszCategory); afx_msg LPDISPATCH OleFind(int nId); afx_msg VOID OleRemove(int nId); enum { dispidCount = 1L, dispidAdd = 2L, dispidFindControl = 4L, dispidRemove = 6L, }; /** @endcond */ # endif protected: /** * @brief * Inserts an existing CXTPControlAction into the collection of actions. * @param pAction Reference to the action to add to the collection of actions. */ void Insert(CXTPControlAction* pAction); /** * @brief * Sets or updates the control ID associated with an action. * @param pAction Reference to an action to be assigned a new ID. * @param nId The action's new identifier. */ void SetActionId(CXTPControlAction* pAction, int nId); protected: CArray m_arrActions; /**< Actions array */ CXTPCommandBars* m_pCommandBars; /**< Parent CommandBars object */ friend class CXTPCommandBars; friend class CXTPControlAction; }; /** * @brief * CXTPControl is a CXTPCmdTarget derived class. * It represents the parent class for the command bar's controls. */ class _XTP_EXT_CLASS CXTPControl : public CXTPCmdTarget , public CXTPAccessible { private: class CDocTemplateMap : public CMap { public: void Copy(CDocTemplateMap& map); }; protected: /** * @brief * Constructs a CXTPControl object. */ CXTPControl(); /** * @brief * Destroys a CXTPControl object, handles cleanup and deallocation. */ virtual ~CXTPControl(); public: /** * @brief * Call this member to set the style of the control. * @param buttonStyle The style to be set. Can be any of the values listed in the Remarks * section. * @details * buttonStyle parameter can be one of the following: * xtpButtonAutomatic: Indicates the default style. * xtpButtonCaption: Indicates caption drawing only. * xtpButtonIcon: Indicates icon drawing only. * xtpButtonIconAndCaption: Indicates icon and caption drawing. */ void SetStyle(XTPButtonStyle buttonStyle); /** * @brief * Call this member to get the control's style. * @return * The style of the control. */ XTPButtonStyle GetStyle() const; public: /** * @brief * Call this member to set the caption of the control. * @param lpszCaption Caption to be set. * @see * SetPrompt, SetDescription, SetTooltip */ void SetCaption(LPCTSTR lpszCaption); /** * @brief * Call this member to set the caption of the control. * @param nIDCaption Caption resource identifier. * @see * SetPrompt, SetDescription, SetTooltip */ void SetCaption(UINT nIDCaption); /** * @brief * Call this member to get the control's caption. * @return * The caption of the control. */ virtual CString GetCaption() const; /** * @brief * Call this member to set the shortcut string to the control. * @param lpszShortcutText Shortcut to be set. */ void SetShortcutText(LPCTSTR lpszShortcutText); /** * @brief * Call this member to get the control's shortcut. * @return * The shortcut of the control. */ CString GetShortcutText() const; /** * @brief * Call this member to set the description of the control. * @param lpszDescription Description to be set. * @see * SetCaption, SetPrompt, SetTooltip */ void SetDescription(LPCTSTR lpszDescription); /** * @brief * Call this member to get the control's description. * @return * The description of the control. */ virtual CString GetDescription() const; /** * @brief * Call this member to set the tooltip of the control. * @param lpszTooltip Tooltip to be set. * @see * SetCaption, SetDescription, SetPrompt */ void SetTooltip(LPCTSTR lpszTooltip); /** * @brief * Call this member to get the control's tooltip. * @return * Tooltip of the control. */ virtual CString GetTooltip() const; /** * @brief * Call this member to set the keyboard tip to the control. * @param lpszKeyboardTip Keyboard tip to be set. */ void SetKeyboardTip(LPCTSTR lpszKeyboardTip); /** * @brief * Call this member to get the keyboard tip. * @return * The keyboard tip of the control. */ CString GetKeyboardTip() const; /** * @brief * Call this member to set the text displayed for the shortcut in a pop-up menu. * @param lpszCustomShortcutText Keyboard tip to be set. */ void SetCustomShortcutText(LPCTSTR lpszCustomShortcutText); /** * @brief * Call this member to get the control's text displayed for the shortcut in * a pop-up menu. * @return * The keyboard tip of the control. */ CString GetCustomShortcutText() const; /** * @brief * Call this member to set the parameter of the control. * @param lpszParameter Parameter to be set. * @details * This method sets the CString value associated with the control. * Use SetTag to set the numeric parameter. * @see * SetTag, GetParameter */ void SetParameter(LPCTSTR lpszParameter); /** * @brief * Call this member to get the control's parameter. * @return * The parameter of the control. * @see * GetTag, SetParameter */ CString GetParameter() const; /** * @brief * Call this member to set the identifier of the control. * @param nId Identifier to be set. */ void SetID(int nId); /** * @brief * Call this member to get the control's identifier. * @return * The identifier of the control. */ int GetID() const; /** * @brief * Call this member to get the index of the control. * @return * The index of the control. */ long GetIndex() const; /** * @brief * Call this member to set the control icon's identifier. * @param nId Icon's identifier to be set. */ void SetIconId(int nId); /** * @brief * Call this member to get the icon's identifier. * @return * An icon's identifier of the control. */ int GetIconId() const; /** * @brief * Call this member to set the control help identifier. * @param nId Help identifier to be set. */ void SetHelpId(int nId); /** * @brief * Call this member to get the help identifier. * @return * Help identifier of the control. */ int GetHelpId() const; /** * @brief * Call this member to begin a new group using a separator. * @param bBeginGroup TRUE if the control starts a new group. */ virtual void SetBeginGroup(BOOL bBeginGroup); /** * @brief * Call this member to determine if the control has a separator. * @return * TRUE if the control starts a new group; otherwise FALSE. */ BOOL GetBeginGroup() const; /** * @brief * Call this member to enable/disable the control. * If the control does not have an xtpFlagManualUpdate flag, you must call * the Enable member of CCmdUI in the ON_UPDATE_COMMAND_UI handler. * @param bEnabled TRUE to enable the control, FALSE to disable the control. * @see * GetEnabled, SetChecked */ virtual void SetEnabled(BOOL bEnabled); /** * @brief * Call this member to check if the control is enabled. * @return * TRUE if the control is enabled, otherwise FALSE. */ BOOL GetEnabled() const; /** * @brief * This method is called when a control's enabled state is changed. */ virtual void OnEnabledChanged(); /** * @brief * Call this member to set the checked state of the control. * If the control does not have an xtpFlagManualUpdate flag, you must call * the SetCheck member of CCmdUI in the ON_UPDATE_COMMAND_UI handler. * @param bChecked TRUE to set the control to checked. * @see * GetChecked, SetEnabled */ virtual void SetChecked(BOOL bChecked); /** * @brief * Call this member to get the checked state of the control. * @return * TRUE if the control is checked, otherwise FALSE. */ BOOL GetChecked() const; /** * @brief * Call this member to check if the control is selected. * @return * TRUE if the control is selected; otherwise FALSE. */ virtual int GetSelected() const; /** * @brief * Call this member to set whether a control should be a part of the * Quick Access panel. * @param bOnQuicAccess True for quick access. */ void SetOnQuickAccess(BOOL bOnQuicAccess = FALSE); /** * @brief * Call this member to check if a control is a part of the Quick Access panel. * @return * TRUE if the control is a part of the Quick Access panel; otherwise FALSE. */ BOOL IsOnQuickAccess() const; /** * @brief * Call this member to set the focused state of the control. * @param bFocused TRUE to set the control to focused. */ virtual void SetFocused(BOOL bFocused); /** * @brief * Call this member to check the focused state of the control. * @return * TRUE if the control is focused, otherwise FALSE. */ virtual BOOL IsFocused() const; /** * @brief * Call this member to set the pressed state of the control. * @param bPressed TRUE to set the control to pressed. */ void SetPressed(BOOL bPressed); /** * @brief * Call this member to check the pressed state of the control. * @return * TRUE if the control is pressed, otherwise FALSE. */ virtual BOOL GetPressed() const; /** * @brief * This member is called to set the bounding rectangle of the control. * @param rcControl Bounding rectangle of the control. */ virtual void SetRect(CRect rcControl); /** * @brief * Call this member to get the bounding rectangle of the control. * @return * The bounding rectangle of the control. */ CRect GetRect() const; /** * @brief * Call this member to get the parent command bar. * @return * The parent command bar object. */ CXTPCommandBar* GetParent() const; /** * @brief * Call this member to determine if the control is visible. * @param dwSkipFlags Combination of XTPControlHideFlags that can be ignored. * @return * TRUE if the control is visible, otherwise FALSE. * @see * XTPControlHideFlags, GetHideFlags */ virtual BOOL IsVisible(DWORD dwSkipFlags = 0) const; /** * @brief * Call this member to determine if the caption of the control is visible. * @return * TRUE if the caption of the control is visible. */ virtual BOOL IsCaptionVisible() const; /** * @brief * Call this member to set the visibility of the control. * @param bVisible TRUE to set the control to visible, * FALSE to set the control to hidden. */ void SetVisible(BOOL bVisible); /** * @brief * Call this member to get the parent controls collection. * @return * A CXTPControls pointer to the parent controls. */ CXTPControls* GetControls() const; /** * @brief * Call this member to get the control's type. * @return * The type of the control. It can be one of the following: * xtpControlButton: Indicates the control is a simple button * (CXTPControlButton). * xtpControlPopup: Indicates the control is a simple pop-up button * (CXTPControlPopup). * xtpControlButtonPopup: Indicates the control is a pop-up button with icon * (CXTPControlPopup). * xtpControlSplitButtonPopup: Indicates the control is a split button * pop-up (CXTPControlPopup). * xtpControlComboBox: Indicates the control is a combobox * (CXTPControlComboBox). * xtpControlEdit: Indicates the control is an edit control (CXTPControlEdit). * xtpControlLabel: Indicates the control is a label (CXTPControlLabel). */ XTPControlType GetType() const; /** * @brief * Call this member to set the flags of the control. * @param dwFlags Control flags. * @details * Flags to be added or removed can be combined by using the bitwise * OR (|) operator. It can be one or more of the following: * xtpFlagRightAlign: Indicates the control is right aligned. * xtpFlagSkipFocus: Indicates the control does not have focus. * xtpFlagLeftPopup: Indicates the child bar should pop-up on the left. * xtpFlagManualUpdate: Indicates the control is manually updated. * xtpFlagNoMovable: Indicates the control's customization is disabled. * xtpFlagControlStretched: Indicates the control is stretched in the parent * command bar. * @see * GetFlags, XTPControlFlags */ void SetFlags(DWORD dwFlags); /** * @brief * Call this member to retrieve control special flags. * @return * Control special flags. * @see * SetFlags, XTPControlFlags */ DWORD GetFlags() const; /** * @brief * This method sets the 32-bit value associated with the control. * @param dwTag The new 32-bit value to associate with the control. */ void SetTag(DWORD_PTR dwTag); /** * @brief * This method retrieves the application-supplied, 32-bit value * associated with the control. * @return * The 32-bit value associated with the control. */ DWORD_PTR GetTag() const; /** * @brief * Call this member to compare controls. * @param pOther The control to compare with. * @return * TRUE if the controls are identical, otherwise FALSE. */ virtual BOOL Compare(CXTPControl* pOther); /** * @brief * Call this member to get the child command bar. * @return * A pointer to the child command bar. */ virtual CXTPCommandBar* GetCommandBar() const; /** * @brief * Call this member function to enable/disable the closing of * sub-menus when a control is clicked in the menu. * @param bCloseOnClick TRUE if the sub-menu will close when a control * is clicked. FALSE if the sub-menu will remain open * after a control is clicked. * @see * GetCloseSubMenuOnClick */ void SetCloseSubMenuOnClick(BOOL bCloseOnClick); /** * @brief * Call this member function to check if sub-menus will close * as soon as a control is clicked. * @return * TRUE if the sub-menu will close when a control is clicked. FALSE * if the sub-menu will remain open after a control is clicked. * @see * SetCloseSubMenuOnClick */ BOOL GetCloseSubMenuOnClick() const; /** * @brief * Call this method to set the delay (in milliseconds) between WM_COMMAND * messages while a button is pressed by the user. * @param nExecuteOnPressInterval The delay (in milliseconds) between each message. * @see * GetExecuteOnPressInterval */ void SetExecuteOnPressInterval(int nExecuteOnPressInterval); /** * @brief * Call this method to get the delay (in milliseconds) between WM_COMMAND * messages while a button is pressed by the user. * @return * The delay (in milliseconds) between each message. * @see * SetExecuteOnPressInterval */ int GetExecuteOnPressInterval() const; /** * @brief * Returns the ribbon group that the control belongs to. * @return * If the control belongs to a ribbon group, then the CXTPRibbonGroup * that the control belongs to is returned. If the control does not * belong to a ribbon group, then NULL is returned. * @see * CXTPRibbonBar::RebuildControls */ CXTPRibbonGroup* GetRibbonGroup() const; /** * @brief * Determines if the control needs to draw its background. * @return * TRUE if the paint manager must skip filling the background of the control. */ virtual BOOL IsTransparent() const { return FALSE; } public: /** * @brief * This method is called to hide the control. * @param bHide TRUE to set hide state. */ void SetHideWrap(BOOL bHide); /** * @brief * This method is called to hide the control. * @param dwFlags Reasons to hide. * @details * HideFlags will tell how a control was hidden if it is hidden * or why it is not visible. Most of these flags are read only * and should not be set by the developer. * There is only one situation where you should set these flags * manually. xtpHideCustomize is the only flag that should * ever be manually set. You would do this when you want the * control to initially be hidden but still exist in the customize * pop-up of a toolbar. This will cause the control to appear in * the Add and Remove Buttons pop-up without a check mark indicating * that it is currently hidden. This flag will automatically * be set when a command is hidden this way. * @see * XTPControlHideFlags */ virtual void SetHideFlags(DWORD dwFlags); /** * @brief * Call this member to set/remove hide flags. * @param dwFlag XTPControlHideFlags type of flag to set/remove. * @param bSet TRUE to set flag; FALSE to remove. * @details * SetHideFlag will tell how a control was hidden if it is hidden * or why it is not visible. Most of these flags are read only * and should not be set by the developer. * @return * TRUE if flags were changed, otherwise FALSE. * @see * XTPControlHideFlags, SetHideFlags */ BOOL SetHideFlag(XTPControlHideFlags dwFlag, BOOL bSet); /** * @brief * Call this method to retrieve hidden flags. * @return * Flags of the control's visibility. * @details * HideFlags will tell how a control was hidden if it is hidden * or why it is not visible. Most of these flags are read only * and should not be set by the developer. * There is only one situation where you should set these flags * manually. xtpHideCustomize is the only flag that should * ever be manually set. You would do this when you want the * control to initially be hidden but still exist in the customize * pop-up of a toolbar. This will cause the control to appear in * the Add and Remove Buttons pop-up without a check mark indicating * that it is currently hidden. This flag will automatically * be set when a command is hidden this way. * @see * XTPControlHideFlags */ DWORD GetHideFlags() const; /** * @brief * Call this method to retrieve the position of the control's row. * @return * Bounding rectangle of the control's row. */ CRect GetRowRect() const; /** * @brief * Call this method to check if the control is wrapped. * @return * TRUE if the control is wrapped; otherwise FALSE. * @see * SetWrap */ BOOL GetWrap() const; /** * @brief * Call this method to set the row of the control. * @param rcRow Rectangle of the control's row. */ void SetRowRect(CRect rcRow); /** * @brief * Call this member to set the control to wrapped. * @param bWrap TRUE to set the control to wrapped. * @see * GetWrap */ void SetWrap(BOOL bWrap); /** * @brief * Call this member to check if the control is expanded. * @return * TRUE if the control is expanded; otherwise FALSE. */ BOOL GetExpanded() const; /** * @brief * Call this member to determine if the mouse pointer is over the control. * @return * TRUE if the mouse cursor is over the control; otherwise FALSE. */ BOOL IsCursorOver() const; /** * @brief * This method is called when the control is executed. */ virtual void OnExecute(); /** * @brief * This method is called to determine the size of the control. * @param pDC Pointer to a valid device context. * @return * A CSize object containing the size of the control. */ virtual CSize GetSize(CDC* pDC); /** * @brief * This method is called to draw the control. * @param pDC Pointer to a valid device context. */ virtual void Draw(CDC* pDC); /** * @brief * This method is called before recalculating the parent command bar * size to calculate the dimensions of the control. * @param dwMode Flags used to determine the height and width of the * dynamic command bar. See Remarks section for a list of * values. * @details * The following predefined flags are used to determine the height and * width of the dynamic command bar. Use the bitwise-OR (|) operator to * combine the flags.

* * LM_STRETCH: Indicates whether the command bar should be * stretched to the size of the frame. Set if the bar is * not a docking bar (not available for docking). Not set * when the bar is docked or floating (available for * docking). If set, LM_STRETCH returns dimensions based * on LM_HORZ state. LM_STRETCH works similarly to * the bStretch parameter used in CalcFixedLayout; * see that member function for more information about * the relationship between stretching and orientation. * LM_HORZ: Indicates that the bar is horizontally or * vertically oriented. Set if the bar is horizontally * oriented, and if it is vertically oriented, it is not * set. LM_HORZ works similarly to the the bHorz * parameter used in CalcFixedLayout; see that member * function for more information about the relationship * between stretching and orientation. * LM_MRUWIDTH: Most Recently Used Dynamic Width. Uses the * remembered most recently used width. * LM_HORZDOCK: Horizontal Docked Dimensions. Returns the * dynamic size with the largest width. * LM_VERTDOCK: Vertical Docked Dimensions. Returns the dynamic * size with the largest height. * LM_COMMIT: Resets LM_MRUWIDTH to the current width of the * floating command bar. * * The framework calls this member function to calculate the dimensions * of a dynamic command bar.

* * Override this member function to provide your own layout in classes * you derive from CXTPControl. XTP classes derived from CXTPControl, * such as CXTPControlComboBox, override this member function to provide * their own implementation. * @see * CXTPControlComboBox, CXTPControlCustom, CXTPControlEdit, * CXTPControlWindowList, CXTPControlWorkspaceActions, CXTPControlToolbars, * CXTPControlOleItems, CXTPControlRecentFileList, CXTPControlSelector, * CXTPControlListBox */ virtual void OnCalcDynamicSize(DWORD dwMode); /** * @brief * Call this method to redraw the parent command bar. */ void DelayRedrawParent(); /** * @brief * Call this method to recalculate the parent command bar size. */ void DelayLayoutParent(); /** * @brief * Call this method to set the category of the control. * @param lpszCategory Category of the control. */ void SetCategory(LPCTSTR lpszCategory); /** * @brief * Call this method to retrieve the category of the control. * @return * Category of the control. */ CString GetCategory() const; /** * @brief * Call this method to retrieve the image manager. * @return * A pointer to a CXTPImageManager object. */ CXTPImageManager* GetImageManager() const; /** * @brief * Call this method to retrieve the paint manager. * @return * A pointer to a CXTPPaintManager object. */ CXTPPaintManager* GetPaintManager() const; /** * @brief * Call this method to retrieve the image of the control. * @param nWidth Width of the image to retrieve. * @return * A pointer to a CXTPImageManagerIcon object. */ virtual CXTPImageManagerIcon* GetImage(int nWidth = 16) const; /** * @brief * Call this method to assign a document template to the control. * Assigned control will be shown only when the child MDI window is activated * with the assigned document template. * @param nIDResource Document template identifier. * @see * AssignDocTemplate */ void AssignDocTemplate(UINT nIDResource); /** * @brief * Call this method to exclude the document template from control. * Control will be shown only when the child MDI window is activated * and the document template is not excluded. * @param nIDResource Document template identifier. * @see * ExcludeDocTemplate */ void ExcludeDocTemplate(UINT nIDResource); /** * @brief * Call this method to check if a control is a default menu item. * @return * TRUE if the control is a default menu item, otherwise FALSE. * @details * A default menu item will appear in bold text. * @see * SetItemDefault */ BOOL IsItemDefault() const; /** * @brief * Call this method to set a control to be a default menu item. * @param bDefault TRUE to set the control to be a default menu item. * @details * A default menu item will appear in bold text. * @see * IsItemDefault */ void SetItemDefault(BOOL bDefault); /** * @brief * Call this method to determine if a control is temporary. * Temporary controls will not be saved to the system registry when * the application is closed (If the CommandBars layout is saved). * @return * TRUE if the control is temporary, otherwise FALSE. */ BOOL IsTemporary() const; /** * @brief * Call this member to reset the icon and caption of a control * to its default settings before it was customized by the user. * @details * The caption and icon of a control is customized while in customization * mode. * @see * SetCustomIcon, m_strCustomCaption */ void Reset(); /** * @brief * Call this member to load a string from a STRINGTABLE resource * to set the tooltip and description of a control. * @param lpszPrompt String from resource file that contains the * tooltip and description of the item. The Caption * will be set to use the tooltip text. The tooltip * and description must be separated by "\n" if both * are included. You can omit the description and * both the tooltip and description will be set to * the same value. * @details * Resource strings are in the format "Description\nToolTip". * * Note: The caption is set to the value of the tooltip when this * member is called. * @see * SetCaption, SetDescription, SetTooltip */ void SetPrompt(LPCTSTR lpszPrompt); /** * @brief * Call this member to retrieve CXTPControl from a CCmdUI structure. * @param pCmdUI Address of the CCmdUI structure. * @return * CXTPControl from the CCmdUI structure. */ static CXTPControl* AFX_CDECL FromUI(CCmdUI* pCmdUI); /** * @brief * Call this member to set a custom icon to this control. * @param hIcon HICON object containing the icon to set to this control. * @see * Reset */ void SetCustomIcon(HICON hIcon); /** * @brief * Either reads this object from or writes this object to an archive. * @param pPX A CXTPPropExchange object to serialize to or from. */ virtual void DoPropExchange(CXTPPropExchange* pPX); /** * @brief * This method is called when the user activates the control using its underline. */ virtual void OnUnderlineActivate(); /** * @brief * Call this member to get the control's pop-up state. * @return * TRUE if the control is a pop-up, otherwise FALSE. */ virtual BOOL GetPopuped() const; /** * @brief * This method is called to redraw the parent command bar. * @param bAnimate TRUE to animate changes. */ void RedrawParent(BOOL bAnimate = TRUE); /** * @brief * This method is called to send message code to the parent site window. * @param code Message to be sent. * @return * Results. */ LRESULT NotifySite(UINT code); /** * @brief * This method is called to send message code to the parent site window. * @param code Message to be sent. * @param pNM Structure that is passed as a parameter in the CBN_XTP_EXECUTE message. * @return * Results. */ LRESULT NotifySite(UINT code, NMXTPCONTROL* pNM); /** * @brief * This method is called to send message code to the parent site window. * @param code Message to be sent. * @param pNM Structure that is passed as a parameter in the CBN_XTP_EXECUTE message. * @param pSite Parent window of commandbar. * @return * Results. */ LRESULT NotifySite(CWnd* pSite, UINT code, NMXTPCONTROL* pNM); /** * @brief * Call this method to manually assign an action for control. * @param pAction Action to assign. * @see * CXTPControlAction, GetAction */ virtual void SetAction(CXTPControlAction* pAction); /** * @brief * Call this method to retrieve an action associated with control. * @return * Action associated with control. * @see * CXTPControlAction, SetAction */ CXTPControlAction* GetAction() const; /** * @brief * This method is called when the paint manager theme is changed. */ virtual void OnThemeChanged(); /** * @brief * Call this member to set the width of the control. * @param nWidth The width of the control. */ virtual void SetWidth(int nWidth); /** * @brief * Call this member to set the height of the control * @param nHeight The height of the control. */ virtual void SetHeight(int nHeight); /** * @brief * Call this member to get the width of the control. * @return * Width of the control in pixels. * @see * GetHeight */ int GetWidth() const; /** * @brief * Call this member to get the height of the control. * @return * Height of the control in pixels. * @see * GetWidth */ int GetHeight() const; /** * @brief * This method is called to determine if control has a Vista DWM transparent area. * @return * TRUE if control has a Vista DWM transparent area, otherwise FALSE. */ BOOL HasDwmCompositedRect() const; /** * @brief * Call this function to get the size of the command bar button. * @return * The width and height values of the command bar button. */ virtual CSize GetButtonSize() const; /** * @brief * Call this member function to get the size of a toolbar icon. * @return Returns size of toolbar icon * @see * GetButtonSize */ virtual CSize GetIconSize() const; /** * @brief * Call this member function to set the size of an icon for an individual control. * @param szIcon Desired size of the icon. * @see * GetIconSize, GetButtonSize */ void SetIconSize(CSize szIcon); /** * @brief * This method is called to copy the control. * @param pControl Pointer to a source CXTPControl object. * @param bRecursive TRUE to copy recursively. */ virtual void Copy(CXTPControl* pControl, BOOL bRecursive = FALSE); /** * @brief * This method is called when the user clicks the control. * @param bKeyboard TRUE if the control is selected using the keyboard. * @param pt Mouse cursor position. */ virtual void OnClick(BOOL bKeyboard = FALSE, CPoint pt = CPoint(0, 0)); /** * @brief * This method is called to determine if control can be repositioned in * customize mode. * @return True if in customize mode, false otherwise * @see * xtpFlagNoMovable */ virtual BOOL IsCustomizeMovable() const; protected: /** * @brief * This method is called to check if the control can accept focus. * @return * TRUE if the control can accept focus, otherwise FALSE. * @see * SetFocused, IsFocused */ virtual BOOL IsFocusable() const; /** * @brief * This method is called to assign the order of the control in * the controls list. * @param nIndex Index of the control. */ void SetIndex(int nIndex) { m_nIndex = nIndex; } /** * @brief * This method is called to set the control's expanded state. * @param bExpanded TRUE to set the control to expanded. */ void SetExpanded(BOOL bExpanded); /** * @brief * This method is called when a non-system key is pressed. * @param nChar Specifies the virtual key code of the given key. * @param lParam Specifies additional message-dependent information. * @return * TRUE if the key was handled, otherwise FALSE. */ virtual BOOL OnHookKeyDown(UINT nChar, LPARAM lParam); /** * @brief * This method is called when the user rotates the mouse wheel. * @param nFlags Indicates whether various virtual keys are down. * @param zDelta Indicates distance rotated. * @param point Specifies the x- and y- coordinates of the cursor. * @return * TRUE if the key was handled, otherwise FALSE. */ virtual BOOL OnHookMouseWheel(UINT nFlags, short zDelta, CPoint point); /** * @brief * This method is called to assign a parent command bar object. * @param pParent Pointer to a CXTPCommandBar object. */ virtual void SetParent(CXTPCommandBar* pParent) { m_pParent = pParent; } /** * @brief * The ScreenToClient function converts the screen coordinates * of a specified point on the screen * @param point Pointer to a CPoint object that specifies the screen * coordinates to be converted. */ void ScreenToClient(CPoint* point); /** * @brief * This helper method is called when the user clicks the toolbar's button. * @param rcActiveRect Rectangle of the control. */ void ClickToolBarButton(CRect rcActiveRect = CRect(0, 0, 0, 0)); /** * @brief * This method is called to pop-up the control. * @param bPopup TRUE to set pop-up. * @return * TRUE if successful; otherwise FALSE. */ virtual BOOL OnSetPopup(BOOL bPopup); /** * @brief * This member is called when the user releases the left mouse button. * @param point Specifies the x- and y- coordinates of the cursor. */ virtual void OnLButtonUp(CPoint point); /** * @brief * This member is called when the user presses the left mouse button down. * @param point Specifies the x- and y- coordinates of the cursor. */ virtual void OnLButtonDown(CPoint point); /** * @brief * This member is called when the user press the right mouse button. * @param point Specifies the x- and y- coordinates of the cursor. * @return True if right mouse button is preseed down, otherwise false */ virtual BOOL OnRButtonDown(CPoint point); /** * @brief * This member is called when the user releases the right mouse button. * @param point Specifies the x- and y- coordinates of the cursor. * @return True when right mouse button is released, otherwise false */ virtual BOOL OnRButtonUp(CPoint point); /** * @brief * This member is called when the user double-clicks the left mouse button. * @param point Specifies the x- and y- coordinates of the cursor. * @return * TRUE if successful; otherwise FALSE. */ virtual BOOL OnLButtonDblClk(CPoint point); /** * @brief * This member is called when the mouse cursor moves. * @param point Specifies the x- and y- coordinates of the cursor. */ virtual void OnMouseMove(CPoint point); /** * @brief * Called after the mouse hovers over the control. */ virtual void OnMouseHover(); /** * @brief * This method is called when the control becomes selected. * @param bSelected TRUE if the control becomes selected. * @return * TRUE if successful, otherwise FALSE. */ virtual BOOL OnSetSelected(int bSelected); /** * @brief * Call this method to determine if command bars is in customize mode. * @return * TRUE if command bars is in Customize mode; otherwise FALSE. */ BOOL IsCustomizeMode() const; /** * @brief * This member is called when the user starts to drag the control in customize mode. * @param point Specifies the x- and y- coordinates of the cursor. * @see * IsCustomizeMode, CustomizeStartResize */ virtual void CustomizeStartDrag(CPoint point); /** * @brief * This method is called when user starts to resize control in customize mode. * @param point Specifies the x- and y- coordinates of the cursor. * @return * TRUE if control processes this event, otherwise FALSE. * @see * IsCustomizeMode, CustomizeStartDrag, GetCustomizeMinWidth */ virtual BOOL CustomizeStartResize(CPoint point); /** * @brief * This member is called when the user moves the mouse over the control. * @param pDataObject Pointer to a CXTPControl object. * @param point Mouse position. * @param dropEffect DROPEFFECT enumerator. */ virtual void OnCustomizeDragOver(CXTPControl* pDataObject, CPoint point, DROPEFFECT& dropEffect); /** * @brief * The implementation may implement a custom drag over handling logic in this method. * @param pCommandBar Pointer to a CXTPCommandBar object. * @param point Mouse position. * @param dropEffect DROPEFFECT enumerator. * @return * TRUE if custom implementation handles drag over, otherwise FALSE. */ virtual BOOL DoCustomDragOver(CXTPCommandBar* pCommandBar, CPoint point, DROPEFFECT& dropEffect); /** @cond */ _XTP_DEPRECATED_IN_FAVOR(DoCustomDragOver) virtual BOOL IsCustomizeDragOverAvail(CXTPCommandBar* pCommandBar, CPoint point, DROPEFFECT& dropEffect) { return DoCustomDragOver(pCommandBar, point, dropEffect); } /** @endcond */ /** * @brief * This member checks if the user can resize the control. * @return * TRUE if the user can resize the control, otherwise FALSE. */ virtual BOOL IsCustomizeResizeAllow() const; /** * @brief * Retrieves the available minimum width of control. * @details * This method is called in CustomizeStartResize to retrieve the width * of available rectangles of a resized control. * @return * Returns zero by default. * @see * CXTPControlComboBox::GetCustomizeMinWidth, CXTPControlEdit::GetCustomizeMinWidth */ virtual int GetCustomizeMinWidth() const; /** * @brief * Retrieves available minimum height of the control. * @details * This method is called in CustomizeStartResize to retrieve the height * of available rectangles of a resized control. * @return * Returns zero by default. * @see * CXTPControlComboBox::GetCustomizeMinHeight, CXTPControlEdit::GetCustomizeMinHeight */ virtual int GetCustomizeMinHeight() const; /** * @brief * This member is called when the mouse cursor moves in customized mode. * @param point Specifies the x- and y- coordinates of the cursor. */ void OnCustomizeMouseMove(CPoint point); /** * @brief * This virtual method is called in idle-time processing. */ virtual void OnIdleUpdate(); /** * @brief * This method is called when a control is removed from the * parent controls collection. */ virtual void OnRemoved(); /** * @brief * The framework calls this member function to determine * whether a point is in the bounding rectangle of the * specified tool. * @param point Specifies the x- and y- coordinates of the cursor. * These coordinates are always relative to the * upper-left corner of the window. * @param pTI A pointer to a TOOLINFO structure. * @return * If the tooltip control was found, the window control ID will be returned. * If the tooltip control was not found, a value of -1 will be returned. */ virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const; protected: /** * @brief * This method is called from LoadCommandBars to restore * controls and its child command bars. * @param pCommandBarList Command bars collection that contains all the * command bars to be restored. * @see * GenerateCommandBarList */ virtual void RestoreCommandBarList(CXTPCommandBarList* pCommandBarList); /** * @brief * This method is called from SaveCommandBars to save all child command bars. * @param nID Current Identifier counter. * @param pCommandBarList List of saved command bars. * @param pParam Serialize parameters. * @see * RestoreCommandBarList */ virtual void GenerateCommandBarList(DWORD& nID, CXTPCommandBarList* pCommandBarList, XTP_COMMANDBARS_PROPEXCHANGE_PARAM* pParam); /** * @brief * This method is called when an action property is changed. * @param nProperty Property of the action. * @see * OnActionChanging */ virtual void OnActionChanged(int nProperty); /** * @brief * This method is called when an action property is about to be changed. * @param nProperty Property of the action. * @see * OnActionChanged */ virtual void OnActionChanging(int nProperty); protected: /** * @brief * This method is called when the control's caption is changed. */ virtual void OnCaptionChanged(); /** * @brief * Determines if right-to-left (RTL) mode is set. * @return * TRUE if text is displayed using right-to-left (RTL) * reading-order properties. */ BOOL IsLayoutRTL() const; /** * @brief * Call this member to determine if the layout has changed * (RTL to LTR or LTR to RLT). * @return * TRUE if the layout has changed, otherwise FALSE. */ BOOL IsLayoutChanged(); protected: /** @cond */ virtual HRESULT GetAccessibleParent(IDispatch** ppdispParent); virtual HRESULT GetAccessibleDescription(VARIANT varChild, BSTR* pszDescription); virtual HRESULT GetAccessibleChildCount(long* pcountChildren); virtual HRESULT GetAccessibleChild(VARIANT varChild, IDispatch** ppdispChild); virtual HRESULT GetAccessibleName(VARIANT varChild, BSTR* pszName); virtual HRESULT GetAccessibleRole(VARIANT varChild, VARIANT* pvarRole); virtual HRESULT AccessibleLocation(long* pxLeft, long* pyTop, long* pcxWidth, long* pcyHeight, VARIANT varChild); virtual HRESULT AccessibleHitTest(long xLeft, long yTop, VARIANT* pvarChild); virtual HRESULT GetAccessibleState(VARIANT varChild, VARIANT* pvarState); virtual CCmdTarget* GetAccessible(); virtual HRESULT GetAccessibleDefaultAction(VARIANT varChild, BSTR* pszDefaultAction); virtual HRESULT AccessibleDoDefaultAction(VARIANT varChild); virtual HRESULT AccessibleSelect(long flagsSelect, VARIANT varChild); virtual HRESULT GetAccessibleKeyboardShortcut(VARIANT /*varChild*/, BSTR* /*pszKeyboardShortcut*/); DECLARE_INTERFACE_MAP() virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo); /** @endcond */ private: void OnInvertTracker(CDC* pDC, CRect rect); BOOL NeedPressOnExecute() const; protected: DWORD_PTR m_nTag; /**< Control tag. */ int m_nIndex; /**< Index of the control. */ int m_nId; /**< Identifier of the control. */ int m_nIconId; /**< Identifier of the control's image. */ int m_nHelpId; /**< Help identifier */ int m_nCustomIconId; /**< Identifier of the control's custom image. */ BOOL m_bWrap; /**< TRUE if the control is wrapped. */ BOOL m_bBeginGroup; /**< TRUE if the control starts new group. */ BOOL m_bEnabled; /**< TRUE if the control is enabled. */ BOOL m_bChecked; /**< TRUE if the control is checked. */ BOOL m_bSelected; /**< TRUE if the control is selected. */ BOOL m_bPressed; /**< TRUE if the control is pushed. */ BOOL m_bTemporary; /**< TRUE if the control is temporary. */ BOOL m_bOnQuickAccess; /**< TRUE if the control is a part of Quick Access panel. */ CRect m_rcRow; /**< Bounding rectangle of the control's row. */ CRect m_rcControl; /**< Bounding rectangle of the control. */ DWORD m_dwHideFlags; /**< Hidden flags. */ DWORD m_dwFlags; /**< Flags of the control. */ CString m_strCaption; /**< Caption of the control. */ CString m_strCustomCaption; /**< User-defined caption. */ CString m_strShortcutText; /**< Shortcut text. */ CString m_strShortcutTextAuto; /**< Shortcut text. */ CString m_strTooltipText; /**< Tooltip text. */ CString m_strDescriptionText; /**< Description text. */ CString m_strParameter; /**< Parameter text. */ CString m_strKeyboardTip; /**< Keyboard tip */ CXTPControls* m_pControls; /**< Parent control collection */ XTPControlType m_controlType; /**< Type of the control. */ CXTPCommandBar* m_pParent; /**< The Parent command bar. */ BOOL m_bExpanded; /**< TRUE if the control is expanded. */ CString m_strCustomShortcutText; CString m_strCategory; /**< Category of the control. */ BOOL m_bDefaultItem; /**< TRUE if the item is default pop-up item. */ CDocTemplateMap m_mapDocTemplatesAssigned; /**< Assigned templates. */ CDocTemplateMap m_mapDocTemplatesExcluded; /**< Excluded templates. */ XTPButtonStyle m_buttonStyle; /**< Button Style. */ XTPButtonStyle m_buttonCustomStyle; /**< User-defined style of button. */ XTPButtonStyle m_buttonRibbonStyle; /**< User-defined style of button. */ BOOL m_bCloseSubMenuOnClick; /**< TRUE is sub-menus are closed as soon as a control is clicked. */ CXTPRibbonGroup* m_pRibbonGroup; /**< Ribbon group of control */ CXTPControlAction* m_pAction; /**< Action of the control. */ int m_nWidth; /**< Width of the control. */ int m_nHeight; /**< Height of the control. */ int m_nExecuteOnPressInterval; /**< Delay between each message when control is pressed. */ CSize m_szIcon; /**< The size of the icon used for the control. */ BOOL m_bLayoutRTL; /**< Indicate does last layout is RTL */ # ifdef _XTP_COMMANDBARS_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_OLETYPELIB_EX(CXTPControl); afx_msg LPDISPATCH OleControls(); afx_msg LPDISPATCH OleParent(); afx_msg long OleGetIndex(); afx_msg long OleGetType(); afx_msg void OleDelete(); afx_msg LPDISPATCH OleCopy(LPDISPATCH lpDispBar, const VARIANT& varBefore); afx_msg LPDISPATCH OleClone(const VARIANT& varBefore); afx_msg void OleSetFocus(); afx_msg void OleExecute(); afx_msg void OleSetCaption(LPCTSTR lpszCaption); afx_msg BSTR OleGetCaption(); afx_msg void OleGetRect(long* pLeft, long* pTop, long* pRight, long* pBottom); afx_msg LPDISPATCH OleGetRibbonGroup(); afx_msg void OleSetIconSize(long cx, long cy); afx_msg LPDISPATCH OleGetCommandBar(); afx_msg int OleGetStyle(); afx_msg void OleSetStyle(int nStyle); afx_msg void OleSetDescription(LPCTSTR lpszCaption); afx_msg BSTR OleGetDescription(); afx_msg BSTR OleGetTooltipText(); afx_msg void OleSetTooltipText(LPCTSTR lpszCaption); afx_msg void OleSetCategory(LPCTSTR lpszCaption); afx_msg BSTR OleGetCategory(); afx_msg void OleSetShortcutText(LPCTSTR lpszCaption); afx_msg BSTR OleGetShortcutText(); afx_msg void OleSetCustomShortcutText(LPCTSTR lpszCustomShortcutText); afx_msg BSTR OleGetCustomShortcutText(); afx_msg LPDISPATCH OleGetAction(); afx_msg void OleSetAction(LPDISPATCH lpDisp); afx_msg BOOL OleGetVisible(); afx_msg int OleGetWidth(); afx_msg void OleSetWidth(int nWidth); afx_msg int OleGetHeight(); afx_msg void OleSetHeight(int nHeight); afx_msg int OleGetTop(); afx_msg int OleGetLeft(); enum { dispidControls = 1L, dispidParent = 2L, dispidBeginGroup = 3L, dispidCaption = 4L, dispidDescriptionText = 5L, dispidId = 6L, dispidIndex = 7L, dispidParameter = 8L, dispidShortcutText = 9L, dispidTooltipText = 10L, dispidType = 11, dispidVisible = 12L, dispidEnabled = 13L, dispidChecked = 14L, dispidIconId = 15L, dispidDelete = 16L, dispidDefaultItem = 17L, dispidFalgs = 18L, dispidCategory = 19L, dispidCopy = 20L, dispidSetFocus = 21L, dispidExecute = 22L, }; /** @endcond */ # endif private: DECLARE_XTP_CONTROL(CXTPControl) friend class CXTPRibbonBuilder; friend class CXTPControls; friend class CXTPCommandBar; friend class CXTPToolBar; friend class CXTPPopupBar; friend class CXTPCustomizeSheet; friend class CXTPCustomizeDropSource; friend class CXTPRibbonGroup; friend class CXTPRibbonGroups; friend class CXTPRibbonBar; friend class CXTPRibbonControls; friend class CXTPControlAction; friend class CXTPRibbonQuickAccessControls; }; ////////////////////////////////////////////////////////////////////////// AFX_INLINE BOOL CXTPControl::IsOnQuickAccess() const { return m_bOnQuickAccess; } AFX_INLINE void CXTPControl::SetOnQuickAccess(BOOL bOnQuickAccess) { m_bOnQuickAccess = bOnQuickAccess; } AFX_INLINE long CXTPControl::GetIndex() const { return m_nIndex; } AFX_INLINE void CXTPControl::SetShortcutText(LPCTSTR lpszShortcutText) { m_strShortcutText = lpszShortcutText; } AFX_INLINE CString CXTPControl::GetShortcutText() const { return !m_strShortcutText.IsEmpty() ? m_strShortcutText : m_pAction && !m_pAction->GetShortcutText().IsEmpty() ? m_pAction->GetShortcutText() : m_strShortcutTextAuto; } AFX_INLINE void CXTPControl::SetCustomShortcutText(LPCTSTR lpszCustomShortcutText) { m_strCustomShortcutText = lpszCustomShortcutText; } AFX_INLINE CString CXTPControl::GetCustomShortcutText() const { return !m_strCustomShortcutText.IsEmpty() ? m_strCustomShortcutText : m_pAction && !m_pAction->GetCustomShortcutText().IsEmpty() ? m_pAction->GetCustomShortcutText() : m_strShortcutTextAuto; } AFX_INLINE void CXTPControl::SetDescription(LPCTSTR lpszDescription) { m_strDescriptionText = lpszDescription; } AFX_INLINE CString CXTPControl::GetDescription() const { return !m_strDescriptionText.IsEmpty() ? m_strDescriptionText : m_pAction ? m_pAction->GetDescription() : CString(); } AFX_INLINE CString CXTPControl::GetTooltip() const { return !m_strTooltipText.IsEmpty() ? m_strTooltipText : m_pAction ? m_pAction->GetTooltip() : CString(); } AFX_INLINE void CXTPControl::SetTooltip(LPCTSTR lpszTooltip) { m_strTooltipText = lpszTooltip; } AFX_INLINE CString CXTPControl::GetCaption() const { return !m_strCustomCaption.IsEmpty() ? m_strCustomCaption : !m_strCaption.IsEmpty() ? m_strCaption : m_pAction ? m_pAction->GetCaption() : CString(); } AFX_INLINE void CXTPControl::SetParameter(LPCTSTR lpszParameter) { m_strParameter = lpszParameter; } AFX_INLINE CString CXTPControl::GetParameter() const { return m_strParameter; } AFX_INLINE int CXTPControl::GetID() const { return m_nId; } AFX_INLINE void CXTPControl::SetIconId(int nId) { if (m_nIconId != nId) { m_nIconId = nId; RedrawParent(FALSE); } } AFX_INLINE int CXTPControl::GetIconId() const { return m_nCustomIconId != 0 ? m_nCustomIconId : m_nIconId > 0 ? m_nIconId : m_pAction ? m_pAction->GetIconId() : m_nId; } AFX_INLINE void CXTPControl::SetHelpId(int nId) { m_nHelpId = nId; } AFX_INLINE int CXTPControl::GetHelpId() const { return m_nHelpId > 0 ? m_nHelpId : m_pAction ? m_pAction->GetHelpId() : m_nId; } AFX_INLINE void CXTPControl::SetBeginGroup(BOOL bBeginGroup) { if (m_bBeginGroup != bBeginGroup) { m_bBeginGroup = bBeginGroup; DelayLayoutParent(); } } AFX_INLINE BOOL CXTPControl::GetBeginGroup() const { return m_bBeginGroup; } AFX_INLINE void CXTPControl::OnEnabledChanged() { } AFX_INLINE void CXTPControl::SetEnabled(BOOL bEnabled) { if (m_bEnabled != bEnabled) { m_bEnabled = bEnabled; OnEnabledChanged(); RedrawParent(); } } AFX_INLINE BOOL CXTPControl::GetChecked() const { return m_bChecked == -1 && m_pAction ? m_pAction->GetChecked() : m_bChecked; } AFX_INLINE void CXTPControl::SetChecked(BOOL bChecked) { if (m_bChecked != bChecked) { m_bChecked = bChecked; RedrawParent(); } } AFX_INLINE int CXTPControl::GetSelected() const { return m_bSelected; } AFX_INLINE BOOL CXTPControl::GetPressed() const { return m_bPressed; } AFX_INLINE void CXTPControl::SetPressed(BOOL bPressed) { m_bPressed = bPressed; } AFX_INLINE void CXTPControl::SetRect(CRect rcControl) { m_rcControl = rcControl; } AFX_INLINE CRect CXTPControl::GetRect() const { return m_rcControl; } AFX_INLINE CXTPCommandBar* CXTPControl::GetParent() const { return m_pParent; } AFX_INLINE BOOL CXTPControl::IsVisible(DWORD dwSkipFlags) const { if (m_pAction && !m_pAction->IsVisible()) return FALSE; return (m_dwHideFlags & ~dwSkipFlags) == xtpNoHide; } AFX_INLINE void CXTPControl::SetHideFlags(DWORD dwFlags) { m_dwHideFlags = dwFlags; } AFX_INLINE BOOL CXTPControl::SetHideFlag(XTPControlHideFlags dwFlag, BOOL bHide) { DWORD dwHideFlags = m_dwHideFlags; if (bHide) SetHideFlags(m_dwHideFlags | dwFlag); else SetHideFlags(m_dwHideFlags & ~dwFlag); return dwHideFlags != m_dwHideFlags; } AFX_INLINE void CXTPControl::SetHideWrap(BOOL bHide) { SetHideFlag(xtpHideWrap, bHide); } AFX_INLINE DWORD CXTPControl::GetHideFlags() const { return m_dwHideFlags; } AFX_INLINE CRect CXTPControl::GetRowRect() const { return m_rcRow; } AFX_INLINE void CXTPControl::SetRowRect(CRect rcRow) { m_rcRow = rcRow; } AFX_INLINE BOOL CXTPControl::GetWrap() const { return m_bWrap; } AFX_INLINE void CXTPControl::SetWrap(BOOL bWrap) { m_bWrap = bWrap; } AFX_INLINE CXTPControls* CXTPControl::GetControls() const { return m_pControls; } AFX_INLINE BOOL CXTPControl::IsTemporary() const { return m_bTemporary; } AFX_INLINE XTPControlType CXTPControl::GetType() const { return m_controlType; } AFX_INLINE BOOL CXTPControl::GetExpanded() const { return m_bExpanded; } AFX_INLINE void CXTPControl::SetCategory(LPCTSTR lpszCategory) { m_strCategory = lpszCategory; } AFX_INLINE CString CXTPControl::GetCategory() const { return !m_strCategory.IsEmpty() ? m_strCategory : m_pAction ? m_pAction->GetCategory() : CString(); } AFX_INLINE void CXTPControl::SetTag(DWORD_PTR dwTag) { m_nTag = dwTag; } AFX_INLINE DWORD_PTR CXTPControl::GetTag() const { return m_nTag; } AFX_INLINE void CXTPControl::AssignDocTemplate(UINT nIDResource) { m_mapDocTemplatesAssigned.SetAt(nIDResource, TRUE); } AFX_INLINE void CXTPControl::ExcludeDocTemplate(UINT nIDResource) { m_mapDocTemplatesExcluded.SetAt(nIDResource, TRUE); } AFX_INLINE void CXTPControl::OnClick(BOOL /*bKeyboard = FALSE*/, CPoint /*pt = CPoint(0, 0)*/) { } AFX_INLINE void CXTPControl::SetStyle(XTPButtonStyle buttonStyle) { if (m_buttonStyle != buttonStyle) { m_buttonStyle = buttonStyle; DelayLayoutParent(); } } AFX_INLINE CXTPCommandBar* CXTPControl::GetCommandBar() const { return NULL; } AFX_INLINE void CXTPControl::SetCloseSubMenuOnClick(BOOL bCloseOnClick) { m_bCloseSubMenuOnClick = bCloseOnClick; } AFX_INLINE BOOL CXTPControl::GetCloseSubMenuOnClick() const { return m_bCloseSubMenuOnClick; } AFX_INLINE int CXTPControl::GetCustomizeMinWidth() const { return 0; } AFX_INLINE int CXTPControl::GetCustomizeMinHeight() const { return 0; } AFX_INLINE void CXTPControl::SetWidth(int nWidth) { if (m_nWidth != nWidth) { m_nWidth = nWidth; DelayLayoutParent(); } } AFX_INLINE void CXTPControl::SetHeight(int nHeight) { if (m_nHeight != nHeight) { m_nHeight = nHeight; DelayLayoutParent(); } } AFX_INLINE BOOL CXTPControl::OnHookKeyDown(UINT /*nChar*/, LPARAM /*lParam*/) { return FALSE; } AFX_INLINE BOOL CXTPControl::OnSetPopup(BOOL /*bPopup*/) { return FALSE; } AFX_INLINE void CXTPControl::OnLButtonUp(CPoint /*point*/) { } AFX_INLINE BOOL CXTPControl::OnRButtonDown(CPoint /*point*/) { return FALSE; } AFX_INLINE BOOL CXTPControl::OnRButtonUp(CPoint /*point*/) { return FALSE; } AFX_INLINE void CXTPControl::OnMouseMove(CPoint /*point*/) { } AFX_INLINE BOOL CXTPControl::IsFocusable() const { return FALSE; } AFX_INLINE void CXTPControl::SetFocused(BOOL /*bFocused*/) { } AFX_INLINE BOOL CXTPControl::IsFocused() const { return FALSE; } AFX_INLINE void CXTPControl::OnCalcDynamicSize(DWORD /*dwMode*/) { } AFX_INLINE CXTPRibbonGroup* CXTPControl::GetRibbonGroup() const { return m_pRibbonGroup; } AFX_INLINE BOOL CXTPControl::OnHookMouseWheel(UINT /*nFlags*/, short /*zDelta*/, CPoint /*pt*/) { return FALSE; } AFX_INLINE BOOL CXTPControl::GetPopuped() const { return FALSE; } AFX_INLINE void CXTPControl::OnIdleUpdate() { } AFX_INLINE CXTPControlAction* CXTPControl::GetAction() const { return m_pAction; } AFX_INLINE void CXTPControl::OnThemeChanged() { } AFX_INLINE int CXTPControl::GetWidth() const { return m_nWidth; } AFX_INLINE int CXTPControl::GetHeight() const { return m_nHeight; } AFX_INLINE void CXTPControl::OnActionChanging(int /*nProperty*/) { } AFX_INLINE void CXTPControl::SetExecuteOnPressInterval(int nExecuteOnPressInterval) { m_nExecuteOnPressInterval = nExecuteOnPressInterval; } AFX_INLINE int CXTPControl::GetExecuteOnPressInterval() const { return m_nExecuteOnPressInterval; } AFX_INLINE void CXTPControl::SetKeyboardTip(LPCTSTR lpszKeyboardTip) { m_strKeyboardTip = lpszKeyboardTip; } AFX_INLINE CString CXTPControl::GetKeyboardTip() const { return !m_strKeyboardTip.IsEmpty() ? m_strKeyboardTip : m_pAction ? m_pAction->GetKeyboardTip() : CString(); } AFX_INLINE INT_PTR CXTPControl::OnToolHitTest(CPoint /*point*/, TOOLINFO* /*pTI*/) const { return -1; } AFX_INLINE void CXTPControl::SetIconSize(CSize szIcon) { m_szIcon = szIcon; RedrawParent(FALSE); } AFX_INLINE void CXTPControl::OnCaptionChanged() { } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // #if !defined(__XTPCONTROL_H__) /** @endcond */