DockPageBar.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /////////////////////////////////////////////////////////////////////////
  2. //
  3. // CDockPageBar Version 1.2
  4. //
  5. // Created: Mar 16, 2004
  6. //
  7. /////////////////////////////////////////////////////////////////////////
  8. // Copyright (C) 2004 by Cuick. All rights reserved.
  9. //
  10. // This code is free for personal and commercial use, providing this
  11. // notice remains intact in the source files and all eventual changes are
  12. // clearly marked with comments.
  13. //
  14. // Send bug reports, bug fixes, enhancements, requests, flames, etc. to
  15. // Cuick@163.net
  16. /////////////////////////////////////////////////////////////////////////
  17. #if !defined(AFX_DOCKPAGEBAR_H__5125E626_E472_4F93_AC8E_20F121A6D1B9__INCLUDED_)
  18. #define AFX_DOCKPAGEBAR_H__5125E626_E472_4F93_AC8E_20F121A6D1B9__INCLUDED_
  19. #if _MSC_VER > 1000
  20. #pragma once
  21. #endif // _MSC_VER > 1000
  22. // DockPageBar.h : header file
  23. //
  24. #define HTSTUD 22
  25. #define HTHIDE 23
  26. #define HTGRIPPER 24
  27. #define HTITEMBUTTON 25
  28. #define HTNCCLIENT 26
  29. #define CAPTION_HEIGHT 16
  30. #define ITEMBUTTON_HEIGHT 24
  31. #define GET_MAIN_FRAME_PURE_CLIENT(a,b) if((a)->IsKindOf(RUNTIME_CLASS(CMDIAutoHideFrame))) \
  32. ((CMDIAutoHideFrame*)(a))->GetPureClientRect(b); \
  33. else if((a)->IsKindOf(RUNTIME_CLASS(CAutoHideFrame))) \
  34. ((CAutoHideFrame*)(a))->GetPureClientRect(b);
  35. #define BRING_CLIENT_WINDOW_TO_BOTTOM(a) if((a)->IsKindOf(RUNTIME_CLASS(CAutoHideFrame))) \
  36. ((CAutoHideFrame*)(a))->BringClientWindowToBottom(); \
  37. else if((a)->IsKindOf(RUNTIME_CLASS(CMDIAutoHideFrame))) \
  38. ((CMDIAutoHideFrame*)(a))->BringClientWindowToBottom(); \
  39. ///////////////////////////////////////////////////////////////////////////
  40. // 标题栏按钮
  41. class CMyButton
  42. {
  43. public:
  44. CMyButton();
  45. void Move(CPoint ptTo) {ptOrg = ptTo; };
  46. virtual CRect GetRect() { return CRect(ptOrg, CSize(13, 13)); };
  47. virtual void Paint(CDC* pDC, BOOL isActive);
  48. BOOL bPushed;
  49. BOOL bRaised;
  50. protected:
  51. CPoint ptOrg;
  52. };
  53. //关闭按钮
  54. class CCloseButton : public CMyButton
  55. {
  56. public:
  57. virtual void Paint(CDC* pDC, BOOL isActive);
  58. };
  59. //图钉按钮
  60. class CStudButton : public CMyButton
  61. {
  62. public:
  63. CStudButton();
  64. BOOL bFloat;
  65. virtual void Paint(CDC* pDC, BOOL isActive);
  66. };
  67. ///////////////////////////////////////////////////////////////////////////
  68. // 标签页
  69. class CPageItem
  70. {
  71. public:
  72. CWnd* m_pWnd; //窗口,可以为NULL
  73. CString m_sText; //文字
  74. HICON m_hIcon; //图标
  75. UINT m_TabWidth; //标签宽度
  76. CRect m_rect; //标签位置
  77. CPageItem() { m_pWnd = NULL; }
  78. public:
  79. void Draw(CDC *pDC,BOOL bActive);
  80. };
  81. /////////////////////////////////////////////////////////////////////////////
  82. // CDockPageBar control bar
  83. #ifndef baseCDockPageBar
  84. #define baseCDockPageBar CSizingControlBar
  85. #endif
  86. class CDockPageBar : public baseCDockPageBar
  87. {
  88. DECLARE_DYNAMIC(CDockPageBar);
  89. // Construction
  90. public:
  91. CDockPageBar();
  92. // Attributes
  93. public:
  94. int m_cyGripper;
  95. // Operations
  96. public:
  97. // Overrides
  98. // ClassWizard generated virtual function overrides
  99. //{{AFX_VIRTUAL(CDockPageBar)
  100. virtual BOOL HasGripper() const;
  101. virtual void UpdateSize();
  102. virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
  103. virtual ~CDockPageBar();
  104. //}}AFX_VIRTUAL
  105. // Implementation
  106. public:
  107. CPtrList m_PageList;
  108. CPtrList m_pDPBContext; //hengai
  109. int m_nActivePage;
  110. BOOL m_isActive;
  111. void OnStudClick();
  112. void EnableDocking(DWORD dwDockStyle);
  113. BOOL AddPage(CDockPageBar* dockPageBar);
  114. BOOL AddPage(CPageItem *pPageItem);
  115. BOOL AddPage(CWnd *pWnd, LPCTSTR sText, UINT IconID);
  116. CPageItem* GetPageItem(int nIndex);
  117. CPageItem* DeletePage();
  118. void DEFLECT_RECT_FOR_STATIC_LINK(CRect &rect);
  119. CSize & GetHorSize(){ return m_szHorz; }
  120. CSize & GetVerSize(){ return m_szVert; }
  121. // Generated message map functions
  122. protected:
  123. CRect m_itemGroupRect;
  124. CString m_Title;
  125. CCloseButton m_biHide;
  126. CStudButton m_stud;
  127. CFont m_font;
  128. void Move(CPoint pt);
  129. void CanDrag(CPoint pt);
  130. void StartDrag(CPoint pt);
  131. void SetActivePage(int nIndex);
  132. void UpdateWindow();
  133. void GetItemGroupRect(LPRECT lpRect);
  134. void GetCaptionRect(LPRECT lpRect);
  135. // implementation helpers
  136. virtual void NcCalcClient(LPRECT pRc, UINT nDockBarID);
  137. virtual void NcPaintGripper(CDC* pDC, CRect rcClient);
  138. //{{AFX_MSG(CDockPageBar)
  139. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  140. afx_msg void OnSize(UINT nType, int cx, int cy);
  141. afx_msg void OnNcPaint();
  142. afx_msg LRESULT OnNcHitTest(CPoint point);
  143. afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
  144. afx_msg void OnNcLButtonDown(UINT nFlags, CPoint point);
  145. afx_msg void OnNcLButtonDblClk(UINT nFlags, CPoint point);
  146. afx_msg void OnDestroy();
  147. //}}AFX_MSG
  148. DECLARE_MESSAGE_MAP()
  149. };
  150. /////////////////////////////////////////////////////////////////////////////
  151. // CDockPageBarContext dockcontext
  152. #ifndef LAYOUT_LTR
  153. #define LAYOUT_LTR 0x00000000
  154. #endif
  155. class CDockPageBarContext : public CDockContext
  156. {
  157. public:
  158. // Construction
  159. CDockPageBarContext(CControlBar* pBar) : CDockContext(pBar)
  160. {
  161. m_curRect.left=m_curRect.right=0;
  162. m_curRect.top=m_curRect.bottom=0;
  163. m_bAdvancedDock=FALSE;
  164. m_endDragDockStruct.dwDockStyle=0;
  165. m_endDragDockStruct.pDockPageBar=NULL;
  166. }
  167. typedef struct END_DRAG_DOCK_STRUCT
  168. {
  169. DWORD dwDockStyle;
  170. CDockPageBar* pDockPageBar;
  171. }END_DRAG_DOCK_STRUCT;
  172. BOOL m_isMe;
  173. BOOL m_isPage;
  174. CDockPageBar* m_pTgDockPage;
  175. END_DRAG_DOCK_STRUCT m_endDragDockStruct;
  176. virtual ~CDockPageBarContext(void);
  177. void FreeAll();
  178. // Drag Operations
  179. virtual void StartDrag(CPoint pt);
  180. virtual BOOL Track();
  181. virtual void Move(CPoint pt);
  182. virtual void EndDrag();
  183. void DrawFocusRect(BOOL bRemoveRect = FALSE);
  184. protected:
  185. CPtrList m_pDPBar; //hengai
  186. CRect m_addRect;
  187. CRect m_curRect;
  188. BOOL m_bAdvancedDock;
  189. CDockPageBar* CreateNewBar();
  190. BOOL isDockPage(CPoint pt);
  191. CDockPageBar * TryToGetDockPageBar(POINT pt);
  192. };
  193. #endif // !defined(AFX_DOCKPAGEBAR_H__5125E626_E472_4F93_AC8E_20F121A6D1B9__INCLUDED_)