GuiStatusBar.cpp
上传用户: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. #include "stdafx.h"
  23. #include "GuiStatusBar.h"
  24. #include "GuiDrawLayer.h"
  25. // CGuiStatusBar
  26. IMPLEMENT_DYNAMIC(CGuiStatusBar, CStatusBar)
  27. CGuiStatusBar::CGuiStatusBar()
  28. {
  29. m_Style=DEVSTUDIO;
  30. m_cfont.CreateFont(14,0,0,0,400,0,0,0,0,1,2,1,34,"Arial");
  31. m_StyleDisplay=GUISTYLE_XP;
  32. }
  33. CGuiStatusBar::~CGuiStatusBar()
  34. {
  35. }
  36. BEGIN_MESSAGE_MAP(CGuiStatusBar, CStatusBar)
  37. ON_WM_PAINT()
  38. END_MESSAGE_MAP()
  39. // CGuiStatusBar message handlers
  40. void CGuiStatusBar::SetStyle(Style nStyle)
  41. {
  42. m_Style=nStyle;
  43. }
  44. void CGuiStatusBar::PreSubclassWindow() 
  45. {
  46. ModifyStyle(0,BS_OWNERDRAW);
  47. CStatusBar::PreSubclassWindow();
  48. }
  49. void CGuiStatusBar::OnPaint()
  50. {
  51. CRect rcClient,rcTemp;
  52. CBrush cb;
  53. CPaintDC dc(this); 
  54. GetClientRect(&rcClient);
  55. cb.CreateSolidBrush(GuiDrawLayer::GetRGBColorFace(m_StyleDisplay));
  56. CWnd::DefWindowProc( WM_PAINT, (WPARAM)dc.m_hDC, 0 );
  57. rcTemp=rcClient;
  58. rcClient.bottom=rcClient.top+2;
  59. rcClient.right+=50;
  60. // dc.FillRect(rcClient,&cb);
  61. Drawpanels(&dc);
  62. cb.DeleteObject();
  63. }
  64. void  CGuiStatusBar::Drawpanels(CDC *pDC)
  65. {
  66. int iCont=GetCount();
  67. CRect rcCli,rcCliente;
  68. CString m_cad;
  69. int OldMode=pDC->SetBkMode(TRANSPARENT);
  70. for (int i=0; i < iCont; i++)
  71. {
  72. GetItemRect(i,&rcCli);
  73. GetPaneText(i, m_cad);
  74. if (i == iCont-1)
  75. {
  76. CSize m_sChar=pDC->GetTextExtent(m_cad,m_cad.GetLength());
  77. if (rcCli.Width() < m_sChar.cx)
  78. {
  79. int dif=m_sChar.cx-rcCli.Width();
  80. rcCli.right=rcCli.left+m_sChar.cx-dif;
  81. }
  82. }
  83. /*if(m_StyleDisplay=GUISTYLE_2003)
  84. {
  85. CFont m_fontMenu;
  86. NONCLIENTMETRICS info;
  87. info.cbSize = sizeof(info);
  88. SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0);
  89. VERIFY(m_fontMenu.CreateFontIndirect(&info.lfMenuFont));
  90. CFont* oldfont=(CFont*)pDC->SelectObject(&m_fontMenu);
  91. CGradient M(CSize(rcCli.Width(),rcCli.Height()));
  92. M.PrepareReverseVert(pDC,m_StyleDisplay);
  93. M.Draw(pDC,rcCli.left,rcCli.top,0,0,rcCli.Width(),rcCli.Height(),SRCCOPY);
  94. rcCli.top+=2;
  95. rcCli.left+=3;
  96. pDC->DrawText(m_cad,rcCli,DT_LEFT   );
  97. pDC->SelectObject(oldfont);
  98. }
  99. else
  100. {*/
  101. if (m_Style == DEVSTUDIO)
  102. pDC->Draw3dRect(rcCli,GuiDrawLayer::GetRGBColorShadow(GuiDrawLayer::m_Style),GuiDrawLayer::GetRGBColorShadow(GuiDrawLayer::m_Style));
  103. else
  104. pDC->Draw3dRect(rcCli,GuiDrawLayer::GetRGBColorTabs(),GuiDrawLayer::GetRGBColorTabs());
  105. //}
  106. if (i == iCont-1)
  107. {
  108. rcCli.left=rcCli.right;
  109. rcCli.right=rcCli.left+2;
  110. pDC->Draw3dRect(rcCli,GuiDrawLayer::GetRGBColorFace(),GuiDrawLayer::GetRGBColorFace());
  111. rcCli.right+=1;
  112. pDC->Draw3dRect(rcCli,GuiDrawLayer::GetRGBColorFace(),GuiDrawLayer::GetRGBColorFace());
  113. rcCli.right+=1;
  114. pDC->Draw3dRect(rcCli,GuiDrawLayer::GetRGBColorFace(),GuiDrawLayer::GetRGBColorFace());
  115. }
  116. }
  117. pDC->SetBkMode(OldMode);
  118. GetClientRect(&rcCliente);
  119. if ((rcCliente.right - rcCli.right) != 0)
  120. {
  121. CBrush cb;
  122. cb.CreateSolidBrush(GuiDrawLayer::GetRGBColorFace());
  123. rcCliente.left = rcCli.right;
  124. rcCliente.bottom= rcCliente.top+6;
  125. pDC->FillRect(rcCliente,&cb);
  126. //DrawLB(&rcCliente,pDC);
  127. }
  128. CRect rc;
  129. GetClientRect(&rc);
  130. rc.left=rc.right-15;
  131. rc.top=rc.bottom-15;
  132. CPen pWhite;
  133. CPen pDark;
  134. pWhite.CreatePen(PS_SOLID,1,RGB(255,255,255));
  135. pDark.CreatePen(PS_SOLID,1,GuiDrawLayer::m_Style==GUISTYLE_2003?GuiDrawLayer::GetRGBColorShadow():GuiDrawLayer::GetRGBPressBXP());
  136. CPen* pPt= pDC->SelectObject(&pWhite);
  137. pDC->MoveTo(rc.left,rc.bottom);
  138. pDC->LineTo(rc.right,rc.top);
  139. pDC->SelectObject(&pDark);
  140. pDC->MoveTo(rc.left+1,rc.bottom);
  141. pDC->LineTo(rc.right,rc.top+1);
  142. pDC->MoveTo(rc.left+2,rc.bottom);
  143. pDC->LineTo(rc.right,rc.top+2);
  144. pDC->SelectObject(&pWhite);
  145. pDC->MoveTo(rc.left+4,rc.bottom);
  146. pDC->LineTo(rc.right,rc.top+4);
  147. pDC->SelectObject(&pDark);
  148. pDC->MoveTo(rc.left+5,rc.bottom);
  149. pDC->LineTo(rc.right,rc.top+5);
  150. pDC->MoveTo(rc.left+6,rc.bottom);
  151. pDC->LineTo(rc.right,rc.top+6);
  152. pDC->SelectObject(&pWhite);
  153. pDC->MoveTo(rc.left+8,rc.bottom);
  154. pDC->LineTo(rc.right,rc.top+8);
  155. pDC->SelectObject(&pDark);
  156. pDC->MoveTo(rc.left+9,rc.bottom);
  157. pDC->LineTo(rc.right,rc.top+9);
  158. pDC->MoveTo(rc.left+10,rc.bottom);
  159. pDC->LineTo(rc.right,rc.top+10);
  160. pDC->SelectObject(&pWhite);
  161. pDC->MoveTo(rc.left+12,rc.bottom);
  162. pDC->LineTo(rc.right,rc.top+12);
  163. pDC->SelectObject(&pDark);
  164. pDC->MoveTo(rc.left+13,rc.bottom);
  165. pDC->LineTo(rc.right,rc.top+13);
  166. pDC->SelectObject(pPt);
  167. }
  168. void CGuiStatusBar::ClearRect(CDC* pDC,CRect rc)
  169. {
  170. CRect rcCli=rc;
  171. rcCli.left+=1;
  172. rcCli.top+=1;
  173. for (int i=0; i < 3; i++)
  174. {
  175. rcCli.right-=1;
  176. rcCli.bottom-=1;
  177.         pDC->Draw3dRect(rcCli,GuiDrawLayer::GetRGBColorFace(),GuiDrawLayer::GetRGBColorFace());
  178. }
  179. }
  180. void CGuiStatusBar::DrawLB(CRect* rcLb,CDC* pDC)
  181. {
  182. pDC->SelectStockObject(COLOR_3DSHADOW);
  183. int gap=10;
  184. for (int i=0; i< 3; i++)
  185. {
  186. pDC->MoveTo(rcLb->left+gap,rcLb->bottom);
  187. pDC->LineTo(rcLb->right,rcLb->top+gap+1);
  188. gap+=2;
  189. }
  190. }
  191. void CGuiStatusBar::SetPanelText(CString szText,UINT uPanel)
  192. {
  193. int nIndex=CommandToIndex(uPanel);
  194. SetPaneText(nIndex,szText);
  195. CWindowDC dc(this);
  196. CSize sizeText=dc.GetTextExtent(szText);
  197. SetPaneInfo(nIndex,uPanel,SBPS_NORMAL,sizeText.cx);
  198. }
  199. BOOL CGuiStatusBar::SetIndicators (const UINT* lpIDArray, int nIDCount)
  200. {
  201.     if ( !CStatusBar::SetIndicators (lpIDArray, nIDCount) )
  202.     {
  203.         return false;
  204.     }
  205.     //SendMessage (SB_SETMINHEIGHT, 20);
  206.     for ( int nIndex = 0; nIndex < nIDCount; nIndex++ )
  207.     {
  208.         UINT nID;
  209. UINT nStyle;
  210.         int cxWidth;
  211.         GetPaneInfo (nIndex, nID, nStyle, cxWidth);
  212.         SetPaneInfo (nIndex, nID, nStyle|SBPS_NOBORDERS, cxWidth);
  213.     }
  214.     return true;
  215. }