X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4e3e485bc855bb6aa3e3e7978eac9fb5eea0287e..ce7208d49d5ce2ca1dc0b3b83f14f1d04f29c4bf:/src/msw/tbar95.cpp?ds=sidebyside diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index f28404d38b..16a2ec95c9 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -29,6 +29,7 @@ #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" @@ -38,10 +39,10 @@ #include "wx/dcmemory.h" #include "wx/control.h" #include "wx/app.h" // for GetComCtl32Version + #include "wx/image.h" #endif #include "wx/sysopt.h" -#include "wx/image.h" #include "wx/msw/private.h" @@ -49,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 @@ -182,7 +180,6 @@ private: DECLARE_NO_COPY_CLASS(wxToolBarTool) }; - // ============================================================================ // implementation // ============================================================================ @@ -248,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); @@ -350,7 +347,7 @@ wxSize wxToolBar::DoGetBestSize() const sizeBest.x *= GetToolsCount(); // reverse horz and vertical components if necessary - if ( HasFlag(wxTB_VERTICAL) ) + if ( IsVertical() ) { int t = sizeBest.x; sizeBest.x = sizeBest.y; @@ -383,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 @@ -405,6 +402,12 @@ WXDWORD wxToolBar::MSWGetStyle(long style, WXDWORD *exstyle) const if ( style & wxTB_VERTICAL ) msStyle |= CCS_VERT; + if( style & wxTB_BOTTOM ) + msStyle |= CCS_BOTTOM; + + if ( style & wxTB_RIGHT ) + msStyle |= CCS_RIGHT; + return msStyle; } @@ -541,8 +544,6 @@ bool wxToolBar::Realize() // nothing to do return true; - const bool isVertical = HasFlag(wxTB_VERTICAL); - #ifdef wxREMAP_BUTTON_COLOURS // don't change the values of these constants, they can be set from the // user code via wxSystemOptions @@ -819,7 +820,7 @@ bool wxToolBar::Realize() // don't add separators to the vertical toolbar with old comctl32.dll // versions as they didn't handle this properly - if ( isVertical && tool->IsSeparator() && + if ( IsVertical() && tool->IsSeparator() && wxApp::GetComCtl32Version() <= 472 ) { continue; @@ -943,7 +944,7 @@ bool wxToolBar::Realize() // get the items size for all items but for the horizontal ones we // don't need to deal with the non controls bool isControl = tool->IsControl(); - if ( !isControl && !isVertical ) + if ( !isControl && !IsVertical() ) continue; // note that we use TB_GETITEMRECT and not TB_GETRECT because the @@ -1034,7 +1035,7 @@ bool wxToolBar::Realize() } int top; - if ( isVertical ) + if ( IsVertical() ) { left = 0; top = y; @@ -1056,7 +1057,7 @@ bool wxToolBar::Realize() // separators which we added just for aligning the controls m_nButtons = index; - if ( !isVertical ) + if ( !IsVertical() ) { if ( m_maxRows == 0 ) // if not set yet, only one row @@ -1273,6 +1274,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 @@ -1372,7 +1379,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 // @@ -1386,30 +1415,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; } } @@ -1422,7 +1429,7 @@ bool wxToolBar::HandleSize(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam) { int w, h; - if ( GetWindowStyle() & wxTB_VERTICAL ) + if ( IsVertical() ) { w = r.right - r.left; if ( m_maxRows )