Generalize changes of the previous commits to wxMac too

Handle "impossible" flag combinations such as wxTB_LEFT|wxTB_RIGHT and
wxTB_TOP|wxTB_BOTTOM that are actually possible under Mac too.
This commit is contained in:
Vadim Zeitlin 2020-05-06 02:14:02 +02:00
parent 101f135445
commit 46dfc54e8d
2 changed files with 22 additions and 13 deletions

View File

@ -62,11 +62,11 @@ wxPoint wxFrame::GetClientAreaOrigin() const
int w, h;
toolbar->GetSize(&w, &h);
if ( toolbar->HasFlag(wxTB_LEFT) )
if ( toolbar->HasFlag(wxTB_LEFT) && !toolbar->HasFlag(wxTB_RIGHT) )
{
pt.x += w;
}
else if ( toolbar->HasFlag(wxTB_TOP) )
else if ( toolbar->HasFlag(wxTB_TOP) && !toolbar->HasFlag(wxTB_BOTTOM) )
{
#if !wxOSX_USE_NATIVE_TOOLBAR
pt.y += h;
@ -342,14 +342,12 @@ void wxFrame::PositionToolBar()
tx = ty = 0 ;
GetToolBar()->GetSize(&tw, &th);
if (GetToolBar()->HasFlag(wxTB_LEFT))
{
// Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
// means, pretend we don't have toolbar/status bar, so we
// have the original client size.
GetToolBar()->SetSize(tx , ty , tw, ch , wxSIZE_NO_ADJUSTMENTS );
}
else if (GetToolBar()->HasFlag(wxTB_RIGHT))
// Note: we need to test for wxTB_RIGHT before wxTB_LEFT, as the latter
// is the same as wxTB_VERTICAL and it's possible to combine wxTB_RIGHT
// with wxTB_VERTICAL, so testing for wxTB_LEFT could be true for a
// right-aligned toolbar (while the reverse is, luckily, impossible).
if (GetToolBar()->HasFlag(wxTB_RIGHT))
{
// Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
// means, pretend we don't have toolbar/status bar, so we
@ -357,6 +355,13 @@ void wxFrame::PositionToolBar()
tx = cw - tw;
GetToolBar()->SetSize(tx , ty , tw, ch , wxSIZE_NO_ADJUSTMENTS );
}
else if (GetToolBar()->HasFlag(wxTB_LEFT))
{
// Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
// means, pretend we don't have toolbar/status bar, so we
// have the original client size.
GetToolBar()->SetSize(tx , ty , tw, ch , wxSIZE_NO_ADJUSTMENTS );
}
else if (GetToolBar()->HasFlag(wxTB_BOTTOM))
{
tx = 0;

View File

@ -1688,10 +1688,14 @@ void wxToolBar::OnPaint(wxPaintEvent& event)
}
dc.SetPen( wxPen( wxColour( 0x51,0x51,0x51 ) ) );
if ( HasFlag(wxTB_LEFT) )
dc.DrawLine(w-1, 0, w-1, h);
else if ( HasFlag(wxTB_RIGHT) )
// Note that testing this is in the "reverse" order, i.e. right before
// left and bottom before top because these flags can actually be
// combined because left/top are the same as vertical/horizontal
if ( HasFlag(wxTB_RIGHT) )
dc.DrawLine(0, 0, 0, h);
else if ( HasFlag(wxTB_LEFT) )
dc.DrawLine(w-1, 0, w-1, h);
else if ( HasFlag(wxTB_BOTTOM) )
dc.DrawLine(0, 0, w, 0);
else if ( HasFlag(wxTB_TOP) )