X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/664e13143ee51a6b1aa1c30d1401ac04b11bdcca..b5a5362e55572bcc057d014c5bdde81d75804653:/src/msw/toolbar.cpp diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index b5d1b6ef2f..75630f870d 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -214,7 +214,7 @@ private: size_t m_nSepCount; wxStaticText *m_staticText; - DECLARE_NO_COPY_CLASS(wxToolBarTool) + wxDECLARE_NO_COPY_CLASS(wxToolBarTool); }; // ---------------------------------------------------------------------------- @@ -282,9 +282,13 @@ void wxToolBar::Init() m_nButtons = 0; - const wxSize size = wxArtProvider::GetNativeSizeHint(wxART_TOOLBAR); - m_defaultWidth = size.x; - m_defaultHeight = size.y; + // even though modern Windows applications typically use 24*24 (or even + // 32*32) size for their bitmaps, the native control itself still uses the + // old 16*15 default size (see TB_SETBITMAPSIZE documentation in MSDN), so + // default to it so that we don't call SetToolBitmapSize() unnecessarily in + // AdjustToolBitmapSize() + m_defaultWidth = 16; + m_defaultHeight = 15; m_pInTool = NULL; } @@ -630,29 +634,22 @@ void wxToolBar::CreateDisabledImageList() } } -void wxToolBar::MSWSetBitmapSize(const wxSize& size) -{ - ::SendMessage(GetHwnd(), TB_SETBITMAPSIZE, 0, MAKELONG(size.x, size.y)); -} - void wxToolBar::AdjustToolBitmapSize() { - // this is the default bitmap size, we only need to call TB_SETBITMAPSIZE - // if we use something different - static const wxSize sizeStd(16, 15); + const wxSize sizeOrig(m_defaultWidth, m_defaultHeight); - wxSize s(m_defaultWidth, m_defaultHeight); + wxSize sizeActual(sizeOrig); for ( wxToolBarToolsList::const_iterator i = m_tools.begin(); i != m_tools.end(); ++i ) { const wxBitmap& bmp = (*i)->GetNormalBitmap(); - s.IncTo(bmp.GetSize()); + sizeActual.IncTo(bmp.GetSize()); } - if ( s != sizeStd ) - MSWSetBitmapSize(s); + if ( sizeActual != sizeOrig ) + SetToolBitmapSize(sizeActual); } bool wxToolBar::Realize() @@ -1354,7 +1351,7 @@ void wxToolBar::SetToolBitmapSize(const wxSize& size) { wxToolBarBase::SetToolBitmapSize(size); - MSWSetBitmapSize(size); + ::SendMessage(GetHwnd(), TB_SETBITMAPSIZE, 0, MAKELONG(size.x, size.y)); } void wxToolBar::SetRows(int nRows) @@ -1599,7 +1596,7 @@ void wxToolBar::OnMouseEvent(wxMouseEvent& event) void wxToolBar::OnEraseBackground(wxEraseEvent& event) { RECT rect = wxGetClientRect(GetHwnd()); - + wxDC *dc = event.GetDC(); if (!dc) return; wxMSWDCImpl *impl = (wxMSWDCImpl*) dc->GetImpl(); @@ -1724,6 +1721,7 @@ bool wxToolBar::HandleSize(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam) return true; } +#ifndef __WXWINCE__ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam) { // erase any dummy separators which were used @@ -1835,14 +1833,14 @@ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam) r.right = clientSize.x; r.top = 0; r.bottom = clientSize.y; - + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); HRESULT hr = theme->DrawThemeBackground(hTheme, GetHdcOf(*impl), 0, 0, & r, & clipRect); if ( hr == S_OK ) haveRefreshed = true; } } -#endif +#endif // wxUSE_UXTHEME if (!haveRefreshed) dc.DrawRectangle(rectItem); @@ -1867,6 +1865,7 @@ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam) return true; } +#endif // __WXWINCE__ void wxToolBar::HandleMouseMove(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam) {