From b8797d96ca1d94443bd2201e9884fc9a16cb53bb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 18 Dec 2009 20:49:23 +0000 Subject: [PATCH] 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 --- include/wx/msw/notebook.h | 2 +- include/wx/msw/window.h | 14 ++++++++------ src/msw/control.cpp | 3 ++- src/msw/notebook.cpp | 6 +++--- src/msw/statbox.cpp | 2 +- src/msw/window.cpp | 16 ++++++---------- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/include/wx/msw/notebook.h b/include/wx/msw/notebook.h index 969e732145..2dfa4337e8 100644 --- a/include/wx/msw/notebook.h +++ b/include/wx/msw/notebook.h @@ -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); diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index c1c4e3555b..c4670e7336 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -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() diff --git a/src/msw/control.cpp b/src/msw/control.cpp index c573e4a29a..1cc9dce77e 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -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 diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 82304be269..831680858f 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -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) diff --git a/src/msw/statbox.cpp b/src/msw/statbox.cpp index 18abded044..0a5b78abd2 100644 --- a/src/msw/statbox.cpp +++ b/src/msw/statbox.cpp @@ -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 diff --git a/src/msw/window.cpp b/src/msw/window.cpp index be4d7d01d2..c95309f8aa 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -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; -- 2.45.2