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

对话框与窗口

开发平台:

Visual C++

  1. // XTPRibbonGroups.h: interface for the CXTPRibbonGroups class.
  2. //
  3. // This file is a part of the XTREME RIBBON 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(__XTPRIBBONGROUPS_H__)
  22. #define __XTPRIBBONGROUPS_H__
  23. //}}AFX_CODEJOCK_PRIVATE
  24. #if _MSC_VER > 1000
  25. #pragma once
  26. #endif // _MSC_VER > 1000
  27. class CXTPRibbonGroup;
  28. class CXTPRibbonTab;
  29. //===========================================================================
  30. // Summary:
  31. //     Represents a collection of CXTPRibbonGroup objects.
  32. // Remarks:
  33. //     A CXTPRibbonTab uses the CXTPRibbonGroups object for its Groups Collection
  34. //     to store all of the RibbonGroup objects that have been added to the
  35. //     RibbonTab.  A CXTPRibbonGroup is used to hold items such as buttons,
  36. //     popups, edit controls, etc.
  37. //
  38. //     Groups are added to the Groups Collection using the Add
  39. //     and InsertAt methods.
  40. // See Also: Add, InsertAt
  41. //===========================================================================
  42. class _XTP_EXT_CLASS CXTPRibbonGroups : public CXTPCmdTarget
  43. {
  44. public:
  45. //-----------------------------------------------------------------------
  46. // Summary:
  47. //     Constructs a CXTPRibbonGroups object
  48. //-----------------------------------------------------------------------
  49. CXTPRibbonGroups();
  50. //-----------------------------------------------------------------------
  51. // Summary:
  52. //     Destroys a CXTPRibbonGroups object, handles cleanup and deallocation.
  53. //-----------------------------------------------------------------------
  54. virtual ~CXTPRibbonGroups();
  55. public:
  56. //-----------------------------------------------------------------------
  57. // Summary:
  58. //     Copies all groups
  59. // Parameters:
  60. //     pGroups - Groups to copy from
  61. //-----------------------------------------------------------------------
  62. void Copy(CXTPRibbonGroups* pGroups);
  63. //-------------------------------------------------------------------------
  64. // Summary:
  65. //     Removes all groups.
  66. // See Also: InsertAt, Remove, GetCount, GetAt, Add
  67. //-------------------------------------------------------------------------
  68. void RemoveAll();
  69. //-----------------------------------------------------------------------
  70. // Summary:
  71. //     Removes the group at the specified index.
  72. // Parameters:
  73. //     nIndex - Index of the group to be removed.
  74. // See Also: InsertAt, Add, GetCount, GetAt, RemoveAll
  75. //-----------------------------------------------------------------------
  76. void Remove(int nIndex);
  77. //-----------------------------------------------------------------------
  78. // Summary:
  79. //     Adds a CXTPRibbonGroup to a CXTPRibbonTab at a specific location.
  80. // Parameters:
  81. //     nIndex      - Position within the tab's Groups Collection to
  82. //                   insert the new CXTPRibbonGroup.
  83. //     lpszCaption - Text to display in the group title bar.
  84. //                   This in the group's caption.
  85. //     nId         - Identifier of new group
  86. //     pGroup      - New group to insert
  87. // Remarks:
  88. //     InsertAt adds a group at a specific location within the tab's
  89. //     Groups Collection.  Groups will be displayed in the order they
  90. //     are added.  This means the group with an Index of zero (0) will
  91. //     be displayed first to the far left, then to the immediate right
  92. //     will be the group with an Index of one (1), etc...
  93. // Returns:
  94. //     Pointer to the CXTPRibbonGroup object added to the CXTPRibbonTab
  95. //     Groups Collection.
  96. // See Also: Add, Remove, GetCount, GetAt, RemoveAll
  97. //-----------------------------------------------------------------------
  98. CXTPRibbonGroup* InsertAt(int nIndex, LPCTSTR lpszCaption, int nId = -1);
  99. CXTPRibbonGroup* InsertAt(int nIndex, CXTPRibbonGroup* pGroup); // <combine CXTPRibbonGroups::InsertAt@int@LPCTSTR@int>
  100. //-----------------------------------------------------------------------
  101. // Summary:
  102. //     Adds a CXTPRibbonGroup to a CXTPRibbonTab.
  103. // Parameters:
  104. //     lpszCaption - Text to display in the group title bar.
  105. //                   This is the group's caption.
  106. //     nId         - Identifier of new group
  107. // Remarks:
  108. //     Tabs in the Ribbon Bar contain one or more CXTPRibbonGroup objects.
  109. //     Buttons, Popups, etc can then be added to the groups.
  110. // Returns:
  111. //     Pointer to the CXTPRibbonGroup object added to the CXTPRibbonTab Groups Collection.
  112. // See Also: InsertAt, Remove, GetCount, GetAt, RemoveAll
  113. //-----------------------------------------------------------------------
  114. CXTPRibbonGroup* Add(LPCTSTR lpszCaption, int nId = -1);
  115. //-----------------------------------------------------------------------
  116. // Summary:
  117. //     Total number of CXTPRibbonGroup objects that have been added to a CXTPRibbonTab.
  118. // Returns:
  119. //     Integer containing the total number of CXTPRibbonGroup objects that
  120. //     have been added to a CXTPRibbonTab.
  121. // See Also: InsertAt, Remove, Add, GetAt, RemoveAll
  122. //-----------------------------------------------------------------------
  123. int GetCount() const;
  124. //-----------------------------------------------------------------------
  125. // Summary:
  126. //     Gets a CXTPRibbonGroup object that has been added to the CXTPRibbonTab
  127. //     at the specified index.
  128. // Parameters:
  129. //     nIndex - Index of the group to retrieve within the
  130. //              collection of groups.
  131. // Remarks:
  132. //     GetAt retrieves the CXTPRibbonGroup from the m_arrGroups groups collection
  133. //     that contains all of the CXTPRibbonGroup objects that have been added
  134. //     to the CXTPRibbonTab.
  135. // Returns:
  136. //     The CXTPRibbonGroup at the specified index.
  137. // See Also: InsertAt, Remove, GetCount, Add, RemoveAll
  138. //-----------------------------------------------------------------------
  139. CXTPRibbonGroup* GetAt(int nIndex) const;
  140. //-----------------------------------------------------------------------
  141. // Summary:
  142. //     This member function determines which ribbon group,
  143. //     if any, is at a specified position.
  144. // Parameters:
  145. //     point - A CPoint that contains the coordinates of the point to test.
  146. // Returns:
  147. //     The CXTPRibbonGroup that is at the specified point, if no group is
  148. //     at the point, then NULL is returned.
  149. //-----------------------------------------------------------------------
  150. CXTPRibbonGroup* HitTest(CPoint point) const;
  151. //-----------------------------------------------------------------------
  152. // Summary:
  153. //     The CXTPRibbonBar object the CXTPRibbonGroup belongs to.
  154. // Returns:
  155. //     A pointer to the CXTPRibbonBar object the CXTPRibbonGroup belongs to.
  156. //     This is the RibbonBar that the group is displayed in.
  157. // See Also: CXTPRibbonBar
  158. //-----------------------------------------------------------------------
  159. CXTPRibbonBar* GetRibbonBar() const;
  160. //-----------------------------------------------------------------------
  161. // Summary:
  162. //     The CXTPRibbonTab object the CXTPRibbonGroup belongs to.
  163. // Returns:
  164. //     A pointer to the CXTPRibbonTab object the CXTPRibbonGroup belongs to.
  165. //     This is the tab that the group is displayed in.
  166. // See Also: CXTPRibbonTab
  167. //-----------------------------------------------------------------------
  168. CXTPRibbonTab* GetParentTab() const;
  169. //-----------------------------------------------------------------------
  170. // Summary:
  171. //     This method is called internally to reposition groups and controls.
  172. // Parameters:
  173. //     pDC      - Pointer to a valid device context
  174. //     nLength  - Length of the parent bar.
  175. //     dwMode   - Mode of the parent bar.
  176. //     rcBorder - Border to be set.
  177. // See Also: CXTPRibbonBar::RepositionGroups
  178. //-----------------------------------------------------------------------
  179. void CalcDynamicSize(CDC* pDC, int nLength, DWORD dwMode, const CRect& rcBorder);
  180. virtual void DoPropExchange(CXTPPropExchange* pPX);
  181. public:
  182. //-----------------------------------------------------------------------
  183. // Summary: Call this method to get group scroll position
  184. // Returns: Position of scroll offset
  185. //-----------------------------------------------------------------------
  186. int GetScrollPos() const;
  187. protected:
  188. //{{AFX_CODEJOCK_PRIVATE
  189. int _CalcSmartLayoutToolBar(int* pWidth);
  190. void _ReduceSmartLayoutToolBar(CDC* pDC, int* pWidth, int nWidth);
  191. //}}AFX_CODEJOCK_PRIVATE
  192. private:
  193. void RefreshIndexes();
  194. protected:
  195. protected:
  196. CArray<CXTPRibbonGroup*, CXTPRibbonGroup*> m_arrGroups;     // Collection of groups.
  197. CXTPRibbonTab* m_pParentTab;    // A pointer to the CXTPRibbonTab object the CXTPRibbonGroup belongs to.
  198.                                 // This is the tab that the group is displayed in.
  199. int m_nGroupsScrollPos;         // Scroll position
  200. friend class CXTPRibbonTab;
  201. friend class CXTPRibbonBar;
  202. };
  203. AFX_INLINE int CXTPRibbonGroups::GetCount() const {
  204. return (int)m_arrGroups.GetSize();
  205. }
  206. AFX_INLINE CXTPRibbonGroup* CXTPRibbonGroups::GetAt(int nIndex) const {
  207. ASSERT(nIndex < m_arrGroups.GetSize());
  208. return (nIndex >= 0 && nIndex < m_arrGroups.GetSize()) ? m_arrGroups.GetAt(nIndex) : NULL;
  209. }
  210. AFX_INLINE CXTPRibbonTab* CXTPRibbonGroups::GetParentTab() const {
  211. return  m_pParentTab;
  212. }
  213. AFX_INLINE int CXTPRibbonGroups::GetScrollPos() const {
  214. return m_nGroupsScrollPos;
  215. }
  216. #endif // !defined(__XTPRIBBONGROUPS_H__)