XTOutBarCtrlTheme.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:8k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // XTOutBarCtrlTheme.cpp: implementation of the CXTOutBarCtrlTheme class.
  2. //
  3. // This file is a part of the XTREME CONTROLS MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "Common/XTPDrawHelpers.h"
  22. #include "Common/XTPImageManager.h"
  23. #include "Common/XTPColorManager.h"
  24. #include "XTDefines.h"
  25. #include "XTOutBarCtrlTheme.h"
  26. #include "XTFlatComboBox.h"
  27. #include "XTOutBarCtrl.h"
  28. #ifdef _DEBUG
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #define new DEBUG_NEW
  32. #endif
  33. IMPLEMENT_THEME_FACTORY(CXTOutBarCtrlTheme)
  34. //===========================================================================
  35. // CXTOutBarCtrlTheme class
  36. //===========================================================================
  37. CXTOutBarCtrlTheme::CXTOutBarCtrlTheme()
  38. {
  39. m_bFlatIcon = FALSE;
  40. m_bPlainText = FALSE;
  41. }
  42. CXTOutBarCtrlTheme::~CXTOutBarCtrlTheme()
  43. {
  44. }
  45. void CXTOutBarCtrlTheme::RefreshMetrics()
  46. {
  47. CXTThemeManagerStyle ::RefreshMetrics();
  48. m_clrBack.SetStandardValue(GetXtremeColor(COLOR_3DSHADOW));
  49. m_clrText.SetStandardValue(GetXtremeColor(COLOR_WINDOW));
  50. }
  51. void CXTOutBarCtrlTheme::DrawItemIcon(CDC* pDC, CPoint pt, CXTOutBarItem* pBarItem, CImageList* pImageList)
  52. {
  53. int nIndex = pBarItem->GetIndex();
  54. if (pBarItem->IsEnabled())
  55. {
  56. pImageList->Draw(pDC, nIndex, pt, ILD_NORMAL);
  57. }
  58. else
  59. {
  60. HICON hIcon = pImageList->ExtractIcon(nIndex);
  61. if (m_bFlatIcon)
  62. {
  63. CBrush brush(GetXtremeColor(COLOR_3DSHADOW));
  64. pDC->DrawState(pt, CSize(0, 0), hIcon,
  65. DST_ICON | DSS_MONO, (HBRUSH)brush);
  66. }
  67. else
  68. {
  69. pDC->DrawState(pt, CSize(0, 0), hIcon,
  70. DSS_DISABLED | DST_ICON, (HBRUSH)NULL);
  71. }
  72. DestroyIcon(hIcon);
  73. }
  74. }
  75. void CXTOutBarCtrlTheme::DrawItemText(CDC* pDC, CRect rc, CXTOutBarItem* pBarItem, UINT nFormat)
  76. {
  77. CString strText = pBarItem->GetName();
  78. if (pBarItem->IsEnabled())
  79. {
  80. pDC->DrawText(strText, rc, nFormat);
  81. }
  82. else
  83. {
  84. if (m_bPlainText)
  85. {
  86. pDC->SetTextColor(GetXtremeColor(COLOR_3DSHADOW));
  87. pDC->DrawText(strText, rc, nFormat);
  88. }
  89. else
  90. {
  91. rc.OffsetRect(1, 1);
  92. pDC->SetTextColor(GetXtremeColor(COLOR_WINDOW));
  93. pDC->DrawText(strText, rc, nFormat);
  94. rc.OffsetRect(-1, -1);
  95. pDC->SetTextColor(GetXtremeColor(COLOR_3DSHADOW));
  96. pDC->DrawText(strText, rc, nFormat);
  97. }
  98. }
  99. }
  100. void CXTOutBarCtrlTheme::DrawFolder(CDC* pDC, CRect rect, CXTOutBarFolder* pBarFolder, const XTMouseState eHilight)
  101. {
  102. CRect rcFolder(rect);
  103. CXTPFontDC fnt(pDC, pBarFolder->GetControl()->GetFontX());
  104. pDC->SetBkMode(TRANSPARENT);
  105. pDC->SetTextColor(GetXtremeColor(COLOR_BTNTEXT));
  106. pDC->FillSolidRect(rect, GetXtremeColor(COLOR_3DFACE));
  107. switch (eHilight)
  108. {
  109. case xtMouseNormal:
  110. pDC->Draw3dRect(rect, GetXtremeColor(COLOR_3DHILIGHT), GetXtremeColor(COLOR_3DSHADOW));
  111. break;
  112. case xtMouseSelect:
  113. pDC->Draw3dRect(rect, GetXtremeColor(COLOR_3DDKSHADOW), GetXtremeColor(COLOR_3DFACE));
  114. rect.InflateRect(-1, -1);
  115. pDC->Draw3dRect(rect, GetXtremeColor(COLOR_3DSHADOW), GetXtremeColor(COLOR_3DHILIGHT));
  116. break;
  117. case xtMouseHover:
  118. pDC->Draw3dRect(rect, GetXtremeColor(COLOR_3DFACE), GetXtremeColor(COLOR_3DDKSHADOW));
  119. rect.InflateRect(-1, -1);
  120. pDC->Draw3dRect(rect, GetXtremeColor(COLOR_3DHILIGHT), GetXtremeColor(COLOR_3DSHADOW));
  121. break;
  122. }
  123. rcFolder.DeflateRect(4, 0);
  124. pDC->DrawText(pBarFolder->GetName(), rcFolder,
  125. DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
  126. }
  127. void CXTOutBarCtrlTheme::FillInsideRect(CDC* pDC, CRect rc)
  128. {
  129. pDC->FillSolidRect(rc, m_clrBack);
  130. }
  131. void CXTOutBarCtrlTheme::DrawIconFrame(CDC* pDC, CRect rcIcon, BOOL bSelected, BOOL bPressed)
  132. {
  133. if (!bSelected)
  134. {
  135. if (bPressed)
  136. pDC->Draw3dRect(rcIcon, GetXtremeColor(COLOR_WINDOWFRAME), GetXtremeColor(COLOR_3DFACE));
  137. else
  138. pDC->Draw3dRect(rcIcon, GetXtremeColor(COLOR_3DFACE), GetXtremeColor(COLOR_WINDOWFRAME));
  139. }
  140. else
  141. {
  142. pDC->Draw3dRect(rcIcon, GetXtremeColor(COLOR_WINDOWFRAME), GetXtremeColor(COLOR_3DFACE));
  143. }
  144. }
  145. //////////////////////////////////////////////////////////////////////////
  146. // CXTOutBarCtrlThemeOfficeXP
  147. CXTOutBarCtrlThemeOfficeXP::CXTOutBarCtrlThemeOfficeXP()
  148. {
  149. m_bFlatIcon = TRUE;
  150. m_bPlainText = TRUE;
  151. }
  152. void CXTOutBarCtrlThemeOfficeXP::RefreshMetrics()
  153. {
  154. CXTOutBarCtrlTheme::RefreshMetrics();
  155. m_clrBack.SetStandardValue(GetXtremeColor(XPCOLOR_TOOLBAR_FACE));
  156. m_clrText.SetStandardValue(GetXtremeColor(COLOR_BTNTEXT));
  157. }
  158. void CXTOutBarCtrlThemeOfficeXP::DrawIconFrame(CDC* pDC, CRect rcIcon, BOOL bSelected, BOOL bPressed)
  159. {
  160. if (!bSelected)
  161. {
  162. pDC->FillSolidRect(rcIcon, GetXtremeColor(bPressed ? XPCOLOR_HIGHLIGHT_PUSHED : XPCOLOR_HIGHLIGHT));
  163. pDC->Draw3dRect(rcIcon, GetXtremeColor(COLOR_HIGHLIGHT), GetXtremeColor(COLOR_HIGHLIGHT));
  164. }
  165. else
  166. {
  167. pDC->Draw3dRect(rcIcon, GetXtremeColor(COLOR_HIGHLIGHT), GetXtremeColor(COLOR_HIGHLIGHT));
  168. }
  169. }
  170. //////////////////////////////////////////////////////////////////////////
  171. //
  172. CXTOutBarCtrlThemeOffice2003::CXTOutBarCtrlThemeOffice2003()
  173. {
  174. RefreshMetrics();
  175. }
  176. void CXTOutBarCtrlThemeOffice2003::RefreshMetrics()
  177. {
  178. CXTOutBarCtrlThemeOfficeXP::RefreshMetrics();
  179. m_grcPushed.SetStandardValue(GetXtremeColor(XPCOLOR_HIGHLIGHT_PUSHED));
  180. m_grcHot.SetStandardValue(GetXtremeColor(XPCOLOR_HIGHLIGHT));
  181. m_grcSelected.SetStandardValue(GetXtremeColor(XPCOLOR_HIGHLIGHT_CHECKED));
  182. m_bLunaTheme = FALSE;
  183. if (!XTPColorManager()->IsLunaColorsDisabled())
  184. {
  185. XTPCurrentSystemTheme systemTheme = XTPColorManager()->GetCurrentSystemTheme();
  186. switch (systemTheme)
  187. {
  188. case xtpSystemThemeBlue:
  189. case xtpSystemThemeRoyale:
  190. case xtpSystemThemeAero:
  191. m_clrBack.SetStandardValue(RGB(216, 231, 252));
  192. break;
  193. case xtpSystemThemeOlive:
  194. m_clrBack.SetStandardValue(RGB(226, 231, 191));
  195. break;
  196. case xtpSystemThemeSilver:
  197. m_clrBack.SetStandardValue(RGB(223, 223, 234));
  198. break;
  199. }
  200. if (systemTheme != xtpSystemThemeUnknown)
  201. {
  202. m_grcSelected.SetStandardValue(RGB(251, 230, 148), RGB(238, 149, 21));
  203. m_grcPushed.SetStandardValue(RGB(232, 127, 8), RGB(247, 218, 124));
  204. m_grcHot.SetStandardValue(RGB(255, 255, 220), RGB(247, 192, 91));
  205. m_bLunaTheme = TRUE;
  206. }
  207. }
  208. }
  209. void CXTOutBarCtrlThemeOffice2003::DrawFolder(CDC* pDC, CRect rect, CXTOutBarFolder* pBarFolder, const XTMouseState eHilight)
  210. {
  211. CRect rcFolder(rect);
  212. CXTPFontDC fnt(pDC, pBarFolder->GetControl()->GetFontX());
  213. pDC->SetBkMode(TRANSPARENT);
  214. pDC->SetTextColor(GetXtremeColor(COLOR_BTNTEXT));
  215. switch (eHilight)
  216. {
  217. case xtMouseNormal:
  218. XTPDrawHelpers()->GradientFill(pDC, rect, XTPColorManager()->grcDockBar.clrDark, XTPColorManager()->grcDockBar.clrLight, FALSE);
  219. break;
  220. case xtMouseSelect:
  221. XTPDrawHelpers()->GradientFill(pDC, rect, m_grcPushed, FALSE);
  222. break;
  223. case xtMouseHover:
  224. XTPDrawHelpers()->GradientFill(pDC, rect, m_grcSelected, FALSE);
  225. break;
  226. }
  227. pDC->Draw3dRect(rect, GetXtremeColor(COLOR_3DHILIGHT), GetXtremeColor(XPCOLOR_FRAME));
  228. rcFolder.DeflateRect(4, 0);
  229. pDC->DrawText(pBarFolder->GetName(), rcFolder,
  230. DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
  231. }
  232. void CXTOutBarCtrlThemeOffice2003::DrawIconFrame(CDC* pDC, CRect rcIcon, BOOL bSelected, BOOL bPressed)
  233. {
  234. if (!m_bLunaTheme)
  235. {
  236. CXTOutBarCtrlThemeOfficeXP::DrawIconFrame(pDC, rcIcon, bSelected, bPressed);
  237. return;
  238. }
  239. if (!bSelected)
  240. {
  241. if (bPressed)
  242. XTPDrawHelpers()->GradientFill(pDC, rcIcon, m_grcPushed, FALSE);
  243. else
  244. XTPDrawHelpers()->GradientFill(pDC, rcIcon, m_grcHot, FALSE);
  245. }
  246. else
  247. {
  248. XTPDrawHelpers()->GradientFill(pDC, rcIcon, m_grcSelected, FALSE);
  249. }
  250. pDC->Draw3dRect(rcIcon, GetXtremeColor(XPCOLOR_FRAME), GetXtremeColor(XPCOLOR_FRAME));
  251. }