From 909adbb6bf832ada3db034cffc5548b8309a1602 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 7 Apr 2019 13:25:25 +0200 Subject: [PATCH] Use correct separator sizes in MSW wxToolBar best size calculation Don't assume that all the items (except for the controls) have the same size in wxToolBar::DoGetBestSize(), this is manifestly not true at least for the separators and resulted in too much space left over at the end of the toolbar. --- src/msw/toolbar.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index bbe0786642..e54bad0745 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -596,16 +596,19 @@ wxSize wxToolBar::DoGetBestSize() const } wxToolBarToolsList::compatibility_iterator node; + int toolIndex = 0; for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) { wxToolBarTool * const tool = static_cast(node->GetData()); + RECT rcItem = wxGetTBItemRect(GetHwnd(), toolIndex++); + if ( IsVertical() ) { if ( !tool->IsControl() ) { - sizeBest.y += sizeTool.y; + sizeBest.y += rcItem.bottom - rcItem.top; } //else: Controls are not shown in vertical toolbars at all. } @@ -622,7 +625,7 @@ wxSize wxToolBar::DoGetBestSize() const } else { - sizeBest.x += sizeTool.x; + sizeBest.x += rcItem.right - rcItem.left; } } }