From 0f97497fcfe46637b67ac1d1cc660be1233dd086 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 22 Mar 2007 02:31:35 +0000 Subject: [PATCH] corrected static box label appearance when its foreground colour was set and either background colour was set too (it was ignored) or font of non default was used (label wasn't drawn correctly) (backport of patch 1683573 from HEAD) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@45009 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 7 +++++ src/msw/statbox.cpp | 76 +++++++++++++++++++++++++++------------------ 2 files changed, 52 insertions(+), 31 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 79a4199d64..c80ebf9533 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -88,6 +88,13 @@ Major new features in 2.8 release wxSearchCtrl, wxAboutBox, wxTreebook, tar streams. +2.8.4 + +wxMSW: + +- Corrected wxStaticBox label appearance when its foreground colour was set: + it didn't respect font size nor background colour then (Juan Antonio Ortega) + 2.8.3 ----- diff --git a/src/msw/statbox.cpp b/src/msw/statbox.cpp index 40b841f56a..692e8a10ca 100644 --- a/src/msw/statbox.cpp +++ b/src/msw/statbox.cpp @@ -402,37 +402,6 @@ void wxStaticBox::PaintForeground(wxDC& dc, const RECT& rc) // Get dimensions of the label const wxString label = GetLabel(); - int width, height; - dc.GetTextExtent(wxStripMenuCodes(label, wxStrip_Mnemonics), - &width, &height); - - int x; - int y = height; - - // first we need to correctly paint the background of the label - // as Windows ignores the brush offset when doing it - // - // FIXME: value of x is hardcoded as this is what it is on my system, - // no idea if it's true everywhere - RECT dimensions = {0, 0, 0, y}; - if ( !rtl ) - { - x = 9; - dimensions.left = x; - dimensions.right = x + width; - } - else - { - x = rc.right - 7; - dimensions.left = x - width; - dimensions.right = x; - } - - // need to adjust the rectangle to cover all the label background - dimensions.left -= 2; - dimensions.right += 2; - dimensions.bottom += 2; - PaintBackground(dc, dimensions); // choose the correct font AutoHFONT font; @@ -482,6 +451,51 @@ void wxStaticBox::PaintForeground(wxDC& dc, const RECT& rc) } } + // Get the font extent + int width, height; + dc.GetTextExtent(wxStripMenuCodes(label, wxStrip_Mnemonics), + &width, &height); + + int x; + int y = height; + + // first we need to correctly paint the background of the label + // as Windows ignores the brush offset when doing it + // + // FIXME: value of x is hardcoded as this is what it is on my system, + // no idea if it's true everywhere + RECT dimensions = {0, 0, 0, y}; + if ( !rtl ) + { + x = 9; + dimensions.left = x; + dimensions.right = x + width; + } + else + { + x = rc.right - 7; + dimensions.left = x - width; + dimensions.right = x; + } + + // need to adjust the rectangle to cover all the label background + dimensions.left -= 2; + dimensions.right += 2; + dimensions.bottom += 2; + + if ( UseBgCol() ) + { + // our own background colour should be used for the background of + // the label: this is consistent with the behaviour under pre-XP + // systems (i.e. without visual themes) and generally makes sense + wxBrush brush = wxBrush(GetBackgroundColour()); + ::FillRect(GetHdcOf(dc), &dimensions, GetHbrushOf(brush)); + } + else // paint parent background + { + PaintBackground(dc, dimensions); + } + // now draw the text if ( !rtl ) {