X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9f8845289521c7f53e95b6dfd8275daab8b05639..85f138db83939ce7c59a942aaecca7fa98168db3:/src/msw/tbar95.cpp?ds=sidebyside diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index de0cc3ffaa..944a1d0b27 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -46,6 +46,10 @@ #include "wx/msw/private.h" +#if wxUSE_UXTHEME +#include "wx/msw/uxtheme.h" +#endif + // include "properly" #include "wx/msw/wrapcctl.h" @@ -246,6 +250,26 @@ bool wxToolBar::Create(wxWindow *parent, SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR)); SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); + // workaround for flat toolbar on Windows XP classic style +#if wxUSE_UXTHEME + if ( style & wxTB_FLAT ) + { + wxUxThemeEngine *p = wxUxThemeEngine::Get(); + if ( !p || !p->IsThemeActive() ) + { + DWORD dwToolbarStyle; + + dwToolbarStyle = (DWORD)::SendMessage(GetHwnd(), TB_GETSTYLE, 0, 0L ); + + if ((dwToolbarStyle & TBSTYLE_FLAT) == 0) + { + dwToolbarStyle |= TBSTYLE_FLAT; + ::SendMessage(GetHwnd(), TB_SETSTYLE, 0, (LPARAM)dwToolbarStyle ); + } + } + } +#endif + return TRUE; } @@ -256,7 +280,7 @@ bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size) // toolbar-specific post initialisation ::SendMessage(GetHwnd(), TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); - + return TRUE; } @@ -481,6 +505,19 @@ bool wxToolBar::Realize() const bool isVertical = HasFlag(wxTB_VERTICAL); + bool doRemap, doRemapBg, doTransparent; + if (wxSystemOptions::GetOptionInt(wxT("msw.remap")) == 2) + { + doRemapBg = doRemap = false; + doTransparent = true; + } + else + { doRemap = !wxSystemOptions::HasOption(wxT("msw.remap")) + || wxSystemOptions::GetOptionInt(wxT("msw.remap")) == 1; + doRemapBg = !doRemap; + doTransparent = false; + } + // delete all old buttons, if any for ( size_t pos = 0; pos < m_nButtons; pos++ ) { @@ -520,6 +557,9 @@ bool wxToolBar::Realize() wxMemoryDC dcAllButtons; wxBitmap bitmap(totalBitmapWidth, totalBitmapHeight); dcAllButtons.SelectObject(bitmap); + if (doTransparent) + dcAllButtons.SetBackground(*wxTRANSPARENT_BRUSH); + else dcAllButtons.SetBackground(*wxLIGHT_GREY_BRUSH); dcAllButtons.Clear(); @@ -544,7 +584,7 @@ bool wxToolBar::Realize() MemoryHDC memoryDC2; #endif // USE_BITMAP_MASKS/!USE_BITMAP_MASKS - if (wxSystemOptions::HasOption(wxT("msw.remap")) && wxSystemOptions::GetOptionInt(wxT("msw.remap")) == 0) + if (doRemapBg) { #if USE_BITMAP_MASKS dcAllButtons.SelectObject(wxNullBitmap); @@ -610,7 +650,7 @@ bool wxToolBar::Realize() bitmap.SetHBITMAP(0); #endif // USE_BITMAP_MASKS/!USE_BITMAP_MASKS - if (!wxSystemOptions::HasOption(wxT("msw.remap")) || wxSystemOptions::GetOptionInt(wxT("msw.remap")) == 1) + if (doRemap) { // Map to system colours hBitmap = (HBITMAP)MapBitmap((WXHBITMAP) hBitmap,