Correctly align background brush when erasing owner drawn bitmaps in wxMSW.

Add a hack to work around the problem with background alignment when drawing
the owner-drawn buttons in wxMSW. This fixes the alignment for any custom
brushes used for background painting but doesn't help with user-defined
EVT_ERASE_BACKGROUND handlers which still don't work well with the owner-drawn
buttons. Unfortunately DrawThemeParentBackground() remains a mystery and I
couldn't understand why not only doesn't it position the DC correctly on its
own but also ignores any attempts to do it manually.

This also doesn't help with the stubbornly remaining one pixel non-transparent
border around non-owner-drawn buttons which I just can't get rid of.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67281 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-03-22 15:07:20 +00:00
parent 4c51a665c6
commit a3b89fa936
2 changed files with 33 additions and 1 deletions

View File

@@ -182,6 +182,13 @@
extern wxMenu *wxCurrentPopupMenu;
#endif
#if wxUSE_UXTHEME
// This is a hack used by the owner-drawn wxButton implementation to ensure
// that the brush used for erasing its background is correctly aligned with the
// control.
extern wxWindowMSW *wxWindowBeingErased = NULL;
#endif // wxUSE_UXTHEME
namespace
{
@@ -4921,9 +4928,17 @@ wxWindowMSW::MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child)
WXHBRUSH wxWindowMSW::MSWGetBgBrush(WXHDC hDC)
{
// Use the special wxWindowBeingErased variable if it is set as the child
// being erased.
wxWindowMSW * const child =
#if wxUSE_UXTHEME
wxWindowBeingErased ? wxWindowBeingErased :
#endif
this;
for ( wxWindowMSW *win = this; win; win = win->GetParent() )
{
WXHBRUSH hBrush = win->MSWGetBgBrushForChild(hDC, this);
WXHBRUSH hBrush = win->MSWGetBgBrushForChild(hDC, child);
if ( hBrush )
return hBrush;