DockPageBar.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. virtual BOOL HasGripper() const;
  103. virtual void UpdateSize();
  104. virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
  105. virtual ~CDockPageBar();
  106. // Implementation
  107. public:
  108. CPtrList m_PageList;
  109. CPtrList m_pDPBContext; //hengai
  110. int m_nActivePage;
  111. BOOL m_isActive;
  112. bool m_bDrawTitleBar;//是否画菜单栏
  113. void OnStudClick();
  114. void EnableDocking(DWORD dwDockStyle);
  115. BOOL AddPage(CDockPageBar* dockPageBar);
  116. BOOL AddPage(CPageItem *pPageItem);
  117. BOOL AddPage(CWnd *pWnd, LPCTSTR sText, UINT IconID);
  118. CPageItem* GetPageItem(int nIndex);
  119. CPageItem* DeletePage();
  120. void DEFLECT_RECT_FOR_STATIC_LINK(CRect &rect);
  121. CSize & GetHorSize(){ return m_szHorz; }
  122. CSize & GetVerSize(){ return m_szVert; }
  123. // Generated message map functions
  124. protected:
  125. CRect m_itemGroupRect;
  126. CString m_Title;
  127. CCloseButton m_biHide;
  128. CStudButton m_stud;
  129. CFont m_font;
  130. void Move(CPoint pt);
  131. void CanDrag(CPoint pt);
  132. void StartDrag(CPoint pt);
  133. void SetActivePage(int nIndex);
  134. void UpdateWindow();
  135. void GetItemGroupRect(LPRECT lpRect);
  136. void GetCaptionRect(LPRECT lpRect);
  137. // implementation helpers
  138. virtual void NcCalcClient(LPRECT pRc, UINT nDockBarID);
  139. virtual void NcPaintGripper(CDC* pDC, CRect rcClient);
  140. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  141. afx_msg void OnSize(UINT nType, int cx, int cy);
  142. afx_msg void OnNcPaint();
  143. afx_msg LRESULT OnNcHitTest(CPoint point);
  144. afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
  145. afx_msg void OnNcLButtonDown(UINT nFlags, CPoint point);
  146. afx_msg void OnNcLButtonDblClk(UINT nFlags, CPoint point);
  147. afx_msg void OnDestroy();
  148. DECLARE_MESSAGE_MAP()
  149. virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  150. };
  151. class CcHnDockPageBar : public baseCDockPageBar
  152. {
  153. DECLARE_DYNAMIC(CcHnDockPageBar);
  154. // Construction
  155. public:
  156. CcHnDockPageBar();
  157. // Attributes
  158. public:
  159. int m_cyGripper;
  160. // Operations
  161. public:
  162. // Overrides
  163. // ClassWizard generated virtual function overrides
  164. //{{AFX_VIRTUAL(CDockPageBar)
  165. virtual BOOL HasGripper() const;
  166. virtual void UpdateSize();
  167. virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
  168. virtual ~CcHnDockPageBar();
  169. //}}AFX_VIRTUAL
  170. // Implementation
  171. public:
  172. CPtrList m_PageList;
  173. CPtrList m_pDPBContext; //hengai
  174. int m_nActivePage;
  175. BOOL m_isActive;
  176. bool m_bDrawStudBtn;
  177. void OnStudClick();
  178. void EnableDocking(DWORD dwDockStyle);
  179. BOOL AddPage(CcHnDockPageBar* dockPageBar);
  180. BOOL AddPage(CPageItem *pPageItem);
  181. BOOL AddPage(CWnd *pWnd, LPCTSTR sText, UINT IconID);
  182. CPageItem* GetPageItem(int nIndex);
  183. CPageItem* DeletePage();
  184. void DEFLECT_RECT_FOR_STATIC_LINK(CRect &rect);
  185. CSize & GetHorSize(){ return m_szHorz; }
  186. CSize & GetVerSize(){ return m_szVert; }
  187. // Generated message map functions
  188. protected:
  189. CRect m_itemGroupRect;
  190. CString m_Title;
  191. CCloseButton m_biHide;
  192. CStudButton m_stud;
  193. CFont m_font;
  194. void Move(CPoint pt);
  195. void CanDrag(CPoint pt);
  196. void StartDrag(CPoint pt);
  197. void SetActivePage(int nIndex);
  198. void UpdateWindow();
  199. void GetItemGroupRect(LPRECT lpRect);
  200. void GetCaptionRect(LPRECT lpRect);
  201. // implementation helpers
  202. virtual void NcCalcClient(LPRECT pRc, UINT nDockBarID);
  203. virtual void NcPaintGripper(CDC* pDC, CRect rcClient);
  204. //{{AFX_MSG(CDockPageBar)
  205. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  206. afx_msg void OnSize(UINT nType, int cx, int cy);
  207. afx_msg void OnNcPaint();
  208. afx_msg LRESULT OnNcHitTest(CPoint point);
  209. afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
  210. afx_msg void OnNcLButtonDown(UINT nFlags, CPoint point);
  211. afx_msg void OnNcLButtonDblClk(UINT nFlags, CPoint point);
  212. afx_msg void OnDestroy();
  213. //}}AFX_MSG
  214. DECLARE_MESSAGE_MAP()
  215. virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  216. };
  217. /////////////////////////////////////////////////////////////////////////////
  218. // CDockPageBarContext dockcontext
  219. #ifndef LAYOUT_LTR
  220. #define LAYOUT_LTR 0x00000000
  221. #endif
  222. class CDockPageBarContext : public CDockContext
  223. {
  224. public:
  225. // Construction
  226. CDockPageBarContext(CControlBar* pBar) : CDockContext(pBar)
  227. {
  228. m_curRect.left=m_curRect.right=0;
  229. m_curRect.top=m_curRect.bottom=0;
  230. m_bAdvancedDock=FALSE;
  231. m_endDragDockStruct.dwDockStyle=0;
  232. m_endDragDockStruct.pDockPageBar=NULL;
  233. }
  234. typedef struct END_DRAG_DOCK_STRUCT
  235. {
  236. DWORD dwDockStyle;
  237. CDockPageBar* pDockPageBar;
  238. }END_DRAG_DOCK_STRUCT;
  239. BOOL m_isMe;
  240. BOOL m_isPage;
  241. CDockPageBar* m_pTgDockPage;
  242. END_DRAG_DOCK_STRUCT m_endDragDockStruct;
  243. virtual ~CDockPageBarContext(void);
  244. void FreeAll();
  245. // Drag Operations
  246. virtual void StartDrag(CPoint pt);
  247. virtual BOOL Track();
  248. virtual void Move(CPoint pt);
  249. virtual void EndDrag();
  250. void DrawFocusRect(BOOL bRemoveRect = FALSE);
  251. protected:
  252. CPtrList m_pDPBar; //hengai
  253. CRect m_addRect;
  254. CRect m_curRect;
  255. BOOL m_bAdvancedDock;
  256. CDockPageBar* CreateNewBar();
  257. BOOL isDockPage(CPoint pt);
  258. CDockPageBar * TryToGetDockPageBar(POINT pt);
  259. };
  260. #endif // !defined(AFX_DOCKPAGEBAR_H__5125E626_E472_4F93_AC8E_20F121A6D1B9__INCLUDED_)