X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6a1b3ead3fd406e870042014eb7bd117586f4fff..96c9f0f6775fb74e549789d714941e97a4407848:/src/msw/tbar95.cpp diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index 1068ff35ed..9b9436d81f 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -26,7 +26,10 @@ #if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE && !defined(__SMARTPHONE__) +#include "wx/toolbar.h" + #ifndef WX_PRECOMP + #include "wx/msw/wrapcctl.h" // include "properly" #include "wx/dynarray.h" #include "wx/frame.h" #include "wx/log.h" @@ -36,11 +39,10 @@ #include "wx/dcmemory.h" #include "wx/control.h" #include "wx/app.h" // for GetComCtl32Version + #include "wx/image.h" #endif -#include "wx/toolbar.h" #include "wx/sysopt.h" -#include "wx/image.h" #include "wx/msw/private.h" @@ -48,9 +50,6 @@ #include "wx/msw/uxtheme.h" #endif -// include "properly" -#include "wx/msw/wrapcctl.h" - // this define controls whether the code for button colours remapping (only // useful for 16 or 256 colour images) is active at all, it's always turned off // for CE where it doesn't compile (and is probably not needed anyhow) and may @@ -181,7 +180,6 @@ private: DECLARE_NO_COPY_CLASS(wxToolBarTool) }; - // ============================================================================ // implementation // ============================================================================ @@ -247,7 +245,7 @@ bool wxToolBar::Create(wxWindow *parent, #if wxUSE_UXTHEME if ( style & wxTB_FLAT ) { - LRESULT style = ::SendMessage(GetHwnd(), TB_GETSTYLE, 0, 0L); + LRESULT style = GetMSWToolbarStyle(); if ( !(style & TBSTYLE_FLAT) ) ::SendMessage(GetHwnd(), TB_SETSTYLE, 0, style | TBSTYLE_FLAT); @@ -382,7 +380,7 @@ WXDWORD wxToolBar::MSWGetStyle(long style, WXDWORD *exstyle) const if ( style & (wxTB_FLAT | wxTB_HORZ_LAYOUT) ) { // static as it doesn't change during the program lifetime - static int s_verComCtl = wxApp::GetComCtl32Version(); + static const int s_verComCtl = wxApp::GetComCtl32Version(); // comctl32.dll 4.00 doesn't support the flat toolbars and using this // style with 6.00 (part of Windows XP) leads to the toolbar with @@ -404,6 +402,9 @@ WXDWORD wxToolBar::MSWGetStyle(long style, WXDWORD *exstyle) const if ( style & wxTB_VERTICAL ) msStyle |= CCS_VERT; + if( style & wxTB_BOTTOM ) + msStyle |= CCS_BOTTOM; + return msStyle; } @@ -1272,6 +1273,12 @@ void wxToolBar::UpdateSize() // toolbar styles // --------------------------------------------------------------------------- +// get the TBSTYLE of the given toolbar window +long wxToolBar::GetMSWToolbarStyle() const +{ + return ::SendMessage(GetHwnd(), TB_GETSTYLE, 0, 0L); +} + void wxToolBar::SetWindowStyleFlag(long style) { // the style bits whose changes force us to recreate the toolbar @@ -1371,7 +1378,29 @@ void wxToolBar::OnEraseBackground(wxEraseEvent& event) RECT rect = wxGetClientRect(GetHwnd()); HDC hdc = GetHdcOf((*event.GetDC())); - if ( UseBgCol() ) +#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 ( !UseBgCol() && !GetParent()->UseBgCol() ) + { + wxUxThemeEngine *theme = wxUxThemeEngine::GetIfActive(); + if ( theme ) + { + HRESULT + hr = theme->DrawThemeParentBackground(GetHwnd(), hdc, &rect); + if ( hr == S_OK ) + return; + + // it can also return S_FALSE which seems to simply say that it + // didn't draw anything but no error really occurred + if ( FAILED(hr) ) + wxLogApiError(_T("DrawThemeParentBackground(toolbar)"), hr); + } + } +#endif // wxUSE_UXTHEME + + if ( UseBgCol() || (GetMSWToolbarStyle() & TBSTYLE_TRANSPARENT) ) { // do draw our background // @@ -1385,30 +1414,8 @@ void wxToolBar::OnEraseBackground(wxEraseEvent& event) } 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 ( hr == S_OK ) - return; - - // it can also return S_FALSE which seems to simply say that it - // didn't draw anything but no error really occurred - if ( FAILED(hr) ) - wxLogApiError(_T("DrawThemeParentBackground(toolbar)"), hr); - } - } -#endif // wxUSE_UXTHEME - + // let the system do it for us event.Skip(); - return; } }