/** * @file XTPCommandBars.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(__XTPCOMMANDBARS_H__) # define __XTPCOMMANDBARS_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPDockBar; class CXTPToolBar; class CXTPControl; class CXTPPopupBar; class CXTPDockState; class CXTPCommandBar; class CXTPCustomizeDropSource; class CXTPCommandBars; class CXTPCommandBarList; class CXTPImageManager; class CXTPPaintManager; class CXTPControls; class CXTPMenuBar; class CXTPMenuTitleBar; class CXTPReBar; class CXTPToolTipContext; class CXTPShortcutManager; class CXTPKeyboardManager; class CXTPStatusBar; class CXTPMouseManager; class CXTPControlActions; class CXTPControlAction; class CXTPPropExchange; class CXTPCommandBarsFrameHook; class CXTPRecentFileList; class CXTPCommandBarsOptions; class CXTPCommandBarsContextMenus; class CXTPCommandBarKeyboardTip; /** * @brief * XTP_COMMANDBARS_PROPEXCHANGE_PARAM is a * structure used to store the CommandBar's save settings. This is * a set of State options that will be used to change how and what * will be saved and loaded when loading and saving XML files. * @details * When saving your XML string to a file, be sure to use the .XML * file extension. If you open up your .XML file in your favorite * web browser it will automatically format the XML string into the * correct format. * * Example: *
* XTP_COMMANDBARS_PROPEXCHANGE_PARAM param;
* param.bSerializeControls = TRUE;
* // Serialize to XML
* CXTPPropExchangeXMLNode px(FALSE, 0, _T("Settings"));
* CXTPPropExchangeSection pxCommandBars(px.GetSection(_T("CommandBars")));
* GetCommandBars()->DoPropExchange(&pxCommandBars, ¶m);
* px.SaveToFile(m_strIniFileName);
*
* @see
* CXTPCommandBars::DoPropExchange, CXTPPropExchangeXMLNode
*/
struct XTP_COMMANDBARS_PROPEXCHANGE_PARAM
{
/** @cond */
/**
* @brief
* Creates a XTP_COMMANDBARS_PROPEXCHANGE_PARAM object which is a
* structure used to store the CommandBar's save settings. This is
* a set of State options that will be used to change how and what
* will be saved and loaded when loading and saving XML files.
* The CXTPPropExchangeXMLNode class is used to create the XML file.
* @details
* When saving your XML string to a file, be sure to use the .XML
* file extension. If you open up your .XML file in your favorite
* web browser it will automatically format the XML string into the
* correct format.
* @see CXTPCommandBars::DoPropExchange, CXTPPropExchangeXMLNode
*/
XTP_COMMANDBARS_PROPEXCHANGE_PARAM()
{
pCommandBars = NULL;
bSerializeControls = FALSE;
bSaveOnlyCustomized = TRUE;
bLoadSilent = FALSE;
bSaveOriginalControls = TRUE;
bSerializeLayout = TRUE;
bSerializeOptions = FALSE;
bSerializeImages = FALSE;
bSerializeDesignerControls = FALSE;
bSerializeActions = FALSE;
}
/** @endcond */
BOOL bSerializeControls; /**< If TRUE, the controls in the CommandBars will be saved. If FALSE,
no controls will be saved, regardless of the other settings. The
default is TRUE. */
BOOL bSaveOnlyCustomized; /**< If TRUE, only CommandBars that have been customized will be
saved. The default is TRUE. */
BOOL bLoadSilent; /**< If TRUE, no message boxes will be displayed when the CommandBar layout is
loaded. i.e. The message box that asks for conformation before the
CommandBar layout is reset. */
BOOL bSaveOriginalControls; /**< If TRUE, the original state of the CommandBars is saved along
with the customized state. For example, if a button on a
toolbar is moved, then both the original and modified states will
be saved. The Default is TRUE. */
BOOL bSerializeImages; /**< If TRUE, the images stored in the ImageManager will be saved. The
default is FALSE. */
BOOL bSerializeOptions; /**< If TRUE, the setting on the Keyboard and Options pages of the
Customize dialog will be saved. This includes shortcut keys and
CommandBar options like large icons and full menus. The default is
FALSE. */
BOOL bSerializeLayout; /**< If TRUE, the layout of the CommandBars will be saved. The Layout
includes information such as bar position, location, and size. The
Default is TRUE. */
BOOL bSerializeDesignerControls; /**< In the CommandBar Designer you can export a XCB file to a
XML file and Load it in your project. If
SerializeDesignerControls is TRUE, then the
DesignerControls property will be filled with Control items
from the CommandBar Designer's controls pane. This allows
you to load the XML file instead of loading the XCB file
using the LoadDesignerBars method. NOTE: DesignerControls
are the controls displayed in the customization dialog. The
CXTPPropExchangeXMLNode class is used to create the XML
file. The default is FALSE.*/
BOOL bSerializeActions; /**< TRUE to save/restore actions for commandbars */
CXTPCommandBars* pCommandBars; /**< Pointer to the CommandBars object that the
XTP_COMMANDBARS_PROPEXCHANGE_PARAM setting apply to. */
};
/**
* @brief
* CXTPCommandBars is a standalone class. It allows developers to manipulate
* toolbars and pop-up bars.
* @see
* CXTPCommandBar, CXTPToolBar, CXTPCommandBarsOptions
*/
class _XTP_EXT_CLASS CXTPCommandBars
: public CXTPCmdTarget
, private IXTPApplicationEvents
{
protected:
/**
* @brief
* Constructs a CXTPCommandBars object.
*/
CXTPCommandBars();
/**
* @brief
* Destroys a CXTPCommandBars object, handles cleanup and deallocation.
*/
virtual ~CXTPCommandBars();
public:
/**
* @brief
* Call this member to create a title menu bar.
* @param lpszName Title of the title menu bar.
* @param nID Menu identifier to be loaded.
* @return
* A CXTPMenuTitleBar object if successful; otherwise NULL.
* @see
* Add
*/
CXTPMenuTitleBar* SetMenuTitleBar(LPCTSTR strName, UINT nID, INT nIconID = -1);
/**
* @brief
* Call this member to get the title menu bar.
* @return
* A CXTPMenuTitleBar pointer associated with the title menu bar.
*/
CXTPMenuTitleBar* GetMenuTitleBar() const;
/**
* @brief
* Call this member to create a menu bar.
* @param lpszName Title of the menu bar.
* @param nID Menu identifier to be loaded.
* @return
* A CXTPMenuBar object if successful; otherwise NULL.
* @see
* Add
*/
CXTPMenuBar* SetMenu(LPCTSTR lpszName, UINT nID);
/**
* @brief
* Call this member to add a new toolbar.
* @param lpszName Title of the toolbar.
* @param nBarPosition Position of toolbar to be created.
* @param pToolbarClass Runtime class of toolbar to create
* @details
* CommandBars will create a new toolbar with pToolbarClass runtime class
* if it specified. If not, then m_pToolBarClass will be used.
* Call SetToolBarClass to set the default runtime class for toolbars.
* @return
* A CXTPToolBar object if successful; otherwise NULL.
* @see
* SetMenu, SetToolBarClass
*/
CXTPToolBar* Add(LPCTSTR lpszName, XTPBarPosition nBarPosition,
CRuntimeClass* pToolbarClass = NULL);
/**
* @brief
* Call this member to add a new toolbar.
* @param strName Attribute name.
* @param nBarPosition Position of toolbar to be created.
* @param pToolBar Pointer to a CXTPToolBar object.
* @details
* CommandBars will create a new toolbar with pToolbarClass runtime class
* if it specified. If not, then m_pToolBarClass will be used.
* Call SetToolBarClass to set the default runtime class for toolbars.
* @return
* A CXTPToolBar object if successful; otherwise NULL.
* @see
* SetMenu, SetToolBarClass
*/
CXTPToolBar* Add(CXTPToolBar* pToolBar, LPCTSTR strName, XTPBarPosition nBarPosition);
/**
* @brief
* Call this member to get the active menu bar.
* @return
* A CXTPMenuBar pointer associated with the menu bar.
*/
virtual CXTPMenuBar* GetMenuBar() const;
/**
* @brief
* Call this member to get the toolbar with the specified identifier.
* @param nID An integer identifier.
* @return
* The CXTPToolBar pointer.
*/
CXTPToolBar* GetToolBar(UINT nID) const;
/**
* @brief
* Call this member to get the site of the command bars.
* @return
* A CFrameWnd pointer representing the site of the command bars.
*/
CWnd* GetSite() const;
/**
* @brief
* Call this member to get the dock bar at the specified position.
* @param barPosition Position of the dockbar.
* @return
* A CXTPDockBar pointer.
*/
CXTPDockBar* GetDockBar(XTPBarPosition barPosition) const;
/**
* @brief
* Call this member to redraw the command bars.
*/
void RedrawCommandBars();
/**
* @brief
* Call this member to invalidate the command bars.
*/
void InvalidateCommandBars();
/**
* @brief
* Call this member to recalculate site layout.
* @param bDelay TRUE to delay dock site layout until remaining framework
* items have been initialized completely.
*/
virtual void RecalcFrameLayout(BOOL bDelay = FALSE);
/**
* @brief
* Call this member to find the specified control.
* @param type Type of the control to find.
* @param nId Control's identifier.
* @param bVisible Control's visibility.
* @param bRecursive To find in the nested command bars.
* @return
* The CXTPControl object if successful; otherwise NULL.
*/
CXTPControl* FindControl(XTPControlType type, UINT nId, BOOL bVisible, BOOL bRecursive) const;
/**
* @brief
* Call this member to display a floating pop-up menu at the
* specified location.
* @param pMenu Menu to be popped up.
* @param nFlags Reserved, currently not used.
* @param xPos Specifies the horizontal position in screen coordinates
* of the pop-up menu.
* @param yPos Specifies the vertical position in screen coordinates of
* the top of the menu on the screen.
* @param pWnd Identifies the window that owns the pop-up menu. This
* window receives all WM_COMMAND messages from the menu.
* @param rcExclude Reserved, currently not used.
* @param pWndOwner Pointer to a CWnd object.
* @param pCommandBars Pointer to a CXTPCommandBars object.
* screen the menu should not overlap. This parameter can be NULL.
* @return
* TRUE if successful; otherwise FALSE.
*
* Example:
*
* void CCustomThemesView::OnRButtonDown(UINT nFlags, CPoint point)
* {
* ClientToScreen(&point);
*
* CMenu menu;
* VERIFY(XTPResourceManager()->LoadMenu(&menu, IDR_MAINFRAME));
*
* // get a pointer to the application window.
* CXTPMDIFrameWnd* pMainWnd = DYNAMIC_DOWNCAST(
* CXTPMDIFrameWnd, AfxGetMainWnd());
*
* if (!pMainWnd)
* return;
*
* // get a pointer to the CXTPCommandBars object.
* CXTPCommandBars* pCommandBars = pMainWnd-\>GetCommandBars();
*
* if (!pCommandBars)
* return;
*
* // display context menu.
* CXTPCommandBars::TrackPopupMenu(&menu, TPM_RIGHTBUTTON,
* point.x, point.y, pMainWnd, 0, 0, pCommandBars);
* }
*
*/
static BOOL AFX_CDECL TrackPopupMenu(CMenu* pMenu, UINT nFlags, int xPos, int yPos, CWnd* pWnd,
LPCRECT rcExclude = NULL, CWnd* pWndOwner = NULL,
CXTPCommandBars* pCommandBars = NULL);
/**
* @brief
* Call this member to display a floating pop-up menu at the
* specified location.
* @param nFlags Reserved, currently not used.
* @param xPos Specifies the horizontal position in screen coordinates
* of the pop-up menu.
* @param yPos Specifies the vertical position in screen coordinates of
* the top of the menu on the screen.
* @param pPopupBar Pointer to a CXTPPopupBar object.
* @param pWnd Identifies the window that owns the pop-up menu. This
* window receives all WM_COMMAND messages from the menu.
* @param rcExclude Reserved, currently not used.
* @param pWndOwner Pointer to a CWnd object.
* screen the menu should not overlap. This parameter can be NULL.
* @return
* TRUE if successful; otherwise FALSE.
*
* Example:
*
* void CCustomThemesView::OnRButtonDown(UINT nFlags, CPoint point)
* {
* ClientToScreen(&point);
*
* CMenu menu;
* VERIFY(XTPResourceManager()->LoadMenu(&menu, IDR_MAINFRAME));
*
* // get a pointer to the application window.
* CXTPMDIFrameWnd* pMainWnd = DYNAMIC_DOWNCAST(
* CXTPMDIFrameWnd, AfxGetMainWnd());
*
* if (!pMainWnd)
* return;
*
* // get a pointer to the CXTPCommandBars object.
* CXTPCommandBars* pCommandBars = pMainWnd-\>GetCommandBars();
*
* if (!pCommandBars)
* return;
*
* // display context menu.
* CXTPCommandBars::TrackPopupMenu(&menu, TPM_RIGHTBUTTON,
* point.x, point.y, pMainWnd, 0, 0, pCommandBars);
* }
*
*/
static BOOL AFX_CDECL TrackPopupMenu(CXTPPopupBar* pPopupBar, UINT nFlags, int xPos, int yPos,
CWnd* pWnd, LPCRECT rcExclude = NULL,
CWnd* pWndOwner = NULL);
/**
* @brief
* Call this member to display a floating pop-up menu at the
* specified location.
* @param nFlags Reserved, currently not used.
* @param xPos Specifies the horizontal position in screen coordinates
* of the pop-up menu.
* @param yPos Specifies the vertical position in screen coordinates of
* the top of the menu on the screen.
* @param rcExclude Reserved, currently not used.
* @param nBarID Identifier CommandBar to track.
* @return
* TRUE if successful; otherwise FALSE.
*
* Example:
*
* void CCustomThemesView::OnRButtonDown(UINT nFlags, CPoint point)
* {
* ClientToScreen(&point);
*
* CMenu menu;
* VERIFY(XTPResourceManager()->LoadMenu(&menu, IDR_MAINFRAME));
*
* // get a pointer to the application window.
* CXTPMDIFrameWnd* pMainWnd = DYNAMIC_DOWNCAST(
* CXTPMDIFrameWnd, AfxGetMainWnd());
*
* if (!pMainWnd)
* return;
*
* // get a pointer to the CXTPCommandBars object.
* CXTPCommandBars* pCommandBars = pMainWnd-\>GetCommandBars();
*
* if (!pCommandBars)
* return;
*
* // display context menu.
* CXTPCommandBars::TrackPopupMenu(&menu, TPM_RIGHTBUTTON,
* point.x, point.y, pMainWnd, 0, 0, pCommandBars);
* }
*
*/
BOOL TrackPopupMenu(UINT nBarID, UINT nFlags, int xPos, int yPos, LPCRECT rcExclude = NULL);
/**
* @brief
* Call this member to display a floating pop-up menu at the
* specified location.
* @param pMenu Menu to be popped up.
* @param nFlags Reserved, currently not used.
* @param xPos Specifies the horizontal position in screen coordinates
* of the pop-up menu.
* @param yPos Specifies the vertical position in screen coordinates of
* the top of the menu on the screen.
* @param pWndOwner Pointer to a CWnd object.
* @param lptpm Pointer to a TPMPARAMS structure that specifies an area of the
* screen the menu should not overlap. This parameter can be NULL.
* @return
* TRUE if successful; otherwise FALSE.
*
* Example:
*
* void CCustomThemesView::OnRButtonDown(UINT nFlags, CPoint point)
* {
* ClientToScreen(&point);
*
* CMenu menu;
* VERIFY(XTPResourceManager()->LoadMenu(&menu, IDR_MAINFRAME));
*
* // get a pointer to the application window.
* CXTPMDIFrameWnd* pMainWnd = DYNAMIC_DOWNCAST(
* CXTPMDIFrameWnd, AfxGetMainWnd());
*
* if (!pMainWnd)
* return;
*
* // get a pointer to the CXTPCommandBars object.
* CXTPCommandBars* pCommandBars = pMainWnd-\>GetCommandBars();
*
* if (!pCommandBars)
* return;
*
* // display context menu.
* CXTPCommandBars::TrackPopupMenu(&menu, TPM_RIGHTBUTTON,
* point.x, point.y, pMainWnd, 0, 0, pCommandBars);
* }
*
*/
BOOL TrackPopupMenuEx(CMenu* pMenu, UINT nFlags, int xPos, int yPos, CWnd* pWndOwner = NULL,
LPTPMPARAMS lptpm = NULL);
/**
* @brief
* Retrieves list of available context menus.
* @return
* Command Bars context menus.
*/
CXTPCommandBarsContextMenus* GetContextMenus() const;
/**
* @brief
* Call this member to retrieve the options of the command bars.
* @return
* Command Bars options.
*/
CXTPCommandBarsOptions* GetCommandBarsOptions() const;
/**
* @brief
* Call this function to save the state information to the registry
* or .INI file.
* @param lpszProfileName Points to a null-terminated string that
* specifies the name of a section in the
* initialization file or a key in the Windows
* registry where state information is stored.
* @param bOnlyCustomized TRUE to save only the state for customized
* command bar items.
* @see
* LoadBarState, DoPropExchange
*/
void SaveBarState(LPCTSTR lpszProfileName, BOOL bOnlyCustomized = TRUE);
/**
* @brief
* Call this function to retrieve state information from the registry
* or .INI file.
* @param lpszProfileName Points to a null-terminated string that
* specifies the name of a section in the initialization
* file or a key in the Windows registry where
* state information is stored.
* @param bSilent TRUE to disable user notifications when command bars are
* restored to their original state.
* @see
* SaveBarState, DoPropExchange
*/
void LoadBarState(LPCTSTR lpszProfileName, BOOL bSilent = FALSE);
/**
* @brief
* Call this function to save the command bars options.
* @param lpszProfileName Points to a null-terminated string that
* specifies the name of a section in the initialization
* file or a key in the Windows registry where
* state information is stored.
* @see
* LoadOptions, DoPropExchange
*/
void SaveOptions(LPCTSTR lpszProfileName);
/**
* @brief
* Call this function to restore the options of the command bars.
* @param lpszProfileName Points to a null-terminated string that
* specifies the name of a section in the initialization
* file or a key in the Windows registry where
* state information is stored.
* @see
* SaveOptions, DoPropExchange
*/
void LoadOptions(LPCTSTR lpszProfileName);
/**
* @brief
* Call this function to either read command bars from or write
* command bars to an archive.
* @param ar A CArchive object to serialize to or from.
* @param bSerializeControls TRUE to store controls information.
* @param bOnlyCustomized TRUE to store each command bar only if it was
* customized by the user.
* @param bSilent TRUE to disable user notifications when command
* bars are restored to their original state.
* @see
* DoPropExchange
*/
void SerializeBarState(CArchive& ar, BOOL bSerializeControls = FALSE,
BOOL bOnlyCustomized = TRUE, BOOL bSilent = FALSE);
/**
* @brief
* Call this function to get the ShortcutManager class pointer.
* @return
* Pointer to the current shortcut manager.
* @see
* SetShortcutManager
*/
CXTPShortcutManager* GetShortcutManager() const;
/**
* @brief
* Call this function to set a custom shortcut manager class.
* @param pShortcutManager New ShortcutManager to be set.
* @see
* GetShortcutManager
*/
void SetShortcutManager(CXTPShortcutManager* pShortcutManager);
/**
* @brief
* Either reads this object from or writes this object to storage.
* @param pPX A CXTPPropExchange object to serialize to or from.
* @param pParam Exchange options.
*
* Example:
*
* XTP_COMMANDBARS_PROPEXCHANGE_PARAM param;
* param.bSerializeControls = TRUE;
* // Serialize to XML
* CXTPPropExchangeXMLNode px(FALSE, 0, _T("Settings"));
* CXTPPropExchangeSection pxCommandBars(px.GetSection(_T("CommandBars")));
* GetCommandBars()->DoPropExchange(&pxCommandBars, ¶m);
* px.SaveToFile(m_strIniFileName);
*
* @see
* CXTPPropExchange, XTP_COMMANDBARS_PROPEXCHANGE_PARAM
*/
void DoPropExchange(CXTPPropExchange* pPX, XTP_COMMANDBARS_PROPEXCHANGE_PARAM* pParam = NULL);
/**
* @brief
* Call this member function to load designer command bars from
* an archive.
* @param ar A CArchive object to serialize to or from.
* @param nSchemaVersion Schema version number that indicates the version of the serialized
* CommandBars data, if it is known. The default value _XTP_SCHEMA_CURRENT assumes that the
* CommandBars data have been created using the current version and hence is fully
* compatible. If the schema version number does not match the actual schema version number
* used for generating the CommandBars data then the behavior is undefined and it may result
* in crashes and memory access issues.
* @see
* CXTPPropExchange, CXTPPropExchange::SetSchema
*/
void LoadDesignerBars(CArchive& ar, UINT nSchemaVersion = _XTP_SCHEMA_CURRENT);
/**
* @brief
* Call this member function to load designer command bars from
* an archive.
* @param pPX A CXTPPropExchange object to serialize to or from.
* @see
* CXTPPropExchange, CXTPPropExchange::SetSchema
*/
void LoadDesignerBars(CXTPPropExchange* pPX);
// # Intelligent menus routines
/**
* @brief
* This member function adds the specified commands to the list of
* menu items to hide until activated by clicking on the chevron.
* @param pCommands An array of command IDs, or menu items, to hide.
* @param nCount Size of the array passed in.
* @details
* The command will not be displayed in pop-up menus until the user
* clicks on the "expand menu" chevron or after a short delay when
* bShowFullAfterDelay is TRUE. Note: bAlwaysShowFullMenus must set
* to FALSE to hide the hidden commands
*/
void HideCommands(const UINT* pCommands, int nCount);
/**
* @brief
* This member function adds the specified command to the list of
* menu items to hide until activated by clicking on the chevron.
* @param nCommand The command ID of a menu item to hide.
*/
void HideCommand(UINT nCommand);
/**
* @brief
* Call this member function to retrieve if the command is hidden
* until activated by clicking on the chevron. I.e. Infrequently
* used commands.
* @param nCommand Command id to check.
* @details
* The command will not be displayed in pop-up menus until the user
* clicks on the "expand menu" chevron or after a short delay when
* bShowFullAfterDelay is TRUE. Note: bAlwaysShowFullMenus must set
* to FALSE to hide the hidden commands
* @return
* TRUE if the command item is hidden; otherwise returns FALSE.
*/
virtual BOOL IsCommandHidden(UINT nCommand);
/**
* @brief
* Call this member function to retrieve if the control is hidden and of type
* CXTPControlPopup when bAutoHideUnusedPopups is TRUE.
* @param pControl Control pointer to check.
* @details
* If bAutoHideUnusedPopups is FALSE, then this member performs the same
* action as IsCommandHidden. Override this member to provide a custom
* intelligent menu scheme.
* @return
* TRUE if the control item is hidden; otherwise returns FALSE.
*/
virtual BOOL IsControlHidden(CXTPControl* pControl);
/**
* @brief
* Call this member function to set the command activated by the user.
* @param nCommand Command ID to set.
*/
void SetCommandUsed(UINT nCommand);
/**
* @brief
* Call this member function to restore the state of the hidden
* commands.
*/
void ResetUsageData();
/**
* @brief
* Retrieves the active MDI document template.
* @return
* Active document template identifier.
*/
virtual UINT GetActiveDocTemplate();
/**
* @brief
* Call this member function to set the application's command bars into and out of
* print-preview mode.
* @param bPreview Specifies whether or not to place the application in print-preview mode.
* Set to TRUE to place in print preview, FALSE to cancel preview mode.
*/
void OnSetPreviewMode(BOOL bPreview);
/**
* @brief
* Sends WM_IDLEUPDATECMDUI message to all tool bars.
*/
void UpdateCommandBars() const;
public:
/**
* @brief
* Gets an all-caps flag value that causes command bars to draw all
* titles uppercase if the flag is set.
* @return
* Current all-caps flag value.
*/
BOOL IsAllCaps() const;
/**
* @brief
* Sets an all-caps flag value that causes command bars to draw all
* titles uppercase if the flag is set.
* @param bAllCaps TRUE to make all command bars title uppercase.
*/
void SetAllCaps(BOOL bAllCaps);
/**
* @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
* Specifies if right-to-left (RTL) mode should be set.
* @param bRightToLeft TRUE to display text using right-to-left (RTL)
* reading-order properties.
*/
void SetLayoutRTL(BOOL bRightToLeft);
public:
/**
* @brief
* Call this method to process frame messages.
* CXTPFrameWndBase derived classes call this method automatically.
* @param pMsg Points to an MSG object.
* @return
* TRUE if the message was handled; otherwise FALSE.
*/
BOOL PreTranslateFrameMessage(MSG* pMsg);
/**
* @brief
* Call this method to process frame messages.
* CXTPFrameWndBase derived classes call this method automatically.
* @param message Specifies the message to be sent.
* @param wParam Specifies additional message-dependent information.
* @param lParam Specifies additional message-dependent information.
* @param pResult The return value of WindowProc. Depends on the message;
* may be NULL.
* @return
* TRUE if the message was handled; otherwise FALSE.
*/
BOOL OnFrameWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
/**
* @brief
* This method shows the context menu for toolbars.
* @param pToolBar Pointer to a CXTPToolBar object.
* @param point Position of the menu to show.
*/
virtual void ContextMenu(CXTPToolBar* pToolBar, CPoint point);
/**
* @brief
* This method creates a context menu for toolbars.
* @return
* A CXTPPopupBar object containing a list of toolbars.
*/
virtual CXTPPopupBar* GetToolbarsPopup();
/**
* @brief
* Call this method to create an expand bar.
* @param pToolBar Pointer to a CXTPToolBar object.
* @param pExpandBar Pointer to a CXTPCommandBar object.
*/
virtual void GetHiddenControls(CXTPToolBar* pToolBar, CXTPCommandBar* pExpandBar);
/**
* @brief
* Call this method to create customized controls.
* @param pToolBar Pointer to a CXTPToolBar object.
* @param pExpandBar Pointer to a CXTPCommandBar object.
*/
virtual void GetAddOrRemovePopup(CXTPToolBar* pToolBar, CXTPCommandBar* pExpandBar);
/**
* @brief
* This method is called to set the site window.
* @param pFrame Points to a CWnd object.
*/
void SetSite(CWnd* pFrame);
/**
* @brief
* Call this member to retrieve the dock bar at the specified point.
* @param pt Point to test.
* @param pMainDock CXTPDockBar class currently docked in.
* @return
* A pointer to a CXTPDockBar object.
*/
CXTPDockBar* CanDock(CPoint pt, CXTPDockBar* pMainDock = NULL) const;
/**
* @brief
* This member creates command bars.
* @return
* A pointer to a CXTPCommandBars object.
*/
static CXTPCommandBars* AFX_CDECL CreateCommandBars();
/**
* @brief
* This member is called to create dock bars.
*/
void EnableDocking();
/**
* @brief
* Call this member to get the toolbar count.
* @return
* Number of the toolbars.
*/
int GetCount() const;
/**
* @brief
* Call this member to retrieve a toolbar with a specified index.
* @param nIndex Index of the toolbar.
* @return
* A pointer to a CXTPToolBar object.
*/
CXTPToolBar* GetAt(int nIndex) const;
/**
* @brief
* This method is called to activate a toolbar.
* @param pCommandBar Toolbar to activate.
* @param bNext TRUE to set focus to the next toolbar.
* @return
* TRUE if successful; otherwise FALSE.
*/
BOOL SetToolBarFocus(CXTPToolBar* pCommandBar, BOOL bNext = FALSE);
/**
* @brief
* Call this member to check if command bars are in customize mode.
* @return
* TRUE if command bars are in customize mode, otherwise FALSE.
*/
BOOL IsCustomizeMode() const;
/**
* @brief
* Call this member to set command bars to customize mode.
* @param bMode TRUE to set command bars to customize mode.
*/
void SetCustomizeMode(BOOL bMode);
/**
* @brief
* Call this member to check if command bars are in quick customize mode.
* @return
* TRUE if command bars are in quick customize mode, otherwise FALSE.
* @see
* SetQuickCustomizeMode
*/
BOOL IsQuickCustomizeMode() const;
/**
* @brief
* Call this member to set command bars to quick customize mode.
* @param bMode TRUE to set command bars to quick customize mode.
* @see
* IsQuickCustomizeMode
*/
void SetQuickCustomizeMode(BOOL bMode);
/**
* @brief
* Call this member to retrieve the CXTPCustomizeDropSource helper
* class for customization.
* @return
* A pointer to a CXTPCustomizeDropSource object.
*/
CXTPCustomizeDropSource* GetDropSource() const;
/**
* @brief
* This member is called when the customized control changes.
* @param pControl Pointer to a CXTPControl object.
*/
void SetDragControl(CCmdTarget* pControl);
/**
* @brief
* Call this member to retrieve the current customized control.
* @return
* A pointer to a CXTPControl object.
*/
CCmdTarget* GetDragControl() const;
/**
* @brief
* Call this member to retrieve if the customize is avail.
* @return
* TRUE if customize is avail; otherwise FALSE.
*/
BOOL IsCustomizeAvail() const;
/**
* @brief
* Call this member to enable/disable customization.
* @param bCustomizeAvail TRUE to enable customization; FALSE to disable.
*/
void EnableCustomization(BOOL bCustomizeAvail);
/**
* @brief
* Call this member to remove the toolbar.
* @param pToolBar Points to a CXTPToolBar object to remove.
*/
void Remove(CXTPToolBar* pToolBar);
/**
* @brief
* Call this member to remove all toolbars.
*/
void RemoveAll();
/**
* @brief
* Call this member to dock a toolbar to the specified dockbar.
* @param pBar Pointer to a CXTPToolBar object.
* @param lpRect Position to dock.
* @param pDockBar Dock bar needed to be docked.
* @return
* TRUE if the toolbar was successfully docked, FALSE if the bar
* could not be docked.
*/
BOOL DockCommandBar(CXTPToolBar* pBar, LPRECT lpRect, CXTPDockBar* pDockBar);
/**
* @brief
* Call this member to dock a toolbar to the specified dockbar.
* @param pBar Pointer to a CXTPToolBar object.
* @param barPosition Position to dock.
* @return
* TRUE if the toolbar was successfully docked, FALSE if the bar
* could not be docked.
*/
BOOL DockCommandBar(CXTPToolBar* pBar, XTPBarPosition barPosition);
/**
* @brief
* Call this member to set the specified paint manager.
* @param pPaintManager Pointer to a CXTPPaintManager object.
*/
void SetPaintManager(CXTPPaintManager* pPaintManager);
/**
* @brief
* Call this member to set the specified paint manager.
* @param paintTheme Visual theme to be set.
*/
void SetTheme(XTPPaintTheme paintTheme);
/**
* @brief
* Call this member to set the specified image manager.
* @param pImageManager Pointer to a CXTPPaintManager object.
*/
void SetImageManager(CXTPImageManager* pImageManager);
/**
* @brief
* Call this member to retrieve the paint manager of the command
* bars.
* @return
* A pointer to a CXTPPaintManager object.
*/
CXTPPaintManager* GetPaintManager() const;
/**
* @brief
* Call this member to retrieve the image manager of the command
* bars.
* @return
* A pointer to a CXTPImageManager object.
*/
CXTPImageManager* GetImageManager() const;
/**
* @brief
* Call this member to show/hide the toolbar.
* @param nIndex Index of the toolbar to show or hide.
*/
void ToggleVisible(int nIndex);
/**
* @brief
* Call this method to set the customization file path.
* @param lpszFile Path to customization file information.
* @details
* CommandBars can't store to registry customization information greater than 16kb,
* so it creates a file with user customization information.
* If a file is not specified, then the current directory will be used
* to save customization.
*
* Example:
*
* if (GetAppDataFolder(strAppDataFolder))
* {
* CreateDirectory(strAppDataFolder + _T("\\") + AfxGetApp()->m_pszAppName, NULL);
*
* // Set customization path as "\\Documents and Settings\\user\\Application
* Data\\CustomThemes\\CommandBars"
* GetCommandBars()->SetCustomizationDataFileName(strAppDataFolder + _T("\\") +
* AfxGetApp()->m_pszAppName + _T("\\") + lpszProfileName);
* }
*
*/
void SetCustomizationDataFileName(LPCTSTR lpszFile);
/**
* @brief
* Enables/disables the default choice for the Reset Customized Toolbar message.
* @param bEnable TRUE to enable the default choice, FALSE to disable the default choice.
* @param bDefaultYes If TRUE, then the default choice will be "Yes". Otherwise "No".
*/
void EnableDefaultResetCustomizedToolbarChoice(BOOL bEnable, BOOL bDefaultYes);
/**
* @brief
* This method finds the rebar of the frame.
* @return
* CXTPReBar pointer if the rebar was found; otherwise NULL.
*/
CXTPReBar* GetFrameReBar() const;
/**
* @brief
* Call this method to set the default toolbar class.
* @param pToolBarClass Runtime class of toolbars to be added.
*
* Example:
*
* class CSystemToolBar : public CXTPToolBar
* {
* DECALRE_DYNCREATE(CSystemToolBar)
*
* ....
*
* }
*
* pCommandBars->SetToolBarClass(RUNTIME_CLASS(CSystemToolBar));
*
* CXTPToolBar* pToolBar = pCommandBars->Add("New ToolBar", xtpBarTop);
* ASSERT_KINDOF(CSystemToolBar, pToolBar);
*
* @return void
* @see
* SetMenuBarClass, SetPopupBarClass
*/
static void AFX_CDECL SetToolBarClass(CRuntimeClass* pToolBarClass);
/**
* @brief
* Call this method to set the default dock bar class.
* @param pDockBarClass Runtime class of dock bars to be added.
* @return void
*/
static void AFX_CDECL SetDockBarClass(CRuntimeClass* pDockBarClass);
/**
* @brief
* Call this method to set the default menu bar class.
* @param pMenuBarClass Runtime class of menu bars to be added.
* @return void
*/
static void AFX_CDECL SetMenuBarClass(CRuntimeClass* pMenuBarClass);
/**
* @brief
* Call this method to set the default menu bar class.
* @param pMenuTitleBarClass Runtime class of menu bars to be added.
*/
static void AFX_CDECL SetMenuTitleBarClass(CRuntimeClass* pMenuTitleBarClass);
/**
* @brief
* Call this method to set the default pop-up bar class.
* @param pPopupBarClass Runtime class of pop-up bars to be added.
* @return void
*/
static void AFX_CDECL SetPopupBarClass(CRuntimeClass* pPopupBarClass);
/**
* @brief
* Call this method to set the default pop-up toolbar class.
* @param pPopupToolBarClass Runtime class of pop-up toolbars to be added.
* @return void
*/
static void AFX_CDECL SetPopupToolBarClass(CRuntimeClass* pPopupToolBarClass);
/**
* @brief
* Call this method to get a pointer to the tooltip context.
* @return
* A pointer to the tooltip context.
*/
CXTPToolTipContext* GetToolTipContext() const;
/**
* @brief
* Call this member to find the index of the specified toolbar.
* @param pToolBar Pointer to a CXTPToolBar object.
* @return
* The index of the matching item.
*/
int FindIndex(CXTPToolBar* pToolBar) const;
/**
* @brief
* Call this member to close all pop-up windows.
*/
void ClosePopups() const;
/**
* @brief
* Call this member to get a reference to the status bar object.
* @return
* Pointer to the CXTPStatusBar object.
*/
CXTPStatusBar* GetStatusBar() const;
protected:
/**
* @brief
* Call this member function to float a CXTPToolBar.
* @param pBar Pointer to a valid CXTPToolBar object.
* @return
* TRUE if the CXTPToolBar was successfully floated, otherwise FALSE.
*/
BOOL FloatCommandBar(CXTPToolBar* pBar);
/**
* @brief
* Call this member function to store state information about the
* frame window's control bars in a CXTPDockState object.
* @param state Contains the current state of the frame window's control
* bars upon return.
*/
void GetDockState(CXTPDockState& state);
/**
* @brief
* Call this member function to apply state information stored in a
* CXTPDockState object to the frame window's control bars.
* @param state Apply the stored state to the frame window's control bars.
*/
void SetDockState(CXTPDockState& state);
/**
* @brief
* This method is called when a toolbar is added.
* @param pToolBar Pointer to the toolbar.
*/
virtual void OnToolBarAdded(CXTPToolBar* pToolBar);
/**
* @brief
* This method is called when a toolbar is removed.
* @param pToolBar Pointer to the toolbar.
*/
virtual void OnToolBarRemoved(CXTPToolBar* pToolBar);
public:
/**
* @brief
* This method is called to add a custom toolbar.
* @param lpcstrCaption Title of the toolbar.
* @param nID Toolbar ID.
* @param bTearOffBar TRUE if toolbar is tear-off.
* @return
* A CXTPToolBar object if successful; otherwise NULL.
* @see
* Add
*/
virtual CXTPToolBar* AddCustomBar(LPCTSTR lpcstrCaption, UINT nID, BOOL bTearOffBar = FALSE);
/**
* @brief
* This method is called when the tracking mode of a command bar changes.
* @param pCommandBar Pointer to the command bar whose mode has changed.
* @param bMode The new mode that the commandbar changed to.
*/
virtual void OnTrackingModeChanged(CXTPCommandBar* pCommandBar, int bMode);
/**
* @brief
* Call this method to get the CXTPMouseManager pointer for command bars.
* @return
* Pointer to a CXTPMouseManager object.
* @see
* GetKeyboardManager
*/
CXTPMouseManager* GetMouseManager() const;
/**
* @brief
* Call this method to get the GetKeyboardManager pointer for command bars.
* @return
* Pointer to a GetKeyboardManager object.
* @see
* CXTPMouseManager
*/
CXTPKeyboardManager* GetKeyboardManager() const;
/**
* @brief
* This method is called when the user press Alt + char.
* @param chAccel Character that was pressed.
* @return
* TRUE if command bars processed this character, otherwise FALSE.
*/
BOOL OnFrameAccel(UINT chAccel);
/**
* @brief
* Determines the Help identifier of a control under the mouse cursor.
* @return
* Identifier of the control under the mouse cursor.
* @see
* CXTPControl::SetHelpId
*/
int GetHelpTrackingId() const;
/**
* @brief
* This method is called to show the keyboard cues of controls.
* @param bShow TRUE to show keyboard cues.
*/
void ShowKeyboardCues(BOOL bShow);
/**
* @brief
* Call this method to get the actions list for command bars.
* @return Returns action list for command bars
*/
CXTPControlActions* GetActions() const;
/**
* @brief
* Call this method to let command bars automatically add actions for new commands.
* @param bEnableActions TRUE to enable actions, FALSE otherwise.
*/
void EnableActions(BOOL bEnableActions = TRUE);
/**
* @brief
* Determines if the EnableActions method was called.
* @return
* TRUE if the EnableActions method was called, otherwise FALSE.
*/
BOOL IsActionsEnabled() const;
/**
* @brief
* Call this method to create a new action for a specified ID.
* @param nId Identifier of the action to create.
* @return Returns new action for specified ID
*/
CXTPControlAction* CreateAction(int nId);
/**
* @brief
* Call this method to find an action for a specified ID.
* @param nId Identifier of the action to find.
* @return Returns action for specified ID
*/
CXTPControlAction* FindAction(int nId) const;
/**
* @brief
* Call this method to enable/disable Office 2007 frame.
* @param bEnable TRUE to enable Office 2007 frame,
* FALSE to disable Office 2007 frame.
* @see
* IsFrameThemeEnabled, EnableToolbarComposition
*/
void EnableFrameTheme(BOOL bEnable = TRUE);
/**
* @brief
* Call this method to check if Office 2007 frame is enabled.
* @return
* TRUE if Office 2007 frame is enabled, otherwise FALSE.
* @see
* IsFrameThemeEnabled, EnableToolbarComposition
*/
BOOL IsEnableFrameTheme();
/**
* @brief
* Call this method to enable Office 2007 frame and toolbar composition.
* @param bEnable TRUE to enable Office 2007 frame and toolbar composition,
* FALSE to disable Office 2007 frame and toolbar composition.
* @see
* IsFrameThemeEnabled, EnableFrameTheme
*/
void EnableToolbarComposition(BOOL bEnable = TRUE);
/**
* @brief
* Gets the CXTPCommandBarsFrameHook hook window used to skin the frame.
* @return Returns CXTPCommandBarsFrameHook hook window
* @see
* EnableFrameTheme
*/
CXTPCommandBarsFrameHook* GetFrameHook() const;
/**
* @brief
* Sets the CXTPCommandBarsFrameHook hook window used to skin the frame.
* @param pFrameHook Hook window object pointer
* @see
* EnableFrameTheme
*/
void SetFrameHook(CXTPCommandBarsFrameHook* pFrameHook);
/**
* @brief
* Determines if Vista Glass Effect is enabled for Ribbon Bar.
* @return
* TRUE if Vista Glass Effect is enabled for Ribbon Bar, otherwise FALSE.
*/
BOOL IsDwmEnabled() const;
/**
* @brief
* Call this method to set a custom font height for command bars.
* @param nFontHeight Font height to set.
*/
void SetFontHeight(int nFontHeight);
/**
* @brief
* Call this method to get the font height used for Ribbon Bar.
* @return
* The font height used for Ribbon Bar.
*/
int GetFontHeight() const;
protected:
/** @cond */
// Implementation of Command Bars
virtual BOOL SaveCommandBarList(CXTPPropExchange* pPX, CXTPCommandBarList* pCommandBarList);
virtual BOOL LoadCommandBarList(CXTPPropExchange* pPX, CXTPCommandBarList* pCommandBarList);
virtual void GenerateCommandBarList(CXTPCommandBarList* pCommandBarList,
XTP_COMMANDBARS_PROPEXCHANGE_PARAM* pParam);
virtual void RestoreCommandBarList(CXTPCommandBarList* pCommandBarList, BOOL bSilent = FALSE);
void SerializeCommandBars(CArchive& ar);
void SaveDockBarsState(LPCTSTR lpszProfileName);
void LoadDockBarsState(LPCTSTR lpszProfileName);
void SerializeDockBarsState(CXTPPropExchange* pPX);
void _GetAddOrRemovePopup(CXTPToolBar* pToolBar, CXTPCommandBar* pExpandBar);
void _LoadControlsPart(CFile& file, XTP_COMMANDBARS_PROPEXCHANGE_PARAM* pParam);
BOOL GetControlsFileName(CString& strFileName, LPCTSTR lpszProfileName);
CDocTemplate* FindDocTemplate(CMDIChildWnd* pChild);
void DelayRedrawCommandBars();
int GetNextVisible(long nIndex, int nDirection) const;
CXTPControl* FindAccel(CXTPCommandBar* pCommandBar, UINT chAccel, BOOL& bSelectOnly) const;
CXTPControl* _GetNextControl(CXTPControls*& pControls, int nIndex) const;
void IdleRecalcLayout();
void SetLayoutRTL(CWnd* pWnd, BOOL bRTLLayout);
CString GetIsolatedFileName(const CString& strPrifileName);
/** @endcond */
private:
virtual void OnAmbientPropertyChanged(CXTPApplication* pApplication,
XTPApplicationAmbientProperty nProperty);
public:
CXTPControls* m_pDesignerControls; /**< Designer controls if used. */
BOOL m_bIgnoreShiftMenuKey; /**< if set menus will ignore Shift+Alt key combinations */
BOOL m_bDesignerMode; /**< TRUE if command bars in designer mode. */
/**
* @brief
* Keyboard tips information.
*/
struct KEYBOARDTIPS
{
CArray