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.
This commit is contained in:
Vadim Zeitlin
2019-04-07 13:25:25 +02:00
parent 955a60a3e1
commit 909adbb6bf

View File

@@ -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<wxToolBarTool *>(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;
}
}
}