/** * @file XTPCaptionButtonThemeOfficeXP.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 "Controls/Util/XTPControlTheme.h" #include "Controls/Button/XTPButtonTheme.h" #include "Controls/Button/XTPButton.h" #include "Controls/Button/Themes/XTPButtonThemeUltraFlat.h" #include "Controls/Button/Themes/XTPButtonThemeOfficeXP.h" #include "Controls/Static/XTPCaption.h" #include "Controls/Static/Themes/XTPCaptionButtonThemeOfficeXP.h" #include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CXTPCaptionButtonThemeOfficeXP CXTPCaptionButtonThemeOfficeXP::CXTPCaptionButtonThemeOfficeXP() { // m_bAnimateIcon = FALSE; // m_bFadedIcon = FALSE; m_bOffsetHiliteText = FALSE; } COLORREF CXTPCaptionButtonThemeOfficeXP::GetTextColor(CXTPButton* pButton) { if (!pButton->IsWindowEnabled()) return GetXtremeColor(COLOR_GRAYTEXT); if (pButton->IsHighlighted() || (pButton->IsPushed() || pButton->GetChecked())) return m_crTextHilite; CXTPCaption* pCaption = ((CXTPCaptionButton*)pButton)->GetCaption(); if (::IsWindow(pCaption->GetSafeHwnd())) { return pCaption->m_clrText; } return m_crText; } void CXTPCaptionButtonThemeOfficeXP::DrawButtonBackground(CDC* pDC, CXTPButton* pButton) { // define some temporary variables. CRect rcItem = pButton->GetButtonRect(); // Paint the background. if (pButton->IsHighlighted() || (pButton->IsPushed() || pButton->GetChecked())) { pDC->FillSolidRect(rcItem, (pButton->IsPushed() || pButton->GetChecked()) ? GetXtremeColor(XPCOLOR_HIGHLIGHT_PUSHED) : GetXtremeColor(XPCOLOR_HIGHLIGHT)); pDC->Draw3dRect(rcItem, GetXtremeColor(XPCOLOR_HIGHLIGHT_BORDER), GetXtremeColor(XPCOLOR_HIGHLIGHT_BORDER)); } else { CXTPCaption* pCaption = ((CXTPCaptionButton*)pButton)->GetCaption(); if (::IsWindow(pCaption->GetSafeHwnd())) { m_crBack = pCaption->m_clrFace; } pDC->FillSolidRect(rcItem, m_crBack); } } void CXTPCaptionButtonThemeOfficeXP::DrawButtonText(CDC* pDC, CXTPButton* pButton) { CXTPCaption* pCaption = ((CXTPCaptionButton*)pButton)->GetCaption(); if (::IsWindow(pCaption->GetSafeHwnd())) { if (pCaption->IsAppCaption() && !pCaption->GetCaptionText().IsEmpty()) { // select font into device context. CXTPFontDC fontDC(pDC, pButton->GetFont()); pDC->SetTextColor(GetTextColor(pButton)); CXTPClientRect rcItem(pButton); if (pButton->IsHighlighted() && m_bOffsetHiliteText) rcItem.OffsetRect(1, 1); // draw the text, and select the original font. pDC->DrawText(pCaption->GetCaptionText(), rcItem, DT_SINGLELINE | DT_END_ELLIPSIS | DT_VCENTER | DT_CENTER | DT_NOPREFIX); } } }