DockPageBar.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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 GET_MAIN_FRAME_PURE_CLIENT(a,b) if((a)->IsKindOf(RUNTIME_CLASS(CMDIAutoHideFrame))) \
  33. ((CMDIAutoHideFrame*)(a))->GetPureClientRect(b); \
  34. else if((a)->IsKindOf(RUNTIME_CLASS(CAutoHideFrame))) \
  35. ((CAutoHideFrame*)(a))->GetPureClientRect(b);
  36. #define BRING_CLIENT_WINDOW_TO_BOTTOM(a) if((a)->IsKindOf(RUNTIME_CLASS(CAutoHideFrame))) \
  37. ((CAutoHideFrame*)(a))->BringClientWindowToBottom(); \
  38. else if((a)->IsKindOf(RUNTIME_CLASS(CMDIAutoHideFrame))) \
  39. ((CMDIAutoHideFrame*)(a))->BringClientWindowToBottom(); \
  40. ///////////////////////////////////////////////////////////////////////////
  41. // 标题栏按钮
  42. class CMyButton
  43. {
  44. public:
  45. CMyButton();
  46. void Move(CPoint ptTo) {ptOrg = ptTo; };
  47. virtual CRect GetRect() { return CRect(ptOrg, CSize(13, 13)); };
  48. virtual void Paint(CDC* pDC, BOOL isActive);
  49. BOOL bPushed;
  50. BOOL bRaised;
  51. protected:
  52. CPoint ptOrg;
  53. };
  54. //关闭按钮
  55. class CCloseButton : public CMyButton
  56. {
  57. public:
  58. virtual void Paint(CDC* pDC, BOOL isActive);
  59. };
  60. //图钉按钮
  61. class CStudButton : public CMyButton
  62. {
  63. public:
  64. CStudButton();
  65. BOOL bFloat;
  66. virtual void Paint(CDC* pDC, BOOL isActive);
  67. };
  68. ///////////////////////////////////////////////////////////////////////////
  69. // 标签页
  70. class CPageItem
  71. {
  72. public:
  73. CWnd* m_pWnd; //窗口,可以为NULL
  74. CString m_sText; //文字
  75. HICON m_hIcon; //图标
  76. UINT m_TabWidth; //标签宽度
  77. CRect m_rect; //标签位置
  78. CPageItem() { m_pWnd = NULL; }
  79. public:
  80. void Draw(CDC *pDC,BOOL bActive);
  81. };
  82. /////////////////////////////////////////////////////////////////////////////
  83. // CDockPageBar control bar
  84. #ifndef baseCDockPageBar
  85. #define baseCDockPageBar CSizingControlBar
  86. #endif
  87. class CDockPageBar : public baseCDockPageBar
  88. {
  89. DECLARE_DYNAMIC(CDockPageBar);
  90. // Construction
  91. public:
  92. CDockPageBar();
  93. // Attributes
  94. public:
  95. int m_cyGripper;
  96. // Operations
  97. public:
  98. // Overrides
  99. // ClassWizard generated virtual function overrides
  100. //{{AFX_VIRTUAL(CDockPageBar)
  101. virtual BOOL HasGripper() const;
  102. virtual void UpdateSize();
  103. virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
  104. virtual ~CDockPageBar();
  105. //}}AFX_VIRTUAL
  106. // Implementation
  107. public:
  108. CPtrList m_PageList;
  109. CPtrList m_pDPBContext; //hengai
  110. int m_nActivePage;
  111. BOOL m_isActive;
  112. void OnStudClick();
  113. void EnableDocking(DWORD dwDockStyle);
  114. BOOL AddPage(CDockPageBar* dockPageBar);
  115. BOOL AddPage(CPageItem *pPageItem);
  116. BOOL AddPage(CWnd *pWnd, LPCTSTR sText, UINT IconID);
  117. CPageItem* GetPageItem(int nIndex);
  118. CPageItem* DeletePage();
  119. void DEFLECT_RECT_FOR_STATIC_LINK(CRect &rect);
  120. CSize & GetHorSize(){ return m_szHorz; }
  121. CSize & GetVerSize(){ return m_szVert; }
  122. // Generated message map functions
  123. protected:
  124. CRect m_itemGroupRect;
  125. CString m_Title;
  126. CCloseButton m_biHide;
  127. CStudButton m_stud;
  128. CFont m_font;
  129. void Move(CPoint pt);
  130. void CanDrag(CPoint pt);
  131. void StartDrag(CPoint pt);
  132. void SetActivePage(int nIndex);
  133. void UpdateWindow();
  134. void GetItemGroupRect(LPRECT lpRect);
  135. void GetCaptionRect(LPRECT lpRect);
  136. // implementation helpers
  137. virtual void NcCalcClient(LPRECT pRc, UINT nDockBarID);
  138. virtual void NcPaintGripper(CDC* pDC, CRect rcClient);
  139. //{{AFX_MSG(CDockPageBar)
  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 UINT 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. //}}AFX_MSG
  149. DECLARE_MESSAGE_MAP()
  150. virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  151. };
  152. /////////////////////////////////////////////////////////////////////////////
  153. // CDockPageBarContext dockcontext
  154. #ifndef LAYOUT_LTR
  155. #define LAYOUT_LTR 0x00000000
  156. #endif
  157. class CDockPageBarContext : public CDockContext
  158. {
  159. public:
  160. // Construction
  161. CDockPageBarContext(CControlBar* pBar) : CDockContext(pBar)
  162. {
  163. m_curRect.left=m_curRect.right=0;
  164. m_curRect.top=m_curRect.bottom=0;
  165. m_bAdvancedDock=FALSE;
  166. m_endDragDockStruct.dwDockStyle=0;
  167. m_endDragDockStruct.pDockPageBar=NULL;
  168. }
  169. typedef struct END_DRAG_DOCK_STRUCT
  170. {
  171. DWORD dwDockStyle;
  172. CDockPageBar* pDockPageBar;
  173. }END_DRAG_DOCK_STRUCT;
  174. BOOL m_isMe;
  175. BOOL m_isPage;
  176. CDockPageBar* m_pTgDockPage;
  177. END_DRAG_DOCK_STRUCT m_endDragDockStruct;
  178. virtual ~CDockPageBarContext(void);
  179. void FreeAll();
  180. // Drag Operations
  181. virtual void StartDrag(CPoint pt);
  182. virtual BOOL Track();
  183. virtual void Move(CPoint pt);
  184. virtual void EndDrag();
  185. void DrawFocusRect(BOOL bRemoveRect = FALSE);
  186. protected:
  187. CPtrList m_pDPBar; //hengai
  188. CRect m_addRect;
  189. CRect m_curRect;
  190. BOOL m_bAdvancedDock;
  191. CDockPageBar* CreateNewBar();
  192. BOOL isDockPage(CPoint pt);
  193. CDockPageBar * TryToGetDockPageBar(POINT pt);
  194. };
  195. #endif // !defined(AFX_DOCKPAGEBAR_H__5125E626_E472_4F93_AC8E_20F121A6D1B9__INCLUDED_)