/** * @file XTPStatusBarThemeVisualStudio2022.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 "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/XTPDrawHelpers.h" #include "Common/XTPColorManager.h" #include "CommandBars/StatusBar/XTPStatusBar.h" #include "CommandBars/StatusBar/XTPStatusBarPaintManager.h" #include "CommandBars/StatusBar/XTPStatusBarThemeOffice2013.h" #include "CommandBars/StatusBar/XTPStatusBarThemeVisualStudio2022.h" #include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif CXTPStatusBarThemeVisualStudio2022::CXTPStatusBarThemeVisualStudio2022( CXTPPaintManager* pPaintManager) : CXTPStatusBarThemeOffice2013(pPaintManager) , m_bAutomaticStateColor(TRUE) { XTPGetApplication()->Subscribe(this); } CXTPStatusBarThemeVisualStudio2022::~CXTPStatusBarThemeVisualStudio2022() { XTPGetApplication()->Unsubscribe(this); } void CXTPStatusBarThemeVisualStudio2022::RefreshMetrics() { CXTPStatusBarThemeOffice2013::RefreshMetrics(); m_clrGripperLite.SetStandardValue( XTPColorManager()->LightColor(m_clrBackground, GetXtremeColor(COLOR_WINDOW), 50)); m_clrGripperDark.SetStandardValue( XTPColorManager()->LightColor(m_clrBackground, GetXtremeColor(COLOR_WINDOWTEXT), 75)); UpdateStateColor(); } void CXTPStatusBarThemeVisualStudio2022::SetStateColor(COLORREF clrState) { if (clrState == COLORREF_NULL) { m_clrTextGray.SetDefaultValue(); m_clrBackground.SetDefaultValue(); m_clrButtonBack.SetDefaultValue(); m_clrGripperLite.SetDefaultValue(); m_clrGripperDark.SetDefaultValue(); m_clrButtonBackPushed.SetDefaultValue(); m_clrButtonBackHighlight.SetDefaultValue(); m_clrButtonBackChecked.SetDefaultValue(); m_bAutomaticStateColor = TRUE; } else { m_clrTextGray = clrState; m_clrBackground = clrState; m_clrButtonBack = clrState; m_clrGripperLite = XTPColorManager()->LightColor(clrState, GetXtremeColor(COLOR_WINDOW), 50); m_clrGripperDark = XTPColorManager()->LightColor(clrState, GetXtremeColor(COLOR_WINDOWTEXT), 75); m_clrButtonBackPushed = m_clrGripperDark; m_clrButtonBackHighlight = m_clrGripperLite; m_clrButtonBackChecked = m_clrGripperDark; m_bAutomaticStateColor = FALSE; } } COLORREF CXTPStatusBarThemeVisualStudio2022::GetStateColor() const { return (m_clrTextGray == m_clrBackground && m_clrTextGray == m_clrButtonBack && m_clrTextGray == m_clrGripperLite && m_clrTextGray == m_clrGripperDark && m_clrTextGray == m_clrButtonBackPushed && m_clrTextGray == m_clrButtonBackHighlight && m_clrTextGray == m_clrButtonBackChecked ? m_clrTextGray.operator COLORREF() : COLORREF_NULL); } void CXTPStatusBarThemeVisualStudio2022::DrawStatusBarGripper(CDC* pDC, CRect rcClient) { CPoint pt(rcClient.BottomRight()); pt.x -= XTP_DPI_X(6); pt.y -= XTP_DPI_Y(6); COLORREF clr = m_clrGripperDark; int diffX = XTP_DPI_X(1), diffY = XTP_DPI_Y(1); CRect rcDot; // CRect(a, b, a + diffX, b + diffY); for (int i = 1; i >= 0; --i) { for (int a = 0, c = 4; a < 4; ++a, --c) { rcDot.left = pt.x - a * XTP_DPI_X(2); rcDot.right = rcDot.left + diffX; for (int b = 0; b < c; ++b) { rcDot.top = pt.y - b * XTP_DPI_Y(2); rcDot.bottom = rcDot.top + diffY; pDC->FillSolidRect(rcDot, clr); } } clr = m_clrGripperLite; pt.x += diffX; pt.y += diffY; } } void CXTPStatusBarThemeVisualStudio2022::OnAmbientPropertyChanged( CXTPApplication* pApplication, XTPApplicationAmbientProperty nProperty) { UNREFERENCED_PARAMETER(pApplication); if (xtpApplicationStateColor != nProperty) return; UpdateStateColor(); } void CXTPStatusBarThemeVisualStudio2022::UpdateStateColor() { if (!m_bAutomaticStateColor) return; COleVariant color = XTPGetApplication()->GetAmbientProperty(xtpApplicationStateColor); color.ChangeType(VT_I4); SetStateColor(static_cast(color.lVal)); m_bAutomaticStateColor = TRUE; }