From 33cda12b74fe5a1eb0a574b6ec3b30bf544ef565 Mon Sep 17 00:00:00 2001 From: PB Date: Tue, 5 May 2020 20:22:11 +0200 Subject: [PATCH] Handle wxToolBars created with wxTB_HORIZONTAL | wxTB_BOTTOM style correctly wxToolBar created with wxTB_HORIZONTAL | wxTB_BOTTOM had two issues: (1) There was a toolbar-high gap below the menu bar. (2) The status bar was not positioned correctly. Fix both issues by taking into account that wxTB_TOP is an alias for wxTB_HORIZONTAL and so a wxToolBar can have quite counter-intuitively set both wxTB_TOP and wxTB_BOTTOM. In such cases it means that the toolbar is horizontal and on the frame bottom, this needs to be accounted for when computing the origin of the frame client area as well as the status bar position. Closes #18760 --- src/msw/frame.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index fe8c35fce7..9b957056be 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -315,7 +315,7 @@ void wxFrame::PositionStatusBar() int x = 0; #if wxUSE_TOOLBAR wxToolBar * const toolbar = GetToolBar(); - if ( toolbar && !toolbar->HasFlag(wxTB_TOP) ) + if ( toolbar ) { const wxSize sizeTB = toolbar->GetSize(); @@ -326,13 +326,14 @@ void wxFrame::PositionStatusBar() w += sizeTB.x; } - else // wxTB_BOTTOM + else + if ( toolbar->HasFlag(wxTB_BOTTOM) ) { // we need to position the status bar below the toolbar h += sizeTB.y; } + //else: no adjustments necessary for the toolbar on top } - //else: no adjustments necessary for the toolbar on top #endif // wxUSE_TOOLBAR // GetSize returns the height of the clientSize in which the statusbar @@ -933,7 +934,12 @@ wxPoint wxFrame::GetClientAreaOrigin() const { const wxSize sizeTB = toolbar->GetSize(); - if ( toolbar->HasFlag(wxTB_TOP) ) + // wxTB_TOP has the same value as wxTB_HORIZONTAL so HasFlag(wxTB_TOP) + // returns true for a toolbar created with wxTB_HORIZONTAL | wxTB_BOTTOM + // style despite the toolbar being on the frame bottom and not affecting + // the client area origin. We therefore need to check here not only for + // presence of wxTB_TOP but also for absence of wxTB_BOTTOM. + if ( toolbar->HasFlag(wxTB_TOP) && !toolbar->HasFlag(wxTB_BOTTOM) ) { pt.y += sizeTB.y; }