Restrict scrolled window virtual area in non-scrollable direction

If a wxScrolledWindow is only scrollable in one direction, its virtual
size should only extend beyond the actual size of the window in this
direction, as any contents not fitting the window wouldn't be visible
anyhow.
This commit is contained in:
Vadim Zeitlin 2018-10-03 01:19:57 +02:00
parent 20466d045f
commit 180fb2f35b

View File

@ -767,8 +767,18 @@ bool wxScrollHelperBase::ScrollLayout()
// If we're the scroll target, take into account the
// virtual size and scrolled position of the window.
wxSize size = m_win->GetVirtualSize();
// However we should use the real window size in the direction in which
// scrolling is disabled, if any.
const wxSize clientSize = m_win->GetClientSize();
if ( !IsScrollbarShown(wxHORIZONTAL) )
size.x = clientSize.x;
if ( !IsScrollbarShown(wxVERTICAL) )
size.y = clientSize.y;
m_win->GetSizer()->SetDimension(CalcScrolledPosition(wxPoint(0, 0)),
m_win->GetVirtualSize());
size);
return true;
}