Fix toolbar size calculations in wxTB_NODIVIDER case

There is no 2px border separating the toolbar from the rest of the
window in this case, so don't overcompensate by accounting for it.
This commit is contained in:
Vadim Zeitlin
2019-03-21 04:45:49 +01:00
parent 50bbfedb31
commit 07673fdb97

View File

@@ -610,13 +610,16 @@ wxSize wxToolBar::DoGetBestSize() const
// Note that this needs to be done after the loop to account for controls // Note that this needs to be done after the loop to account for controls
// too high to fit into the toolbar without the border size but that could // too high to fit into the toolbar without the border size but that could
// fit if we had added the border beforehand. // fit if we had added the border beforehand.
if ( IsVertical() ) if ( !HasFlag(wxTB_NODIVIDER) )
{ {
sizeBest.x += 2 * ::GetSystemMetrics(SM_CXBORDER); if ( IsVertical() )
} {
else sizeBest.x += 2 * ::GetSystemMetrics(SM_CXBORDER);
{ }
sizeBest.y += 2 * ::GetSystemMetrics(SM_CYBORDER); else
{
sizeBest.y += 2 * ::GetSystemMetrics(SM_CYBORDER);
}
} }
return sizeBest; return sizeBest;
@@ -1218,8 +1221,14 @@ bool wxToolBar::Realize()
// We don't trust the height returned by wxGetTBItemRect() as it may not // We don't trust the height returned by wxGetTBItemRect() as it may not
// have been updated yet, use the height that the toolbar will actually // have been updated yet, use the height that the toolbar will actually
// have instead. Also, account for 2px toolbar border here. // have instead.
const int height = GetBestSize().y - 2 * ::GetSystemMetrics(SM_CYBORDER); int height = GetBestSize().y;
if ( !HasFlag(wxTB_NODIVIDER) )
{
// We want just the usable height, so remove the space taken by the
// border/divider.
height -= 2 * ::GetSystemMetrics(SM_CYBORDER);
}
// adjust the controls size to fit nicely in the toolbar and compute its // adjust the controls size to fit nicely in the toolbar and compute its
// total size while doing it // total size while doing it