From 07673fdb97f82e22962c10a11a69c7685e5f6767 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 21 Mar 2019 04:45:49 +0100 Subject: [PATCH] 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. --- src/msw/toolbar.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index fac4b9f28f..1c792f209e 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -610,13 +610,16 @@ wxSize wxToolBar::DoGetBestSize() const // 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 // fit if we had added the border beforehand. - if ( IsVertical() ) + if ( !HasFlag(wxTB_NODIVIDER) ) { - sizeBest.x += 2 * ::GetSystemMetrics(SM_CXBORDER); - } - else - { - sizeBest.y += 2 * ::GetSystemMetrics(SM_CYBORDER); + if ( IsVertical() ) + { + sizeBest.x += 2 * ::GetSystemMetrics(SM_CXBORDER); + } + else + { + sizeBest.y += 2 * ::GetSystemMetrics(SM_CYBORDER); + } } return sizeBest; @@ -1218,8 +1221,14 @@ bool wxToolBar::Realize() // 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 instead. Also, account for 2px toolbar border here. - const int height = GetBestSize().y - 2 * ::GetSystemMetrics(SM_CYBORDER); + // have instead. + 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 // total size while doing it