X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1bba1946d5d2c724b51d760eecbeb3238eccdb09..020707bba9c960c155f4257d9a027d6aecdae5b8:/src/msw/tbar95.cpp diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index 304a161756..de0cc3ffaa 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -39,13 +39,10 @@ #include "wx/control.h" #endif -#if wxUSE_TOOLBAR && defined(__WIN95__) && wxUSE_TOOLBAR_NATIVE +#if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE && (!defined(_WIN32_WCE) || (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__))) #include "wx/toolbar.h" - -#if !defined(__GNUWIN32__) && !defined(__SALFORDC__) - #include "malloc.h" -#endif +#include "wx/sysopt.h" #include "wx/msw/private.h" @@ -58,7 +55,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 @@ -243,6 +240,8 @@ 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)); @@ -389,6 +388,7 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool) // Realize() later tool->Attach(this); + InvalidateBestSize(); return TRUE; } @@ -466,6 +466,7 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool) } } + InvalidateBestSize(); return TRUE; } @@ -543,6 +544,22 @@ 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 USE_BITMAP_MASKS + dcAllButtons.SelectObject(wxNullBitmap); +#endif + + // Even if we're not remapping the bitmap + // content, we still have to remap the background. + hBitmap = (HBITMAP)MapBitmap((WXHBITMAP) hBitmap, + totalBitmapWidth, totalBitmapHeight); + +#if USE_BITMAP_MASKS + dcAllButtons.SelectObject(bitmap); +#endif + } + // the button position wxCoord x = 0; @@ -557,13 +574,15 @@ bool wxToolBar::Realize() const wxBitmap& bmp = tool->GetNormalBitmap(); if ( bmp.Ok() ) { + int xOffset = wxMax(0, (m_defaultWidth - bmp.GetWidth())/2); + int yOffset = wxMax(0, (m_defaultHeight - bmp.GetHeight())/2); #if USE_BITMAP_MASKS // notice the last parameter: do use mask - dcAllButtons.DrawBitmap(bmp, x, 0, TRUE); + dcAllButtons.DrawBitmap(bmp, x+xOffset, yOffset, TRUE); #else // !USE_BITMAP_MASKS SelectInHDC hdcSelector2(memoryDC2, GetHbitmapOf(bmp)); if ( !BitBlt(memoryDC, - x, 0, m_defaultWidth, m_defaultHeight, + x+xOffset, yOffset, m_defaultWidth, m_defaultHeight, memoryDC2, 0, 0, SRCCOPY) ) { @@ -591,9 +610,12 @@ bool wxToolBar::Realize() bitmap.SetHBITMAP(0); #endif // USE_BITMAP_MASKS/!USE_BITMAP_MASKS - // Map to system colours - hBitmap = (HBITMAP)MapBitmap((WXHBITMAP) hBitmap, - totalBitmapWidth, totalBitmapHeight); + if (!wxSystemOptions::HasOption(wxT("msw.remap")) || wxSystemOptions::GetOptionInt(wxT("msw.remap")) == 1) + { + // Map to system colours + hBitmap = (HBITMAP)MapBitmap((WXHBITMAP) hBitmap, + totalBitmapWidth, totalBitmapHeight); + } bool addBitmap = TRUE; @@ -902,6 +924,7 @@ bool wxToolBar::Realize() } } + InvalidateBestSize(); return TRUE; } @@ -1350,7 +1373,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 ) {