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

对话框与窗口

开发平台:

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 "guilabelbutton.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. IMPLEMENT_DYNAMIC(CGuiLabelButton,CGuiToolButton)
  31. CGuiLabelButton::CGuiLabelButton(void)
  32. {
  33. m_cfont.CreateFont(14,0,0,0,FW_BOLD,0,0,0,0,1,2,1,34,_T("Arial"));
  34. m_bDrawLine=FALSE;
  35. }
  36. CGuiLabelButton::~CGuiLabelButton(void)
  37. {
  38. }
  39. void CGuiLabelButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
  40. {
  41. CDC*  pdc= CDC::FromHandle(lpDrawItemStruct->hDC);
  42. CRect rc=lpDrawItemStruct->rcItem;
  43. UINT  uState=lpDrawItemStruct->itemState;
  44. CFont* m_OldFont;
  45. CBrush cb;
  46. int calculodify;
  47. cb.CreateSolidBrush(m_clColor); //deberia ser blanco
  48. m_OldFont=pdc->SelectObject(&m_cfont);
  49. pdc->FillRect(rc,&cb);
  50. calculodify=rc.Height()-(m_SizeImage.cy);
  51. calculodify/=2;
  52. CPoint m_point=CPoint(2,calculodify+1);
  53. if (m_SizeImage.cx > 2)
  54. {
  55. pdc->DrawState (m_point, m_SizeImage,m_Icon,
  56. (uState==ODS_DISABLED?DSS_DISABLED:DSS_NORMAL),(CBrush*)NULL);
  57. }
  58. if (m_SizeText.cx > 2)
  59. {
  60. int nMode = pdc->SetBkMode(TRANSPARENT);
  61. CRect rectletra=rc;
  62. rectletra.left+=m_SizeImage.cx > 0 ? m_SizeImage.cx+8: 0;
  63. CPoint pt=CSize(rectletra.top,rectletra.left);
  64. if (uState & ODS_DISABLED)
  65. pdc->DrawState(pt, m_SizeText, m_szText, DSS_DISABLED, TRUE, 0, (CBrush*)NULL);
  66. else
  67. pdc->DrawText(m_szText,rectletra,DT_SINGLELINE|DT_LEFT|DT_VCENTER);
  68. pdc->SetBkMode(nMode);
  69. }
  70. pdc->SelectObject(m_OldFont);
  71. if (m_bDrawLine)
  72. {
  73. CPen p(PS_SOLID,1,GuiDrawLayer::GetRGBColorShadow());
  74. CPen* pOldPen=pdc->SelectObject(&p);
  75. pdc->MoveTo(rc.left,rc.bottom-2);
  76. pdc->LineTo(rc.right,rc.bottom-2);
  77. pdc->SelectObject(pOldPen);
  78. }
  79. // TODO:  Add your code to draw the specified item
  80. }