Simplify and correct MSW selection of background brush for children painting.
Check for the transparency of the window background in MSWGetBgBrush() itself and let MSWGetBgBrushForChild() just return the brush to be used. This required adding a MSW-specific hack to wxPanel to allow inheriting background of wxNotebook by its children which is slightly ugly but is exactly what we need to do in this case and makes the rest of the code much simpler. Also add a possibility to set the background of the page containing the control being tested to the widgets sample to test for background inheritance. This shows problems with wxSlider and wxRadioBox backgrounds but they're not new with this patch. Closes #12057. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64372 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -4916,42 +4916,32 @@ bool wxWindowMSW::DoEraseBackground(WXHDC hDC)
|
||||
}
|
||||
|
||||
WXHBRUSH
|
||||
wxWindowMSW::MSWGetBgBrushForChild(WXHDC WXUNUSED(hDC), wxWindowMSW *child)
|
||||
wxWindowMSW::MSWGetBgBrushForChild(WXHDC WXUNUSED(hDC),
|
||||
wxWindowMSW * WXUNUSED(child))
|
||||
{
|
||||
if ( m_hasBgCol )
|
||||
{
|
||||
// our background colour applies to:
|
||||
// 1. this window itself, always
|
||||
// 2. all children unless the colour is "not inheritable"
|
||||
// 3. even if it is not inheritable, our immediate transparent
|
||||
// children should still inherit it -- but not any transparent
|
||||
// children because it would look wrong if a child of non
|
||||
// transparent child would show our bg colour when the child itself
|
||||
// does not
|
||||
if ( child == this ||
|
||||
m_inheritBgCol ||
|
||||
(child->HasTransparentBackground() &&
|
||||
child->GetParent() == this) )
|
||||
{
|
||||
// draw children with the same colour as the parent
|
||||
wxBrush *
|
||||
brush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour());
|
||||
wxBrush *
|
||||
brush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour());
|
||||
|
||||
return (WXHBRUSH)GetHbrushOf(*brush);
|
||||
}
|
||||
return (WXHBRUSH)GetHbrushOf(*brush);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
WXHBRUSH wxWindowMSW::MSWGetBgBrush(WXHDC hDC, wxWindowMSW *child)
|
||||
WXHBRUSH wxWindowMSW::MSWGetBgBrush(WXHDC hDC)
|
||||
{
|
||||
for ( wxWindowMSW *win = this; win; win = win->GetParent() )
|
||||
{
|
||||
WXHBRUSH hBrush = win->MSWGetBgBrushForChild(hDC, child);
|
||||
WXHBRUSH hBrush = win->MSWGetBgBrushForChild(hDC, this);
|
||||
if ( hBrush )
|
||||
return hBrush;
|
||||
|
||||
// don't use the parent background if we're not transparent
|
||||
if ( !win->HasTransparentBackground() )
|
||||
break;
|
||||
|
||||
// background is not inherited beyond top level windows
|
||||
if ( win->IsTopLevel() )
|
||||
break;
|
||||
|
Reference in New Issue
Block a user