From 053889ad4b189e882e2a7b707ff6bcc88fdc6267 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 8 Feb 2006 14:42:48 +0000 Subject: [PATCH] don't set colours for the toolbar manually, this prevents default redrawing from taking place; draw themed background if the parent is themed (based on patch 1358919) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37387 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/tbar95.cpp | 54 +++++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index a65d6202db..8e2a0e4267 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -234,10 +234,6 @@ bool wxToolBar::Create(wxWindow *parent, wxSetCCUnicodeFormat(GetHwnd()); - // set up the colors and fonts - SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); - SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); - // workaround for flat toolbar on Windows XP classic style: we have to set // the style after creating the control; doing it at creation time doesn't work #if wxUSE_UXTHEME @@ -1344,27 +1340,45 @@ void wxToolBar::OnMouseEvent(wxMouseEvent& event) // colour: for example, when it must blend in with a notebook page. void wxToolBar::OnEraseBackground(wxEraseEvent& event) { - if ( !UseBgCol() ) - { - event.Skip(); - return; - } - - wxColour bgCol = GetBackgroundColour(); - - // notice that this 'dumb' implementation may cause flicker for some of the - // controls in which case they should intercept wxEraseEvent and process it - // themselves somehow - RECT rect = wxGetClientRect(GetHwnd()); + HDC hdc = GetHdcOf((*event.GetDC())); - AutoHBRUSH hBrush(wxColourToRGB(bgCol)); + if ( UseBgCol() ) + { + // do draw our background + // + // notice that this 'dumb' implementation may cause flicker for some of + // the controls in which case they should intercept wxEraseEvent and + // process it themselves somehow + AutoHBRUSH hBrush(wxColourToRGB(GetBackgroundColour())); - HDC hdc = GetHdcOf((*event.GetDC())); + wxCHANGE_HDC_MAP_MODE(hdc, MM_TEXT); + ::FillRect(hdc, &rect, hBrush); + } + else // we have no non default background colour + { +#if wxUSE_UXTHEME + // we may need to draw themed colour so that we appear correctly on + // e.g. notebook page under XP with themes but only do it if the parent + // draws themed background itself + if ( !GetParent()->UseBgCol() ) + { + wxUxThemeEngine *theme = wxUxThemeEngine::GetIfActive(); + if ( theme ) + { + HRESULT + hr = theme->DrawThemeParentBackground(GetHwnd(), hdc, &rect); + if ( SUCCEEDED(hr) ) + return; - wxCHANGE_HDC_MAP_MODE(hdc, MM_TEXT); + wxLogApiError(_T("DrawThemeParentBackground(toolbar)"), hr); + } + } +#endif // wxUSE_UXTHEME - ::FillRect(hdc, &rect, hBrush); + event.Skip(); + return; + } } bool wxToolBar::HandleSize(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam) -- 2.45.2