DockPageBar.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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 WM_MY_INVALIDATE WM_USER+ 201
  32. #define WM_MY_SIZECHANGE WM_USER+ 202
  33. #define WM_MY_SIZECHANGE2 WM_USER+ 203
  34. #define GET_MAIN_FRAME_PURE_CLIENT(a,b) if((a)->IsKindOf(RUNTIME_CLASS(CMDIAutoHideFrame))) \
  35. ((CMDIAutoHideFrame*)(a))->GetPureClientRect(b); \
  36. else if((a)->IsKindOf(RUNTIME_CLASS(CAutoHideFrame))) \
  37. ((CAutoHideFrame*)(a))->GetPureClientRect(b);
  38. #define BRING_CLIENT_WINDOW_TO_BOTTOM(a) if((a)->IsKindOf(RUNTIME_CLASS(CAutoHideFrame))) \
  39. ((CAutoHideFrame*)(a))->BringClientWindowToBottom(); \
  40. else if((a)->IsKindOf(RUNTIME_CLASS(CMDIAutoHideFrame))) \
  41. ((CMDIAutoHideFrame*)(a))->BringClientWindowToBottom(); \
  42. ///////////////////////////////////////////////////////////////////////////
  43. // 标题栏按钮
  44. class CMyButton
  45. {
  46. public:
  47. CMyButton();
  48. void Move(CPoint ptTo) {ptOrg = ptTo; };
  49. virtual CRect GetRect() { return CRect(ptOrg, CSize(13, 13)); };
  50. virtual void Paint(CDC* pDC, BOOL isActive);
  51. BOOL bPushed;
  52. BOOL bRaised;
  53. protected:
  54. CPoint ptOrg;
  55. };
  56. //关闭按钮
  57. class CCloseButton : public CMyButton
  58. {
  59. public:
  60. virtual void Paint(CDC* pDC, BOOL isActive);
  61. };
  62. //图钉按钮
  63. class CStudButton : public CMyButton
  64. {
  65. public:
  66. CStudButton();
  67. BOOL bFloat;
  68. virtual void Paint(CDC* pDC, BOOL isActive);
  69. };
  70. ///////////////////////////////////////////////////////////////////////////
  71. // 标签页
  72. class CPageItem
  73. {
  74. public:
  75. CWnd* m_pWnd; //窗口,可以为NULL
  76. CString m_sText; //文字
  77. HICON m_hIcon; //图标
  78. UINT m_TabWidth; //标签宽度
  79. CRect m_rect; //标签位置
  80. CPageItem() { m_pWnd = NULL; }
  81. public:
  82. void Draw(CDC *pDC,BOOL bActive);
  83. };
  84. /////////////////////////////////////////////////////////////////////////////
  85. // CDockPageBar control bar
  86. #ifndef baseCDockPageBar
  87. #define baseCDockPageBar CSizingControlBar
  88. #endif
  89. class CDockPageBar : public baseCDockPageBar
  90. {
  91. DECLARE_DYNAMIC(CDockPageBar);
  92. // Construction
  93. public:
  94. CDockPageBar();
  95. // Attributes
  96. public:
  97. int m_cyGripper;
  98. // Operations
  99. public:
  100. // Overrides
  101. // ClassWizard generated virtual function overrides
  102. //{{AFX_VIRTUAL(CDockPageBar)
  103. virtual BOOL HasGripper() const;
  104. virtual void UpdateSize();
  105. virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
  106. virtual ~CDockPageBar();
  107. //}}AFX_VIRTUAL
  108. // Implementation
  109. public:
  110. CPtrList m_PageList;
  111. CPtrList m_pDPBContext; //hengai
  112. int m_nActivePage;
  113. BOOL m_isActive;
  114. bool m_bDrawTitleBar;//是否画菜单栏
  115. void OnStudClick();
  116. void EnableDocking(DWORD dwDockStyle);
  117. BOOL AddPage(CDockPageBar* dockPageBar);
  118. BOOL AddPage(CPageItem *pPageItem);
  119. BOOL AddPage(CWnd *pWnd, LPCTSTR sText, UINT IconID);
  120. CPageItem* GetPageItem(int nIndex);
  121. CPageItem* DeletePage();
  122. void DEFLECT_RECT_FOR_STATIC_LINK(CRect &rect);
  123. CSize & GetHorSize(){ return m_szHorz; }
  124. CSize & GetVerSize(){ return m_szVert; }
  125. // Generated message map functions
  126. protected:
  127. CRect m_itemGroupRect;
  128. CString m_Title;
  129. CCloseButton m_biHide;
  130. CStudButton m_stud;
  131. CFont m_font;
  132. void Move(CPoint pt);
  133. void CanDrag(CPoint pt);
  134. void StartDrag(CPoint pt);
  135. void SetActivePage(int nIndex);
  136. void UpdateWindow();
  137. void GetItemGroupRect(LPRECT lpRect);
  138. void GetCaptionRect(LPRECT lpRect);
  139. // implementation helpers
  140. virtual void NcCalcClient(LPRECT pRc, UINT nDockBarID);
  141. virtual void NcPaintGripper(CDC* pDC, CRect rcClient);
  142. //{{AFX_MSG(CDockPageBar)
  143. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  144. afx_msg void OnSize(UINT nType, int cx, int cy);
  145. afx_msg void OnNcPaint();
  146. afx_msg UINT OnNcHitTest(CPoint point);
  147. afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
  148. afx_msg void OnNcLButtonDown(UINT nFlags, CPoint point);
  149. afx_msg void OnNcLButtonDblClk(UINT nFlags, CPoint point);
  150. afx_msg void OnDestroy();
  151. //}}AFX_MSG
  152. DECLARE_MESSAGE_MAP()
  153. virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  154. };
  155. class CcHnDockPageBar : public baseCDockPageBar
  156. {
  157. DECLARE_DYNAMIC(CcHnDockPageBar);
  158. // Construction
  159. public:
  160. CcHnDockPageBar();
  161. // Attributes
  162. public:
  163. int m_cyGripper;
  164. // Operations
  165. public:
  166. // Overrides
  167. // ClassWizard generated virtual function overrides
  168. //{{AFX_VIRTUAL(CDockPageBar)
  169. virtual BOOL HasGripper() const;
  170. virtual void UpdateSize();
  171. virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
  172. virtual ~CcHnDockPageBar();
  173. //}}AFX_VIRTUAL
  174. // Implementation
  175. public:
  176. CPtrList m_PageList;
  177. CPtrList m_pDPBContext; //hengai
  178. int m_nActivePage;
  179. BOOL m_isActive;
  180. bool m_bDrawStudBtn;
  181. void OnStudClick();
  182. void EnableDocking(DWORD dwDockStyle);
  183. BOOL AddPage(CcHnDockPageBar* dockPageBar);
  184. BOOL AddPage(CPageItem *pPageItem);
  185. BOOL AddPage(CWnd *pWnd, LPCTSTR sText, UINT IconID);
  186. CPageItem* GetPageItem(int nIndex);
  187. CPageItem* DeletePage();
  188. void DEFLECT_RECT_FOR_STATIC_LINK(CRect &rect);
  189. CSize & GetHorSize(){ return m_szHorz; }
  190. CSize & GetVerSize(){ return m_szVert; }
  191. // Generated message map functions
  192. protected:
  193. CRect m_itemGroupRect;
  194. CString m_Title;
  195. CCloseButton m_biHide;
  196. CStudButton m_stud;
  197. CFont m_font;
  198. void Move(CPoint pt);
  199. void CanDrag(CPoint pt);
  200. void StartDrag(CPoint pt);
  201. void SetActivePage(int nIndex);
  202. void UpdateWindow();
  203. void GetItemGroupRect(LPRECT lpRect);
  204. void GetCaptionRect(LPRECT lpRect);
  205. // implementation helpers
  206. virtual void NcCalcClient(LPRECT pRc, UINT nDockBarID);
  207. virtual void NcPaintGripper(CDC* pDC, CRect rcClient);
  208. //{{AFX_MSG(CDockPageBar)
  209. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  210. afx_msg void OnSize(UINT nType, int cx, int cy);
  211. afx_msg void OnNcPaint();
  212. afx_msg UINT OnNcHitTest(CPoint point);
  213. afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
  214. afx_msg void OnNcLButtonDown(UINT nFlags, CPoint point);
  215. afx_msg void OnNcLButtonDblClk(UINT nFlags, CPoint point);
  216. afx_msg void OnDestroy();
  217. //}}AFX_MSG
  218. DECLARE_MESSAGE_MAP()
  219. virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  220. };
  221. /////////////////////////////////////////////////////////////////////////////
  222. // CDockPageBarContext dockcontext
  223. #ifndef LAYOUT_LTR
  224. #define LAYOUT_LTR 0x00000000
  225. #endif
  226. class CDockPageBarContext : public CDockContext
  227. {
  228. public:
  229. // Construction
  230. CDockPageBarContext(CControlBar* pBar) : CDockContext(pBar)
  231. {
  232. m_curRect.left=m_curRect.right=0;
  233. m_curRect.top=m_curRect.bottom=0;
  234. m_bAdvancedDock=FALSE;
  235. m_endDragDockStruct.dwDockStyle=0;
  236. m_endDragDockStruct.pDockPageBar=NULL;
  237. }
  238. typedef struct END_DRAG_DOCK_STRUCT
  239. {
  240. DWORD dwDockStyle;
  241. CDockPageBar* pDockPageBar;
  242. }END_DRAG_DOCK_STRUCT;
  243. BOOL m_isMe;
  244. BOOL m_isPage;
  245. CDockPageBar* m_pTgDockPage;
  246. END_DRAG_DOCK_STRUCT m_endDragDockStruct;
  247. virtual ~CDockPageBarContext(void);
  248. void FreeAll();
  249. // Drag Operations
  250. virtual void StartDrag(CPoint pt);
  251. virtual BOOL Track();
  252. virtual void Move(CPoint pt);
  253. virtual void EndDrag();
  254. void DrawFocusRect(BOOL bRemoveRect = FALSE);
  255. protected:
  256. CPtrList m_pDPBar; //hengai
  257. CRect m_addRect;
  258. CRect m_curRect;
  259. BOOL m_bAdvancedDock;
  260. CDockPageBar* CreateNewBar();
  261. BOOL isDockPage(CPoint pt);
  262. CDockPageBar * TryToGetDockPageBar(POINT pt);
  263. };
  264. #endif // !defined(AFX_DOCKPAGEBAR_H__5125E626_E472_4F93_AC8E_20F121A6D1B9__INCLUDED_)