From 6e7ebad658a34a903b012c476d08334ef68127fd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 8 Feb 2014 14:12:20 +0000 Subject: [PATCH] Fix wxToolBar size in wxMSW when not using icons. There were several problems when the toolbar style was toggled to not show icons, fix them by adding missing checks for wxTB_NOICONS style. Closes #13578. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75846 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/tbarbase.cpp | 6 ++++++ src/msw/toolbar.cpp | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index e36d96eccf..18c889dcf5 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -437,6 +437,12 @@ void wxToolBarBase::ClearTools() void wxToolBarBase::AdjustToolBitmapSize() { + if ( HasFlag(wxTB_NOICONS) ) + { + SetToolBitmapSize(wxSize(0, 0)); + return; + } + const wxSize sizeOrig(m_defaultWidth, m_defaultHeight); wxSize sizeActual(sizeOrig); diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index 600ff8cd4b..e4926639b5 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -974,6 +974,16 @@ bool wxToolBar::Realize() switch ( tool->GetStyle() ) { case wxTOOL_STYLE_CONTROL: + if ( wxStaticText *staticText = tool->GetStaticText() ) + { + // Display control and its label only if buttons have icons + // and texts as otherwise there is not enough room on the + // toolbar to fit the label. + staticText-> + Show(HasFlag(wxTB_TEXT) && !HasFlag(wxTB_NOICONS)); + } + // Fall through + case wxTOOL_STYLE_SEPARATOR: if ( tool->IsStretchableSpace() ) { @@ -1127,7 +1137,7 @@ bool wxToolBar::Realize() wxSize size = control->GetSize(); wxSize staticTextSize; - if ( staticText ) + if ( staticText && staticText->IsShown() ) { staticTextSize = staticText->GetSize(); staticTextSize.y += 3; // margin between control and its label @@ -1464,6 +1474,12 @@ bool wxToolBar::MSWOnNotify(int WXUNUSED(idCtrl), void wxToolBar::SetToolBitmapSize(const wxSize& size) { + // Leave the effective size as (0, 0) if we are not showing bitmaps at all. + wxSize effectiveSize; + + if ( !HasFlag(wxTB_NOICONS) ) + effectiveSize = size; + wxToolBarBase::SetToolBitmapSize(size); ::SendMessage(GetHwnd(), TB_SETBITMAPSIZE, 0, MAKELONG(size.x, size.y));