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
This commit is contained in:
Vadim Zeitlin
2007-03-22 02:31:35 +00:00
parent b4bc14f4f1
commit 0f97497fcf
2 changed files with 52 additions and 31 deletions

View File

@@ -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
-----

View File

@@ -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 )
{