/** * @file XTPCommandBar.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(__XTPCOMMANDBAR_H__) # define __XTPCOMMANDBAR_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPDockBar; class CXTPControls; class CXTPControl; class CXTPControlPopup; class CXTPCommandBars; class CXTPCommandBar; class CXTPCommandBarAnimation; class CXTPPaintManager; class CXTPImageManager; class CXTPPropExchange; struct XTP_COMMANDBARS_PROPEXCHANGE_PARAM; class CXTPToolTipContext; class CXTPCommandBarAnimation; class CXTPCommandBarKeyboardTip; class CXTPCommandBarList; /** @cond */ # define XTP_TID_HOVER 112223 # define XTP_TID_EXPANDED_POPUP 112224 # define XTP_BOOL_DEFAULT 2 # define XTP_TID_SHOWKEYBOARDTIPS 0xCCCA /** @endcond */ /** * @brief * CXTPCommandBar is a CWnd derived class. It represents the parent * class for command bars. */ class _XTP_EXT_CLASS CXTPCommandBar : public CWnd , public CXTPHookManagerHookAble , public CXTPAccessible , IXTPPaintManagerEvents { protected: /** * @brief * Constructs a CXTPCommandBar object. */ CXTPCommandBar(); /** * @brief * Destroys a CXTPCommandBar object, handles cleanup and deallocation. */ virtual ~CXTPCommandBar(); public: /** * @brief * Call this member to get the tracking state. * @return * TRUE if the command bar is in the tracking mode. */ int IsTrackingMode() const; /** * @brief * Call this member to get the controls collection. * @return * A CXTPControls pointer. */ CXTPControls* GetControls() const; /** * @brief * Call this member to set the controls collection of the command bar. * @param pControls New controls to be set. * @see * GetControls */ void SetControls(CXTPControls* pControls); /** * @brief * Call this member to get the type of the command bar. * @return * The type of the command bar. It can be one of the following: * xtpBarTypeMenuBar Indicates the command bar is a menu bar (CXTPMenuBar) * xtpBarTypeNormal Indicates the command bar is a simple toolbar (CXTPToolBar) * xtpBarTypePopup Indicates the command bar is a pop-up bar (CXTPPopupBar) * @see * XTPBarType, GetPosition */ XTPBarType GetType() const; /** * @brief * Call this member to change text orientation. * @param nTextOrientation xtpBarTextHorizontal to draw text horizontally, * xtpBarTextVertical to draw text vertically. */ void SetTextOrientation(XTPBarTextOrientation nTextOrientation); /** * @brief * Call this member to get the text orientation. * @return Returns text orientation */ XTPBarTextOrientation GetTextOrientation() const; /** * @brief * Call this member to get the position of the command bar. * @return * The position of the command bar. * @see * XTPBarPosition, GetType */ XTPBarPosition GetPosition() const; /** * @brief * Call this member to recalculate the layout. */ void DelayLayout(); /** * @brief * Call this member to redraw the command bar. */ virtual void DelayRedraw(); /** * @brief * Call this member to change the tracking state. * @param bMode TRUE to set the tracking mode; otherwise FALSE. * @param bSelectFirst TRUE to select the first item. * @param bKeyboard TRUE if the item is popped by the keyboard. * @return * TRUE if the method was successful, otherwise FALSE. * @see * IsTrackingMode. */ virtual BOOL SetTrackingMode(int bMode, BOOL bSelectFirst = TRUE, BOOL bKeyboard = FALSE); /** * @brief * Call this member to convert menu items to command bar controls. * @param pMenu Menu to be converted. * @param bRemoveControls TRUE to remove all controls first. * @return * TRUE if the method was successful; otherwise FALSE. */ virtual BOOL LoadMenu(CMenu* pMenu, BOOL bRemoveControls = TRUE); /** * @brief * Call this member to return the control at the specified index. * @param nIndex An integer index. * @return * The CXTPControl pointer currently at this index. * @see * GetControls, CXTPControls::GetAt */ CXTPControl* GetControl(int nIndex) const; /** * @brief * Call this member to get the count of the controls. * @return * The count of the controls. */ int GetControlCount() const; /** * @brief * Call this member to select the specified control. * @param nSelected An integer index of the item to be selected. * @param bKeyboard TRUE if the item was selected using the keyboard. * @return * TRUE if the method was successful; otherwise FALSE. */ virtual BOOL SetSelected(int nSelected, BOOL bKeyboard = FALSE); /** * @brief * Call this member to get the currently selected control. * @return * Pointer to a CXTPControl object containing the currently * selected control. */ CXTPControl* GetSelected() const; /** * @brief * Call this member to pop-up the specified control. * @param nPopuped An integer index of the item to be popped. * @param bKeyboard TRUE if the item is popped by the keyboard. * @return * TRUE if the method was successful; otherwise FALSE. */ BOOL SetPopuped(int nPopuped, BOOL bKeyboard = FALSE); /** * @brief * Call this member to set a title for this command bar. * @param lpszTitle Title to be set. */ void SetTitle(LPCTSTR lpszTitle); /** * @brief * Call this member to get a title for this command bar. * @return * The title of the command bar. */ CString GetTitle() const; /** * @brief * Call this member to get the command bar's object. * @return * A CXTPCommandBars pointer (can be NULL). */ CXTPCommandBars* GetCommandBars() const; /** * @brief * Call this member to set the command bar's object. * @param pCommandBars CXTPCommandBars to be set. */ void SetCommandBars(CXTPCommandBars* pCommandBars); /** * @brief * Call this member to get the command bar's site. * @return * Command bar's site (cannot be NULL). */ CWnd* GetSite() const; void SetOwner(CWnd* pWnd); /** * @brief * Call this member to get the command bar's site as CFrameWnd. * @return * The command bar's site (can be NULL). */ CFrameWnd* GetFrameSite() const; /** * @brief * Call this member to set the command bar's flags. * @param dwFlagsAdd Flags to be added. * @param dwFlagsRemove Flags to be removed. * @details * dwFlagsAdd and dwFlagsRemove can be combination of XTPToolBarFlags and * XTPMenuBarFlags.
Use the bitwise-OR (|) operator to combine the flags. * xtpFlagAlignTop: Allows docking at the top of the client area. * xtpFlagAlignBottom: Allows docking at the bottom of the client area. * xtpFlagAlignLeft: Allows docking on the left side of the client area. * xtpFlagAlignRight: Allows docking on the right side of the client area. * xtpFlagAlignAny: Allows docking on any side of the client area. * xtpFlagFloating: Allows floating. * xtpFlagHideWrap: Allow to hide wrapped controls. * xtpFlagStretched: Bar is stretched. * xtpFlagStretchedShared: Bar is stretched, but does not fill a whole row. * xtpFlagSmartLayout: Smart layout is enabled. * xtpFlagHideMinimizeBox: To hide minimize box. * xtpFlagHideMaximizeBox: To hide maximize box. * xtpFlagIgnoreSetMenuMessage: To ignore MDI menus. * xtpFlagHideClose: To hide close button. * xtpFlagHideMDIButtons: Specifies to hide all MDI buttons displayed on the * Command Bar. * xtpFlagAddMDISysPopup: To add system MDI pop-up bar. Specifies to add * system MDI pop-up menu to the Menu Bar. This will * appear as an icon to the far left of the Menu Bar * and will display the MDI menu bar options when * clicked. * @see * XTPMenuBarFlags, XTPToolBarFlags */ void SetFlags(DWORD dwFlagsAdd, DWORD dwFlagsRemove = 0); /** * @brief * Call this member to set the controls from the button array. * @param pButtons Pointer to an array of command IDs. It cannot be NULL. * @param nCount Number of elements in the array pointed to by pButtons. * @return * Nonzero if successful; otherwise 0. * @see * LoadToolBar, LoadMenu. */ BOOL SetButtons(UINT* pButtons, int nCount); /** * @brief * Call this member function to load the toolbar specified by nIDResource. * @param nIDResource Resource ID of the toolbar to be loaded. * @param bLoadIcons TRUE if the toolbar icons are to be used by CXTPImageManager. * @return * Nonzero if successful; otherwise 0. * @see * LoadMenu, SetButtons. */ virtual BOOL LoadToolBar(UINT nIDResource, BOOL bLoadIcons = TRUE); /** * @brief * Call this function to set the size of the actual bitmapped * images to be added to a toolbar. * @param size Width and height, in pixels, of the toolbar's icons. */ void SetIconSize(CSize size); /** * @brief * Call this member function to get the size of the toolbar icon. * @return * The size of the toolbar icon. * @see * GetLargeIconSize */ virtual CSize GetIconSize() const; /** * @brief * Call this method to get the large icon size of the toolbar. * @param bAutoSize TRUE to adjust size using current DPI mode. * @return * CSize value containing the size of large toolbar icons. * @see * GetIconSize */ CSize GetLargeIconSize(BOOL bAutoSize) const; /** * @brief * Sets the size of the buttons in the command bar. * @param size Width and height, in pixels, of the buttons. * @details * The button size must always be at least as large as the bitmap * size it encloses. This function must be called only before adding * any bitmaps to the command bar. If the application does not explicitly * set the button size, it is set to the default size. */ void SetButtonSize(CSize size); /** * @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 to show the caption below control's icon. * @param bTextBelow TRUE to show the caption below the icon. */ void ShowTextBelowIcons(BOOL bTextBelow = TRUE); /** * @brief * Checks whether the caption is below the control's icon. * @return * TRUE if the caption is below the icon, otherwise FALSE. */ BOOL IsTextBelowIcons() const; /** * @brief * This method is called to pop-up the command bar. * @param pControlPopup Points to a CXTPControlPopup object. * @param bSelectFirst TRUE to select the first item. * @return * TRUE if successful, otherwise FALSE. */ virtual BOOL Popup(CXTPControlPopup* pControlPopup, BOOL bSelectFirst = FALSE); /** * @brief * Call this method to retrieve the current focused control. * @return * Window handle of the focused control. */ HWND GetTrackFocus() const; /** * @brief * Call this method to set focus to the window. * @param hwnd Window handle of the focused control */ void SetTrackFocus(HWND hwnd); /** * @brief * Call this method to set the visibility state of the control. * @param bVisible TRUE to set control visible. */ virtual void SetVisible(BOOL bVisible); /** * @brief * Returns a Boolean value indicating if the command bar is visible. * @return * TRUE if the command bar is visible; FALSE if the command bar is hidden. */ virtual BOOL IsVisible() const; /** * @brief * Call this member function to set the position of the command bar. * @param barPosition Position of the command bar. * @return * TRUE if successful; otherwise FALSE. */ virtual BOOL SetPosition(XTPBarPosition barPosition); /** * @brief * Call this method to get the index of the control with the specified * accelerator character. * @param chAccel Character to find. * @return * Index of the control with the specified accelerator character. */ int FindAccel(TCHAR chAccel) const; /** * @brief * Call this method to get the index of the control with the specified * accelerator character. * @param chAccel Character to find. * @param bSelectOnly TRUE to select only. * @return * Index of the control with the specified accelerator character. */ int FindAccelEx(UINT chAccel, BOOL& bSelectOnly) const; /** * @brief * Call this method to check if the command bars are in customize mode. * @return * TRUE if the command bars are in customize mode, otherwise FALSE. */ BOOL IsCustomizeMode() const; /** * @brief * This member is called when a control is entered into the * command bar. * @param pDataObject Pointer to a CXTPControl object. * @param point Point to test. * @return * DROPEFFECT enumerator. */ virtual DROPEFFECT OnCustomizeDragEnter(CXTPControl* pDataObject, CPoint point); /** * @brief * This method is called when a control leaves the command bar. */ virtual void OnCustomizeDragLeave(); /** * @brief * This member is called when control is over the command bar. * @param pDataObject Pointer to a CXTPControl object. * @param point Point to test. * @return * DROPEFFECT enumerator. */ virtual DROPEFFECT OnCustomizeDragOver(CXTPControl* pDataObject, CPoint point); /** * @brief * This method is called when a control is dropped to the command bar. * @param pDataObject Pointer to a CXTPControl object. * @param dropEffect DROPEFFECT enumerator. * @param ptDrop Point where the user dropped the control. * @param ptDrag Point where the user started dragging the control. */ virtual void OnCustomizeDrop(CXTPControl* pDataObject, DROPEFFECT& dropEffect, CPoint ptDrop, CPoint ptDrag); /** * @brief * Call this method to check if the command bar is customizable. * @return * TRUE if the command bar is customizable, otherwise FALSE. */ virtual BOOL IsCustomizable() const; /** * @brief * Call this method to check if the command bar is present in Customize dialog. * @return * TRUE if the command bar is present in Customize dialog, otherwise FALSE. */ BOOL IsCustomizeDialogPresent() const; /** * @brief * Call this method to enable/disable customization of the command bar. * @param bEnable TRUE to enable customization, FALSE to disable customization. */ void EnableCustomization(BOOL bEnable = TRUE); /** * @brief * This method is called to recalculate the command bar layout. */ virtual void OnRecalcLayout(); /** * @brief * Call this method to remove the tracking state of the command bar. */ virtual void OnTrackLost(); /** * @brief * Call this method to track the command bar. */ virtual void OnTrackEnter(); /** * @brief * Call this method to retrieve the owner window of the command bar. * @return * A pointer to a CWnd object. */ CWnd* GetOwnerSite() const; /** * @brief * Call this method to redraw all parent command bars. */ void InvalidateParents(); /** * @brief * Call this method to retrieve the current behavior modification * flags of the command bar. * @return * Flags of the command bar that are currently in effect. */ DWORD GetFlags() const; /** * @brief * Call this method to retrieve the identifier of the command bar. * @return * Identifier of the command bar. */ UINT GetBarID() const; /** * @brief * Call this method to set the identifier of the command bar. * @param nID Identifier to set. */ void SetBarID(UINT nID); /** * @brief * This method is called when a child control becomes selected. * @param bSelected TRUE when control becomes selected. * @param pControl Pointer to a CXTPControl object. */ virtual void OnControlSelected(BOOL bSelected, CXTPControl* pControl); /** * @brief * This method is called to set the description context. * @param strDescription Description string. * @return * TRUE if successful, otherwise FALSE */ BOOL SetStatusText(const CString& strDescription); /** * @brief * This method sets the 32-bit value associated with the command bar. * @param dwData Contains the new 32-bit value to associate with the command bar. * @see * GetCommandBarData */ void SetCommandBarData(DWORD_PTR dwData); /** * @brief * This method retrieves the application-supplied, 32-bit value * associated with the command bar. * @return * The 32-bit value associated with the command bar. * @see * SetCommandBarData */ DWORD_PTR GetCommandBarData() const; /** * @brief * This method retrieves the parent command bar. * @return * A pointer to a CXTPCommandBar object. */ virtual CXTPCommandBar* GetParentCommandBar() const; /** * @brief * Call this method to retrieve the top-level parent command bar. * @return * A pointer to the top-level CXTPCommandBar object. */ CXTPCommandBar* GetRootParent() 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 manager. * @return * A pointer to a CXTPImageManager object. */ CXTPImageManager* GetImageManager() const; /** * @brief * Call this member to set the width of the floated or pop-up toolbar. * @param nWidth Width of the floated or pop-up toolbar. */ void SetWidth(int nWidth); /** * @brief * Call this member to get the width of the floated or pop-up toolbar. * @return * The width, in pixels, of the floated or pop-up toolbar. */ int GetWidth() const; /** * @brief * Call this member to set the specified paint manager. * @param pPaintManager Pointer to a CXTPPaintManager object to be set. */ void SetPaintManager(CXTPPaintManager* pPaintManager); /** * @brief * Call this member to set the specified image manager. * @param pImageManager Pointer to a CXTPImageManager object to be set. */ void SetImageManager(CXTPImageManager* pImageManager); /** * @brief * Call this member function to determine if the command bar layout * is Right-to-Left (RTL). * @return * TRUE if the command bar layout is RTL, otherwise FALSE. */ BOOL IsLayoutRTL() const; /** * @brief * Call this member function to determine if the command bar is a * CXTPDialogBar. * @return * TRUE if the command bar is a CXTPDialogBar, otherwise FALSE. * @see * CXTPToolBar, CXTPDialogBar */ virtual BOOL IsDialogBar() const; /** * @brief * Call this member function to determine if the command bar is a * CXTPRibbonBar. * @return * TRUE if the command bar is a CXTPRibbonBar, otherwise FALSE. * @see * CXTPCommandBar, CXTPRibbonBar */ virtual BOOL IsRibbonBar() const; /** * @brief * Call this member function to determine if the command bar is a * CXTPMenuTitleBar. * @return * TRUE if the command bar is a CXTPMenuTitleBar, otherwise FALSE. * @see * CXTPCommandBar, CXTPMenuTitleBar */ virtual BOOL IsMenuTitleBar() const; /** * @brief * Call this member function to determine if the command bar is a * CXTPPopupBar. * @return * TRUE if the command bar is a CXTPPopupBar, otherwise FALSE. * @see * CXTPCommandBar, CXTPPopupBar */ virtual BOOL IsPopupBar() const; /** * @brief * 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 * Determines if underlines are visible in the command bar control. * * @return TRUE if underlines are visible in the command bar control, otherwise FALSE. */ virtual BOOL IsKeyboardCuesVisible() const; /** * @brief * This method is called internally to prevent the command bar from * grabbing edit focus. * @param bGrabFocus FALSE to prevent the command bar from grabbing edit focus. */ void SetGrabFocus(BOOL bGrabFocus); /** * @brief * The framework calls this member function to redraw the command bar. * @param lpRect The rectangular area of the bar that is invalid. * @param bAnimate TRUE to animate changes in the bounding rectangle. */ virtual void Redraw(LPCRECT lpRect = 0, BOOL bAnimate = TRUE); /** * @brief * This method is called to draw the command bar in the given context. * @param pDC Pointer to a valid device context. * @param rcClipBox The rectangular area of the control that is invalid. */ virtual void DrawCommandBar(CDC* pDC, CRect rcClipBox); /** * @brief * Call this method to enable animation for the command bar. * @param bEnable TRUE to enable animation, FALSE to disable. */ void EnableAnimation(BOOL bEnable = TRUE); /** * @brief * Call this method to enable double buffer for toolbar drawing. * @param bEnable TRUE to enable double buffer for toolbar drawing. * @see * EnableAnimation */ void EnableDoubleBuffer(BOOL bEnable = TRUE); /** * @brief * Determines if animation is enabled for the specified command bar. * @return * TRUE if animation is enabled, otherwise FALSE. * @see * EnableAnimation */ BOOL IsAnimationEnabled() const; /** * @brief * This member function is called by WindowProc, or is called during * message reflection. * @param hWnd Window handle message belongs to. * @param nMessage Specifies the message to be sent. * @param wParam Specifies additional message-dependent information. * @param lParam Specifies additional message-dependent information. * @param lResult The return value of WindowProc. Depends on the message; * may be NULL. * @return A non-zero value if a hooked message is processed, 0 otherwise. */ virtual int OnHookMessage(HWND hWnd, UINT nMessage, WPARAM& wParam, LPARAM& lParam, LRESULT& lResult); /** * @brief * Call this method to ensure that a specified control is visible on the toolbar. * @param pControl Pointer to the CXTPControl object whose visibility must be ensured. */ virtual void EnsureVisible(CXTPControl* pControl); /** * @brief * Call this method to retrieve the default button style of the command bar. * @return * XTPButtonStyle value representing the default button style. * @see * SetDefaultButtonStyle */ XTPButtonStyle GetDefaultButtonStyle() const; /** * @brief * Call this method to set the default button style of the command bar. * @param buttonStyle XTPButtonStyle value representing the default button style. * @see * GetDefaultButtonStyle */ void SetDefaultButtonStyle(XTPButtonStyle buttonStyle); /** * @brief * Call this method to freeze redrawing until UnlockRedraw is called. * @see * UnlockRedraw */ void LockRedraw(); /** * @brief * Call this method to unfreeze redrawing. * @see * LockRedraw */ void UnlockRedraw(); /** * @brief * Call this method to set the visibility of the command bar's gripper. * @param bShow TRUE to show the gripper, FALSE to hide the gripper. * @see * GetShowGripper */ void SetShowGripper(BOOL bShow); /** * @brief * Call this method to check if the command bar's gripper is visible. * @return * TRUE if the gripper is visible, otherwise FALSE. * @see * SetShowGripper */ BOOL GetShowGripper() const; /** * @brief * This method is called to get the border margins of the command bar. * @return * A CRect object containing the border margins of the command bar. */ virtual CRect GetBorders(); /** * @brief * This method is called to draw the background of the command bar. * @param pDC Pointer to the device context to draw. * @see * DrawCommandBar */ virtual void FillCommandBarEntry(CDC* pDC); /** * @brief * Specifies whether the pop-up gallery can be resized by the user. * @return * TRUE if the pop-up gallery can be resized by the user, otherwise FALSE. * @see * XTPGalleryResizable */ virtual BOOL IsResizable() const; public: /** * @brief * Call this method to check if keyboard tips are visible for the command bar. * @return * TRUE if keyboard tips are visible for the command bar, otherwise FALSE. * @see * CreateKeyboardTips */ BOOL IsKeyboardTipsVisible() const; /** * @brief * This method is called to create a keyboard tips collection for the command bar. * @see * IsKeyboardTipsVisible */ virtual void CreateKeyboardTips(); /** * @brief * This method is called when the user presses a key while keyboard tips are visible. * @param chAccel Virtual key. * @see * OnKeyboardTip */ void OnKeyboardTipChar(UINT chAccel); /** * @brief * This method is called when a keyboard tip is found for the command bar. * @param pTip Keyboard tip that was found for the commandbar. * @see * OnKeyboardTipChar */ virtual void OnKeyboardTip(CXTPCommandBarKeyboardTip* pTip); /** * @brief * Call this method to hide keyboard tips. * @see * IsKeyboardTipsVisible */ void HideKeyboardTips(); /** * @brief * Locks the mouse cursor for a specified control. * @param pControl Pointer to a CXTPControl object. */ void LockMouseMove(CXTPControl* pControl); /** * @brief * Unlocks the mouse cursor. */ void UnlockMouseMove(); protected: /** * @brief * The framework calls this member function 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 returns FALSE. */ virtual BOOL OnHookKeyDown(UINT nChar, LPARAM lParam); /** * @brief * This method is called to get the size of the command bar. * @param nLength The requested dimension of the control bar, either * horizontal or vertical depending on dwMode. * @param dwMode See CControlBar::CalcDynamicLayout for the list of * supported flags. * @return * The size of the command bar. */ virtual CSize CalcDynamicLayout(int nLength, DWORD dwMode); /** * @brief * This method is called to process special keys. * @param key Special keys enumerator. Can be any of the values listed in * the Remarks section. * @details * CXTPCommandBar maps key passed as parameter of OnKeyDown to XTPSpecialKey * enumerator and call ProcessSpecialKey. The key parameter can be one * of the following: * xtpKeyNext: Indicates that the RIGHT or DOWN key was pressed. * Next control must be selected. * xtpKeyPrev: Indicates that the LEFT or UP key was pressed. * Previous control must be selected. * xtpKeyBack: Indicates that the LEFT key was pressed for pop-up bar. * Current sub-menu must be closed. * xtpKeyPopup: Indicates that the RIGHT key was pressed for pop-up bar. * Sub-menu must be opened. * xtpKeyEscape: Indicates that the ESCAPE key was pressed. * xtpKeyReturn: Indicates that the RETURN key was pressed. * xtpKeyHome: Indicates that the HOME key was pressed. * First control must be selected. * xtpKeyEnd: Indicates that the END key was pressed. * Last control must be selected. * @return * TRUE if the key was handled, otherwise FALSE. */ virtual BOOL ProcessSpecialKey(XTPSpecialKey key); /** * @brief * This method is called when the controls array is changed. */ virtual void OnControlsChanged(); /** * @brief * This method makes a copy of the command bar. * @param pCommandBar Command bar to be copied. * @param bRecursive TRUE to copy recursively. */ virtual void Copy(CXTPCommandBar* pCommandBar, BOOL bRecursive = FALSE); /** * @brief * This method is called to determine mouse hit code. * @param pt Position to test. * @return * HTCLIENT if the pointer belongs to the client area, otherwise HTNOWHERE. */ virtual int OnMouseHitTest(CPoint pt); /** * @brief * Updates the control's shortcuts. */ virtual void UpdateShortcuts(); public: BOOL IsDwmEnabled() const; protected: /** * @brief * Retrieves the active MDI document template. * @details * This method calls CXTPCommandBars::GetActiveDocTemplate. * @return * Active document template identifier. * @see * CXTPCommandBars::GetActiveDocTemplate */ UINT GetActiveDocTemplate() const; protected: /** * @brief * This method is called to assign self identifiers for the serialization process. * @param nID Identifier to assign. * @param pCommandBarList List of CommandBars. * @param pParam Address of a XTP_COMMANDBARS_PROPEXCHANGE_PARAM structure. */ virtual void GenerateCommandBarList(DWORD& nID, CXTPCommandBarList* pCommandBarList, XTP_COMMANDBARS_PROPEXCHANGE_PARAM* pParam); /** * @brief * This method is called in the serialization process to restore pop-ups * from a list of command bars. * @param pCommandBarList List of command bars. */ virtual void RestoreCommandBarList(CXTPCommandBarList* pCommandBarList); /** * @brief * Determines if the parent frame is in help mode. * @return True if it's in help mode. false otherwise */ BOOL IsHelpMode() const; /** * @brief * This method is called when a toolbar is removed from the command bars collection. */ virtual void OnRemoved(); virtual BOOL IsControlEnabled(const CXTPControl* pControl) const; protected: /** @cond */ virtual void OnPaintManagerDestroyed(CXTPPaintManager* pPaintManager); virtual void CustomizeFindDropIndex(CXTPControl* pDataObject, const CPoint& point, CRect& rcMarker, int& nDropIndex, BOOL& bDropAfter); void CustomizeDrawMarker(CDC* pDC); void UpdateDocTemplateControls(); BOOL IsMouseLocked() const; CSize GetAutoIconSize(BOOL bLarge) const; /** @endcond */ protected: /** @cond */ // System accessibility support. virtual HRESULT GetAccessibleParent(IDispatch** ppdispParent); 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(); /** @endcond */ protected: /** @cond */ //{{AFX_VIRTUAL(CXTPCommandBar) public: virtual void OnFinalRelease(); virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const; BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult); virtual LRESULT OnIdleUpdateCmdUI(WPARAM wParam, LPARAM); void FilterToolTipMessage(UINT message, WPARAM wParam, LPARAM lParam); virtual BOOL PreviewAccel(UINT chAccel); //}}AFX_VIRTUAL //{{AFX_MSG(CXTPCommandBar) afx_msg void OnUpdateCmdUI(); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnInitialUpdate(); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnRButtonUp(UINT nFlags, CPoint point); virtual void OnPopupRButtonUp(CXTPCommandBar* pCommandBar, CPoint point); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnMouseLeave(); afx_msg void OnPaint(); afx_msg LRESULT OnPrintClient(WPARAM wParam, LPARAM); afx_msg void OnTimer(UINT_PTR nIDEvent); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnDestroy(); afx_msg void OnRButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); afx_msg LRESULT OnHelpHitTest(WPARAM, LPARAM lParam); afx_msg LRESULT OnNcHitTest(CPoint point); afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point); afx_msg LRESULT OnGetObject(WPARAM wParam, LPARAM lParam); //}}AFX_MSG /** @endcond */ public: int m_nStateFlags; /**< State of the command bars. */ static int s_nHoverDelay; /**< Hover delay time */ static int s_nExpandDelay; /**< Expand delay time */ static int s_nExpandHoverDelay; /**< Expand hover delay */ BOOL m_bComboBar; /**< TRUE if it is combobox list */ BOOL m_bTrackOnHover; /**< TRUE to select item if mouse stay over control */ protected: BOOL m_bGrabFocus; /**< TRUE to grab current focus. */ int m_nMRUWidth; /**< Recent width. */ int m_nSelected; /**< Selected control index. */ int m_nPopuped; /**< Pop-up'ed control index. */ HWND m_hwndFocus; /**< The handle of the window that currently has focus. */ UINT m_nBarID; /**< Command bar's identifier. */ BOOL m_bTracking; /**< TRUE if the command bar is in tracking mode. */ CWnd* m_pSite; /**< Command bar's site. */ DWORD m_nIdleFlags; /**< Idle flags. */ DWORD m_dwFlags; /**< Command bar's flags. */ DWORD m_dwStyle; /**< Command bar's styles. */ CString m_strTitle; /**< Command bar's caption. */ XTPBarType m_barType; /**< Type of the command bar. */ CXTPControls* m_pControls; /**< A pointer to controls collection. */ XTPBarPosition m_barPosition; /**< Position of the command bar. */ CXTPCommandBars* m_pCommandBars; /**< parent command bars class. */ CWnd* m_pOwner; /**< Owner window. */ CSize m_szIcons; /**< Size of the command bar's icons. */ CSize m_szButtons; /**< Size of the command bar's buttons. */ BOOL m_bTextBelow; /**< TRUE if text is shown below the CommandBar buttons. */ BOOL m_bExecOnRButton; /**< TRUE if the control button is executed on a right-click */ BOOL m_bIgnoreUpdateHandler; /**< TRUE to skip update handler for all child controls */ BOOL m_bRecursePopup; /**< TRUE if pop-up bar was opened recursively. See TPM_RECURSE flag description. */ int m_nLockRecurse; // TRUE if another pop-up bar is opened recursively. BOOL m_bKeyboardSelect; /**< TRUE if last item was selected by keyboard. */ BOOL m_bCloseable; /**< TRUE if the CommandBar can be closed and-or Hidden */ BOOL m_bCustomizable; /**< TRUE if command bar is customizable. */ CRect m_rcMarker; /**< Marker position. */ BOOL m_bVerticalMarker; /**< TRUE to draw marker vertically. */ DWORD_PTR m_dwData; /**< The 32-bit value associated with the command bar. */ UINT* m_pReturnCmd; /**< Return command holder. */ BOOL m_bCustomizeDialogPresent; /**< TRUE if the command bar is present in Customize dialog. */ BOOL m_bAnimatePopup; /**< TRUE to animate pop-up bar. */ BOOL m_nLockRedraw; /**< TRUE if all drawing routines skipped */ CXTPPaintManager* m_pPaintManager; /**< Selected paint manager for command bar */ CXTPImageManager* m_pImageManager; /**< Selected image manager for command bar */ BOOL m_bMultiLine; /**< True if multi line commandbar */ XTPButtonStyle m_buttonStyle; /**< Default button Style */ XTPBarTextOrientation m_nTextOrientation; /**< Commandbar text orientation. */ CXTPControl* m_pMouseMoveLockControl; CXTPToolTipContext* m_pToolTipContext; /**< Tool tip Context. */ CXTPCommandBarAnimation* m_pAnimation; /**< Animation context */ CSize m_szButtonSpacing; /**< Spacing used between toolbar buttons */ private: int m_nClickedControl; /** @cond */ DECLARE_MESSAGE_MAP() DECLARE_XTP_COMMANDBAR(CXTPCommandBar) class CCommandBarCmdUI; DECLARE_INTERFACE_MAP() XTP_DECLARE_CMDTARGETPROVIDER_INTERFACE() # ifdef _XTP_COMMANDBARS_ACTIVEX DECLARE_DISPATCH_MAP() DECLARE_OLETYPELIB_EX(CXTPCommandBar); afx_msg LPDISPATCH OleControls(); afx_msg long OleGetType(); afx_msg LPDISPATCH OleGetCommandBars(); afx_msg long OleGetPosition(); afx_msg void OleSetPosition(long); afx_msg long OleShowPopup(const VARIANT& Flags, const VARIANT& x, const VARIANT& y); afx_msg void OleSetIconSize(long cx, long cy); afx_msg int OleGetIconWidth(); afx_msg int OleGetIconHeight(); afx_msg void OleEnableDocking(long dwFlags); afx_msg void OleSetTearOffPopup(LPCTSTR strCaption, long nID, long nWidth); afx_msg LPDISPATCH OleFindControl(const VARIANT& varType, const VARIANT& nId, const VARIANT& bVisible, const VARIANT& bRecursive); afx_msg LPDISPATCH OleParent(); afx_msg BOOL OleBuiltIn(); afx_msg void OleModifyStyle(long dwRemove, long dwAdd); afx_msg void OleGetWindowRect(long* pLeft, long* pTop, long* pRight, long* pBottom); afx_msg void OleSetPopupToolBar(BOOL bToolBarType); afx_msg LPDISPATCH OleGetControlPopup(); afx_msg BOOL OleGetCustomizable(); afx_msg void OleSetCustomizable(BOOL); afx_msg void OleRedrawBar(); afx_msg void OleRecalcLayout(); afx_msg void OleSetSelectedControl(LPDISPATCH); afx_msg LPDISPATCH OleGetSelectedControl(); afx_msg HWND OleGetHandle(); afx_msg BOOL OleGetVisible(); afx_msg void OleSetVisible(BOOL bVisible); public: void OlePixelToUnits(CRect& rc); void OleUnitsToPixel(CPoint& pt); BOOL m_bAutoMenuLoad; void OleFireTrackingModeChanged(int bMode); enum { dispidTitle = 1L, dispidControls = 2L, dispidType = 3L, dispidVisible = 4L, dispidPosition = 5L, dispidShowPopup = 6L, dispidSetIconSize = 7L, dispidEnableDocking = 8L, dispidSetTearOffPopup = 9L, dispidBarID = 10L, dispidFindControl = 11L, dispidParent = 12L, dispidBuiltIn = 13L, dispidDelete = 14L, dispidModifyStyle = 16L, dispidGetWindowRect = 17L, dispidSetFlags = 18L }; public: static CXTPCommandBar* AFX_CDECL FromDispatch(LPDISPATCH pDisp); # endif /*_XTP_COMMANDBARS_ACTIVEX*/ friend class CXTPCommandBars; friend class CXTPDockBar; friend class CCommandBarCmdUI; friend class CXTPControl; friend class CXTPControls; friend class CXTPControlPopup; friend class CXTPToolBar; friend class CXTPMouseManager; friend class CXTPPopupBar; friend class CXTPCustomizeSheet; friend class CXTPPaintManager; friend class CXTPMiniToolBar; /** @endcond */ }; ////////////////////////////////////////////////////////////////////////// AFX_INLINE int CXTPCommandBar::IsTrackingMode() const { return m_bTracking; } AFX_INLINE CXTPControls* CXTPCommandBar::GetControls() const { return m_pControls; } AFX_INLINE XTPBarType CXTPCommandBar::GetType() const { return m_barType; } AFX_INLINE XTPBarPosition CXTPCommandBar::GetPosition() const { return m_barPosition; } AFX_INLINE void CXTPCommandBar::DelayLayout() { m_nIdleFlags |= xtpIdleLayout; } # ifndef _XTP_COMMANDBARS_ACTIVEX AFX_INLINE void CXTPCommandBar::DelayRedraw() { m_nIdleFlags |= xtpIdleRedraw; } # endif # ifdef _XTP_COMMANDBARS_ACTIVEX /** @cond */ AFX_INLINE void CXTPCommandBar::DelayRedraw() { Redraw(); } /** @endcond */ # endif AFX_INLINE void CXTPCommandBar::SetTitle(LPCTSTR lpszTitle) { m_strTitle = lpszTitle; Redraw(); } AFX_INLINE CString CXTPCommandBar::GetTitle() const { return m_strTitle; } AFX_INLINE void CXTPCommandBar::SetCommandBars(CXTPCommandBars* pCommandBars) { m_pCommandBars = pCommandBars; } AFX_INLINE HWND CXTPCommandBar::GetTrackFocus() const { return m_hwndFocus; } AFX_INLINE void CXTPCommandBar::SetTrackFocus(HWND hwnd) { m_hwndFocus = hwnd; } AFX_INLINE void CXTPCommandBar::SetVisible(BOOL /*bVisible*/) { } AFX_INLINE BOOL CXTPCommandBar::IsVisible() const { return FALSE; } AFX_INLINE BOOL CXTPCommandBar::SetPosition(XTPBarPosition /*barPosition*/) { return FALSE; } AFX_INLINE CSize CXTPCommandBar::CalcDynamicLayout(int, DWORD /*nMode*/) { return CSize(0, 0); } AFX_INLINE CXTPCommandBar* CXTPCommandBar::GetParentCommandBar() const { return NULL; } AFX_INLINE void CXTPCommandBar::OnRecalcLayout() { } AFX_INLINE BOOL CXTPCommandBar::IsCustomizable() const { return m_bCustomizable; } AFX_INLINE BOOL CXTPCommandBar::IsCustomizeDialogPresent() const { return m_bCustomizeDialogPresent; } AFX_INLINE BOOL CXTPCommandBar::IsDialogBar() const { return FALSE; } AFX_INLINE void CXTPCommandBar::EnableCustomization(BOOL bEnable) { if (!IsDialogBar()) m_bCustomizable = bEnable; } AFX_INLINE void CXTPCommandBar::SetIconSize(CSize size) { m_szIcons = size; } AFX_INLINE void CXTPCommandBar::SetButtonSize(CSize size) { m_szButtons = size; } AFX_INLINE DWORD CXTPCommandBar::GetFlags() const { return m_dwFlags; } AFX_INLINE UINT CXTPCommandBar::GetBarID() const { return m_nBarID; } AFX_INLINE void CXTPCommandBar::SetCommandBarData(DWORD_PTR dwData) { m_dwData = dwData; } AFX_INLINE DWORD_PTR CXTPCommandBar::GetCommandBarData() const { return m_dwData; } AFX_INLINE void CXTPCommandBar::LockRedraw() { m_nLockRedraw++; } AFX_INLINE void CXTPCommandBar::UnlockRedraw() { m_nLockRedraw--; if (m_nLockRedraw == 0 && (m_nIdleFlags & xtpIdleRedraw)) Redraw(); } AFX_INLINE void CXTPCommandBar::SetGrabFocus(BOOL bGrabFocus) { m_bGrabFocus = bGrabFocus; } /** @cond */ AFX_INLINE BOOL CXTPCommandBar::PreviewAccel(UINT) { return FALSE; } /** @endcond */ AFX_INLINE BOOL CXTPCommandBar::IsRibbonBar() const { return FALSE; } AFX_INLINE BOOL CXTPCommandBar::IsMenuTitleBar() const { return FALSE; } AFX_INLINE BOOL CXTPCommandBar::IsPopupBar() const { return FALSE; } AFX_INLINE void CXTPCommandBar::SetBarID(UINT nID) { m_nBarID = nID; } AFX_INLINE XTPButtonStyle CXTPCommandBar::GetDefaultButtonStyle() const { return m_buttonStyle; } AFX_INLINE void CXTPCommandBar::SetDefaultButtonStyle(XTPButtonStyle buttonStyle) { m_buttonStyle = buttonStyle; } AFX_INLINE BOOL CXTPCommandBar::IsResizable() const { return FALSE; } /** @cond */ AFX_INLINE void CXTPCommandBar::OnPopupRButtonUp(CXTPCommandBar* /*pCommandBar*/, CPoint /*point*/) { } /** @endcond */ AFX_INLINE CXTPControl* CXTPCommandBar::GetSelected() const { return GetControl(m_nSelected); } AFX_INLINE void CXTPCommandBar::SetTextOrientation(XTPBarTextOrientation nTextOrientation) { m_nTextOrientation = nTextOrientation; DelayLayout(); } AFX_INLINE XTPBarTextOrientation CXTPCommandBar::GetTextOrientation() const { return m_nTextOrientation; } AFX_INLINE void CXTPCommandBar::SetOwner(CWnd* pWnd) { m_pOwner = pWnd; } AFX_INLINE BOOL CXTPCommandBar::IsControlEnabled(const CXTPControl* /*pControl*/) const { return (BOOL)-1; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPCOMMANDBAR_H__) /** @endcond */