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

对话框与窗口

开发平台:

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. #include "stdafx.h"
  23. #include "GuiCapOutBar.h"
  24. #include "GuiDrawLayer.h"
  25. #ifdef _DEBUG
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #define new DEBUG_NEW
  29. #endif
  30. //////////////////////////////////////////////////////////////////////
  31. // Construction/Destruction
  32. //////////////////////////////////////////////////////////////////////
  33. BEGIN_MESSAGE_MAP(GuiCapOutBar, CControlBar)
  34. //{{AFX_MSG_MAP(GuiCapOutBar)
  35. ON_WM_CREATE()
  36. ON_WM_PAINT()
  37. ON_WM_ERASEBKGND()
  38. ON_WM_SIZE()
  39. ON_WM_SYSCOLORCHANGE()
  40. ON_WM_NCCALCSIZE()
  41. ON_WM_NCPAINT()
  42. ON_WM_LBUTTONDOWN()
  43. ON_WM_LBUTTONUP()
  44. ON_WM_TIMER()
  45. ON_WM_SETCURSOR()
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. GuiCapOutBar::GuiCapOutBar()
  49. {
  50. m_iBorder      = 2;
  51. m_MiniTool     = NULL;
  52. m_miniSplitter = NULL;
  53. m_StyleDisplay=GUISTYLE_XP;
  54. }
  55. GuiCapOutBar::~GuiCapOutBar()
  56. {
  57. }
  58. BOOL GuiCapOutBar::Create(DWORD dwStyle, CWnd* pParentWnd, UINT uID, int iMaxi)
  59. {
  60. SetBarStyle(CBRS_ALIGN_TOP);
  61. m_uID   = uID;
  62. m_iHigh = iMaxi;
  63. return CControlBar::Create(0, 0, dwStyle|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, CRect(0, 0, 0, 0), pParentWnd, uID);
  64. }
  65. void GuiCapOutBar::SetStyleFlag(BOOL m_bFlag)
  66. {
  67. m_bIsFlag = m_bFlag;  // si quiere que se comporte como un boton
  68. }
  69. void GuiCapOutBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
  70. {
  71. }
  72. CSize GuiCapOutBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
  73. {
  74. return CSize(32767, m_iHigh);
  75. }
  76. int GuiCapOutBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
  77. {
  78. if (CControlBar::OnCreate(lpCreateStruct)==-1)
  79. return -1;
  80. return 0;
  81. }
  82. void GuiCapOutBar::OnPaint()
  83. {
  84. CPaintDC dc(this);
  85. CRect rcClient;
  86. GetClientRect(&rcClient);
  87. CBrush cb;
  88. cb.CreateSysColorBrush(GuiDrawLayer::GetRGBColorFace(m_StyleDisplay));
  89. dc.FillRect(rcClient, &cb);
  90. }
  91. void GuiCapOutBar::RecalLayout()
  92. {
  93. if (!GetSafeHwnd())
  94. return;
  95. CRect m_rc;
  96. GetClientRect(m_rc);
  97. if (m_MiniTool != NULL  && m_miniSplitter != NULL) 
  98. {
  99. CRect m_rctemp = m_rc;
  100. m_rctemp.right = m_rc.Width()/2;
  101. m_MiniTool->MoveWindow(m_rctemp);
  102. m_rctemp = m_rc;
  103. m_rctemp.left = (m_rc.Width()/2) + 1;
  104. m_miniSplitter->MoveWindow(m_rctemp);
  105. }
  106. else if (m_MiniTool != NULL)
  107. {
  108. m_MiniTool->MoveWindow(m_rc);
  109. }
  110. else if (m_miniSplitter != NULL)
  111. {
  112. m_miniSplitter->MoveWindow(m_rc);
  113. }
  114. }
  115. BOOL  GuiCapOutBar::SetSplitter(CGuiMiniSplitter* m_sppliter)
  116. {
  117. if (!m_sppliter->Create(this))
  118. return FALSE;
  119. m_miniSplitter = m_sppliter;
  120. RecalLayout();
  121. return TRUE;
  122. }
  123. BOOL GuiCapOutBar::SetMiniTool(CGuiMiniTool* m_sppliter)
  124. {
  125. if (!m_sppliter->Create(_T(""), WS_VISIBLE | WS_CHILD |SS_OWNERDRAW, 
  126. CRect(0, 0, 0, 0), this))
  127. return FALSE;
  128. m_MiniTool = m_sppliter;
  129. RecalLayout();
  130. return TRUE;
  131. }
  132. BOOL GuiCapOutBar::OnEraseBkgnd(CDC* pDC)
  133. {
  134. CBrush cbr;
  135. cbr.CreateSolidBrush(GuiDrawLayer::GetRGBColorFace(m_StyleDisplay));
  136. CRect m_rect;
  137. GetClientRect(m_rect);
  138. pDC->FillRect(m_rect, &cbr);
  139. cbr.DeleteObject();
  140. return TRUE;
  141. }
  142. void GuiCapOutBar::OnSize(UINT nType, int cx, int cy)
  143. {
  144. CControlBar::OnSize(nType, cx, cy);
  145. RecalLayout();
  146. }
  147. void GuiCapOutBar::OnSysColorChange()
  148. {
  149. CControlBar::OnSysColorChange();
  150. }
  151. void GuiCapOutBar::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
  152. {
  153. lpncsp->rgrc[0].bottom -= m_iBorder;
  154. lpncsp->rgrc[0].top    += m_iBorder + 3;
  155. lpncsp->rgrc[0].left   += m_iBorder;
  156. lpncsp->rgrc[0].right  -= m_iBorder;
  157. }
  158. void GuiCapOutBar::OnNcPaint()
  159. {
  160. CRect rcWindow;
  161. CRect rcClient;
  162. CWindowDC dc(this);
  163. GetWindowRect(&rcWindow);
  164. GetClientRect(&rcClient);
  165. CBrush cbr;
  166. cbr.CreateSolidBrush(GuiDrawLayer::GetRGBColorFace(m_StyleDisplay));
  167. rcClient.OffsetRect(-rcWindow.TopLeft());
  168.     rcWindow.OffsetRect(-rcWindow.TopLeft());
  169.     ScreenToClient(rcWindow);
  170. rcClient.OffsetRect(-rcWindow.left, - rcWindow.top);
  171. dc.ExcludeClipRect(rcClient);   
  172. rcWindow.OffsetRect(-rcWindow.left, -rcWindow.top);
  173. int ibotton = rcWindow.bottom;
  174. rcWindow.top = rcWindow.bottom - m_iBorder;
  175. dc.FillRect(rcWindow, &cbr); 
  176. rcWindow.top = 0;
  177. rcWindow.bottom += 3;
  178. dc.FillRect(rcWindow, &cbr); 
  179. dc.FillSolidRect(0, rcWindow.top + 1, rcWindow.right + 1, 1, 
  180. GuiDrawLayer::GetRGBColorBTNHigh()); 
  181. cbr.DeleteObject();
  182. }