X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4c51a665c649f7579fb39e62070cef4f66b3210d..bf2c43c76e2819be443ab1d830ab68d9569d66b1:/src/generic/vscroll.cpp diff --git a/src/generic/vscroll.cpp b/src/generic/vscroll.cpp index c1b5a4071a..3a66aa34b5 100644 --- a/src/generic/vscroll.cpp +++ b/src/generic/vscroll.cpp @@ -4,7 +4,6 @@ // Author: Vadim Zeitlin // Modified by: Brad Anderson, David Warkentin // Created: 30.05.03 -// RCS-ID: $Id$ // Copyright: (c) 2003 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -31,6 +30,8 @@ #include "wx/vscroll.h" +#include "wx/utils.h" // For wxMin/wxMax(). + // ============================================================================ // wxVarScrollHelperEvtHandler declaration // ============================================================================ @@ -308,14 +309,17 @@ size_t wxVarScrollHelperBase::GetNewScrollPosition(wxScrollWinEvent& event) cons } else if ( evtType == wxEVT_SCROLLWIN_PAGEUP ) { - return FindFirstVisibleFromLast(m_unitFirst); + // Page up should do at least as much as line up. + return wxMin(FindFirstVisibleFromLast(m_unitFirst), + m_unitFirst ? m_unitFirst - 1 : 0); } else if ( evtType == wxEVT_SCROLLWIN_PAGEDOWN ) { + // And page down should do at least as much as line down. if ( GetVisibleEnd() ) - return GetVisibleEnd() - 1; + return wxMax(GetVisibleEnd() - 1, m_unitFirst + 1); else - return GetVisibleEnd(); + return wxMax(GetVisibleEnd(), m_unitFirst + 1); } else if ( evtType == wxEVT_SCROLLWIN_THUMBRELEASE ) { @@ -482,10 +486,10 @@ void wxVarScrollHelperBase::RefreshUnits(size_t from, size_t to) to = GetVisibleEnd(); // calculate the rect occupied by these units on screen - int orient_size, nonorient_size, orient_pos; - orient_size = nonorient_size = orient_pos = 0; + int orient_size = 0, + orient_pos = 0; - nonorient_size = GetNonOrientationTargetSize(); + int nonorient_size = GetNonOrientationTargetSize(); for ( size_t nBefore = GetVisibleBegin(); nBefore < from;