Opened 8 years ago

Closed 8 years ago

#12057 closed defect (fixed)

MSWGetBgBrush() doesn't consider transparent windows correctly

Reported by: vaclavslavik Owned by: vadz
Priority: normal Milestone: 3.0.0
Component: wxMSW Version: stable-latest
Keywords: Cc:
Blocked By: Blocking:
Patch: no


Current implementation of MSWGetBgBrush() unconditionally travels windows hierarchy upwards until it find a window that returns valid brush from MSWGetBgBrushForChild(). But the background should be "inherited" from parent window only for windows with transparent background.

wxWindowMSW::MSWGetBgBrushForChild() attempts to do this check, but it does it incorrectly: it only gives background to direct children with transparent background. It should do it for the whole chain of transparent children. Similarly for wxNotebook::MSWGetBgBrushForChild() that didn't even consider transparency.

This should probably be fixed by performing the transparency checks in MSWGetBgBrush() itself. But this would only work with wxNotebook if wxPanels (i.e. notebook pages) were transparent.

Change History (3)

comment:1 Changed 8 years ago by VS

(In [64314]) Fix incorrect painting of backgrounds inside notebook.

Children without transparent background (e.g. wxListBox) were still
pained using notebook's background brush. They shouldn't, it should
apply only to transparent-bg controls.

This fix is not perfect, see #12057.

comment:2 Changed 8 years ago by vadz

  • Status changed from new to accepted

comment:3 Changed 8 years ago by VZ

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [64372]) 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.

Note: See TracTickets for help on using tickets.