No real changes, just change type of MSWGetBgBrush() argument.

Pass wxWindow instead of HWND to it as in most cases we already have wxWindow
for the HWND we have and calling wxFindWinFromHandle() once more is
unnecessary.

This also makes the code of MSWGetBgBrushForChild() slightly simpler.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62932 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2009-12-18 20:49:23 +00:00
parent b93051ef46
commit b8797d96ca
6 changed files with 21 additions and 22 deletions

View File

@ -183,7 +183,7 @@ public:
}
// return the themed brush for painting our children
virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, WXHWND hWnd);
virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, wxWindow *child);
// draw child background
virtual bool MSWPrintChild(WXHDC hDC, wxWindow *win);

View File

@ -399,17 +399,19 @@ public:
// background or 0 if this window doesn't impose any particular background
// on its children
//
// the hDC parameter is the DC background will be drawn on, it can be used
// to call SetBrushOrgEx() on it if the returned brush is a bitmap one
//
// child parameter is never NULL
//
// the base class version returns a solid brush if we have a non default
// background colour or 0 otherwise
virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, WXHWND hWnd);
virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child);
// return the background brush to use for painting the given window by
// quering the parent windows via their MSWGetBgBrushForChild() recursively
//
// hWndToPaint is normally NULL meaning this window itself, but it can also
// be a child of this window which is used by the static box and could be
// potentially useful for other transparent controls
WXHBRUSH MSWGetBgBrush(WXHDC hDC, WXHWND hWndToPaint = NULL);
WXHBRUSH MSWGetBgBrush(WXHDC hDC) { return MSWGetBgBrush(hDC, this); }
WXHBRUSH MSWGetBgBrush(WXHDC hDC, wxWindowMSW *child);
// gives the parent the possibility to draw its children background, e.g.
// this is used by wxNotebook to do it using DrawThemeBackground()

View File

@ -367,7 +367,8 @@ WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd)
WXHBRUSH hbr = 0;
if ( !colBg.Ok() )
{
hbr = MSWGetBgBrush(pDC, hWnd);
if ( wxWindow *win = wxFindWinFromHandle(hWnd) )
hbr = MSWGetBgBrush(pDC, win);
// if the control doesn't have any bg colour, foreground colour will be
// ignored as the return value would be 0 -- so forcefully give it a

View File

@ -1248,14 +1248,14 @@ void wxNotebook::UpdateBgBrush()
}
}
WXHBRUSH wxNotebook::MSWGetBgBrushForChild(WXHDC hDC, WXHWND hWnd)
WXHBRUSH wxNotebook::MSWGetBgBrushForChild(WXHDC hDC, wxWindow *child)
{
if ( m_hbrBackground )
{
// before drawing with the background brush, we need to position it
// correctly
RECT rc;
::GetWindowRect((HWND)hWnd, &rc);
::GetWindowRect(GetHwndOf(child), &rc);
::MapWindowPoints(NULL, GetHwnd(), (POINT *)&rc, 1);
@ -1267,7 +1267,7 @@ WXHBRUSH wxNotebook::MSWGetBgBrushForChild(WXHDC hDC, WXHWND hWnd)
return m_hbrBackground;
}
return wxNotebookBase::MSWGetBgBrushForChild(hDC, hWnd);
return wxNotebookBase::MSWGetBgBrushForChild(hDC, child);
}
bool wxNotebook::MSWPrintChild(WXHDC hDC, wxWindow *child)

View File

@ -365,7 +365,7 @@ void wxStaticBox::PaintBackground(wxDC& dc, const RECT& rc)
// see http://groups.google.com/groups?selm=4252E932.3080801%40able.es
wxWindow *parent = GetParent();
wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl();
HBRUSH hbr = (HBRUSH)parent->MSWGetBgBrush(impl->GetHDC(), GetHWND());
HBRUSH hbr = (HBRUSH)parent->MSWGetBgBrush(impl->GetHDC(), this);
// if there is no special brush for painting this control, just use the
// solid background colour

View File

@ -4816,7 +4816,7 @@ bool wxWindowMSW::DoEraseBackground(WXHDC hDC)
}
WXHBRUSH
wxWindowMSW::MSWGetBgBrushForChild(WXHDC WXUNUSED(hDC), WXHWND hWnd)
wxWindowMSW::MSWGetBgBrushForChild(WXHDC WXUNUSED(hDC), wxWindowMSW *child)
{
if ( m_hasBgCol )
{
@ -4828,11 +4828,10 @@ wxWindowMSW::MSWGetBgBrushForChild(WXHDC WXUNUSED(hDC), WXHWND hWnd)
// children because it would look wrong if a child of non
// transparent child would show our bg colour when the child itself
// does not
wxWindow *win = wxFindWinFromHandle(hWnd);
if ( win == this ||
if ( child == this ||
m_inheritBgCol ||
(win && win->HasTransparentBackground() &&
win->GetParent() == this) )
(child->HasTransparentBackground() &&
child->GetParent() == this) )
{
// draw children with the same colour as the parent
wxBrush *
@ -4845,14 +4844,11 @@ wxWindowMSW::MSWGetBgBrushForChild(WXHDC WXUNUSED(hDC), WXHWND hWnd)
return 0;
}
WXHBRUSH wxWindowMSW::MSWGetBgBrush(WXHDC hDC, WXHWND hWndToPaint)
WXHBRUSH wxWindowMSW::MSWGetBgBrush(WXHDC hDC, wxWindowMSW *child)
{
if ( !hWndToPaint )
hWndToPaint = GetHWND();
for ( wxWindowMSW *win = this; win; win = win->GetParent() )
{
WXHBRUSH hBrush = win->MSWGetBgBrushForChild(hDC, hWndToPaint);
WXHBRUSH hBrush = win->MSWGetBgBrushForChild(hDC, child);
if ( hBrush )
return hBrush;