From 32bf537043ad8416924191b41cc00b0f880a96ba Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 4 Mar 2014 14:20:28 +0000 Subject: [PATCH] Fix bug in vertical toolbar size calculation in wxMSW. Correct the changes of the r76035 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/trunk@76080 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 da0d4638ce..959672519b 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -1743,12 +1743,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;