From acfd7147439d44d7133d89a9040cc8616d4df032 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 28 Feb 2019 23:31:49 +0100 Subject: [PATCH] Make toolbar height compatible with previous wx version Restore the hack with making the toolbars with wxTB_FLAT style 3px less tall than the value given to them by TB_AUTOSIZE. There is no real explanation for doing this, this adjustment was added by 98b9643647468b3670c87e2d15dcba5c0fe32d11 back in 2002 with the rationale "make flat toolbars look slightly better", but after doing it for 17 years during which nobody complained about this, we probably should keep doing it now. --- src/msw/toolbar.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index 7654ab8106..63b1b44c79 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -1678,6 +1678,8 @@ void wxToolBar::UpdateSize() wxPoint pos = GetPosition(); ::SendMessage(GetHwnd(), TB_AUTOSIZE, 0, 0); + wxSize size = GetSize(); + // TB_AUTOSIZE doesn't seem to work for vertical toolbars which it resizes // to have the same width as a horizontal toolbar would have, even though // we do use TBSTATE_WRAP which should make it start a new row after each @@ -1708,11 +1710,19 @@ void wxToolBar::UpdateSize() maxWidth = width; } - SetSize(maxWidth, GetSize().y); + size.x = maxWidth; + } + else // horizontal + { + // For (flat) horizontal toolbars we used to make the toolbar 3px less + // tall in the previous wx versions, for some reason. It's not obvious + // at all if this is the right thing to do, but continue doing it now + // for compatibility. + if ( HasFlag(wxTB_FLAT) ) + size.y -= 3; } - if (pos != GetPosition()) - Move(pos); + SetSize(wxRect(pos, size)); // In case Realize is called after the initial display (IOW the programmer // may have rebuilt the toolbar) give the frame the option of resizing the