GuiVisioFolder.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 "guivisiofolder.h"
  24. #include "guiDrawLayer.h"
  25. #include "Guivisiofolder.h"
  26. #ifdef _DEBUG
  27. #undef THIS_FILE
  28. static char THIS_FILE[]=__FILE__;
  29. #define new DEBUG_NEW
  30. #endif
  31. IMPLEMENT_DYNAMIC(CGuiVisioFolder, CGuiFolder)
  32. void  CGuiVisioFolder::SetImageList(UINT nBitmapID, int cx, int nGrow, COLORREF crMask)
  33. {
  34. CBitmap cbmp;
  35. BITMAP bmp;
  36. m_Img.Create(nBitmapID,cx,nGrow,crMask);
  37. cbmp.LoadBitmap(nBitmapID);
  38. cbmp.GetBitmap(&bmp);
  39. m_Img.Add(&cbmp,crMask);
  40. }
  41. void CGuiVisioFolder::DrawFolder(CFolderBar* cfb,Style m_Style)
  42. {
  43. CRect rc=cfb->m_rect;
  44. CRect rcWin=cfb->m_rect;
  45. int nNuImage=cfb->m_img;
  46. CString szStringPoints=_T("...");
  47. CBrush cb;
  48. CClientDC pDC(this);
  49. cb.CreateSysColorBrush(COLOR_BTNFACE);
  50. rc.top+=1;
  51. pDC.FillRect(&rc,&cb);
  52. //se pintan  bordes que simulen un boton
  53. if (m_Style == mNormal)  //el folder no tiene el mouse 
  54. {
  55. pDC.Draw3dRect(rc, GuiDrawLayer::GetRGBColorBTNHigh(),GuiDrawLayer::GetRGBColorShadow());
  56. rc.DeflateRect(1,1);
  57. pDC.Draw3dRect(rc, GuiDrawLayer::GetRGBColorFace(),GuiDrawLayer::GetRGBColorShadow());
  58. }
  59. else if (m_Style == mFlat) //el mouse esta sobre el folder pero no presiona
  60. pDC.Draw3dRect(rc, GuiDrawLayer::GetRGBColorBTNHigh(),GuiDrawLayer::GetRGBColorShadow());
  61. else if (m_Style == mPush) //el mouse esta sobre el folder y presiona
  62. pDC.Draw3dRect(rc, GuiDrawLayer::GetRGBColorShadow(),GuiDrawLayer::GetRGBColorBTNHigh());
  63. int OldMode=pDC.SetBkMode(TRANSPARENT);
  64. cfont = pDC.SelectObject(CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT)));
  65. CString m_cadBreak=cfb->m_lpMsg;
  66. int cont=m_cadBreak.GetLength();
  67. CSize coor=pDC.GetTextExtent(m_cadBreak,m_cadBreak.GetLength());
  68. CSize szImage=CSize(0,0);
  69. //se dibuja la imagen
  70. if(nNuImage != -1) 
  71. {
  72. IMAGEINFO pImageInfo;
  73. m_Img.GetImageInfo(nNuImage,&pImageInfo);
  74. CRect rcima =pImageInfo.rcImage;
  75. szImage=CSize(rcima.Width(),rcima.Height());
  76. CPoint pti=CPoint(rc.left+2,rc.top+3);
  77. m_Img.Draw(&pDC, nNuImage, pti, ILD_TRANSPARENT);
  78. }
  79. //guardar espacio para la imagen
  80. rc.left+=szImage.cx+4;
  81. rc.right-=8;
  82. if ( coor.cx > rc.Width())
  83. {
  84. rc.left+=1;
  85. while(cont > 1 )
  86. {
  87. CString m_scadtemp=m_cadBreak+szStringPoints;
  88. CSize coor=pDC.GetTextExtent(m_scadtemp,m_scadtemp.GetLength());
  89. if(coor.cx > rc.Width())
  90. m_cadBreak=m_cadBreak.Left(m_cadBreak.GetLength()-1);
  91. else
  92. break;
  93. cont--;
  94. }
  95. m_cadBreak+=szStringPoints;
  96. rc.right+=3;
  97. pDC.DrawText(m_cadBreak,rc,DT_SINGLELINE|DT_LEFT|DT_VCENTER);
  98. }
  99. else
  100. pDC.DrawText(cfb->m_lpMsg,rc,DT_WORDBREAK|DT_SINGLELINE|DT_CENTER|DT_VCENTER);
  101. //----se dibuja el gripper----------
  102. rcWin.top+=5;
  103. rcWin.right-=4;
  104. rcWin.left=rcWin.right-3;
  105. rcWin.bottom-=4;
  106. for (int i=0; i < rcWin.Height(); i+=2)
  107. {
  108. CRect rcWindow;
  109. CBrush cb;
  110. cb.CreateSolidBrush(::GetSysColor(COLOR_BTNSHADOW));
  111. rcWindow=rcWin;
  112. rcWindow.top=rcWin.top+i;
  113. rcWindow.bottom=rcWindow.top+1;
  114. pDC.FillRect(rcWindow,&cb);
  115. cb.DeleteObject();
  116. }
  117. //-------------------------
  118. cb.DeleteObject();
  119.     pDC.SetBkColor(OldMode);
  120. }
  121. CGuiVisioFolder::CGuiVisioFolder(void)
  122. {
  123. }
  124. CGuiVisioFolder::~CGuiVisioFolder(void)
  125. {
  126. }
  127. BEGIN_MESSAGE_MAP(CGuiVisioFolder, CGuiFolder)
  128. ON_WM_MOUSEMOVE()
  129. ON_WM_LBUTTONDOWN()
  130. END_MESSAGE_MAP()
  131. void CGuiVisioFolder::OnMouseMove(UINT nFlags, CPoint point)
  132. {
  133. // TODO: Add your message handler code here and/or call default
  134. CGuiFolder::OnMouseMove(nFlags, point);
  135. ::SetCursor(::LoadCursor(NULL,MAKEINTRESOURCE(32649)));//IDC_HAND));
  136. }
  137. void CGuiVisioFolder::OnLButtonDown(UINT nHitTest, CPoint point)
  138. {
  139. // TODO: Add your message handler code here and/or call default
  140. ::SetCursor(::LoadCursor(NULL,MAKEINTRESOURCE(32649)));
  141. CGuiFolder::OnLButtonDown(nHitTest, point);
  142. }