/** * @file XTPRibbonThemeOffice2007System.cpp * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ #include "StdAfx.h" #include "GraphicLibrary/unzip/unzip.h" #include "Common/XTPTypeId.h" #include "Common/XTPFramework.h" #include "Common/XTPSystemHelpers.h" #include "Common/XTPSynchro.h" #include "Common/XTPApplication.h" #include "Common/XTPSingleton.h" #include "Common/XTPGdiObjects.h" #include "Common/XTPMarkupTheme.h" #include "Common/XTPResource.h" #include "Common/XTPHookManager.h" #include "Common/XTPColorManager.h" #include "Common/XTPDrawHelpers.h" #include "Common/ScrollBar/XTPScrollInfo.h" #include "Common/Hook/XTPWinEventHook.h" #include "Common/FrameShadow/XTPFrameShadowManager.h" #include "CommandBars/XTPCommandBarsDefines.h" #include "CommandBars/XTPPaintManager.h" #include "CommandBars/XTPCommandBar.h" #include "CommandBars/XTPToolBar.h" #include "CommandBars/XTPMenuBar.h" #include "CommandBars/XTPMenuTitleBar.h" #include "CommandBars/XTPPopupBar.h" #include "CommandBars/XTPControls.h" #include "CommandBars/XTPControl.h" #include "CommandBars/XTPControlButton.h" #include "CommandBars/XTPControlPopup.h" #include "CommandBars/Frame/XTPFrameHook.h" #include "Ribbon/XTPRibbonPopups.h" #include "Ribbon/XTPRibbonBar.h" #include "Ribbon/XTPRibbonPaintManager.h" #include "Ribbon/XTPRibbonMarkupTheme.h" #include "Ribbon/Themes/XTPRibbonThemeOffice2007System.h" #include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" #ifdef _DEBUG # undef THIS_FILE static char THIS_FILE[] = __FILE__; # define new DEBUG_NEW #endif CXTPRibbonThemeOffice2007System::CXTPRibbonThemeOffice2007System(CXTPPaintManager* pPaintManager) : CXTPRibbonMarkupTheme(pPaintManager) { LoadParts(); if (XTPSystemVersion()->IsWinVistaOrGreater()) { m_pPaintManager->m_bUseOfficeFont = TRUE; m_pPaintManager->m_strOfficeFont = _T("Segoe UI"); m_pPaintManager->SetFontHeight(XTP_DPI_Y(12)); } } CXTPRibbonThemeOffice2007System::~CXTPRibbonThemeOffice2007System() { } void CXTPRibbonThemeOffice2007System::RefreshMetrics() { CXTPRibbonMarkupTheme::RefreshMetrics(); m_pPaintManager->GetIconsInfo()->bUseFadedIcons = FALSE; m_pPaintManager->GetIconsInfo()->bIconsWithShadow = FALSE; m_pPaintManager->GetIconsInfo()->bUseDisabledIcons = TRUE; } void CXTPRibbonThemeOffice2007System::DrawRibbonQuickAccessControls(CDC* pDC, CXTPRibbonBar* pRibbonBar) { if (!pRibbonBar->IsQuickAccessBelowRibbon() && pRibbonBar->IsQuickAccessVisible() && ((CXTPControls*)pRibbonBar->GetQuickAccessControls())->GetVisibleCount() > 0) { CRect rcQuickAccess = pRibbonBar->GetQuickAccessRect(); int nFrameBorder = -GetSystemMetrics(SM_CYBORDER); if (pRibbonBar->IsDwmEnabled()) { nFrameBorder += pRibbonBar->GetFrameHook()->CalcFrameBorder().top; } CRect rcQuickAccessArea(rcQuickAccess.left - XTP_DPI_X(15), rcQuickAccess.top + nFrameBorder / 2, rcQuickAccess.right, rcQuickAccess.bottom - XTP_DPI_Y(1)); CString strMarkupText; CSize sz = rcQuickAccessArea.Size(); strMarkupText.Format(_T(""), sz.cy / 2, 0, (sz.cy / 4) * 3, sz.cy, sz.cx - sz.cy / 2, sz.cy, sz.cx, sz.cy, sz.cx, sz.cy / 2, sz.cx, 0, sz.cx - sz.cy / 2, 0); RenderMarkup(pDC, rcQuickAccessArea, strMarkupText); } } void CXTPRibbonThemeOffice2007System::DrawRibbonQuickAccessButton(CDC* pDC, CXTPControlPopup* pControl) { _ASSERTE(pControl); m_pPaintManager->DrawRectangle(pDC, pControl->GetRect(), pControl->GetSelected(), pControl->GetPressed(), pControl->GetEnabled(), FALSE, pControl->GetPopuped(), xtpBarTypeNormal, xtpBarTop); CPoint pt; pt.x = pControl->GetRect().CenterPoint().x - XTP_DPI_X(16) / 2; pt.y = pControl->GetRect().CenterPoint().y - XTP_DPI_Y(16) / 2; CRect rc(pt.x, pt.y, pt.x + XTP_DPI_X(16), pt.y + XTP_DPI_Y(16)); rc.OffsetRect(0, XTP_DPI_Y(1)); XTPPrimitiveDrawer()->DrawSymbol(pDC, xtpPrimitiveSymbolEjectDown, rc, GetSysColor(COLOR_3DHIGHLIGHT)); rc.OffsetRect(0, XTP_DPI_Y(-1)); XTPPrimitiveDrawer()->DrawSymbol(pDC, xtpPrimitiveSymbolEjectDown, rc, GetSysColor(COLOR_BTNTEXT)); } BOOL CXTPRibbonThemeOffice2007System::LoadResource() { LoadParts(); return TRUE; } void CXTPRibbonThemeOffice2007System::LoadParts(BOOL bReload /*= FALSE*/) { if (bReload) m_bLoaded = FALSE; if (m_bLoaded) return; static LPCTSTR lpszName = _T("XTP_IDR_OFFICE2007SYSTEM_STYLE"); static LPCTSTR lpszType = _T("STYLE"); HINSTANCE hResource = AfxFindResourceHandle(lpszName, lpszType); CXTPResource resource; resource.LoadResource(hResource, lpszName, lpszType); if (NULL != resource.m_hResource) { HZIP hZip = OpenZip(resource.m_pvResourceData, resource.m_dwSize, NULL); _ASSERTE(NULL != hZip); // Invalid file if (NULL != hZip) STATIC_DOWNCAST(CXTPRibbonMarkupTheme, this)->LoadParts(hZip); CloseZip(hZip); } } int CXTPRibbonThemeOffice2007System::GetRibbonCaptionHeight(const CXTPRibbonBar* pRibbonBar) const { int nRibbonCaptionHeight = ::GetSystemMetrics(SM_CYCAPTION); if (!pRibbonBar->IsQuickAccessVisible() || pRibbonBar->IsQuickAccessBelowRibbon()) { nRibbonCaptionHeight -= XTP_DPI_Y(4); } return nRibbonCaptionHeight; }