GuiStatusBar.cpp
上传用户:zhanglf88
上传日期:2013-11-19
资源大小:6036k
文件大小:4k
源码类别:

金融证券系统

开发平台:

Visual C++

  1. //-----------------------------------------------------------------------//
  2. // This is a part of the GuiLib MFC Extention.  //
  3. // Autor  :  Francisco Campos  //
  4. // (C) 2002 Francisco Campos <www.beyondata.com> All rights reserved     //
  5. // This code is provided "as is", with absolutely no warranty expressed  //
  6. // or implied. Any use is at your own risk.  //
  7. // You must obtain the author's consent before you can include this code //
  8. // in a software library.  //
  9. // If the source code in  this file is used in any application  //
  10. // then acknowledgement must be made to the author of this program  //
  11. // fcampos@tutopia.com  //
  12. //-----------------------------------------------------------------------//
  13. #include "stdafx.h"
  14. #include "GuiStatusBar.h"
  15. #include "GuiDrawLayer.h"
  16. // CGuiStatusBar
  17. IMPLEMENT_DYNAMIC(CGuiStatusBar, CStatusBar)
  18. CGuiStatusBar::CGuiStatusBar()
  19. {
  20. m_Style=DEVSTUDIO;
  21. }
  22. CGuiStatusBar::~CGuiStatusBar()
  23. {
  24. }
  25. BEGIN_MESSAGE_MAP(CGuiStatusBar, CStatusBar)
  26. ON_WM_PAINT()
  27. END_MESSAGE_MAP()
  28. // CGuiStatusBar message handlers
  29. void CGuiStatusBar::SetStyle(Style nStyle)
  30. {
  31. m_Style=nStyle;
  32. }
  33. void CGuiStatusBar::PreSubclassWindow() 
  34. {
  35. ModifyStyle(0,BS_OWNERDRAW);
  36. CStatusBar::PreSubclassWindow();
  37. }
  38. void CGuiStatusBar::OnPaint()
  39. {
  40. CRect rcClient,rcTemp;
  41. CBrush cb;
  42. CPaintDC dc(this); 
  43. GetClientRect(&rcClient);
  44. cb.CreateSolidBrush(GuiDrawLayer::GetRGBColorFace());
  45. CWnd::DefWindowProc( WM_PAINT, (WPARAM)dc.m_hDC, 0 );
  46. rcTemp=rcClient;
  47. rcClient.bottom=rcClient.top+2;
  48. rcClient.right+=50;
  49. dc.FillRect(rcClient,&cb);
  50. Drawpanels(&dc);
  51. }
  52. void  CGuiStatusBar::Drawpanels(CDC *pDC)
  53. {
  54. int iCont=GetCount();
  55. CRect rcCli,rcCliente;
  56. CString m_cad;
  57. int OldMode=pDC->SetBkMode(TRANSPARENT);
  58. for (int i=0; i < iCont; i++)
  59. {
  60. GetItemRect(i,&rcCli);
  61. GetPaneText(i, m_cad);
  62. if (i == iCont-1)
  63. {
  64. CSize m_sChar=pDC->GetTextExtent(m_cad,m_cad.GetLength());
  65. if (rcCli.Width() < m_sChar.cx)
  66. {
  67. int dif=m_sChar.cx-rcCli.Width();
  68. rcCli.right=rcCli.left+m_sChar.cx-dif;
  69. }
  70. }
  71. if (m_Style == DEVSTUDIO)
  72. pDC->Draw3dRect(rcCli,GuiDrawLayer::GetRGBColorShadow(),GuiDrawLayer::GetRGBColorShadow());
  73. else
  74. pDC->Draw3dRect(rcCli,GuiDrawLayer::GetRGBColorTabs(),GuiDrawLayer::GetRGBColorTabs());
  75. ClearRect(pDC,rcCli);
  76. if (i == iCont-1)
  77. {
  78. rcCli.left=rcCli.right;
  79. rcCli.right=rcCli.left+2;
  80. pDC->Draw3dRect(rcCli,GuiDrawLayer::GetRGBColorFace(),GuiDrawLayer::GetRGBColorFace());
  81. rcCli.right+=1;
  82. pDC->Draw3dRect(rcCli,GuiDrawLayer::GetRGBColorFace(),GuiDrawLayer::GetRGBColorFace());
  83. rcCli.right+=1;
  84. pDC->Draw3dRect(rcCli,GuiDrawLayer::GetRGBColorFace(),GuiDrawLayer::GetRGBColorFace());
  85. }
  86. //rcCli.left+=1;
  87. }
  88. pDC->SetBkMode(OldMode);
  89. GetClientRect(&rcCliente);
  90. if ((rcCliente.right - rcCli.right) != 0)
  91. {
  92. CBrush cb;
  93. cb.CreateSolidBrush(GuiDrawLayer::GetRGBColorFace());
  94. rcCliente.left = rcCli.right;
  95. rcCliente.bottom= rcCliente.top+5;
  96. pDC->FillRect(rcCliente,&cb);
  97. //DrawLB(&rcCliente,pDC);
  98. }
  99. }
  100. void CGuiStatusBar::ClearRect(CDC* pDC,CRect rc)
  101. {
  102. CRect rcCli=rc;
  103. rcCli.left+=1;
  104. rcCli.top+=1;
  105. for (int i=0; i < 3; i++)
  106. {
  107. rcCli.right-=1;
  108. rcCli.bottom-=1;
  109.         pDC->Draw3dRect(rcCli,GuiDrawLayer::GetRGBColorFace(),GuiDrawLayer::GetRGBColorFace());
  110. }
  111. }
  112. void CGuiStatusBar::DrawLB(CRect* rcLb,CDC* pDC)
  113. {
  114. pDC->SelectStockObject(COLOR_3DSHADOW);
  115. int gap=10;
  116. for (int i=0; i< 3; i++)
  117. {
  118. pDC->MoveTo(rcLb->left+gap,rcLb->bottom);
  119. pDC->LineTo(rcLb->right,rcLb->top+gap+1);
  120. gap+=2;
  121. }
  122. }