X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c36f1fc7c9c91a008b308cf6775f2f7a134ef2f1..fcf90ee1b10d41b4ddfbfa537481a9c64e30348f:/src/msw/tbar95.cpp diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index 425a9c80b4..944a1d0b27 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -39,13 +39,17 @@ #include "wx/control.h" #endif -#if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE && (!defined(_WIN32_WCE) || (_WIN32_WCE >= 400 && !wxUSE_POCKETPC_UI)) +#if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE && (!defined(_WIN32_WCE) || (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__))) #include "wx/toolbar.h" #include "wx/sysopt.h" #include "wx/msw/private.h" +#if wxUSE_UXTHEME +#include "wx/msw/uxtheme.h" +#endif + // include "properly" #include "wx/msw/wrapcctl.h" @@ -55,7 +59,7 @@ // conditional compilation // ---------------------------------------------------------------------------- -// wxWindows previously always considered that toolbar buttons have light grey +// wxWidgets previously always considered that toolbar buttons have light grey // (0xc0c0c0) background and so ignored any bitmap masks - however, this // doesn't work with XPMs which then appear to have black background. To make // this work, we must respect the bitmap masks - which we do now. This should @@ -240,10 +244,32 @@ bool wxToolBar::Create(wxWindow *parent, if ( !MSWCreateToolbar(pos, size) ) return FALSE; + wxSetCCUnicodeFormat(GetHwnd()); + // set up the colors and fonts 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; } @@ -254,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; } @@ -386,6 +412,7 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool) // Realize() later tool->Attach(this); + InvalidateBestSize(); return TRUE; } @@ -463,6 +490,7 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool) } } + InvalidateBestSize(); return TRUE; } @@ -477,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++ ) { @@ -516,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(); @@ -540,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); @@ -606,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, @@ -920,6 +964,7 @@ bool wxToolBar::Realize() } } + InvalidateBestSize(); return TRUE; } @@ -1368,7 +1413,7 @@ void wxToolBar::HandleMouseMove(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam) } } -long wxToolBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) +WXLRESULT wxToolBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { switch ( nMsg ) {