From aa8b1fe82f501c4cc903a0514c005f4237cbb5db Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 28 Feb 2014 23:39:54 +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/branches/WX_3_0_BRANCH@76034 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/msw/toolbar.cpp | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 3e5d3fe8a5..3e5033920a 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -634,6 +634,7 @@ wxMSW: - Fix checking menu items before appending them to the menu. - Fix crash when adding/removing the same path to/from wxFileSystemWatcher. - Draw "classic" disabled owner drawn buttons better (Artur Wieczorek). +- Fix width of the vertical toolbars (Artur Wieczorek). wxOSX: diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index 05ff1534f5..7a89067b48 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -1718,12 +1718,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;