From e31dc22ee400957bc01fb3ddcbdd7221331c7222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 26 Jan 2009 23:32:16 +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/branches/WX_2_8_BRANCH@58446 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 3 +++ include/wx/msw/tbar95.h | 3 +++ src/msw/tbar95.cpp | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index f5da698990..7738ad7f96 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -147,6 +147,9 @@ wxMSW: - Fix handling of abandoned mutexes in wxMutex (David Heffernan). - Avoid warnings about deprecated localtime with MSVC8/9 (Chris Stankevitz). - Fixed invisible CHM tooltip text bug when window text colour is black. +- Automatically adjust toolbar's tool size if the provided bitmaps + don't fit into the default size. + wxMSW/CE: diff --git a/include/wx/msw/tbar95.h b/include/wx/msw/tbar95.h index 44f52610e9..029dfc89f1 100644 --- a/include/wx/msw/tbar95.h +++ b/include/wx/msw/tbar95.h @@ -142,6 +142,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/tbar95.cpp b/src/msw/tbar95.cpp index 0752d3f4f8..1c8476be2a 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -574,6 +574,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(wxSize(bmp.GetWidth(), bmp.GetHeight())); + } + + if ( s != orig_s ) + SetToolBitmapSize(s); +} + bool wxToolBar::Realize() { const size_t nTools = GetToolsCount(); @@ -581,6 +598,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