XTPCustomizeCommandsPage.h
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:10k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // XTPCustomizeCommandsPage.h : interface for the CXTPCustomizeCommandsPage class.
  2. //
  3. // This file is a part of the XTREME COMMANDBARS MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. //{{AFX_CODEJOCK_PRIVATE
  21. #if !defined(__XTPCUSTOMIZECOMMANDSPAGE_H__)
  22. #define __XTPCUSTOMIZECOMMANDSPAGE_H__
  23. //}}AFX_CODEJOCK_PRIVATE
  24. #if _MSC_VER > 1000
  25. #pragma once
  26. #endif // _MSC_VER > 1000
  27. class CXTPCustomizeSheet;
  28. class CXTPControl;
  29. class CXTPControls;
  30. class CXTPCommandBar;
  31. //-----------------------------------------------------------------------
  32. // Summary:
  33. //     This structure stores categories for CXTPCustomizeCommandsPage and CXTPCustomizeKeyboardPage option
  34. //     pages
  35. // See Also: CXTPCustomizeCommandsPage, CXTPCustomizeKeyboardPage
  36. //-----------------------------------------------------------------------
  37. struct _XTP_EXT_CLASS XTP_COMMANDBARS_CATEGORYINFO
  38. {
  39. //{{AFX_CODEJOCK_PRIVATE
  40. //-----------------------------------------------------------------------
  41. // Summary:
  42. //     Constructs a XTP_COMMANDBARS_CATEGORYINFO struct
  43. // Parameters:
  44. //     strCategory  - Category caption
  45. //     pCommandBars - Pointer to a CXTPCommandBars object.
  46. //-----------------------------------------------------------------------
  47. XTP_COMMANDBARS_CATEGORYINFO(LPCTSTR strCategory, CXTPCommandBars* pCommandBars);
  48. //-------------------------------------------------------------------------
  49. // Summary:
  50. //     Destroys a XTP_COMMANDBARS_CATEGORYINFO, handles cleanup
  51. //     and deallocation.
  52. //-------------------------------------------------------------------------
  53. ~XTP_COMMANDBARS_CATEGORYINFO();
  54. //}}AFX_CODEJOCK_PRIVATE
  55. CString strCategory;        // Category caption
  56. CXTPControls* pControls;    // Controls of this category.
  57. };
  58. //----------------------------------------------------------------------
  59. // Summary:
  60. //     This array is used by the CXTPCustomizeCommandsPage class for
  61. //     maintaining a list of XTP_COMMANDBARS_CATEGORYINFO structures.
  62. // See Also:
  63. //     CXTPCustomizeCommandsPage
  64. //----------------------------------------------------------------------
  65. typedef CArray<XTP_COMMANDBARS_CATEGORYINFO*, XTP_COMMANDBARS_CATEGORYINFO*> CXTPCommandBarsCategoryArray;
  66. //-----------------------------------------------------------------------
  67. // Summary:
  68. //     List of the commands
  69. //-----------------------------------------------------------------------
  70. class _XTP_EXT_CLASS CXTPCustomizeCommandsListBox : public CListBox
  71. {
  72. public:
  73. //-----------------------------------------------------------------------
  74. // Summary:
  75. //     Constructs a CXTPCustomizeCommandsListBox object
  76. //-----------------------------------------------------------------------
  77. CXTPCustomizeCommandsListBox()
  78. {
  79. m_bDragable = FALSE;
  80. m_pCommandBars = NULL;
  81. }
  82. protected:
  83. //{{AFX_CODEJOCK_PRIVATE
  84. DECLARE_MESSAGE_MAP()
  85. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  86. virtual void DrawItem(LPDRAWITEMSTRUCT);
  87. virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  88. //}}AFX_CODEJOCK_PRIVATE
  89. public:
  90. CXTPCommandBars* m_pCommandBars;  // Parent CommandBars object
  91. BOOL m_bDragable;                 // TRUE if user can drag controls from list
  92. };
  93. //===========================================================================
  94. // Summary:
  95. //     CXTPCustomizeCommandsPage is a CPropertyPage derived class.
  96. //     It represents the Commands page of the Customize dialog.
  97. //===========================================================================
  98. class _XTP_EXT_CLASS CXTPCustomizeCommandsPage : public CPropertyPage
  99. {
  100. DECLARE_DYNCREATE(CXTPCustomizeCommandsPage)
  101. public:
  102. //-----------------------------------------------------------------------
  103. // Summary:
  104. //     Constructs a CXTPCustomizeCommandsPage object
  105. // Parameters:
  106. //     pSheet - Points to a CXTPCustomizeSheet object
  107. //-----------------------------------------------------------------------
  108. CXTPCustomizeCommandsPage(CXTPCustomizeSheet* pSheet = NULL);
  109. //-----------------------------------------------------------------------
  110. // Summary:
  111. //     Destroys a CXTPCustomizeCommandsPage object, handles cleanup
  112. //     and deallocation.
  113. //-----------------------------------------------------------------------
  114. ~CXTPCustomizeCommandsPage();
  115. public:
  116. //-----------------------------------------------------------------------
  117. // Summary:
  118. //     Adds categories branch from menu resource.
  119. // Parameters:
  120. //     nIDResource   - Menu resource from where categories will be built.
  121. //     bListSubItems - TRUE to add sub menus to categories.
  122. // Returns:
  123. //     TRUE if successful; otherwise returns FALSE
  124. //-----------------------------------------------------------------------
  125. BOOL AddCategories(UINT nIDResource,  BOOL bListSubItems = FALSE);
  126. //-----------------------------------------------------------------------
  127. // Summary:
  128. //     Adds categories branch from Controls.
  129. // Parameters:
  130. //     pControls - Points to a CXTPControls object
  131. // Returns:
  132. //     TRUE if successful; otherwise returns FALSE
  133. //-----------------------------------------------------------------------
  134. BOOL AddCategories(CXTPControls* pControls);
  135. //-----------------------------------------------------------------------
  136. // Summary:
  137. //     Adds a new category from a CMenu object.
  138. // Parameters:
  139. //     strCategory   - Category to be added.
  140. //     pMenu         - Points to a CMenu object
  141. //     bListSubItems - TRUE to add sub menus to the category.
  142. // Returns:
  143. //     TRUE if successful; otherwise returns FALSE
  144. //-----------------------------------------------------------------------
  145. BOOL AddCategory(LPCTSTR strCategory, CMenu* pMenu, BOOL bListSubItems = FALSE);
  146. //-----------------------------------------------------------------------
  147. // Summary:
  148. //     Adds a new category from a toolbar resource.
  149. // Parameters:
  150. //     strCategory - Category to be added.
  151. //     nIDResource - Toolbar resource identifier.
  152. // Returns:
  153. //     TRUE if successful; otherwise returns FALSE
  154. //-----------------------------------------------------------------------
  155. BOOL AddToolbarCategory(LPCTSTR strCategory, UINT nIDResource);
  156. //-----------------------------------------------------------------------
  157. // Summary:
  158. //     This method adds a new empty category in the given index.
  159. // Parameters:
  160. //     strCategory - Category to be added.
  161. //     nIndex      - Index to insert.
  162. // Returns:
  163. //     A pointer to a CXTPControls object
  164. //-----------------------------------------------------------------------
  165. CXTPControls* InsertCategory(LPCTSTR strCategory, int nIndex = -1);
  166. //-----------------------------------------------------------------------
  167. // Summary:
  168. //     Adds single "New menu" category.
  169. // Parameters:
  170. //     nIDResource - "New Menu" category string resource.
  171. //     nIndex      - Index to insert
  172. //-----------------------------------------------------------------------
  173. void InsertNewMenuCategory(UINT nIDResource = XTP_IDS_NEWMENU, int nIndex = -1);
  174. //-----------------------------------------------------------------------
  175. // Summary:
  176. //     Adds "All Commands" category and adds all controls already
  177. //     created in other categories here.
  178. // Parameters:
  179. //     nIDResource - "All commands" category string resource.
  180. //     nIndex      - Index to insert
  181. //-----------------------------------------------------------------------
  182. void InsertAllCommandsCategory(UINT nIDResource = XTP_IDS_ALLCOMMANDS, int nIndex = -1);
  183. //-----------------------------------------------------------------------
  184. // Summary:
  185. //     Adds built-in menus category.
  186. // Parameters:
  187. //     nIDResourceMenu     - Menu resource identifier.
  188. //     nIDResourceCategory - "Built-in" string identifier.
  189. //     nIndex              - Index to insert.
  190. // Returns:
  191. //     TRUE if successful; otherwise returns FALSE.
  192. //-----------------------------------------------------------------------
  193. BOOL InsertBuiltInMenus(UINT nIDResourceMenu, UINT nIDResourceCategory = XTP_IDS_BUILTINMENUS, int nIndex = -1);
  194. //-----------------------------------------------------------------------
  195. // Summary:
  196. //     Retrieves the control list of the given category.
  197. // Parameters:
  198. //     strCategory - Category to retrieve.
  199. // Returns:
  200. //     A pointer to a CXTPControls object.
  201. //-----------------------------------------------------------------------
  202. CXTPControls* GetControls(LPCTSTR strCategory);
  203. protected:
  204. //{{AFX_CODEJOCK_PRIVATE
  205. DECLARE_MESSAGE_MAP()
  206. //{{AFX_VIRTUAL(CXTPCustomizeCommandsPage)
  207. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  208. BOOL OnInitDialog();
  209. //}}AFX_VIRTUAL
  210. //{{AFX_MSG(CXTPCustomizeCommandsPage)
  211. afx_msg void OnCategoriesSelectionChanged();
  212. afx_msg void OnDestroy();
  213. //}}AFX_MSG
  214. //}}AFX_CODEJOCK_PRIVATE
  215. private:
  216. XTP_COMMANDBARS_CATEGORYINFO* FindCategory(LPCTSTR strCategory) const;
  217. XTP_COMMANDBARS_CATEGORYINFO* GetCategoryInfo(int nIndex);
  218. BOOL _LoadToolBar(CXTPCommandBar* pCommandBar, UINT nIDResource);
  219. protected:
  220. CXTPCustomizeCommandsListBox    m_lstCommands;      // List box of commands
  221. CListBox    m_lstCategories;            // List box of categories
  222. protected:
  223. CXTPCustomizeSheet* m_pSheet;                   // Parent Customize dialog
  224. CXTPCommandBarsCategoryArray m_arrCategories;   // Array of categories.
  225. private:
  226. friend class CCommandsListBox;
  227. };
  228. #endif // !defined(__XTPCUSTOMIZECOMMANDSPAGE_H__)