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
This commit is contained in:
PB
2020-05-05 20:22:11 +02:00
parent 7158c9b5be
commit 33cda12b74

View File

@@ -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;
}