From 2b6649ed3ba64b7f878593ab79ace7e7da345520 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 4 Mar 2014 14:17:22 +0000 Subject: [PATCH] Fix bug in vertical toolbar size calculation in wxMSW. Correct the changes of the r76034 to avoid using separators when calculating the fitting width of the vertical toolbars as this doesn't always work correctly. Closes #3788. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@76079 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/toolbar.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index 7a89067b48..f7f347ea25 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -1727,12 +1727,24 @@ bool wxToolBar::HandleSize(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam) // Find bounding box for any toolbar item. RECT r; ::SetRectEmpty(&r); - for( int i = 0; i < toolsCount; i++ ) + wxToolBarToolsList::compatibility_iterator node; + int i = 0; + for ( node = m_tools.GetFirst(); node; node = node->GetNext(), i++) { - RECT ritem = wxGetTBItemRect(GetHwnd(), i); - ::OffsetRect(&ritem, -ritem.left, -ritem.top); // Shift origin to (0,0) - ::UnionRect(&r, &r, &ritem); + wxToolBarTool * const tool = (wxToolBarTool*)node->GetData(); + + // Separators shouldn't be taken into account as they are sometimes + // reported to have the width of the entire client area by the toolbar. + // And we know that they are not the biggest items in the toolbar in + // any case, so just skip them. + if( !tool->IsSeparator() ) + { + RECT ritem = wxGetTBItemRect(GetHwnd(), i); + ::OffsetRect(&ritem, -ritem.left, -ritem.top); // Shift origin to (0,0) + ::UnionRect(&r, &r, &ritem); + } } + if ( !r.right ) return false;