From 26dd7154d5b4ab79db3cf4a6dc07c6404e6e14d8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 26 Jan 2009 23:20:17 +0000 Subject: [PATCH] Automatically adjust toolbar's tool size if the provided bitmaps don't fit into the default size. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58444 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/toolbar.h | 3 +++ src/msw/toolbar.cpp | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/wx/msw/toolbar.h b/include/wx/msw/toolbar.h index ce467dad50..7a689eba01 100644 --- a/include/wx/msw/toolbar.h +++ b/include/wx/msw/toolbar.h @@ -146,6 +146,9 @@ protected: wxToolBarToolBase *m_pInTool; private: + // makes sure tool bitmap size is sufficient for all tools + void AdjustToolBitmapSize(); + DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxToolBar) DECLARE_NO_COPY_CLASS(wxToolBar) diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index 13d0789116..c02310686d 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -629,6 +629,23 @@ void wxToolBar::CreateDisabledImageList() } } +void wxToolBar::AdjustToolBitmapSize() +{ + wxSize s(m_defaultWidth, m_defaultHeight); + const wxSize orig_s(s); + + for ( wxToolBarToolsList::const_iterator i = m_tools.begin(); + i != m_tools.end(); + ++i ) + { + const wxBitmap& bmp = (*i)->GetNormalBitmap(); + s.IncTo(bmp.GetSize()); + } + + if ( s != orig_s ) + SetToolBitmapSize(s); +} + bool wxToolBar::Realize() { const size_t nTools = GetToolsCount(); @@ -636,6 +653,10 @@ bool wxToolBar::Realize() // nothing to do return true; + // make sure tool size is larger enough for all all bitmaps to fit in + // (this is consistent with what other ports do): + AdjustToolBitmapSize(); + #ifdef wxREMAP_BUTTON_COLOURS // don't change the values of these constants, they can be set from the // user code via wxSystemOptions -- 2.45.2