Simplify MacHasScrollBarCorner() by removing pre-10.7 code

We don't support macOS versions earlier than 10.7 any longer, so there
is no need to check for 10.7 during run-time and all the code checking
for the resize box presence can be completely removed as, according to
the preexisting comment, the resize box is never present in the
currently supported versions.
This commit is contained in:
Vadim Zeitlin
2019-04-17 19:44:30 +02:00
parent b53c516564
commit a8262abc11

View File

@@ -2052,69 +2052,18 @@ bool wxWindowMac::MacHasScrollBarCorner() const
{
#if wxUSE_SCROLLBAR && !wxOSX_USE_IPHONE
/* Returns whether the scroll bars in a wxScrolledWindow should be
* shortened. Scroll bars should be shortened if either:
*
* - both scroll bars are visible, or
*
* - there is a resize box in the parent frame's corner and this
* window shares the bottom and right edge with the parent
* frame.
* shortened, which happens only when both scroll bars are visible.
*/
if ( m_hScrollBar == NULL && m_vScrollBar == NULL )
return false;
if ( ( m_hScrollBar && m_hScrollBar->IsShown() )
&& ( m_vScrollBar && m_vScrollBar->IsShown() ) )
{
// Both scroll bars visible
return true;
}
else
{
wxPoint thisWindowBottomRight = GetScreenRect().GetBottomRight();
for ( const wxWindow *win = (wxWindow*)this; win; win = win->GetParent() )
{
const wxFrame *frame = wxDynamicCast( win, wxFrame ) ;
if ( frame )
{
// starting from 10.7 there are no resize indicators anymore
if ( (frame->GetWindowStyleFlag() & wxRESIZE_BORDER) && !wxPlatformInfo::Get().CheckOSVersion(10, 7) )
{
// Parent frame has resize handle
wxPoint frameBottomRight = frame->GetScreenRect().GetBottomRight();
// Note: allow for some wiggle room here as wxMac's
// window rect calculations seem to be imprecise
if ( abs( thisWindowBottomRight.x - frameBottomRight.x ) <= 2
&& abs( thisWindowBottomRight.y - frameBottomRight.y ) <= 2 )
{
// Parent frame has resize handle and shares
// right bottom corner
return true ;
}
else
{
// Parent frame has resize handle but doesn't
// share right bottom corner
return false ;
}
}
else
{
// Parent frame doesn't have resize handle
return false ;
}
}
}
// No parent frame found
return false ;
}
#else
return false;
#endif
return false;
}
void wxWindowMac::MacCreateScrollBars( long style )