/** * @file XTPCustomizePageCommands.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(__XTPCUSTOMIZECOMMANDSPAGE_H__) && defined(_XTP_INCLUDE_CONTROLS) # define __XTPCUSTOMIZECOMMANDSPAGE_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPCustomizeSheet; class CXTPControl; class CXTPControls; class CXTPCommandBar; /** * @brief * This structure stores categories for CXTPCustomizeCommandsPage and CXTPCustomizeKeyboardPage * option pages * * @see CXTPCustomizeCommandsPage, CXTPCustomizeKeyboardPage */ struct _XTP_EXT_CLASS XTP_COMMANDBARS_CATEGORYINFO { /** @cond */ /** * @brief * Constructs a XTP_COMMANDBARS_CATEGORYINFO struct * * @param strCategory Category caption * @param pCommandBars Pointer to a CXTPCommandBars object. */ XTP_COMMANDBARS_CATEGORYINFO(LPCTSTR strCategory, CXTPCommandBars* pCommandBars); /** * @brief * Destroys a XTP_COMMANDBARS_CATEGORYINFO, handles cleanup * and deallocation. */ ~XTP_COMMANDBARS_CATEGORYINFO(); /** @endcond */ CString strCategory; /**< Category caption*/ CXTPControls* pControls; /**< Controls of this category.*/ }; /** * @brief * This array is used by the CXTPCustomizeCommandsPage class for * maintaining a list of XTP_COMMANDBARS_CATEGORYINFO structures. * * @see * CXTPCustomizeCommandsPage */ typedef CArray CXTPCommandBarsCategoryArray; /** * @brief * List of the commands */ class _XTP_EXT_CLASS CXTPCustomizeCommandsListBox : # ifdef _XTP_INCLUDE_CONTROLS public CXTPListBox { typedef CXTPListBox BaseType; # else public CListBox { typedef CListBox BaseType; # endif public: /** * @brief * Constructs a CXTPCustomizeCommandsListBox object */ CXTPCustomizeCommandsListBox() { m_bDragable = FALSE; m_pCommandBars = NULL; } protected: /** @cond */ DECLARE_MESSAGE_MAP() afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnSetFocus(CWnd* pOldWnd); virtual void DrawItem(LPDRAWITEMSTRUCT); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnPaint(); afx_msg LRESULT OnPrintClient(WPARAM wParam, LPARAM lParam); /** @endcond */ public: CXTPCommandBars* m_pCommandBars; /**< Parent CommandBars object*/ BOOL m_bDragable; /**< TRUE if user can drag controls from list*/ }; /** * @brief * CXTPCustomizeCommandsPage is a CPropertyPage derived class. * It represents the Commands page of the Customize dialog. */ class _XTP_EXT_CLASS CXTPCustomizeCommandsPage : public CXTPPropertyPage { /** @cond */ DECLARE_DYNCREATE(CXTPCustomizeCommandsPage) /** @endcond */ public: /** * @brief * Constructs a CXTPCustomizeCommandsPage object * * @param pSheet Points to a CXTPCustomizeSheet object */ CXTPCustomizeCommandsPage(CXTPCustomizeSheet* pSheet = NULL); /** * @brief * Destroys a CXTPCustomizeCommandsPage object, handles cleanup * and deallocation. */ ~CXTPCustomizeCommandsPage(); public: /** * @brief * Adds categories branch from menu resource. * * @param nIDResource Menu resource from where categories will be built. * @param bListSubItems TRUE to add sub menus to categories. * * @return * TRUE if successful; otherwise returns FALSE */ BOOL AddCategories(UINT nIDResource, BOOL bListSubItems = FALSE); /** * @brief * Adds categories branch from Controls. * * @param pControls Points to a CXTPControls object * * @return * TRUE if successful; otherwise returns FALSE */ BOOL AddCategories(CXTPControls* pControls); /** * @brief * Adds a new category from a CMenu object. * * @param strCategory Category to be added. * @param pMenu Points to a CMenu object * @param bListSubItems TRUE to add sub menus to the category. * * @return * TRUE if successful; otherwise returns FALSE */ BOOL AddCategory(LPCTSTR strCategory, CMenu* pMenu, BOOL bListSubItems = FALSE); /** * @brief * Adds a new category from a toolbar resource. * * @param strCategory Category to be added. * @param nIDResource Toolbar resource identifier. * * @return * TRUE if successful; otherwise returns FALSE */ BOOL AddToolbarCategory(LPCTSTR strCategory, UINT nIDResource); /** * @brief * This method adds a new empty category in the given index. * * @param strCategory Category to be added. * @param nIndex Index to insert. * * @return * A pointer to a CXTPControls object */ CXTPControls* InsertCategory(LPCTSTR strCategory, int nIndex = -1); /** * @brief * Adds single "New menu" category. * * @param nIDResource "New Menu" category string resource. * @param nIndex Index to insert */ void InsertNewMenuCategory(UINT nIDResource = XTP_IDS_NEWMENU, int nIndex = -1); /** * @brief * Adds "All Commands" category and adds all controls already * created in other categories here. * * @param nIDResource "All commands" category string resource. * @param nIndex Index to insert. * @param bSortCommands TRUE to sort the commands list. */ void InsertAllCommandsCategory(UINT nIDResource = XTP_IDS_ALLCOMMANDS, int nIndex = -1, BOOL bSortCommands = TRUE); /** * @brief * Adds built-in menus category. * * @param nIDResourceMenu Menu resource identifier. * @param nIDResourceCategory "Built-in" string identifier. * @param nIndex Index to insert. * * @return * TRUE if successful; otherwise returns FALSE. */ BOOL InsertBuiltInMenus(UINT nIDResourceMenu, UINT nIDResourceCategory = XTP_IDS_BUILTINMENUS, int nIndex = -1); /** * @brief * Retrieves the control list of the given category. * * @param strCategory Category to retrieve. * * @return * A pointer to a CXTPControls object. */ CXTPControls* GetControls(LPCTSTR strCategory); /** * @brief * Finds the category. * * @param strCategory Category needed to find. * @return Returns category */ XTP_COMMANDBARS_CATEGORYINFO* FindCategory(LPCTSTR strCategory) const; /** * @brief * Gets the category by its index. * * @param nIndex Index of category * @return Returns category index */ XTP_COMMANDBARS_CATEGORYINFO* GetCategoryInfo(int nIndex) const; protected: /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_VIRTUAL(CXTPCustomizeCommandsPage) virtual void DoDataExchange(CDataExchange* pDX); /**< DDX/DDV support*/ BOOL OnInitDialog(); //}}AFX_VIRTUAL //{{AFX_MSG(CXTPCustomizeCommandsPage) afx_msg void OnCategoriesSelectionChanged(); afx_msg void OnDestroy(); afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); //}}AFX_MSG /** @endcond */ private: BOOL _LoadToolBar(CXTPCommandBar* pCommandBar, UINT nIDResource); protected: CXTPCustomizeCommandsListBox m_lstCommands; /**< List box of commands*/ # ifdef _XTP_INCLUDE_CONTROLS COLORREF m_clrText; CXTPListBox m_lstCategories; /**< List box of categories*/ # else CListBox m_lstCategories; /**< List box of categories*/ # endif protected: CXTPCustomizeSheet* m_pSheet; /**< Parent Customize dialog*/ CXTPCommandBarsCategoryArray m_arrCategories; /**< Array of categories.*/ private: friend class CCommandsListBox; }; /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // !defined(__XTPCUSTOMIZECOMMANDSPAGE_H__) /** @endcond */