GuiControlBar.h
上传用户:wlkj888
上传日期:2022-08-01
资源大小:806k
文件大小:7k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. /****************************************************************************
  2.  * *
  3.  * GuiToolKit   *
  4.  *                           (MFC extension) *
  5.  * Created by Francisco Campos G. www.beyondata.com fcampos@beyondata.com *
  6.  *--------------------------------------------------------------------------*
  7.  * *
  8.  * This program is free software; so you are free to use it any of your *
  9.  * applications(Freeware, Shareware, Commercial), but leave this header *
  10.  * intact. *
  11.  * *
  12.  * These files are provided "as is" without warranty of any kind. *
  13.  * *
  14.  *        GuiToolKit is forever FREE CODE !!!!! *
  15.  * *
  16.  *--------------------------------------------------------------------------*
  17.  * Created by: Francisco Campos G. *
  18.  * Bug Fixes and improvements :(Add your name) *
  19.  * -Francisco Campos *
  20.  * *
  21.  ****************************************************************************/
  22. #if _MSC_VER > 1000
  23. #pragma once
  24. #endif
  25. #define NORMAL 0
  26. #define OVER   1
  27. #define PRESS  2
  28. #include "GuiDrawLayer.h"
  29. class GUILIBDLLEXPORT   CGuiControlBar : public CControlBar
  30. {
  31. DECLARE_DYNAMIC(CGuiControlBar)
  32. protected:
  33. int nGapGripper;
  34. UINT nDockBarAling;
  35. CSize m_sizeMinFloating;
  36. CSize m_sizeMinFloating1;
  37. CSize m_sizeMinFloatingBck; //save the position before/after autohide
  38. CSize m_sizeHorz;
  39. CSize m_sizeVert;
  40. CSize m_sizeHorzt;
  41. CSize m_sizeVertt;
  42. CSize m_sizeMinV;
  43. CSize m_sizeMinH;
  44. int m_pos;
  45. int m_Last;
  46. int m_First;
  47. CRect m_rcBorder;
  48. CRect m_rcOldBorder;
  49. BOOL m_bTracking;
  50. UINT m_SideMove;  // Que lado se arrastra
  51. CPoint m_ptOld; // la ultima posicion del mouse
  52. BOOL m_Initialize; // es cierto si no se ha inicializado esta ventana
  53. CPoint m_ptPos;
  54. CPoint m_ptStartPos;
  55. CPoint m_ptActualPos;
  56. UINT m_Orient;
  57. BOOL m_bForcepaint;
  58. CGuiControlBarButton m_CloseBtn; // arreglo de botones para control de la barra
  59. CGuiControlBarButton m_AutoHideBtn; // arreglo de botones para control de la barra
  60. CRect m_rcCloseBtn;
  61. CRect m_rcAutoHideBtn;
  62. int m_stateBtn;
  63. int m_stateAHBtn;
  64. COLORREF m_clrFondo; // para el color de fondo de la barra
  65. BOOL m_bAutoHide;
  66. BOOL m_bComplete;
  67. UINT m_nLastAlingDocking;  //ultimo docking
  68. UINT m_nLastAlingDockingBck;
  69. BOOL m_IsLoadDocking;
  70. int m_nSizeMed;
  71. CWnd* pMf;
  72. HICON m_hIcon; //icono para las ventanas autohide
  73. CImageList  m_Imglist;
  74. public:
  75. CSize CalcWinPos();
  76. void SetIcon(UINT hIcon, int cx, int nGrow, COLORREF crMask, int pos=0)
  77. {
  78. CBitmap cbmp;
  79. BITMAP bmp;
  80. m_Imglist.Create(hIcon,cx,nGrow,crMask);
  81. cbmp.LoadBitmap(hIcon);
  82. cbmp.GetBitmap(&bmp);
  83. m_Imglist.Add(&cbmp,crMask);
  84. m_hIcon=m_Imglist.ExtractIcon(pos);
  85.     
  86. }
  87. HICON GetIcon(){ return m_hIcon;}
  88. void SetAutoHide(BOOL bAutoH=FALSE)
  89. {
  90. m_bAutoHide=bAutoH;
  91. }
  92. void InitAutoHide();
  93. BOOL GetComplete(){return m_bComplete;}
  94. UINT GetLastDocking()
  95. {
  96. return m_nLastAlingDocking;
  97. }
  98. BOOL IsAutoHide() {return m_bAutoHide==TRUE;}
  99. BOOL IsTracking() {return m_bTracking;}
  100. UINT  GetDlgID()
  101. {
  102. if (m_IsLoadDocking!=TRUE)
  103. return GetParent()->GetDlgCtrlID();
  104. else
  105. {
  106. m_IsLoadDocking=FALSE;
  107. switch(m_nLastAlingDocking)
  108. {
  109. case CBRS_ALIGN_RIGHT:
  110. return AFX_IDW_DOCKBAR_RIGHT;
  111.   break;
  112. case CBRS_ALIGN_LEFT:
  113. return AFX_IDW_DOCKBAR_LEFT;
  114. break;
  115. case CBRS_ALIGN_TOP:
  116. return AFX_IDW_DOCKBAR_TOP;
  117. break;
  118. case CBRS_ALIGN_BOTTOM:
  119. return AFX_IDW_DOCKBAR_BOTTOM;
  120. break;
  121. }
  122. }
  123. return AFX_IDW_DOCKBAR_LEFT;
  124. }
  125. void ScrollOff();
  126. void ScrollOn();
  127. void ScrollOnEfect(BOOL On=TRUE);
  128. virtual void DrawGripper(CDC* pDC, CRect* rc);
  129. BOOL IsLegal(UINT uAlin);
  130. CGuiControlBar* GetGuiControlBar(int nPos, BOOL bAll = FALSE) const;
  131. void AjustReDinSize(CPoint cp);
  132. void OnActiveWindow();
  133. void SetEqualWidth();
  134. int GetHiWid();
  135. int GetWidthMax();
  136. int  GetFirstPos();
  137. int  GetLastPos();
  138.     BOOL IsLeft();
  139. BOOL IsRight();
  140. BOOL IsTop();
  141. BOOL IsBottom();
  142. BOOL IsVert();
  143. BOOL IsHorz();
  144. BOOL IsFloating();
  145. //autohide
  146. BOOL IsHideVert();
  147. BOOL IsHideLeft();
  148. BOOL IsHideRight();
  149. BOOL IsHideTop();
  150. BOOL IsHideBottom();
  151. void OnInvertTracker(const CRect& rect);
  152. void OnInvertTrackerH(const CRect& rect);
  153. void RecalWindowPos();
  154. void AjustVert(BOOL bGrow, int nDif);
  155. void AjustHorz(BOOL bGrow, int nDif);
  156. CRect GetDockRect();
  157. CRect GetDockRectBck();
  158. void ActiveCaption();
  159. void SetColorFondo(COLORREF clrFondo);
  160. void SaveBar(CString sProfile);
  161. void LoadStateBar(CString sProfile);
  162. // esta funcion permite soportar multiples vistas
  163. void SetSupporMultiView(BOOL bMultiView = TRUE){ m_bSupportMultiView = bMultiView;}
  164. void StyleDispl(DWORD dwDsp=GUISTYLE_XP)
  165. {
  166. m_StyleDisplay=dwDsp;
  167. m_clrFondo=GuiDrawLayer::GetRGBColorFace(m_StyleDisplay);
  168. SendMessage(WM_NCPAINT);Invalidate(); UpdateWindow();
  169. }
  170. BOOL m_bSupportMultiView;
  171. void SetMenuContext(UINT MnuContext)
  172. {
  173. m_MenuContext = MnuContext;
  174. };
  175. protected:
  176. BOOL m_bActive; // esta ventana tiene el foco
  177. BOOL m_bOldActive;
  178. UINT m_MenuContext;
  179. DWORD m_StyleDisplay;
  180. float Porc;
  181. public:
  182. CGuiControlBar();
  183. virtual ~CGuiControlBar();
  184. virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
  185. virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
  186. virtual CSize CalcDynamicLayout(int nLength, DWORD nMode);
  187. virtual BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, CWnd* pParentWnd, UINT nID);
  188. void OnShowTitle();
  189. public:
  190. DECLARE_MESSAGE_MAP()
  191. public:
  192. afx_msg virtual int OnCreate(LPCREATESTRUCT lpCreateStruct);
  193. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  194. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  195. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  196. afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
  197. afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
  198. afx_msg void OnNcPaint();
  199. afx_msg void OnNcCalcSize(BOOL, NCCALCSIZE_PARAMS*);
  200. afx_msg void OnWindowPosChanged(WINDOWPOS* lpwndpos);
  201. afx_msg void OnPaint();
  202. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  203. afx_msg void OnNcLButtonDblClk(UINT nFlags, CPoint point);
  204. afx_msg UINT OnNcHitTest(CPoint point);
  205. afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  206. afx_msg void OnMouseMove(UINT, CPoint);
  207. afx_msg void OnSize(UINT nType, int cx, int cy);
  208. afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
  209. afx_msg void OnTimer(UINT nIDEvent);
  210. afx_msg void OnSysColorChange();
  211. afx_msg void OnNcRButtonDown(UINT nHitTest, CPoint point);
  212. afx_msg void OnWindowPosChanging(WINDOWPOS* lpwndpos);
  213. };