sizecbar.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /////////////////////////////////////////////////////////////////////////
  2. //
  3. // CSizingControlBar Version 2.43
  4. //
  5. // Created: Jan 24, 1998 Last Modified: August 03, 2000
  6. //
  7. // See the official site at www.datamekanix.com for documentation and
  8. // the latest news.
  9. //
  10. /////////////////////////////////////////////////////////////////////////
  11. // Copyright (C) 1998-2000 by Cristi Posea. All rights reserved.
  12. //
  13. // This code is free for personal and commercial use, providing this
  14. // notice remains intact in the source files and all eventual changes are
  15. // clearly marked with comments.
  16. //
  17. // You must obtain the author's consent before you can include this code
  18. // in a software library.
  19. //
  20. // No warrantee of any kind, express or implied, is included with this
  21. // software; use at your own risk, responsibility for damages (if any) to
  22. // anyone resulting from the use of this software rests entirely with the
  23. // user.
  24. //
  25. // Send bug reports, bug fixes, enhancements, requests, flames, etc. to
  26. // cristi@datamekanix.com or post them at the message board at the site.
  27. /////////////////////////////////////////////////////////////////////////
  28. #if !defined(__SIZECBAR_H__)
  29. #define __SIZECBAR_H__
  30. #include <afxpriv.h> // for CDockContext
  31. //#include <afxtempl.h> // for CTypedPtrArray
  32. #if _MSC_VER >= 1000
  33. #pragma once
  34. #endif // _MSC_VER >= 1000
  35. #if defined(_SCB_MINIFRAME_CAPTION) && !defined(_SCB_REPLACE_MINIFRAME)
  36. #error "_SCB_MINIFRAME_CAPTION requires _SCB_REPLACE_MINIFRAME"
  37. #endif
  38. /////////////////////////////////////////////////////////////////////////
  39. // CSCBDockBar dummy class for access to protected members
  40. class CSCBDockBar : public CDockBar
  41. {
  42. friend class CSizingControlBar;
  43. };
  44. /////////////////////////////////////////////////////////////////////////
  45. // CSizingControlBar control bar styles
  46. #define SCBS_EDGELEFT 0x00000001
  47. #define SCBS_EDGERIGHT 0x00000002
  48. #define SCBS_EDGETOP 0x00000004
  49. #define SCBS_EDGEBOTTOM 0x00000008
  50. #define SCBS_EDGEALL 0x0000000F
  51. #define SCBS_SHOWEDGES 0x00000010
  52. #define SCBS_SIZECHILD 0x00000020
  53. /////////////////////////////////////////////////////////////////////////
  54. // CSizingControlBar control bar
  55. #ifndef baseCSizingControlBar
  56. #define baseCSizingControlBar CControlBar
  57. #endif
  58. class CSizingControlBar;
  59. typedef CTypedPtrArray <CPtrArray, CSizingControlBar*> CSCBArray;
  60. class CSizingControlBar : public baseCSizingControlBar
  61. {
  62. DECLARE_DYNAMIC(CSizingControlBar);
  63. // Construction
  64. public:
  65. CSizingControlBar();
  66. virtual BOOL Create(LPCTSTR lpszWindowName, CWnd* pParentWnd,
  67. CSize sizeDefault, BOOL bHasGripper,
  68. UINT nID, DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_TOP);
  69. virtual BOOL Create(LPCTSTR lpszWindowName, CWnd* pParentWnd,
  70. UINT nID, DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_TOP);
  71. // Attributes
  72. public:
  73. const BOOL IsFloating() const;
  74. const BOOL IsHorzDocked() const;
  75. const BOOL IsVertDocked() const;
  76. const BOOL IsSideTracking() const;
  77. const BOOL GetSCBStyle() const {return m_dwSCBStyle;}
  78. // Operations
  79. public:
  80. #if defined(_SCB_REPLACE_MINIFRAME) && !defined(_SCB_MINIFRAME_CAPTION)
  81. void EnableDocking(DWORD dwDockStyle);
  82. #endif
  83. virtual void LoadState(LPCTSTR lpszProfileName);
  84. virtual void SaveState(LPCTSTR lpszProfileName);
  85. static void GlobalLoadState(CFrameWnd* pFrame, LPCTSTR lpszProfileName);
  86. static void GlobalSaveState(CFrameWnd* pFrame, LPCTSTR lpszProfileName);
  87. void SetSCBStyle(DWORD dwSCBStyle)
  88. {m_dwSCBStyle = (dwSCBStyle & ~SCBS_EDGEALL);}
  89. // Overridables
  90. virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
  91. // Overrides
  92. public:
  93. // ClassWizard generated virtual function overrides
  94. //{{AFX_VIRTUAL(CSizingControlBar)
  95. public:
  96. virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
  97. virtual CSize CalcDynamicLayout(int nLength, DWORD dwMode);
  98. //}}AFX_VIRTUAL
  99. // Implementation
  100. public:
  101. virtual ~CSizingControlBar();
  102. protected:
  103. // implementation helpers
  104. UINT GetEdgeHTCode(int nEdge);
  105. BOOL GetEdgeRect(CRect rcWnd, UINT nHitTest, CRect& rcEdge);
  106. virtual void StartTracking(UINT nHitTest, CPoint point);
  107. virtual void StopTracking();
  108. virtual void OnTrackUpdateSize(CPoint& point);
  109. virtual void OnTrackInvertTracker();
  110. virtual void NcPaintGripper(CDC* pDC, CRect rcClient);
  111. virtual void NcCalcClient(LPRECT pRc, UINT nDockBarID);
  112. virtual void AlignControlBars();
  113. void GetRowInfo(int& nFirst, int& nLast, int& nThis);
  114. void GetRowSizingBars(CSCBArray& arrSCBars);
  115. void GetRowSizingBars(CSCBArray& arrSCBars, int& nThis);
  116. BOOL NegotiateSpace(int nLengthTotal, BOOL bHorz);
  117. protected:
  118. DWORD m_dwSCBStyle;
  119. UINT m_htEdge;
  120. CSize m_szHorz;
  121. CSize m_szVert;
  122. CSize m_szFloat;
  123. CSize m_szMinHorz;
  124. CSize m_szMinVert;
  125. CSize m_szMinFloat;
  126. int m_nTrackPosMin;
  127. int m_nTrackPosMax;
  128. int m_nTrackPosOld;
  129. int m_nTrackEdgeOfs;
  130. static BOOL m_bTracking;
  131. BOOL m_bKeepSize;
  132. BOOL m_bParentSizing;
  133. BOOL m_bDragShowContent;
  134. UINT m_nDockBarID;
  135. int m_cxEdge;
  136. // Generated message map functions
  137. protected:
  138. //{{AFX_MSG(CSizingControlBar)
  139. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  140. afx_msg void OnNcPaint();
  141. afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp);
  142. afx_msg LRESULT OnNcHitTest(CPoint point);
  143. afx_msg void OnCaptureChanged(CWnd *pWnd);
  144. afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
  145. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  146. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  147. afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
  148. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  149. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  150. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  151. afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos);
  152. afx_msg void OnPaint();
  153. afx_msg void OnClose();
  154. afx_msg void OnSize(UINT nType, int cx, int cy);
  155. //}}AFX_MSG
  156. afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
  157. DECLARE_MESSAGE_MAP()
  158. #ifdef _SCB_REPLACE_MINIFRAME
  159. friend class CSCBMiniDockFrameWnd;
  160. #endif //_SCB_REPLACE_MINIFRAME
  161. };
  162. #ifdef _SCB_REPLACE_MINIFRAME
  163. #ifndef _SCB_MINIFRAME_CAPTION
  164. /////////////////////////////////////////////////////////////////////////
  165. // CSCBDockContext dockcontext
  166. class CSCBDockContext : public CDockContext
  167. {
  168. public:
  169. // Construction
  170. CSCBDockContext(CControlBar* pBar) : CDockContext(pBar) {}
  171. // Drag Operations
  172. virtual void StartDrag(CPoint pt);
  173. };
  174. #endif //_SCB_MINIFRAME_CAPTION
  175. /////////////////////////////////////////////////////////////////////////
  176. // CSCBMiniDockFrameWnd miniframe
  177. #ifndef baseCSCBMiniDockFrameWnd
  178. #define baseCSCBMiniDockFrameWnd CMiniDockFrameWnd
  179. #endif
  180. class CSCBMiniDockFrameWnd : public baseCSCBMiniDockFrameWnd
  181. {
  182. DECLARE_DYNCREATE(CSCBMiniDockFrameWnd)
  183. // Overrides
  184. // ClassWizard generated virtual function overrides
  185. //{{AFX_VIRTUAL(CSCBMiniDockFrameWnd)
  186. public:
  187. virtual BOOL Create(CWnd* pParent, DWORD dwBarStyle);
  188. //}}AFX_VIRTUAL
  189. // Implementation
  190. public:
  191. CSizingControlBar* GetSizingControlBar();
  192. //{{AFX_MSG(CSCBMiniDockFrameWnd)
  193. afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
  194. afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
  195. afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos);
  196. afx_msg void OnSize(UINT nType, int cx, int cy);
  197. //}}AFX_MSG
  198. DECLARE_MESSAGE_MAP()
  199. };
  200. #endif //_SCB_REPLACE_MINIFRAME
  201. #endif // !defined(__SIZECBAR_H__)