From b2b49c32ec3ed998aa266f795386d69e247aea96 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 28 Feb 2014 23:40:22 +0000 Subject: [PATCH] Fix calculating the size of vertical toolbar in wxMSW. Use the width of the largest toolbar item as the toolbar width, not the width of the first one. The implicit assumption that all items had the same width was wrong and resulted in items wider than the first one being truncated. Closes #3788. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76035 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/toolbar.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index e4926639b5..da0d4638ce 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -1734,12 +1734,21 @@ void wxToolBar::OnEraseBackground(wxEraseEvent& event) bool wxToolBar::HandleSize(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam) { // wait until we have some tools - if ( !GetToolsCount() ) + const int toolsCount = GetToolsCount(); + if ( toolsCount == 0 ) return false; // calculate our minor dimension ourselves - we're confusing the standard // logic (TB_AUTOSIZE) with our horizontal toolbars and other hacks - const RECT r = wxGetTBItemRect(GetHwnd(), 0); + // Find bounding box for any toolbar item. + RECT r; + ::SetRectEmpty(&r); + for( int i = 0; i < toolsCount; i++ ) + { + 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;