From 72a55896e5bdf4ac03006fd280194afa1fd88cc1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 19 May 2005 00:00:26 +0000 Subject: [PATCH] respect label foreground colour for static boxes when using XP themes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34156 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/statbox.cpp | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/msw/statbox.cpp b/src/msw/statbox.cpp index 42fec06f70..04d9874b6b 100644 --- a/src/msw/statbox.cpp +++ b/src/msw/statbox.cpp @@ -42,6 +42,7 @@ #include "wx/dcmemory.h" #include "wx/sysopt.h" +#include "wx/msw/uxtheme.h" #include "wx/msw/private.h" #include "wx/msw/missing.h" @@ -343,11 +344,31 @@ void wxStaticBox::PaintBackground(wxDC& dc, const RECT& rc) void wxStaticBox::PaintForeground(wxDC& dc, const RECT& WXUNUSED(rc)) { - // NB: neither setting the text colour nor transparent background mode - // doesn't change anything: the static box def window proc still - // draws the label in its own colours, so if we want to have control - // over this we really have to draw everything ourselves MSWDefWindowProc(WM_PAINT, (WPARAM)GetHdcOf(dc), 0); + + // when using XP themes, neither setting the text colour nor transparent + // background mode doesn't change anything: the static box def window proc + // still draws the label in its own colours, so we need to redraw the text + // ourselves if we have a non default fg colour + if ( m_hasFgCol && wxUxThemeEngine::GetIfActive() ) + { + // draw over the text in default colour in our colour + dc.SetFont(GetFont()); + + HDC hdc = GetHdcOf(dc); + ::SetTextColor(hdc, GetForegroundColour().GetPixel()); + + // FIXME: value of x is hardcoded as this is what it is on my system, + // no idea if it's true everywhere + const int y = dc.GetCharHeight(); + const int x = 9; + + // TODO: RTL? + RECT rc = { x, 0, GetSize().x - x, y }; + + const wxString label = GetLabel(); + ::DrawText(hdc, label, label.length(), &rc, DT_SINGLELINE | DT_VCENTER); + } } void wxStaticBox::OnPaint(wxPaintEvent& WXUNUSED(event)) -- 2.45.2