X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/95fab76ba02122dccea89445ab9c40bb4970983b..aa1b2573f3cccee32b0f9b2ed36465c0de7cc005:/src/msw/statbox.cpp diff --git a/src/msw/statbox.cpp b/src/msw/statbox.cpp index 40b841f56a..0d4df55d13 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,17 +451,62 @@ 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 ) { RECT rc2 = { x, 0, x + width, y }; - ::DrawText(hdc, label, label.length(), &rc2, + ::DrawText(hdc, label.wx_str(), label.length(), &rc2, DT_SINGLELINE | DT_VCENTER); } else // RTL { RECT rc2 = { x, 0, x - width, y }; - ::DrawText(hdc, label, label.length(), &rc2, + ::DrawText(hdc, label.wx_str(), label.length(), &rc2, DT_SINGLELINE | DT_VCENTER | DT_RTLREADING); } }