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

对话框与窗口

开发平台:

Visual C++

  1. // XTPRibbonTheme.cpp: implementation of the CXTPRibbonTheme class.
  2. //
  3. // This file is a part of the XTREME RIBBON 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/XTPImageManager.h"
  22. #include "Common/XTPVC80Helpers.h"
  23. #include "Common/XTPOffice2007Image.h"
  24. #include "Common/XTPResourceManager.h"
  25. #include "Common/XTPHookManager.h"
  26. #include "TabManager/XTPTabManager.h"
  27. #include "TabManager/XTPTabPaintManager.h"
  28. #include "CommandBars/XTPOffice2007Theme.h"
  29. #include "CommandBars/XTPOffice2007FrameHook.h"
  30. #include "CommandBars/XTPControlPopup.h"
  31. #include "CommandBars/XTPControlComboBox.h"
  32. #include "CommandBars/XTPControlEdit.h"
  33. #include "CommandBars/XTPCommandBar.h"
  34. #include "CommandBars/XTPPopupBar.h"
  35. #include "CommandBars/XTPStatusBar.h"
  36. #include "CommandBars/XTPCommandBars.h"
  37. #include "XTPRibbonGroup.h"
  38. #include "XTPRibbonBar.h"
  39. #include "XTPRibbonTheme.h"
  40. #include "XTPRibbonTab.h"
  41. #include "XTPRibbonControlTab.h"
  42. #ifdef _DEBUG
  43. #undef THIS_FILE
  44. static char THIS_FILE[]=__FILE__;
  45. #define new DEBUG_NEW
  46. #endif
  47. //////////////////////////////////////////////////////////////////////
  48. // Construction/Destruction
  49. //////////////////////////////////////////////////////////////////////
  50. CXTPRibbonTheme::CXTPRibbonTheme()
  51. {
  52. m_bHotTrackingGroups = TRUE;
  53. m_bFrameStatusBar = TRUE;
  54. m_bClearTypeTextQuality = TRUE;
  55. m_nSplitButtonDropDownWidth = 12;
  56. m_nSplitButtonPopupWidth = 26;
  57. m_nStatusBarMinHeight = 22;
  58. m_pTabPaintManager = CreateTabPaintManager();
  59. m_pTabPaintManager->RefreshMetrics();
  60. m_strOfficeFont = _T("Segoe UI");
  61. m_bUseOfficeFont = TRUE;
  62. m_bOffsetPopupLabelText = FALSE;
  63. m_nFontHeight = 0;
  64. m_rcStatusBarBorder.SetRect(0, 0, 0, 1);
  65. m_pShadowManager->SetShadowOptions(xtpShadowOfficeAlpha);
  66. }
  67. CXTPRibbonTheme::~CXTPRibbonTheme()
  68. {
  69. CMDTARGET_RELEASE(m_pTabPaintManager);
  70. }
  71. AFX_INLINE LPCTSTR FormatName(LPCTSTR lpszName)
  72. {
  73. return lpszName;
  74. }
  75. AFX_INLINE CString FormatName(LPCTSTR lpszFormat, LPCTSTR lpszParameter)
  76. {
  77. CString strResult;
  78. strResult.Format(lpszFormat, lpszParameter);
  79. return strResult;
  80. }
  81. AFX_INLINE BOOL IsCompositeRect(CXTPCommandBar* pRibbonBar, const CRect& rc)
  82. {
  83. if (!pRibbonBar || !pRibbonBar->IsRibbonBar() || !((CXTPRibbonBar*)pRibbonBar)->IsDwmEnabled())
  84. return FALSE;
  85. return CRect().IntersectRect(((CXTPRibbonBar*)pRibbonBar)->GetCaptionRect(), rc);
  86. }
  87. #ifdef _XTP_INCLUDE_RIBBON
  88. BOOL CXTPControl::HasDwmCompositedRect() const
  89. {
  90. return IsCompositeRect(GetParent(), GetRect());
  91. }
  92. #endif
  93. AFX_INLINE DWORD GetDrawImageFlags(CXTPControl* pControl, const CRect& rc)
  94. {
  95. return IsCompositeRect(pControl->GetParent(), rc) ? XTP_DI_COMPOSITE : 0;
  96. }
  97. AFX_INLINE DWORD GetDrawImageFlags(CXTPControl* pControl)
  98. {
  99. return IsCompositeRect(pControl->GetParent(), pControl->GetRect()) ? XTP_DI_COMPOSITE : 0;
  100. }
  101. CString GetColorName(XTPRibbonTabContextColor color)
  102. {
  103. switch (color)
  104. {
  105. case xtpRibbonTabContextColorBlue: return _T("BLUE");
  106. case xtpRibbonTabContextColorYellow: return _T("YELLOW");
  107. case xtpRibbonTabContextColorGreen: return _T("GREEN");
  108. case xtpRibbonTabContextColorRed: return _T("RED");
  109. case xtpRibbonTabContextColorPurple: return _T("PURPLE");
  110. case xtpRibbonTabContextColorCyan: return _T("CYAN");
  111. case xtpRibbonTabContextColorOrange: return _T("ORANGE");
  112. }
  113. return _T("");
  114. }
  115. //////////////////////////////////////////////////////////////////////////
  116. // CXTPRibbonTheme
  117. class CXTPRibbonTheme::CRibbonAppearanceSet : public CXTPTabPaintManager::CAppearanceSetPropertyPageFlat
  118. {
  119. public:
  120. CRibbonAppearanceSet(CXTPRibbonTheme* pRibbonTheme)
  121. : m_pRibbonTheme(pRibbonTheme)
  122. {
  123. m_rcHeaderMargin.SetRect(0, 1, 0, 0);
  124. }
  125. protected:
  126. void DrawSingleButton(CDC* pDC, CXTPTabManagerItem* pItem);
  127. int GetButtonHeight(const CXTPTabManager* /*pTabManager*/)
  128. {
  129. return m_pRibbonTheme->m_nTabsHeight + 1;
  130. }
  131. CXTPRibbonTheme* m_pRibbonTheme;
  132. };
  133. class CXTPRibbonTheme::CRibbonColorSet : public CXTPTabPaintManager::CColorSetOffice2003
  134. {
  135. protected:
  136. void RefreshMetrics()
  137. {
  138. CColorSetOffice2003::RefreshMetrics();
  139. }
  140. };
  141. void CXTPRibbonTheme::DrawRibbonTab(CDC* pDC, CXTPRibbonTab* pItem)
  142. {
  143. XTPTabPosition tabPosition = pItem->GetTabManager()->GetPosition();
  144. CRect rcEntry(pItem->GetRect());
  145. CXTPTabPaintManager::CAppearanceSet::InflateRectEx(rcEntry, CRect(0, 1, -1,  -1), tabPosition);
  146. XTPRibbonTabContextColor tabColor = pItem->GetContextColor();
  147. CXTPRibbonBar* pRibbonBar = pItem->GetRibbonBar();
  148. BOOL bSelected = pItem->IsSelected();
  149. BOOL bHighlighted = pItem->IsHighlighted();
  150. BOOL bFocused = pItem->IsFocused();
  151. if (bSelected && pRibbonBar->IsRibbonMinimized())
  152. {
  153. CXTPRibbonControlTab* pControlTab =  (CXTPRibbonControlTab*)pItem->GetTabManager();
  154. if (pControlTab->GetCommandBar() && pControlTab->GetCommandBar()->IsTrackingMode())
  155. {
  156. bFocused = bHighlighted = FALSE;
  157. }
  158. else if (pControlTab->GetSelected() && bFocused)
  159. {
  160. bFocused = bSelected = FALSE;
  161. bHighlighted = TRUE;
  162. }
  163. else
  164. {
  165. bFocused = bSelected = FALSE;
  166. }
  167. }
  168. if (tabColor != xtpRibbonTabContextColorNone)
  169. {
  170. if (bSelected || bHighlighted)
  171. {
  172. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("CONTEXTTAB%s"), GetColorName(tabColor)));
  173. int nState = 0;
  174. if (bSelected)
  175. {
  176. nState = bFocused || bHighlighted ? 4 : 3;
  177. }
  178. else if (bHighlighted)
  179. {
  180. nState = 1;
  181. }
  182. if (nState == 4)
  183. {
  184. pImage = LoadImage(FormatName(_T("RIBBONTAB")));
  185. if (pImage) pImage->DrawImage(pDC, rcEntry, pImage->GetSource(5, 6), CRect(5, 5, 5, 5), 0xFF00FF);
  186. }
  187. else
  188. {
  189. if (pImage) pImage->DrawImage(pDC, rcEntry, pImage->GetSource(nState, 5), CRect(5, 5, 5, 5));
  190. }
  191. }
  192. }
  193. else
  194. {
  195. if (bSelected || bHighlighted)
  196. {
  197. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("RIBBONTAB")));
  198. int nState = 0;
  199. if (bSelected && bFocused)
  200. {
  201. nState = 5;
  202. }
  203. else if (bSelected && bHighlighted)
  204. {
  205. nState = 4;
  206. }
  207. else if (bSelected)
  208. {
  209. nState = 3;
  210. }
  211. else if (pItem->IsPressed())
  212. {
  213. nState = 2;
  214. }
  215. else if (bHighlighted)
  216. {
  217. nState = 1;
  218. }
  219. if (pImage) pImage->DrawImage(pDC, rcEntry, pImage->GetSource(nState, 6), CRect(5, 5, 5, 5), 0xFF00FF);
  220. }
  221. }
  222. if (pItem->GetButtonLength() < pItem->GetContentLength())
  223. {
  224. CRect rcSeparator(rcEntry.right, rcEntry.top, rcEntry.right + 1, rcEntry.bottom);
  225. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("RIBBONTABSEPARATOR")));
  226. if (pImage) pImage->DrawImage(pDC, rcSeparator, pImage->GetSource(), CRect(0, 0, 0, 0));
  227. }
  228. if (tabColor != xtpRibbonTabContextColorNone && pItem->GetContextHeader() &&
  229. (pItem->GetContextHeader()->m_pFirstTab == pItem))
  230. {
  231. CRect rcSeparator(rcEntry.left, rcEntry.top, rcEntry.left + 1, rcEntry.bottom - 1);
  232. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("CONTEXTTABSEPARATOR")));
  233. if (pImage) pImage->DrawImage(pDC, rcSeparator, pImage->GetSource(), CRect(0, 0, 0, 0));
  234. }
  235. if (tabColor != xtpRibbonTabContextColorNone && pItem->GetContextHeader() &&
  236. (pItem->GetContextHeader()->m_pLastTab == pItem))
  237. {
  238. CRect rcSeparator(rcEntry.right, rcEntry.top, rcEntry.right + 1, rcEntry.bottom - 1);
  239. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("CONTEXTTABSEPARATOR")));
  240. if (pImage) pImage->DrawImage(pDC, rcSeparator, pImage->GetSource(), CRect(0, 0, 0, 0));
  241. }
  242. }
  243. void CXTPRibbonTheme::CRibbonAppearanceSet::DrawSingleButton(CDC* pDC, CXTPTabManagerItem* pItem)
  244. {
  245. m_pRibbonTheme->DrawRibbonTab(pDC, (CXTPRibbonTab*)pItem);
  246. m_pPaintManager->DrawSingleButtonIconAndText(pDC, pItem, pItem->GetRect() , TRUE);
  247. }
  248. void CXTPRibbonTheme::UpdateFonts()
  249. {
  250. CNonClientMetrics ncm;
  251. CLogFont lf;
  252. int nBaseHeight = ncm.lfMenuFont.lfHeight < 0 ? -ncm.lfMenuFont.lfHeight : ncm.lfMenuFont.lfHeight;
  253. if (m_nFontHeight > 11)
  254. nBaseHeight = m_nFontHeight;
  255. if (nBaseHeight <= 12) nBaseHeight = 11;
  256. int nLogPixel = 96; //CWindowDC(NULL).GetDeviceCaps(LOGPIXELSY);
  257. lf.lfWeight = FW_NORMAL;
  258. lf.lfItalic = FALSE;
  259. lf.lfCharSet = ncm.lfMenuFont.lfCharSet;
  260. lf.lfQuality = ncm.lfMenuFont.lfQuality;
  261. if (m_bClearTypeTextQuality && XTPSystemVersion()->IsClearTypeTextQualitySupported())
  262. {
  263. lf.lfQuality = 5;
  264. ncm.lfSmCaptionFont.lfQuality = 5;
  265. ncm.lfStatusFont.lfQuality = 5;
  266. }
  267. if (m_bUseOfficeFont && FontExists(m_strOfficeFont))
  268. {
  269. STRCPY_S(lf.lfFaceName, LF_FACESIZE, m_strOfficeFont);
  270. STRCPY_S(ncm.lfStatusFont.lfFaceName, LF_FACESIZE, m_strOfficeFont);
  271. }
  272. else
  273. {
  274. STRCPY_S(lf.lfFaceName, LF_FACESIZE, ncm.lfMenuFont.lfFaceName);
  275. }
  276. lf.lfHeight = nBaseHeight * 120 / nLogPixel;
  277. if (m_bUseStandardFont)
  278. {
  279. LOGFONT lfFont = lf;
  280. SetCommandBarsFontIndirect(&lfFont, TRUE);
  281. }
  282. m_nTextHeight = max(22, nBaseHeight * 144 / nLogPixel + 6);
  283. m_nEditHeight = max(22, nBaseHeight * 195 / nLogPixel);
  284. m_nTabsHeight = m_nEditHeight > 22 ? m_nEditHeight + 2 : 23;
  285. m_nGroupCaptionHeight = max(17, nBaseHeight * 144 / nLogPixel);
  286. m_nSplitButtonDropDownWidth = max(12, m_nTextHeight / 2);
  287. m_fontGroupCaption.SetStandardFont(&lf);
  288. LOGFONT lfIcon = lf;
  289. STRCPY_S(lfIcon.lfFaceName, LF_FACESIZE, ncm.lfMenuFont.lfFaceName);
  290. VERIFY(m_fontIcon.SetStandardFont(&lfIcon));
  291. lfIcon.lfWeight = FW_BOLD;
  292. VERIFY(m_fontIconBold.SetStandardFont(&lfIcon));
  293. m_pTabPaintManager->RefreshMetrics();
  294. m_pTabPaintManager->SetFontIndirect(&lf, TRUE);
  295. m_fontSmCaption.SetStandardFont(&ncm.lfSmCaptionFont);
  296. m_fontToolTip.SetStandardFont(&ncm.lfStatusFont);
  297. }
  298. void CXTPRibbonTheme::RefreshMetrics()
  299. {
  300. CXTPOffice2007Theme::RefreshMetrics();
  301. //////////////////////////////////////////////////////////////////////////
  302. // Colors
  303. CXTPOffice2007Images* pImages = GetImages();
  304. m_clrRibbonFace = GetImages()->GetImageColor(_T("Ribbon"), _T("RibbonFace"));
  305. m_pTabPaintManager->GetColorSet()->m_clrHighlightText.SetStandardValue(pImages->GetImageColor(_T("Ribbon"), _T("TabNormalText")));
  306. m_pTabPaintManager->GetColorSet()->m_clrNormalText.SetStandardValue(pImages->GetImageColor(_T("Ribbon"), _T("TabNormalText")));
  307. m_pTabPaintManager->GetColorSet()->m_clrSelectedText.SetStandardValue(pImages->GetImageColor(_T("Ribbon"), _T("TabSelectedText")));
  308. m_clrRibbonGroupCaptionText = pImages->GetImageColor(_T("Ribbon"), _T("GroupCaptionText"));
  309. m_arrColor[XPCOLOR_TOOLBAR_TEXT].SetStandardValue(pImages->GetImageColor(_T("Ribbon"), _T("GroupClientText")));
  310. m_clrRibbonText = pImages->GetImageColor(_T("Ribbon"), _T("RibbonText"));
  311. m_clrControlEditNormal = pImages->GetImageColor(_T("Ribbon"), _T("ControlEditNormal"));
  312. m_clrMinimizedFrameEdgeHighLight = pImages->GetImageColor(_T("Ribbon"), _T("MinimizedFrameEdgeHighLight"));
  313. m_clrMinimizedFrameEdgeShadow = pImages->GetImageColor(_T("Ribbon"), _T("MinimizedFrameEdgeShadow"));
  314. m_arrColor[XPCOLOR_MENUBAR_TEXT].SetStandardValue(pImages->GetImageColor(_T("Ribbon"), _T("MenuPopupText")));
  315. m_clrMenuGripper.SetStandardValue(pImages->GetImageColor(_T("Ribbon"), _T("MenuPopupGripper")));
  316. m_clrMenuExpandedGripper.SetStandardValue(pImages->GetImageColor(_T("Ribbon"), _T("MenuPopupExpandedGripperLight")),
  317. pImages->GetImageColor(_T("Ribbon"), _T("MenuPopupExpandedGripperDark")));
  318. m_pShadowManager->SetShadowColor(0);
  319. m_arrColor[XPCOLOR_MENUBAR_GRAYTEXT].SetStandardValue(RGB(167, 167, 167));
  320. m_arrColor[XPCOLOR_HIGHLIGHT_TEXT].SetStandardValue(pImages->GetImageColor(_T("Ribbon"), _T("ControlHighlightText")));
  321. m_arrColor[XPCOLOR_MENUBAR_BORDER].SetStandardValue(RGB(134, 134, 134));
  322. m_arrColor[XPCOLOR_MENUBAR_FACE].SetStandardValue(RGB(250, 250, 250));
  323. m_clrMenuExpand.SetStandardValue(RGB(233, 238, 238), RGB(233, 238, 238));
  324. CreateGradientCircle();
  325. }
  326. CXTPTabPaintManager* CXTPRibbonTheme::CreateTabPaintManager()
  327. {
  328. CXTPTabPaintManager* pTabPaintManager = new CXTPTabPaintManager();
  329. pTabPaintManager->SetAppearanceSet(new CRibbonAppearanceSet(this));
  330. pTabPaintManager->SetLayout(xtpTabLayoutSizeToFit);
  331. pTabPaintManager->SetColorSet(new CRibbonColorSet);
  332. pTabPaintManager->m_bFillBackground = FALSE;
  333. pTabPaintManager->m_bHotTracking = TRUE;
  334. pTabPaintManager->m_clientFrame = xtpTabFrameSingleLine;
  335. pTabPaintManager->m_bDrawTextNoPrefix = FALSE;
  336. pTabPaintManager->m_rcButtonMargin.SetRect(0, 2, 0, 2);
  337. pTabPaintManager->m_rcButtonTextPadding.SetRect(4, 0, 4, 0);
  338. pTabPaintManager->m_nButtonExtraLength = 21;
  339. pTabPaintManager->m_bDrawTextEndEllipsis = FALSE;
  340. pTabPaintManager->m_bDrawFocusRect = FALSE;
  341. pTabPaintManager->EnableToolTips(xtpTabToolTipShrinkedOnly);
  342. pTabPaintManager->m_bClearTypeTextQuality = m_bClearTypeTextQuality;
  343. pTabPaintManager->m_bClipHeader = FALSE;
  344. return pTabPaintManager;
  345. }
  346. void CXTPRibbonTheme::FillGroupPopupToolBar(CDC* pDC, CXTPRibbonGroup* pGroup, CXTPCommandBar* pCommandBar)
  347. {
  348. pDC->SetBkMode(TRANSPARENT);
  349. CXTPClientRect rcRibbon(pCommandBar);
  350. pDC->FillSolidRect(rcRibbon, RGB(191, 219, 255));
  351. rcRibbon.InflateRect(3, 3);
  352. XTPRibbonTabContextColor tabColor = pGroup->GetParentTab()->GetContextColor();
  353. if (tabColor != xtpRibbonTabContextColorNone)
  354. {
  355. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("CONTEXTTAB%sCLIENT"), GetColorName(tabColor)));
  356. if (pImage) pImage->DrawImage(pDC, rcRibbon, pImage->GetSource(0, 1), CRect(8, 8, 8, 8));
  357. }
  358. else
  359. {
  360. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("RIBBONGROUPS")));
  361. if (pImage) pImage->DrawImage(pDC, rcRibbon, pImage->GetSource(0, 1), CRect(8, 8, 8, 8));
  362. }
  363. }
  364. void CXTPRibbonTheme::DrawGroup(CDC* pDC, CXTPRibbonGroup* pGroup)
  365. {
  366. CRect rcGroup(pGroup->GetRect());
  367. CRect rcGroupClient(rcGroup.left, rcGroup.top, rcGroup.right, rcGroup.bottom - m_nGroupCaptionHeight);
  368. CRect rcGroupCaption(rcGroup.left, rcGroupClient.bottom, rcGroup.right, rcGroup.bottom);
  369. if (!pGroup->IsReduced())
  370. {
  371. CXTPOffice2007Image* pImage, *pImageCaption;
  372. if (pGroup->GetParentTab()->GetContextColor() == xtpRibbonTabContextColorNone)
  373. {
  374. pImage = LoadImage(FormatName(_T("RIBBONGROUPCLIENT")));
  375. pImageCaption = LoadImage(FormatName(_T("RIBBONGROUPCAPTION")));
  376. }
  377. else
  378. {
  379. pImage = LoadImage(FormatName(_T("CONTEXTTABGROUPCLIENT")));
  380. pImageCaption = LoadImage(FormatName(_T("CONTEXTTABGROUPCAPTION")));
  381. }
  382. int nState = pGroup->IsHighlighted() ? 1 : 0;
  383. if (pImage) pImage->DrawImage(pDC, rcGroupClient, pImage->GetSource(nState, 2), CRect(5, 5, 5, 5));
  384. if (pImageCaption) pImageCaption->DrawImage(pDC, rcGroupCaption,  pImageCaption->GetSource(nState, 2), CRect(5, 5, 5, 5));
  385. CString strCaption = pGroup->GetCaption();
  386. XTPDrawHelpers()->StripMnemonics(strCaption);
  387. CXTPFontDC font(pDC, &m_fontGroupCaption);
  388. CRect rcGroupCaptionText(rcGroupCaption);
  389. rcGroupCaptionText.OffsetRect(0, -1);
  390. if (pGroup->IsOptionButtonVisible())
  391. rcGroupCaptionText.right -= m_nGroupCaptionHeight + 1;
  392. rcGroupCaptionText.DeflateRect(2, 2);
  393. pDC->SetTextColor(m_clrRibbonGroupCaptionText);
  394. pDC->DrawText(strCaption, rcGroupCaptionText, DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_END_ELLIPSIS | DT_CENTER);
  395. }
  396. }
  397. void CXTPRibbonTheme::FillTabPopupToolBar(CDC* pDC, CXTPPopupToolBar* pPopupToolBar)
  398. {
  399. CXTPClientRect rcRibbonClient(pPopupToolBar);
  400. pDC->FillSolidRect(rcRibbonClient, m_clrRibbonFace);
  401. }
  402. void CXTPRibbonTheme::FillRibbonBar(CDC* pDC, CXTPRibbonBar* pRibbonBar)
  403. {
  404. CXTPClientRect rcRibbonClient(pRibbonBar);
  405. if (pRibbonBar->IsFrameThemeEnabled())
  406. rcRibbonClient.top += m_nRibbonCaptionHeight;
  407. CRect rcRibbonTabs(rcRibbonClient.left, rcRibbonClient.top, rcRibbonClient.right, rcRibbonClient.top + m_nTabsHeight);
  408. CRect rcRibbonGroups(rcRibbonClient.left, rcRibbonTabs.bottom, rcRibbonClient.right, rcRibbonClient.bottom);
  409. pDC->FillSolidRect(rcRibbonTabs, m_clrRibbonFace);
  410. pDC->FillSolidRect(rcRibbonGroups, m_clrRibbonFace);
  411. if (pRibbonBar->IsQuickAccessBelowRibbon())
  412. {
  413. CRect rcQuickAccess = pRibbonBar->GetQuickAccessRect();
  414. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("RIBBONQUICKACCESSFRAME")));
  415. if (pImage) pImage->DrawImage(pDC, rcQuickAccess, pImage->GetSource(0, 1), CRect(3, 3, 3, 3));
  416. }
  417. if (!pRibbonBar->IsGroupsVisible() && !pRibbonBar->IsQuickAccessBelowRibbon())
  418. {
  419. HorizontalLine(pDC, rcRibbonClient.left, rcRibbonClient.bottom - 2, rcRibbonClient.right, m_clrMinimizedFrameEdgeShadow);
  420. HorizontalLine(pDC, rcRibbonClient.left, rcRibbonClient.bottom - 1, rcRibbonClient.right, m_clrMinimizedFrameEdgeHighLight);
  421. }
  422. }
  423. void CXTPRibbonTheme::FillGroupRect(CDC* pDC, CXTPRibbonTab* pActiveTab, CRect rcGroups)
  424. {
  425. XTPRibbonTabContextColor tabColor = pActiveTab ? pActiveTab->GetContextColor() : xtpRibbonTabContextColorNone;
  426. if (tabColor != xtpRibbonTabContextColorNone)
  427. {
  428. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("CONTEXTTAB%sCLIENT"), GetColorName(tabColor)));
  429. if (pImage) pImage->DrawImage(pDC, rcGroups, pImage->GetSource(0, 1), CRect(8, 8, 8, 8));
  430. }
  431. else
  432. {
  433. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("RIBBONGROUPS")));
  434. if (pImage) pImage->DrawImage(pDC, rcGroups, pImage->GetSource(0, 1), CRect(8, 8, 8, 8));
  435. }
  436. }
  437. CSize CXTPRibbonTheme::DrawControlGroupOption(CDC* pDC, CXTPControl* pControlGroupOption, BOOL bDraw)
  438. {
  439. if (bDraw)
  440. {
  441. CRect rc = pControlGroupOption->GetRect();
  442. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("RIBBONOPTIONBUTTON")));
  443. int nState = 0;
  444. if (pControlGroupOption->GetSelected()) nState = 1;
  445. if (pControlGroupOption->GetPressed()) nState = 2;
  446. if (pImage) pImage->DrawImage(pDC, rc, pImage->GetSource(nState, 4), CRect(3, 2, 2, 2), 0xFF00FF);
  447. }
  448. return CSize(15, 14);
  449. }
  450. CSize CXTPRibbonTheme::DrawControlGroupPopup(CDC* pDC, CXTPControlPopup* pControlGroupPopup, BOOL bDraw)
  451. {
  452. CXTPRibbonGroup* pRibbonGroup = pControlGroupPopup->GetRibbonGroup();
  453. CXTPOffice2007Image* pImage = NULL;
  454. int nOffset = 0;
  455. if (pControlGroupPopup->GetSelected()) nOffset = 1;
  456. if (pControlGroupPopup->GetPopuped()) nOffset = 2;
  457. if (!pRibbonGroup)
  458. {
  459. if (bDraw)
  460. {
  461. pImage = LoadImage(FormatName(_T("RIBBONGROUPQUICKACCESS")));
  462. ASSERT(pImage);
  463. if (pImage) pImage->DrawImage(pDC, pControlGroupPopup->GetRect(),
  464. pImage->GetSource(nOffset, 3), CRect(2, 2, 2, 2), 0xFF00FF, GetDrawImageFlags(pControlGroupPopup));
  465. }
  466. return DrawControlToolBarParent(pDC, pControlGroupPopup, bDraw);
  467. }
  468. if (bDraw)
  469. {
  470. CRect rc = pControlGroupPopup->GetRect();
  471. XTPRibbonTabContextColor tabColor = pRibbonGroup ? pRibbonGroup->GetParentTab()->GetContextColor() : xtpRibbonTabContextColorNone;
  472. if (tabColor != xtpRibbonTabContextColorNone)
  473. {
  474. pImage = LoadImage(FormatName(_T("CONTEXTTAB%sGROUPBUTTON"), GetColorName(tabColor)));
  475. }
  476. else
  477. {
  478. pImage = LoadImage(FormatName(_T("RIBBONGROUPBUTTON")));
  479. }
  480. if (pImage) pImage->DrawImage(pDC, rc, pImage->GetSource(nOffset, 3), CRect(5, 5, 5, 5));
  481. }
  482. CSize szButton(max(42, m_nTextHeight * 2 - 3), m_nEditHeight * 3);
  483. CXTPFontDC font(pDC, GetCommandBarFont(pControlGroupPopup->GetParent(), FALSE));
  484. int nSplitDropDownHeight = GetSplitDropDownHeight();
  485. if (bDraw)
  486. {
  487. CXTPImageManagerIcon* pImageIcon = pControlGroupPopup->GetImage(0);
  488. BOOL bDrawImage = (pImageIcon != NULL);
  489. CRect rcButton = pControlGroupPopup->GetRect();
  490. if (bDrawImage)
  491. {
  492. CSize sz(pImageIcon->GetWidth(), pImageIcon->GetHeight());
  493. CPoint pt = CPoint(rcButton.CenterPoint().x - sz.cx / 2, rcButton.top + 4);
  494. if (sz.cx < 20)
  495. {
  496. CXTPOffice2007Image* pImageButton = LoadImage(FormatName(_T("RIBBONGROUPBUTTONICON")));
  497. CRect rc(CPoint(rcButton.CenterPoint().x - pImageButton->GetWidth() / 2, rcButton.top + 2),
  498. CSize(pImageButton->GetWidth(), pImageButton->GetHeight()));
  499. if (pImageButton) pImageButton->DrawImage(pDC, rc, pImageButton->GetSource(0, 1), CRect(0, 0, 0, 0));
  500. pt.y = rcButton.top + 9;
  501. }
  502. DrawImage(pDC, pt, sz, pImageIcon,
  503. pControlGroupPopup->GetSelected(), pControlGroupPopup->GetPressed(),
  504. pControlGroupPopup->GetEnabled(), FALSE, pControlGroupPopup->GetPopuped());
  505. }
  506. CRect rcText = rcButton;
  507. rcText.bottom -= m_nGroupCaptionHeight + 2;
  508. rcText.top = rcText.bottom - nSplitDropDownHeight;
  509. pDC->SetTextColor(GetControlTextColor(pControlGroupPopup));
  510. DrawControlText2(pDC, pControlGroupPopup, rcText, TRUE, FALSE, TRUE);
  511. }
  512. else
  513. {
  514. CSize szText = DrawControlText2(pDC, pControlGroupPopup, CXTPEmptyRect(), FALSE, FALSE, TRUE);
  515. szButton.cx = max(szButton.cx, szText.cx + 5);
  516. }
  517. return szButton;
  518. }
  519. //////////////////////////////////////////////////////////////////////////
  520. // CommandBars Theme
  521. BOOL CXTPRibbonTheme::IsImagesAvailable()
  522. {
  523. return TRUE;
  524. }
  525. void CXTPRibbonTheme::DrawControlEntry(CDC* pDC, CXTPControl* pButton)
  526. {
  527. if (pButton->GetRibbonGroup() && pButton->GetRibbonGroup()->IsControlsGrouping())
  528. {
  529. BOOL bLeft = pButton->GetBeginGroup() || pButton->GetWrap();
  530. int nIndexNext = pButton->GetControls()->GetNext(pButton->GetIndex());
  531. BOOL bRight = nIndexNext <= pButton->GetIndex() ||
  532. pButton->GetControls()->GetAt(nIndexNext)->GetBeginGroup() ||
  533. pButton->GetControls()->GetAt(nIndexNext)->GetWrap();
  534. CString strImage = FormatName(bLeft && bRight ? _T("TOOLBARBUTTONSSPECIALSINGLE") :
  535. bLeft ? _T("TOOLBARBUTTONSSPECIALLEFT") :
  536. bRight ? _T("TOOLBARBUTTONSSPECIALRIGHT") :
  537. _T("TOOLBARBUTTONSSPECIALCENTER"));
  538. CXTPOffice2007Image* pImage = LoadImage(strImage);
  539. ASSERT(pImage);
  540. if (!pImage)
  541. return;
  542. BOOL bPopuped = pButton->GetPopuped();
  543. BOOL bEnabled = pButton->GetEnabled();
  544. BOOL bChecked = pButton->GetChecked();
  545. BOOL bSelected = pButton->GetSelected();
  546. BOOL bPressed = pButton->GetPressed();
  547. CRect rc = pButton->GetRect();
  548. CRect rcSrc = CRect(0, 0, 22, 22);
  549. int nState = 0;
  550. if (!bEnabled)
  551. {
  552. if (IsKeyboardSelected(bSelected)) nState = 0 + 1;
  553. }
  554. else if (bPopuped) nState = 2 + 1;
  555. else if (bChecked && !bSelected && !bPressed) nState = 2 + 1;
  556. else if (bChecked && bSelected && !bPressed) nState = 3 + 1;
  557. else if (IsKeyboardSelected(bPressed) || (bSelected && bPressed)) nState = 1 + 1;
  558. else if (bSelected || bPressed) nState = 0 + 1;
  559. rcSrc.OffsetRect(0, rcSrc.Height() * nState);
  560. pImage->DrawImage(pDC, rc, rcSrc, CRect(2, 2, 2, 2), 0xFF00FF);
  561. return;
  562. }
  563. CXTPOffice2007Theme::DrawControlEntry(pDC, pButton);
  564. }
  565. COLORREF CXTPRibbonTheme::GetControlTextColor(CXTPControl* pButton)
  566. {
  567. if (pButton->GetRibbonGroup() == NULL && pButton->GetParent()->IsRibbonBar())
  568. {
  569. CXTPRibbonBar* pRibbonBar = (CXTPRibbonBar*)pButton->GetParent();
  570. BOOL bCheckBoxStyle = (pButton->GetType() == xtpControlCheckBox || pButton->GetType() == xtpControlRadioButton);
  571. if (pButton->IsKindOf(RUNTIME_CLASS(CXTPRibbonGroupControlPopup)))
  572. bCheckBoxStyle = TRUE;
  573. BOOL bNormalText = bCheckBoxStyle ? pButton->GetEnabled() :
  574. !pButton->GetSelected() && pButton->GetEnabled() &&
  575. !pButton->GetPressed() && !pButton->GetChecked() && !pButton->GetPopuped();
  576. if (bNormalText && pRibbonBar->IsQuickAccessControl(pButton))
  577. {
  578. if (pButton->HasDwmCompositedRect())
  579. {
  580. return pRibbonBar->GetSite()->GetStyle() & WS_MAXIMIZE ? RGB(255, 255, 255) : RGB(0, 0, 0);
  581. }
  582. return m_clrRibbonText;
  583. }
  584. if (bNormalText)
  585. {
  586. return m_clrRibbonText;
  587. }
  588. }
  589. return CXTPOffice2007Theme::GetControlTextColor(pButton);
  590. }
  591. COLORREF CXTPRibbonTheme::GetRectangleTextColor(BOOL bSelected, BOOL bPressed, BOOL bEnabled, BOOL bChecked, BOOL bPopuped, XTPBarType barType, XTPBarPosition /*barPosition*/)
  592. {
  593. if (barType == xtpBarTypeMenuBar && !bSelected && bEnabled && !bPressed && !bChecked && !bPopuped)
  594. {
  595. return m_clrMenuBarText;
  596. }
  597. if (barType == xtpBarTypePopup)
  598. {
  599. return GetXtremeColor(!bEnabled ? XPCOLOR_MENUBAR_GRAYTEXT : XPCOLOR_MENUBAR_TEXT);
  600. }
  601. return GetXtremeColor(!bEnabled ? XPCOLOR_TOOLBAR_GRAYTEXT : XPCOLOR_TOOLBAR_TEXT);
  602. }
  603. void CXTPRibbonTheme::DrawRectangle(CDC* pDC, CRect rc, BOOL bSelected, BOOL bPressed, BOOL bEnabled /*= TRUE*/, BOOL bChecked /*= FALSE*/, BOOL bPopuped /*= FALSE*/, XTPBarType barType, XTPBarPosition barPosition)
  604. {
  605. if (!IsImagesAvailable())
  606. {
  607. CXTPOffice2003Theme::DrawRectangle(pDC, rc, bSelected, bPressed, bEnabled, bChecked, bPopuped, barType, barPosition);
  608. return;
  609. }
  610. if (barType != xtpBarTypePopup)
  611. {
  612. BOOL bSmallSize = rc.Height() < 33;
  613. CXTPOffice2007Image* pImage = LoadImage(FormatName(bSmallSize ? _T("TOOLBARBUTTONS22") : _T("TOOLBARBUTTONS50")));
  614. ASSERT(pImage);
  615. if (!pImage)
  616. return;
  617. int nState = -1;
  618. if (!bEnabled)
  619. {
  620. if (IsKeyboardSelected(bSelected)) nState = 0;
  621. }
  622. else if (bPopuped) nState = 2;
  623. else if (bChecked && !bSelected && !bPressed) nState = 2;
  624. else if (bChecked && bSelected && !bPressed) nState = 3;
  625. else if (IsKeyboardSelected(bPressed) || (bSelected && bPressed)) nState = 1;
  626. else if (bSelected || bPressed) nState = 0;
  627. if (nState != -1)
  628. {
  629. pImage->DrawImage(pDC, rc, pImage->GetSource(nState, 4), CRect(8, 8, 8, 8), COLORREF_NULL);
  630. }
  631. }
  632. else if (barPosition == xtpBarPopup && bChecked && barType == xtpBarTypePopup)
  633. {
  634. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("MENUCHECKEDITEM")));
  635. ASSERT(pImage);
  636. if (!pImage)
  637. return;
  638. pImage->DrawImage(pDC, rc, pImage->GetSource(bEnabled ? 0 : 1, 2), CRect(4, 4, 4, 4));
  639. }
  640. else if (barPosition == xtpBarPopup && bSelected && barType == xtpBarTypePopup)
  641. {
  642. if (!bEnabled && !IsKeyboardSelected(bSelected))
  643. return;
  644. BOOL bSmallSize = rc.Height() < 33;
  645. CXTPOffice2007Image* pImage = LoadImage(FormatName(
  646. !bEnabled ? bSmallSize ? _T("MENUSELECTEDDISABLEDITEM22") : _T("MENUSELECTEDDISABLEDITEM54") :
  647. bSmallSize ? _T("MENUSELECTEDITEM22") : _T("MENUSELECTEDITEM54")));
  648. ASSERT(pImage);
  649. if (!pImage)
  650. return;
  651. pImage->DrawImage(pDC, rc, pImage->GetSource(), CRect(4, 4, 4, 4));
  652. }
  653. else
  654. {
  655. CXTPOffice2003Theme::DrawRectangle(pDC, rc, bSelected, bPressed, bEnabled, bChecked, bPopuped, barType, barPosition);
  656. }
  657. }
  658. void CXTPRibbonTheme::DrawSplitButtonFrame(CDC* pDC, CXTPControl* pButton, CRect rcButton)
  659. {
  660. if (!IsImagesAvailable())
  661. {
  662. CXTPOffice2003Theme::DrawSplitButtonFrame(pDC, pButton, rcButton);
  663. return;
  664. }
  665. BOOL bPressed = pButton->GetPressed(), bSelected = pButton->GetSelected(), bEnabled = pButton->GetEnabled(), bChecked = pButton->GetChecked(),
  666. bPopuped = pButton->GetPopuped();
  667. BOOL bSmallSize = pButton->GetStyle() != xtpButtonIconAndCaptionBelow;
  668. CXTPOffice2007Image* pImageSplit, *pImageSplitDropDown;
  669. int nSpecialOffset = 0;
  670. if (pButton->GetRibbonGroup() && pButton->GetRibbonGroup()->IsControlsGrouping())
  671. {
  672. bSmallSize = TRUE;
  673. BOOL bLeft = pButton->GetBeginGroup() || pButton->GetWrap();
  674. int nIndexNext = pButton->GetControls()->GetNext(pButton->GetIndex());
  675. BOOL bRight = nIndexNext <= pButton->GetIndex() ||
  676. pButton->GetControls()->GetAt(nIndexNext)->GetBeginGroup() ||
  677. pButton->GetControls()->GetAt(nIndexNext)->GetWrap();
  678. CString strImage = bLeft ? FormatName(_T("TOOLBARBUTTONSSPECIALSPLITLEFT")) :
  679. FormatName(_T("TOOLBARBUTTONSSPECIALSPLITCENTER"));
  680. pImageSplit = LoadImage(strImage);
  681. strImage = bRight ? FormatName(_T("TOOLBARBUTTONSSPECIALSPLITDROPDOWNRIGHT")) :
  682. FormatName(_T("TOOLBARBUTTONSSPECIALSPLITDROPDOWNCENTER"));
  683. pImageSplitDropDown  = LoadImage(strImage);
  684. nSpecialOffset = 1;
  685. }
  686. else
  687. {
  688. pImageSplit = LoadImage(bSmallSize ? FormatName(_T("TOOLBARBUTTONSSPLIT22")) : FormatName(_T("TOOLBARBUTTONSSPLIT50")));
  689. pImageSplitDropDown = LoadImage(bSmallSize ? FormatName(_T("TOOLBARBUTTONSSPLITDROPDOWN22")) : FormatName(_T("TOOLBARBUTTONSSPLITDROPDOWN50")));
  690. }
  691. if (!pImageSplit || !pImageSplitDropDown)
  692. return;
  693. int nSplitDropDownHeight = GetSplitDropDownHeight();
  694. COLORREF clrText = !bEnabled ? RGB(141, 141, 141) : RGB(21, 66, 139);
  695. pDC->SetTextColor(clrText);
  696. pDC->SetBkMode (TRANSPARENT);
  697. CRect rcSplit = bSmallSize ? CRect(rcButton.left, rcButton.top, rcButton.right - m_nSplitButtonDropDownWidth, rcButton.bottom) :
  698. CRect(rcButton.left, rcButton.top, rcButton.right, rcButton.bottom - nSplitDropDownHeight);
  699. CRect rcSplitSrc  = pImageSplit->GetSource(0, 6 + nSpecialOffset);
  700. CRect rcSplitDropDown = bSmallSize ? CRect(rcButton.right - m_nSplitButtonDropDownWidth, rcButton.top, rcButton.right, rcButton.bottom) :
  701. CRect(rcButton.left, rcButton.bottom - nSplitDropDownHeight, rcButton.right, rcButton.bottom);
  702. CRect rcSplitDropDownSrc = pImageSplitDropDown->GetSource(0, 5 + nSpecialOffset);
  703. int nStateSplit = -1;
  704. BOOL bMouseInSplit = bSelected == TRUE_SPLITCOMMAND;
  705. BOOL bMouseInSplitDropDown = bSelected == TRUE_SPLITDROPDOWN;
  706. if (bEnabled == TRUE_SPLITDROPDOWN && (bSelected || bPressed || bPopuped))
  707. {
  708. nStateSplit = 4;
  709. }
  710. else if (!bEnabled)
  711. {
  712. if (IsKeyboardSelected(bSelected)) nStateSplit = 5;
  713. }
  714. else if (bChecked)
  715. {
  716. if (bPopuped) nStateSplit = 5;
  717. else if (!bSelected && !bPressed) nStateSplit = 2;
  718. else if (bSelected && !bPressed) nStateSplit = 3;
  719. else if (IsKeyboardSelected(bPressed) || (bSelected && bPressed)) nStateSplit = 1;
  720. else if (bPressed) nStateSplit = 2;
  721. else if (bSelected || bPressed) nStateSplit = !bMouseInSplit ? 5 : 0;
  722. }
  723. else
  724. {
  725. if (bPopuped) nStateSplit = 5;
  726. else if (IsKeyboardSelected(bPressed) || (bSelected && bPressed)) nStateSplit = 1;
  727. else if (bSelected || bPressed) nStateSplit = !bMouseInSplit ? 5 : 0;
  728. }
  729. nStateSplit += nSpecialOffset;
  730. if (nStateSplit != -1)
  731. {
  732. rcSplitSrc.OffsetRect(0, rcSplitSrc.Height() * nStateSplit);
  733. pImageSplit->DrawImage(pDC, rcSplit, rcSplitSrc,
  734. CRect(2, 2, 2, 2), 0xFF00FF, GetDrawImageFlags(pButton, rcSplit));
  735. }
  736. int nStateSplitDropDown = -1;
  737. if (bEnabled == TRUE_SPLITCOMMAND && (bSelected || bPressed || bPopuped))
  738. {
  739. nStateSplitDropDown = 3;
  740. }
  741. else if (!bEnabled)
  742. {
  743. if (IsKeyboardSelected(bSelected)) nStateSplitDropDown = 4;
  744. }
  745. else if (bChecked)
  746. {
  747. if (bPopuped) nStateSplitDropDown = 2;
  748. else if (!bSelected && !bPressed) nStateSplitDropDown = 2;
  749. else if (IsKeyboardSelected(bPressed) || (bSelected && bPressed)) nStateSplitDropDown = 0;
  750. else if (bSelected || bPressed) nStateSplitDropDown = !bMouseInSplitDropDown ? 4 : 0;
  751. else nStateSplitDropDown = 4;
  752. }
  753. else
  754. {
  755. if (bPopuped) nStateSplitDropDown = 2;
  756. else if (IsKeyboardSelected(bPressed) || (bSelected && bPressed)) nStateSplitDropDown = 0;
  757. else if (bSelected || bPressed) nStateSplitDropDown = !bMouseInSplitDropDown ? 4 : 0;
  758. }
  759. nStateSplitDropDown += nSpecialOffset;
  760. if (nStateSplitDropDown != -1)
  761. {
  762. rcSplitDropDownSrc.OffsetRect(0, rcSplitDropDownSrc.Height() * nStateSplitDropDown);
  763. pImageSplitDropDown->DrawImage(pDC, rcSplitDropDown, rcSplitDropDownSrc, CRect(2, 2, 2, 2), 0xFF00FF,
  764. GetDrawImageFlags(pButton, rcSplitDropDown));
  765. }
  766. if (bSmallSize)
  767. {
  768. if (bEnabled == TRUE_SPLITCOMMAND) bEnabled = FALSE;
  769. CPoint pt = CPoint(rcButton.right - m_nSplitButtonDropDownWidth / 2 - 1, rcButton.CenterPoint().y);
  770. DrawDropDownGlyph(pDC, pButton, pt, bSelected, bPopuped, bEnabled, FALSE);
  771. }
  772. }
  773. void CXTPRibbonTheme::DrawPopupBarGripper(CDC* pDC, int x, int y, int cx, int cy, BOOL bExpanded)
  774. {
  775. XTPDrawHelpers()->GradientFill(pDC, CRect(CPoint(x + 1, y), CSize(cx - 1, cy)),
  776. bExpanded ? m_clrMenuExpandedGripper : m_clrMenuGripper, TRUE);
  777. pDC->FillSolidRect(x + cx - 1, y, 1, cy, RGB(197, 197, 197));
  778. pDC->FillSolidRect(x + cx, y, 1, cy, RGB(245, 245, 245));
  779. }
  780. void CXTPRibbonTheme::FillPopupLabelEntry(CDC* pDC, CRect rc)
  781. {
  782. pDC->FillSolidRect(rc, GetXtremeColor(XPCOLOR_LABEL));
  783. pDC->FillSolidRect(rc.left, rc.bottom - 1, rc.Width(), 1, RGB(197, 197, 197));
  784. }
  785. void CXTPRibbonTheme::FillMorePopupToolBarEntry(CDC* pDC, CXTPCommandBar* pBar)
  786. {
  787. CRect rc;
  788. pBar->GetClientRect(&rc);
  789. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("MOREPOPUPBARFRAME")));
  790. if (!pImage)
  791. pImage = LoadImage(FormatName(_T("POPUPBARFRAME")));
  792. ASSERT(pImage);
  793. if (!pImage)
  794. return;
  795. pImage->DrawImage(pDC, rc, pImage->GetSource(), CRect(4, 4, 4, 4));
  796. }
  797. CSize CXTPRibbonTheme::DrawSpecialControl(CDC* pDC, XTPSpecialControl controlType, CXTPControl* pButton, CXTPCommandBar* pBar, BOOL bDraw, LPVOID lpParam)
  798. {
  799. if (controlType == xtpButtonExpandToolbar)
  800. {
  801. BOOL bVert = IsVerticalPosition(pBar->GetPosition());
  802. CXTPOffice2007Image* pImage = LoadImage(FormatName(
  803. bVert ? _T("TOOLBAREXPANDBUTTONVERTICAL") : _T("TOOLBAREXPANDBUTTONHORIZONTAL")));
  804. if (!pImage)
  805. return CXTPOffice2007Theme::DrawSpecialControl(pDC, controlType, pButton, pBar, bDraw, lpParam);
  806. if (!bDraw)
  807. {
  808. CSize szBar = *(CSize*)lpParam;
  809. if (!bVert)
  810. pButton->SetRect(CRect(szBar.cx - 12, 0, szBar.cx, szBar.cy));
  811. else
  812. pButton->SetRect(CRect(0, szBar.cy - 12, szBar.cx, szBar.cy));
  813. }
  814. else
  815. {
  816. CRect rc = pButton->GetRect();
  817. pImage->DrawImage(pDC, rc, pImage->GetSource(
  818. pButton->GetPopuped() ? 2 : pButton->GetSelected() ? 1 : 0 , 3), CRect(3, 3, 3, 3));
  819. COLORREF clrText = GetXtremeColor(pButton->GetPopuped() ? XPCOLOR_TOOLBAR_TEXT: pButton->GetSelected() ? XPCOLOR_HIGHLIGHT_TEXT : XPCOLOR_TOOLBAR_TEXT);
  820. BOOL bHiddenExists = *(BOOL*)lpParam;
  821. if (!bVert) rc.OffsetRect(-1, 0); else rc.OffsetRect(0, -1);
  822. DrawExpandSymbols(pDC, IsVerticalPosition(pBar->GetPosition()), CRect(CPoint(rc.left + 1, rc.top + 1), rc.Size()) , bHiddenExists, GetXtremeColor(COLOR_BTNHIGHLIGHT));
  823. DrawExpandSymbols(pDC, IsVerticalPosition(pBar->GetPosition()), rc, bHiddenExists, clrText);
  824. }
  825. return 0;
  826. }
  827. return CXTPOffice2007Theme::DrawSpecialControl(pDC, controlType, pButton, pBar, bDraw, lpParam);
  828. }
  829. void CXTPRibbonTheme::FillCommandBarEntry(CDC* pDC, CXTPCommandBar* pBar)
  830. {
  831. CRect rc;
  832. pBar->GetClientRect(&rc);
  833. if (pBar->GetPosition() == xtpBarPopup)
  834. {
  835. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("POPUPBARFRAME")));
  836. ASSERT(pImage);
  837. if (!pImage)
  838. return;
  839. pImage->DrawImage(pDC, rc, pImage->GetSource(), CRect(4, 4, 4, 4));
  840. }
  841. else if (IsFlatToolBar(pBar))
  842. {
  843. CXTPOffice2003Theme::FillCommandBarEntry(pDC, pBar);
  844. }
  845. else if (pBar->GetPosition() == xtpBarTop || pBar->GetPosition() == xtpBarBottom)
  846. {
  847. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("TOOLBARFACEHORIZONTAL")));
  848. if (!pImage)
  849. {
  850. CXTPOffice2003Theme::FillCommandBarEntry(pDC, pBar);
  851. return;
  852. }
  853. pImage->DrawImage(pDC, rc, pImage->GetSource(), CRect(5, 5, 5, 5));
  854. }
  855. else if (pBar->GetPosition() == xtpBarLeft || pBar->GetPosition() == xtpBarRight)
  856. {
  857. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("TOOLBARFACEVERTICAL")));
  858. if (!pImage)
  859. {
  860. CXTPOffice2003Theme::FillCommandBarEntry(pDC, pBar);
  861. return;
  862. }
  863. pImage->DrawImage(pDC, rc, pImage->GetSource(), CRect(5, 5, 5, 5));
  864. }
  865. else
  866. {
  867. CXTPOffice2003Theme::FillCommandBarEntry(pDC, pBar);
  868. }
  869. }
  870. CSize CXTPRibbonTheme::DrawCommandBarSeparator(CDC* pDC, CXTPCommandBar* pBar, CXTPControl* pControl, BOOL bDraw)
  871. {
  872. if (pBar->GetType() == xtpBarTypePopup)
  873. {
  874. if (!bDraw)
  875. return CSize(2, 2);
  876. CRect rc;
  877. pBar->GetClientRect(&rc);
  878. CRect rcControl = pControl->GetRect();
  879. if (!pControl->GetWrap())
  880. {
  881. int nLeft = rcControl.left - 1 + GetPopupBarGripperWidth(pBar) + m_nPopupBarTextPadding;
  882. HorizontalLine(pDC, nLeft, rcControl.top - 2, rcControl.right, RGB(197, 197, 197));
  883. HorizontalLine(pDC, nLeft, rcControl.top - 1, rcControl.right, RGB(245, 245, 245));
  884. }
  885. else
  886. {
  887. VerticalLine(pDC, rcControl.left - 2, pControl->GetRowRect().top - 1, pControl->GetRowRect().bottom + 1, RGB(197, 197, 197));
  888. }
  889. return CSize(2, 2);
  890. }
  891. else
  892. {
  893. return CXTPOffice2003Theme::DrawCommandBarSeparator(pDC, pBar, pControl, bDraw);
  894. }
  895. }
  896. void CXTPRibbonTheme::DrawRibbonFrameContextHeaders(CDC* pDC, CXTPRibbonBar* pRibbonBar, CXTPRibbonTabContextHeaders* pContextHeaders)
  897. {
  898. int nCount = pContextHeaders->GetCount();
  899. if (nCount == 0)
  900. return;
  901. CXTPFontDC font(pDC, m_pTabPaintManager->GetFont());
  902. pDC->SetBkMode(TRANSPARENT);
  903. pDC->SetTextColor(m_pTabPaintManager->GetColorSet()->m_clrNormalText);
  904. for (int i = 0; i < nCount; i++)
  905. {
  906. CXTPRibbonTabContextHeader* pHeader = pContextHeaders->GetHeader(i);
  907. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("ContextTab%sHeader"), GetColorName(pHeader->m_color)));
  908. if (!pImage)
  909. return;
  910. CRect rc(pHeader->m_rcRect);
  911. pImage->DrawImage(pDC, rc, pImage->GetSource(), CRect(1, 1, 1, 1));
  912. rc.left += 6;
  913. int nFrameBorder = pRibbonBar->IsFrameThemeEnabled() ?
  914. pRibbonBar->GetFrameHook()->GetFrameBorder() : 0;
  915. rc.top += nFrameBorder - 2;
  916. if (pRibbonBar->IsDwmEnabled())
  917. {
  918. DrawDwmCaptionText(pDC, rc, pHeader->m_strCaption, pRibbonBar->GetSite(), pRibbonBar->GetFrameHook()->IsFrameActive());
  919. }
  920. else
  921. {
  922. pDC->DrawText(pHeader->m_strCaption, rc, DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_END_ELLIPSIS | DT_LEFT);
  923. }
  924. }
  925. }
  926. #define XTP_DTT_GLOWSIZE        (1UL << 11)     // iGlowSize has been specified
  927. #define XTP_DTT_COMPOSITED      (1UL << 13)     // Draws text with antialiased alpha (needs a DIB section)
  928. void CXTPRibbonTheme::DrawDwmCaptionText(CDC* pDC, CRect rcCaptionText, CString strWindowText, CWnd* pSite, BOOL bActive)
  929. {
  930. if (pSite->GetStyle() & WS_MAXIMIZE)
  931. {
  932. pDC->SetTextColor(0xFFFFFF);
  933. pDC->DrawText(strWindowText, rcCaptionText,
  934. DT_VCENTER | DT_LEFT| DT_END_ELLIPSIS | DT_SINGLELINE | DT_NOPREFIX);
  935. return;
  936. }
  937. CXTPWinThemeWrapper wrapper(FALSE);
  938. wrapper.OpenTheme(0, L"WINDOW");
  939. if (!wrapper.IsAppThemed())
  940. {
  941. pDC->SetTextColor(0);
  942. pDC->DrawText(strWindowText, rcCaptionText, DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_END_ELLIPSIS | DT_LEFT);
  943. return;
  944. }
  945. CRect rcBuffer(rcCaptionText);
  946. rcBuffer.InflateRect(5, 0);
  947. HDC hDC = 0;
  948. HPAINTBUFFER pb = wrapper.BeginBufferedPaint(pDC->GetSafeHdc(), rcBuffer, XTP_BPBF_TOPDOWNDIB, 0, &hDC);
  949. if (hDC != NULL)
  950. {
  951. ::BitBlt(hDC, rcBuffer.left, rcBuffer.top, rcBuffer.Width(), rcBuffer.Height(), pDC->GetSafeHdc(), rcBuffer.left, rcBuffer.top, SRCCOPY);
  952. ::SetTextColor(hDC, 0);
  953. XTP_UX_DTTOPTS op;
  954. op.dwSize = sizeof(op);
  955. op.dwFlags = XTP_DTT_COMPOSITED | XTP_DTT_GLOWSIZE;
  956. op. iGlowSize = 8;
  957. CXTPFontDC font(CDC::FromHandle(hDC), &m_fontFrameCaption);
  958. wrapper.DrawThemeTextEx(hDC, pSite->GetStyle() & WS_MAXIMIZE ? WP_MAXCAPTION : WP_CAPTION, bActive ? FS_ACTIVE : FS_INACTIVE, XTP_CT2CW(strWindowText), -1,
  959. DT_VCENTER | DT_LEFT| DT_END_ELLIPSIS | DT_SINGLELINE | DT_NOPREFIX,  rcCaptionText, &op);
  960. }
  961. wrapper.EndBufferedPaint(pb, TRUE);
  962. }
  963. void CXTPRibbonTheme::DrawRibbonFrameCaptionBar(CDC* pDC, CXTPRibbonBar* pRibbonBar)
  964. {
  965. CRect rcCaption = pRibbonBar->GetCaptionRect();
  966. rcCaption.top--;
  967. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("FRAMETOPCENTER")));
  968. pImage->DrawImage(pDC, rcCaption, pImage->GetSource(0, 2), CRect(0, 5, 0, 3));
  969. if (!pRibbonBar->IsQuickAccessBelowRibbon() && pRibbonBar->IsQuickAccessVisible() &&
  970. ((CXTPControls*)pRibbonBar->GetQuickAccessControls())->GetVisibleCount() > 0)
  971. {
  972. CRect rcQuickAccess = pRibbonBar->GetQuickAccessRect();
  973. int nFrameBorder = 0;
  974. CRect rcQuickAccessArea(rcQuickAccess.left - 15, nFrameBorder, rcQuickAccess.right, pRibbonBar->GetQuickAccessHeight() + nFrameBorder);
  975. BOOL bDwm = FALSE;
  976. pImage = LoadImage(FormatName(bDwm ? _T("RIBBONQUICKACCESSAREADWM") : _T("RIBBONQUICKACCESSAREA")));
  977. if (pImage)
  978. {
  979. pImage->PreserveOrientation();
  980. pImage->DrawImage(pDC, rcQuickAccessArea, pImage->GetSource(), CRect(16, 3, 16, 3));
  981. }
  982. }
  983. CXTPRibbonTabContextHeaders* pContextHeaders = pRibbonBar->GetContextHeaders();
  984. if (pContextHeaders->GetCount() != 0)
  985. {
  986. DrawRibbonFrameContextHeaders(pDC, pRibbonBar, pContextHeaders);
  987. }
  988. }
  989. void CXTPRibbonTheme::DrawRibbonFrameCaption(CDC* pDC, CXTPRibbonBar* pRibbonBar, BOOL bActive)
  990. {
  991. CFrameWnd* pSite = (CFrameWnd*)pRibbonBar->GetSite();
  992. CRect rcCaption = pRibbonBar->GetCaptionRect();
  993. CXTPOffice2007Image* pImage;
  994. if (!pRibbonBar->IsDwmEnabled())
  995. {
  996. pImage = LoadImage(FormatName(_T("FRAMETOPLEFT")));
  997. ASSERT(pImage);
  998. if (!pImage)
  999. return;
  1000. CRect rcSrc(pImage->GetSource(bActive ? 0 : 1, 2));
  1001. CRect rcTopLeft(rcCaption.left, rcCaption.top, rcCaption.left + rcSrc.Width(), rcCaption.bottom);
  1002. pImage->DrawImage(pDC, rcTopLeft, rcSrc, CRect(0, 5, 0, 3), 0xFF00FF);
  1003. //////////////////////////////////////////////////////////////////////////
  1004. pImage = LoadImage(FormatName(_T("FRAMETOPRIGHT")));
  1005. rcSrc = pImage->GetSource(bActive ? 0 : 1, 2);
  1006. CRect rcTopRight(rcCaption.right - rcSrc.Width(), rcCaption.top, rcCaption.right, rcCaption.bottom);
  1007. pImage->DrawImage(pDC, rcTopRight, rcSrc, CRect(0, 5, 0, 3));
  1008. //////////////////////////////////////////////////////////////////////////
  1009. pImage = LoadImage(FormatName(_T("FRAMETOPCENTER")));
  1010. CRect rcTopCenter(rcTopLeft.right, rcCaption.top, rcTopRight.left, rcCaption.bottom);
  1011. pImage->DrawImage(pDC, rcTopCenter, pImage->GetSource(bActive ? 0 : 1, 2), CRect(0, 5, 0, 3));
  1012. }
  1013. else
  1014. {
  1015. pDC->FillSolidRect(rcCaption, 0);
  1016. }
  1017. //////////////////////////////////////////////////////////////////////////
  1018. if (!pRibbonBar->IsQuickAccessBelowRibbon() && pRibbonBar->IsQuickAccessVisible() &&
  1019. ((CXTPControls*)pRibbonBar->GetQuickAccessControls())->GetVisibleCount() > 0)
  1020. {
  1021. CRect rcQuickAccess = pRibbonBar->GetQuickAccessRect();
  1022. CRect rcQuickAccessArea(rcQuickAccess.left - 15, rcQuickAccess.top + 2, rcQuickAccess.right, rcQuickAccess.top + 2 + pRibbonBar->GetQuickAccessHeight());
  1023. BOOL bDwm = IsCompositeRect(pRibbonBar, rcQuickAccess);
  1024. pImage = LoadImage(FormatName(bDwm ? _T("RIBBONQUICKACCESSAREADWM") : _T("RIBBONQUICKACCESSAREA")));
  1025. if (pImage)
  1026. {
  1027. pImage->PreserveOrientation();
  1028. pImage->DrawImage(pDC, rcQuickAccessArea, pImage->GetSource(), CRect(16, 3, 16, 3));
  1029. }
  1030. }
  1031. //////////////////////////////////////////////////////////////////////////
  1032. if (pRibbonBar->GetSystemButton() == NULL)
  1033. {
  1034. HICON hIcon = GetFrameSmallIcon(pSite);
  1035. if (hIcon)
  1036. {
  1037. CSize szIcon(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
  1038. int nTop = (rcCaption.Height()  - szIcon.cy)/2;
  1039. int nLeft = rcCaption.left + 10;
  1040. DrawIconEx(pDC->GetSafeHdc(), nLeft, nTop, hIcon,
  1041. szIcon.cx, szIcon.cy, 0, NULL, DI_NORMAL);
  1042. }
  1043. }
  1044. CRect rcCaptionText = pRibbonBar->GetCaptionTextRect();
  1045. CXTPRibbonTabContextHeaders* pContextHeaders = pRibbonBar->GetContextHeaders();
  1046. if (pContextHeaders->GetCount() != 0)
  1047. {
  1048. DrawRibbonFrameContextHeaders(pDC, pRibbonBar, pContextHeaders);
  1049. }
  1050. CXTPFontDC font(pDC, &m_fontFrameCaption);
  1051. CString strWindowText;
  1052. pSite->GetWindowText(strWindowText);
  1053. rcCaptionText.left += max(0, (rcCaptionText.Width() - pDC->GetTextExtent(strWindowText).cx) / 2);
  1054. if (pSite->GetStyle() & WS_MAXIMIZE)
  1055. {
  1056. rcCaptionText.top += pRibbonBar->GetFrameHook()->GetFrameBorder() / 2;
  1057. }
  1058. if (!pRibbonBar->IsDwmEnabled())
  1059. {
  1060. DrawCaptionText(pDC, rcCaptionText, pSite, bActive);
  1061. }
  1062. else
  1063. {
  1064. DrawDwmCaptionText(pDC, rcCaptionText, strWindowText, pSite, bActive);
  1065. }
  1066. }
  1067. void CXTPRibbonTheme::DrawRibbonQuickAccessButton(CDC* pDC, CXTPControlPopup* pControl)
  1068. {
  1069. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("RIBBONQUICKACCESSBUTTON")));
  1070. ASSERT(pImage);
  1071. if (!pImage)
  1072. return;
  1073. pImage->DrawImage(pDC, pControl->GetRect(), pImage->GetSource(pControl->GetPopuped() ? 2 : pControl->GetSelected() ? 1 : 0, 4),
  1074. CRect(2, 2, 2, 2), 0xFF00FF, GetDrawImageFlags(pControl));
  1075. }
  1076. void CXTPRibbonTheme::DrawRibbonQuickAccessMoreButton(CDC* pDC, CXTPControlPopup* pControl)
  1077. {
  1078. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("RIBBONQUICKACCESSMORE")));
  1079. ASSERT(pImage);
  1080. if (!pImage)
  1081. return;
  1082. pImage->DrawImage(pDC, pControl->GetRect(), pImage->GetSource(pControl->GetPopuped() ? 2 : pControl->GetSelected() ? 1 : 0, 4),
  1083. CRect(2, 2, 2, 2), 0xFF00FF, GetDrawImageFlags(pControl));
  1084. }
  1085. void CXTPRibbonTheme::DrawRibbonFrameSystemButton(CDC* pDC, CXTPControlPopup* pControl, CRect rc)
  1086. {
  1087. CXTPRibbonBar* pRibbonBar = (CXTPRibbonBar*)pControl->GetParent();
  1088. if (!pRibbonBar->IsCaptionVisible() || !pRibbonBar->IsTabsVisible())
  1089. {
  1090. CXTPRibbonTheme::DrawControlToolBarParent(pDC, pControl, TRUE);
  1091. return;
  1092. }
  1093. XTPImageState nState = xtpImageNormal;
  1094. if (pControl->GetPopuped())
  1095. nState = xtpImagePressed;
  1096. else if (pControl->GetSelected())
  1097. nState = xtpImageHot;
  1098. CXTPImageManagerIcon* pIcon = pControl->GetImage(32);
  1099. if (pIcon && pIcon->GetWidth() > 32)
  1100. {
  1101. CPoint ptIcon((rc.left + rc.right - pIcon->GetWidth()) / 2, (rc.top + rc.bottom - pIcon->GetHeight()) / 2);
  1102. pIcon->m_bDrawComposited = pControl->HasDwmCompositedRect();
  1103. pIcon->Draw(pDC, ptIcon, pIcon->GetIcon(nState));
  1104. pIcon->m_bDrawComposited = FALSE;
  1105. return;
  1106. }
  1107. CXTPOffice2007Image* pImage = NULL;
  1108. if (rc.Width() > 54 && rc.Height() > 54)
  1109. pImage = LoadImage(FormatName(_T("FRAMESYSTEMBUTTON52")));
  1110. if (pImage == NULL)
  1111. pImage = LoadImage(FormatName(_T("FRAMESYSTEMBUTTON")));
  1112. ASSERT(pImage);
  1113. if (!pImage)
  1114. return;
  1115. int nOffset = 0;
  1116. if (rc.top < 0)
  1117. {
  1118. nOffset = rc.top;
  1119. rc.OffsetRect(0, -nOffset);
  1120. }
  1121. CRect rcSrc(pImage->GetSource(nState == xtpImageNormal ? 0 : nState == xtpImageHot ? 1 : 2, 3));
  1122. CSize szDest(rcSrc.Size());
  1123. CPoint ptDest((rc.left + rc.right - szDest.cx) / 2, nOffset + (rc.top + rc.bottom - szDest.cy) / 2);
  1124. pImage->DrawImage(pDC, CRect(ptDest, szDest), rcSrc, CRect(0, 0, 0, 0));
  1125. if (pIcon)
  1126. {
  1127. CPoint ptIcon((rc.left + rc.right - pIcon->GetWidth()) / 2, nOffset + (rc.top + rc.bottom + 1 - pIcon->GetHeight()) / 2);
  1128. pIcon->m_bDrawComposited = pControl->HasDwmCompositedRect();
  1129. pIcon->Draw(pDC, ptIcon, pIcon->GetIcon(nState));
  1130. pIcon->m_bDrawComposited = FALSE;
  1131. }
  1132. else
  1133. {
  1134. CWnd* pSite = pControl->GetParent()->GetSite();
  1135. HICON hIcon = GetFrameLargeIcon(pSite);
  1136. if (hIcon)
  1137. {
  1138. CPoint ptIcon((rc.left + rc.right - 33) / 2, nOffset + (rc.top + rc.bottom - 31) / 2);
  1139. DrawIconEx(pDC->GetSafeHdc(), ptIcon.x, ptIcon.y, hIcon, 32, 32, NULL, NULL, DI_NORMAL);
  1140. }
  1141. }
  1142. }
  1143. void CXTPRibbonTheme::DrawRibbonScrollButton(CDC* pDC, CXTPControl* pControl, BOOL bScrollLeft)
  1144. {
  1145. CXTPOffice2007Image* pImage = LoadImage(FormatName(bScrollLeft ? _T("RIBBONGROUPSSCROLLLEFT") : _T("RIBBONGROUPSSCROLLRIGHT")));
  1146. ASSERT(pImage);
  1147. if (!pImage)
  1148. return;
  1149. CRect rc(pControl->GetRect());
  1150. int nState = pControl->GetPressed() ? 2 : pControl->GetSelected() ? 1 : 0;
  1151. CXTPOffice2007Image* pImageGlyph = LoadImage(FormatName(bScrollLeft ? _T("RIBBONGROUPSSCROLLLEFTGLYPH") : _T("RIBBONGROUPSSCROLLRIGHTGLYPH")));
  1152. pImage->PreserveOrientation();
  1153. pImage->DrawImage(pDC, rc, pImage->GetSource(nState, 3), CRect(4, 6, 3, 6), 0xFF00FF);
  1154. CSize szGlyph = pImageGlyph->GetSource(0, 3).Size();
  1155. CRect rcGlyph(CPoint((rc.right + rc.left - szGlyph.cx) / 2, (rc.top + rc.bottom - szGlyph.cy) / 2), szGlyph);
  1156. pImageGlyph->DrawImage(pDC, rcGlyph, pImageGlyph->GetSource(nState, 3), CRect(0, 0, 0, 0), 0xFF00FF);
  1157. }
  1158. void CXTPRibbonTheme::FillStatusBar(CDC* pDC, CXTPStatusBar* pBar)
  1159. {
  1160. CXTPClientRect rc(pBar);
  1161. int nWidth = rc.Width() - (::GetSystemMetrics(SM_CXVSCROLL) + ::GetSystemMetrics(SM_CXBORDER) * 2);
  1162. if (pBar->GetPaneCount() > 0)
  1163. {
  1164. int nIndex = min(pBar->GetPaneCount() - 1, pBar->GetRibbonDividerIndex() + 1);
  1165. for (;nIndex < pBar->GetPaneCount(); nIndex++)
  1166. {
  1167. CXTPStatusBarPane* pPane = pBar->GetPane(nIndex);
  1168. if (!pPane->IsVisible())
  1169. continue;
  1170. nWidth = pPane->GetRect().left - 3;
  1171. break;
  1172. }
  1173. }
  1174. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("STATUSBARLIGHT")));
  1175. ASSERT(pImage);
  1176. if (!pImage)
  1177. return;
  1178. CRect rcSrc(0, 0, pImage->GetWidth(), pImage->GetHeight());
  1179. CRect rcLight(rc.left, rc.top, rc.left + nWidth - 3, rc.bottom);
  1180. pImage->DrawImage(pDC, rcLight, rcSrc, CRect(0, 0, 0, 0));
  1181. pImage = LoadImage(FormatName(_T("STATUSBARDEVIDER")));
  1182. rcSrc.SetRect(0, 0, pImage->GetWidth(), pImage->GetHeight());
  1183. CRect rcDevider(rcLight.right, rc.top, rcLight.right + rcSrc.Width(), rc.bottom);
  1184. pImage->DrawImage(pDC, rcDevider, rcSrc, CRect(0, 0, 0, 0));
  1185. pImage = LoadImage(FormatName(_T("STATUSBARDARK")));
  1186. CRect rcDark(rcDevider.right, rc.top, rc.right, rc.bottom);
  1187. rcSrc.SetRect(0, 0, pImage->GetWidth(), pImage->GetHeight());
  1188. pImage->DrawImage(pDC, rcDark, rcSrc, CRect(0, 0, 0, 0));
  1189. }
  1190. void CXTPRibbonTheme::DrawStatusBarPaneBorder(CDC* pDC, CRect rc, CXTPStatusBarPane* pPane, BOOL /*bGripperPane*/)
  1191. {
  1192. if (pPane->GetIndex() >= pPane->GetStatusBar()->GetRibbonDividerIndex())
  1193. return;
  1194. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("STATUSBARSEPARATOR")));
  1195. ASSERT(pImage);
  1196. if (!pImage)
  1197. return;
  1198. rc.left = rc.right - 2;
  1199. rc.top -= 2;
  1200. pImage->DrawImage(pDC, rc, pImage->GetSource(), CRect(0, 2, 0, 2));
  1201. }
  1202. void CXTPRibbonTheme::DrawStatusBarPaneSeparator(CDC* pDC, CRect rc, CXTPStatusBarPane* pPane)
  1203. {
  1204. if (pPane->GetIndex() > pPane->GetStatusBar()->GetRibbonDividerIndex())
  1205. return;
  1206. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("STATUSBARSEPARATOR")));
  1207. ASSERT(pImage);
  1208. if (!pImage)
  1209. return;
  1210. CRect rcSrc(pImage->GetSource());
  1211. rc.left = rc.left - 2;
  1212. rc.right = rc.left + 2;
  1213. rc.top -= 2;
  1214. pImage->DrawImage(pDC, rc, pImage->GetSource(), CRect(0, 2, 0, 2));
  1215. }
  1216. void CXTPRibbonTheme::DrawStatusBarGripper(CDC* pDC, CRect rcClient)
  1217. {
  1218. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("STATUSBARGRIPPER")));
  1219. ASSERT(pImage);
  1220. if (!pImage)
  1221. return;
  1222. CRect rcSrc(0, 0, pImage->GetWidth(), pImage->GetHeight());
  1223. CRect rcGripper(rcClient.right - rcSrc.Width() , rcClient.bottom - rcSrc.Height() - 4, rcClient.right, rcClient.bottom - 4);
  1224. pImage->DrawImage(pDC, rcGripper, rcSrc, CRect(0, 0, 0, 0), RGB(0xFF, 0, 0xFF));
  1225. }
  1226. int CXTPRibbonTheme::DrawStatusBarSwitchPane(CDC* pDC, CRect rcItem, CXTPStatusBarSwitchPane* pPane)
  1227. {
  1228. int nWidth = 0;
  1229. int nCount = pPane->GetSwitchCount();
  1230. if (pDC)
  1231. {
  1232. for (int i = 0; i < nCount; i++)
  1233. {
  1234. CXTPStatusBarSwitchPane::SWITCH* pSwitch = pPane->GetSwitch(i);
  1235. rcItem.right = rcItem.left + pSwitch->nWidth;
  1236. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("STATUSBARSWITCHES")));
  1237. ASSERT(pImage);
  1238. if (!pImage)
  1239. return 0;
  1240. int nState = !pPane->IsEnabled() ? 5 : pSwitch->bPressed ? 2 : pSwitch->bChecked ? (pSwitch->bHighlighted ? 4 : 3) : pSwitch->bHighlighted ? 1 : 0;
  1241. CRect rcSrc(pImage->GetSource(nState, 6));
  1242. int nSrcWidth = rcSrc.Width() / 4;
  1243. int nImage = nCount == 1 ? 3 : i == 0 ? 0 : i == pPane->GetSwitchCount() - 1 ? 2 : 1;
  1244. if (pPane->GetStatusBar()->GetExStyle() & WS_EX_LAYOUTRTL) nImage = 3 - nImage;
  1245. pImage->PreserveOrientation();
  1246. rcSrc.left = nSrcWidth * nImage;
  1247. rcSrc.right = rcSrc.left + nSrcWidth;
  1248. pImage->DrawImage(pDC, rcItem, rcSrc, CRect(2, 2, 2, 2), RGB(0xFF, 0, 0xFF));
  1249. CXTPImageManagerIcon* pIcon = pPane->GetStatusBar()->GetImageManager()->GetImage(pSwitch->nID, ICON_SMALL);
  1250. if (pIcon)
  1251. {
  1252. CPoint pt((rcItem.left + rcItem.right - pIcon->GetWidth()) / 2, (rcItem.top + rcItem.bottom - pIcon->GetHeight()) / 2);
  1253. pIcon->Draw(pDC, pt, pIcon->GetIcon(!pPane->IsEnabled() ? xtpImageDisabled : pSwitch->bChecked ? xtpImageChecked : xtpImageNormal));
  1254. }
  1255. rcItem.left = rcItem.right;
  1256. }
  1257. }
  1258. else
  1259. {
  1260. for (int i = 0; i < nCount; i++)
  1261. {
  1262. CXTPStatusBarSwitchPane::SWITCH* pSwitch = pPane->GetSwitch(i);
  1263. pSwitch->nWidth = i == 0 || i == nCount - 1 ? 19 : 18;
  1264. nWidth += pSwitch->nWidth;
  1265. }
  1266. }
  1267. return nWidth;
  1268. }
  1269. CSize CXTPRibbonTheme::DrawControlCheckBoxMark(CDC* pDC, CRect rc, BOOL bDraw, BOOL bSelected, BOOL bPressed, BOOL bChecked, BOOL bEnabled)
  1270. {
  1271. if (!bDraw)
  1272. return CSize(13, 13);
  1273. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("TOOLBARBUTTONCHECKBOX")));
  1274. ASSERT(pImage);
  1275. if (!pImage)
  1276. return CSize(13, 13);
  1277. int nState = 0;
  1278. if (!bEnabled)
  1279. nState = 3;
  1280. else if (bSelected && bPressed)
  1281. nState = 2;
  1282. else if (bSelected)
  1283. nState = 1;
  1284. if (bChecked == 1)
  1285. nState += 4;
  1286. if (bChecked == 2)
  1287. nState += 8;
  1288. pImage->DrawImage(pDC, rc, pImage->GetSource(nState, 12), CRect(0, 0, 0, 0));
  1289. return CSize(13, 13);
  1290. }
  1291. CSize CXTPRibbonTheme::DrawControlRadioButtonMark(CDC* pDC, CRect rc, BOOL bDraw, BOOL bSelected, BOOL bPressed, BOOL bChecked, BOOL bEnabled)
  1292. {
  1293. if (!bDraw)
  1294. return CSize(13, 13);
  1295. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("TOOLBARBUTTONRADIOBUTTON")));
  1296. ASSERT(pImage);
  1297. if (!pImage)
  1298. return CSize(13, 13);
  1299. int nState = 0;
  1300. if (!bEnabled)
  1301. nState = 3;
  1302. else if (bSelected && bPressed)
  1303. nState = 2;
  1304. else if (bSelected)
  1305. nState = 1;
  1306. if (bChecked)
  1307. nState += 4;
  1308. pImage->DrawImage(pDC, rc, pImage->GetSource(nState, 8), CRect(0, 0, 0, 0));
  1309. return CSize(13, 13);
  1310. }
  1311. void CXTPRibbonTheme::DrawDropDownGlyph(CDC* pDC, CXTPControl* pControl, CPoint pt, BOOL bSelected, BOOL bPopuped, BOOL bEnabled, BOOL bVert)
  1312. {
  1313. if (bVert)
  1314. {
  1315. CXTPOffice2003Theme::DrawDropDownGlyph(pDC, pControl, pt, bSelected, bPopuped, bEnabled, bVert);
  1316. return;
  1317. }
  1318. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("TOOLBARBUTTONDROPDOWNGLYPH")));
  1319. ASSERT(pImage);
  1320. if (!pImage)
  1321. return;
  1322. CRect rc(pt.x - 2, pt.y - 2, pt.x + 3, pt.y + 2);
  1323. pImage->DrawImage(pDC, rc, pImage->GetSource(!bEnabled ? 3 : bSelected ? 1 : 0, 4),
  1324. CRect(0, 0, 0, 0), 0xFF00FF, GetDrawImageFlags(pControl, rc)) ;
  1325. }
  1326. CSize CXTPRibbonTheme::DrawControlComboBox(CDC* pDC, CXTPControlComboBox* pControlCombo, BOOL bDraw)
  1327. {
  1328. if (!bDraw)
  1329. {
  1330. return CXTPPaintManager::DrawControlComboBox(pDC, pControlCombo, bDraw);
  1331. }
  1332. BOOL bPopupBar = pControlCombo->GetParent()->GetType() == xtpBarTypePopup;
  1333. CXTPFontDC font(pDC, GetIconFont());
  1334. CRect rc = pControlCombo->GetRect();
  1335. BOOL bDropped = pControlCombo->GetDroppedState() != 0;
  1336. BOOL bSelected = pControlCombo->GetSelected();
  1337. BOOL bEnabled = pControlCombo->GetEnabled();
  1338. CXTPPaintManager::DrawControlComboBox(pDC, pControlCombo, bDraw);
  1339. rc.left += pControlCombo->GetLabelWidth();
  1340. int nThumb = pControlCombo->GetThumbWidth();
  1341. CRect rcBtn (rc.right - nThumb, rc.top, rc.right, rc.bottom);
  1342. CRect rcText(rc.left + 3, rc.top + 1, rc.right - rcBtn.Width(), rc.bottom - 1);
  1343. CXTPOffice2007Image* pImage = LoadImage(FormatName(_T("TOOLBARBUTTONSCOMBODROPDOWN")));
  1344. ASSERT(pImage);
  1345. if (!pImage)
  1346. return 0;
  1347. if (!bEnabled)
  1348. {
  1349. pDC->FillSolidRect(rc, GetXtremeColor(COLOR_3DFACE));
  1350. pDC->Draw3dRect(rc, GetXtremeColor(XPCOLOR_EDITCTRLBORDER), GetXtremeColor(XPCOLOR_EDITCTRLBORDER));
  1351. pImage->DrawImage(pDC, rcBtn, pImage->GetSource(4, 5), CRect(2, 2, 2, 2));
  1352. }
  1353. else if (bDropped)
  1354. {
  1355. pDC->FillSolidRect(rc, GetXtremeColor(COLOR_WINDOW));
  1356. pDC->Draw3dRect(rc, GetXtremeColor(XPCOLOR_EDITCTRLBORDER), GetXtremeColor(XPCOLOR_EDITCTRLBORDER));
  1357. pImage->DrawImage(pDC, rcBtn, pImage->GetSource(3, 5), CRect(2, 2, 2, 2));
  1358. }
  1359. else if (bSelected)
  1360. {
  1361. pDC->FillSolidRect(rc, GetXtremeColor(COLOR_WINDOW));
  1362. pDC->Draw3dRect(rc, GetXtremeColor(XPCOLOR_EDITCTRLBORDER), GetXtremeColor(XPCOLOR_EDITCTRLBORDER));
  1363. int nState = !pControlCombo->GetEditCtrl() || pControlCombo->IsFocused() ? 2 : bSelected == TRUE ? 1 : 2;
  1364. pImage->DrawImage(pDC, rcBtn, pImage->GetSource(nState, 5), CRect(2, 2, 2, 2));
  1365. }
  1366. else
  1367. {
  1368. if (!bPopupBar) pDC->FillSolidRect(rc, m_clrControlEditNormal);
  1369. pDC->Draw3dRect(rc, GetXtremeColor(XPCOLOR_EDITCTRLBORDER), GetXtremeColor(XPCOLOR_EDITCTRLBORDER));
  1370. pImage->DrawImage(pDC, rcBtn, pImage->GetSource(0, 5), CRect(2, 2, 2, 2));
  1371. }
  1372. pControlCombo->DrawEditText(pDC, rcText);
  1373. CPoint pt = rcBtn.CenterPoint();
  1374. DrawDropDownGlyph(pDC, pControlCombo, pt, bSelected, bDropped, bEnabled, FALSE);
  1375. if (pControlCombo->HasDwmCompositedRect())
  1376. {
  1377. FillCompositeAlpha(pDC, pControlCombo->GetRect());
  1378. }
  1379. return 0;
  1380. }
  1381. COLORREF CXTPRibbonTheme::GetControlEditBackColor(CXTPControl* pControl)
  1382. {
  1383. return !pControl->GetEnabled() ? GetXtremeColor(COLOR_3DFACE) :
  1384. pControl->GetSelected() ? GetXtremeColor(COLOR_WINDOW) :
  1385. pControl->GetParent()->GetType() == xtpBarTypePopup ?
  1386. GetXtremeColor(XPCOLOR_MENUBAR_FACE) : m_clrControlEditNormal;
  1387. }
  1388. CSize CXTPRibbonTheme::DrawControlEdit(CDC* pDC, CXTPControlEdit* pControlEdit, BOOL bDraw)
  1389. {
  1390. if (!bDraw)
  1391. {
  1392. return CXTPPaintManager::DrawControlEdit(pDC, pControlEdit, bDraw);
  1393. }
  1394. BOOL bPopupBar = pControlEdit->GetParent()->GetType() == xtpBarTypePopup;
  1395. BOOL bSelected = pControlEdit->GetSelected(), bEnabled = pControlEdit->GetEnabled();
  1396. if (bPopupBar) pDC->SetTextColor(GetXtremeColor(!pControlEdit->GetEnabled() ? XPCOLOR_MENUBAR_GRAYTEXT: bSelected ? XPCOLOR_HIGHLIGHT_TEXT : XPCOLOR_MENUBAR_TEXT));
  1397. else pDC->SetTextColor(GetXtremeColor(!pControlEdit->GetEnabled() ? XPCOLOR_TOOLBAR_GRAYTEXT : XPCOLOR_TOOLBAR_TEXT));
  1398. CXTPPaintManager::DrawControlEdit(pDC, pControlEdit, bDraw);
  1399. CRect rc = pControlEdit->GetRect();
  1400. rc.left += pControlEdit->GetLabelWidth();
  1401. if (!bEnabled)
  1402. {
  1403. rc.DeflateRect(1, 0, 0, 0);
  1404. Rectangle (pDC, rc, IsKeyboardSelected(bSelected) ? XPCOLOR_HIGHLIGHT_BORDER : XPCOLOR_EDITCTRLBORDER, COLOR_3DFACE);
  1405. }
  1406. else
  1407. {
  1408. if (bSelected)
  1409. {
  1410. Rectangle(pDC, rc, XPCOLOR_EDITCTRLBORDER, COLOR_WINDOW);
  1411. }
  1412. else
  1413. {
  1414. if (!bPopupBar) pDC->FillSolidRect(rc, m_clrControlEditNormal);
  1415. pDC->Draw3dRect(rc, GetXtremeColor(XPCOLOR_EDITCTRLBORDER), GetXtremeColor(XPCOLOR_EDITCTRLBORDER));
  1416. }
  1417. }
  1418. CRect rcText(pControlEdit->GetRect());
  1419. rcText.DeflateRect(pControlEdit->GetLabelWidth() + 3, 1, 3, 1);
  1420. pControlEdit->DrawEditText(pDC, rcText);
  1421. if (pControlEdit->IsSpinButtonsVisible())
  1422. {
  1423. CXTPOffice2007Image* pImage = LoadImage(_T("TOOLBARBUTTONSPINARROWSVERTICAL"));
  1424. if (!pImage)
  1425. return 0;
  1426. BOOL bPressed = pControlEdit->GetPressed();
  1427. int nState = !bEnabled ? 4 : bSelected && bPressed == XTP_EDITSPIN_UP ? 3 : bSelected == XTP_EDITSPIN_UP ? 2 : bSelected ? 1 : 0;
  1428. CRect rcTop(rc.right - 18, rc.top + 1, rc.right - 1, rc.CenterPoint().y);
  1429. pImage->DrawImage(pDC, rcTop, pImage->GetSource(nState, 10), CRect(0, 0, 0, 0), 0xFF00FF);
  1430. nState = !bEnabled ? 9 : bSelected && bPressed == XTP_EDITSPIN_DOWN ? 8 : bSelected == XTP_EDITSPIN_DOWN ? 7 : bSelected ? 6 : 5;
  1431. CRect rcBottom(rcTop.left, rcTop.bottom, rcTop.right, rc.bottom - 1);
  1432. pImage->DrawImage(pDC, rcBottom, pImage->GetSource(nState, 10), CRect(0, 0, 0, 0), 0xFF00FF);
  1433. pImage = rcTop.Width() > 12 && rcTop.Height() > 12 ? LoadImage(_T("CONTROLGALLERYSCROLLARROWGLYPHS")) :
  1434. LoadImage(_T("TOOLBARBUTTONSPINARROWGLYPHS"));
  1435. if (!pImage)
  1436. return 0;
  1437. nState = !bEnabled ? 3 : bSelected && bPressed == XTP_EDITSPIN_UP ? 2 : bSelected == XTP_EDITSPIN_UP ? 2 : bSelected ? 1 :  0;
  1438. CRect rcSrc = pImage->GetSource(nState, 16);
  1439. CSize sz(rcSrc.Size());
  1440. pImage->DrawImage(pDC, CRect( CPoint((rcTop.left + rcTop.right - sz.cx) / 2, (rcTop.top + rcTop.bottom + 1 - sz.cy) / 2), rcSrc.Size()), rcSrc, CRect(0, 0, 0, 0), 0xFF00FF);
  1441. nState = 4 + (!bEnabled ? 3 : bSelected && bPressed == XTP_EDITSPIN_DOWN ? 2 : bSelected == XTP_EDITSPIN_DOWN ? 2 : bSelected ? 1 :  0);
  1442. rcSrc = pImage->GetSource(nState, 16);
  1443. pImage->DrawImage(pDC, CRect(CPoint((rcBottom.left + rcBottom.right - sz.cx) / 2, (rcBottom.top + rcBottom.bottom - sz.cy) / 2), rcSrc.Size()), rcSrc, CRect(0, 0, 0, 0), 0xFF00FF);
  1444. }
  1445. if (pControlEdit->HasDwmCompositedRect())
  1446. {
  1447. FillCompositeAlpha(pDC, pControlEdit->GetRect());
  1448. }
  1449. return 0;
  1450. }
  1451. void CXTPRibbonTheme::DrawKeyboardTip(CDC* pDC, CXTPCommandBarKeyboardTip* pWnd, BOOL bSetRegion)
  1452. {
  1453. if (bSetRegion)
  1454. {
  1455. SetRoundRectRegion(pWnd);
  1456. }
  1457. else
  1458. {
  1459. CXTPClientRect rc(pWnd);
  1460. CXTPFontDC font(pDC, &m_fontToolTip);
  1461. COLORREF clrLight = GetImages()->GetImageColor(_T("Window"), _T("TooltipLight"));
  1462. COLORREF clrDark = GetImages()->GetImageColor(_T("Window"), _T("TooltipDark"));
  1463. XTPDrawHelpers()->GradientFill(pDC, rc, clrLight, clrDark, FALSE);
  1464. CXTPOffice2007Image* pImage = XTPOffice2007Images()->LoadFile(_T("TOOLTIPFRAME"));
  1465. if (pImage)
  1466. {
  1467. pImage->DrawImage(pDC, rc, pImage->GetSource(0, 1), CRect(3, 3, 3, 3), 0xFF00FF);
  1468. }
  1469. else
  1470. {
  1471. COLORREF clrBorder = GetImages()->GetImageColor(_T("Window"), _T("TooltipBorder"));
  1472. pDC->Draw3dRect(rc, clrBorder, clrBorder);
  1473. }
  1474. pDC->SetBkMode(TRANSPARENT);
  1475. pDC->SetTextColor(GetXtremeColor(pWnd->m_bEnabled ? COLOR_BTNTEXT : COLOR_GRAYTEXT));
  1476. pDC->DrawText(pWnd->m_strTip, rc, DT_VCENTER | DT_CENTER | DT_SINGLELINE);
  1477. }
  1478. }
  1479. void CXTPRibbonTheme::SetRoundRectRegion(CWnd* pWnd)
  1480. {
  1481. CXTPWindowRect rc(pWnd);
  1482. rc.OffsetRect(-rc.TopLeft());
  1483. int cx = rc.Width(), cy = rc.Height();
  1484. RECT rgn[] =
  1485. {
  1486. {1, 0, cx - 1, 1}, {0, 1, cx, cy - 1}, {1, cy - 1, cx - 1, cy}
  1487. };
  1488. int nSizeData = sizeof(RGNDATAHEADER) + sizeof(rgn);
  1489. RGNDATA* pRgnData = (RGNDATA*)malloc(nSizeData);
  1490. if (!pRgnData)
  1491. return;
  1492. MEMCPY_S(&pRgnData->Buffer, (void*)&rgn, sizeof(rgn));
  1493. pRgnData->rdh.dwSize = sizeof(RGNDATAHEADER);
  1494. pRgnData->rdh.iType = RDH_RECTANGLES;
  1495. pRgnData->rdh.nCount = sizeof(rgn) / sizeof(RECT);
  1496. pRgnData->rdh.nRgnSize = 0;
  1497. pRgnData->rdh.rcBound = CRect(0, 0, cx, cy);
  1498. CRgn rgnResult;
  1499. VERIFY(rgnResult.CreateFromData(NULL, nSizeData, pRgnData));
  1500. free(pRgnData);
  1501. pWnd->SetWindowRgn((HRGN)rgnResult.Detach(), FALSE);
  1502. }
  1503. void CXTPRibbonTheme::SetCommandBarRegion(CXTPCommandBar* pCommandBar)
  1504. {
  1505. if (pCommandBar->GetPosition() != xtpBarPopup)
  1506. return;
  1507. SetRoundRectRegion(pCommandBar);
  1508. }
  1509. void CXTPRibbonTheme::AdjustExcludeRect(CRect& /*rc*/, CXTPControl* /*pControl*/, BOOL /*bVertical*/)
  1510. {
  1511. }
  1512. void CXTPRibbonTheme::DrawSplitButtonPopup(CDC* pDC, CXTPControl* pButton)
  1513. {
  1514. CRect rcButton = pButton->GetRect();
  1515. BOOL bSelected = pButton->GetSelected(), bPopuped = pButton->GetPopuped(), bEnabled = pButton->GetEnabled();
  1516. if (rcButton.Height() > 33 && bEnabled)
  1517. {
  1518. CXTPOffice2007Image* pImage = LoadImage(_T("MENUSPLITITEM"));
  1519. if (pImage)
  1520. {
  1521. int nState = !bSelected  ? 0 : bSelected == TRUE_SPLITCOMMAND || (IsKeyboardSelected(bSelected) && !bPopuped) ? 2 : 1;
  1522. pImage->DrawImage(pDC, CRect(rcButton.left, rcButton.top, rcButton.right - m_nSplitButtonPopupWidth, rcButton.bottom),
  1523. pImage->GetSource(nState, 3), CRect(2, 2, 2, 2), 0xFF00FF);
  1524. }
  1525. }
  1526. CXTPOffice2007Image* pImage = LoadImage(_T("MENUSPLITDROPDOWN"));
  1527. int nState = !bSelected || !bEnabled ? 0 : bPopuped ? 2 : 1;
  1528. pImage->DrawImage(pDC, CRect(rcButton.right - m_nSplitButtonPopupWidth, rcButton.top, rcButton.right, rcButton.bottom),
  1529. pImage->GetSource(nState, 3), CRect(2, 2, 2, 2), 0xFF00FF);
  1530. }
  1531. void CXTPRibbonTheme::DrawControlPopupGlyph(CDC* pDC, CXTPControl* pButton)
  1532. {
  1533. CRect rcButton = pButton->GetRect();
  1534. CXTPOffice2007Image* pImage = LoadImage(_T("MENUPOPUPGLYPH"));
  1535. CRect rcSrc(pImage->GetSource(pButton->GetEnabled() ? 0 : 1, 2));
  1536. CPoint pt = CPoint(rcButton.right - 14, (rcButton.top + rcButton.bottom - rcSrc.Height()) / 2);
  1537. pImage->DrawImage(pDC, CRect(pt, rcSrc.Size()), rcSrc, CRect(0, 0, 0, 0), 0xFF00FF);
  1538. }
  1539. void CXTPRibbonTheme::DrawPopupResizeGripper(CDC* pDC, CRect rcGripper, int nFlags)
  1540. {
  1541. CXTPOffice2007Image* pImage = LoadImage(_T("POPUPBARRESIZEGRIPPERFACE"));
  1542. ASSERT(pImage);
  1543. if (!pImage)
  1544. {
  1545. CXTPOffice2003Theme::DrawPopupResizeGripper(pDC, rcGripper, nFlags);
  1546. return;
  1547. }
  1548. pImage->DrawImage(pDC, rcGripper, pImage->GetSource(), CRect(1, 1, 1, 1), 0xFF00FF);
  1549. if (nFlags == 2)
  1550. {
  1551. pImage = LoadImage(_T("POPUPBARRESIZEGRIPPERHEIGHT"));
  1552. CRect rc = pImage->GetSource();
  1553. CRect rcDest(CPoint(rcGripper.CenterPoint().x - rc.Width() / 2,
  1554. rcGripper.bottom - rc.Height()), rc.Size());
  1555. pImage->DrawImage(pDC, rcDest, rc, CRect(0, 0, 0, 0), 0xFF00FF);
  1556. }
  1557. else
  1558. {
  1559. pImage = LoadImage(_T("POPUPBARRESIZEGRIPPERWIDTH"));
  1560. CRect rc = pImage->GetSource();
  1561. CRect rcDest(CRect(CPoint(rcGripper.right - rc.Width(),
  1562. rcGripper.bottom - rc.Height()), rc.Size()));
  1563. pImage->DrawImage(pDC, rcDest, rc, CRect(0, 0, 0, 0), 0xFF00FF);
  1564. }
  1565. }
  1566. void CXTPRibbonTheme::DrawPopupBarCheckMark(CDC* pDC, CRect rc, BOOL bEnabled, COLORREF clr)
  1567. {
  1568. CXTPOffice2007Image* pImage = LoadImage(_T("MENUCHECKEDITEMMARK"));
  1569. ASSERT(pImage);
  1570. if (!pImage)
  1571. {
  1572. CXTPPaintManager::DrawPopupBarCheckMark(pDC, rc, bEnabled, clr);
  1573. return;
  1574. }
  1575. CRect rcSrc = pImage->GetSource(bEnabled ? 0 : 1, 4);
  1576. CRect rcDest(CPoint((rc.left + rc.right - rcSrc.Width()) / 2, (rc.top + rc.bottom - rcSrc.Height()) / 2), rcSrc.Size());
  1577. pImage->DrawImage(pDC, rcDest, rcSrc, CRect(0, 0, 0, 0), 0xFF00FF);
  1578. }
  1579. void CXTPRibbonTheme::DrawPopupBarRadioMark(CDC* pDC, CRect rc, BOOL bEnabled, COLORREF clr)
  1580. {
  1581. CXTPOffice2007Image* pImage = LoadImage(_T("MENUCHECKEDITEMMARK"));
  1582. ASSERT(pImage);
  1583. if (!pImage)
  1584. {
  1585. CXTPPaintManager::DrawPopupBarRadioMark(pDC, rc, bEnabled, clr);
  1586. return;
  1587. }
  1588. CRect rcSrc = pImage->GetSource(bEnabled ? 2 : 3, 4);
  1589. CRect rcDest(CPoint((rc.left + rc.right - rcSrc.Width()) / 2, (rc.top + rc.bottom - rcSrc.Height()) / 2), rcSrc.Size());
  1590. pImage->DrawImage(pDC, rcDest, rcSrc, CRect(0, 0, 0, 0), 0xFF00FF);
  1591. }
  1592. //////////////////////////////////////////////////////////////////////////
  1593. //