Fix scrolling in small wxVListBox with tall items.

Scrolling in a small wxVListBox with tall items (i.e. taller than the height
of wxVListBox itself) behaved wrongly: wrong item was being scrolled into view
and Page Up/Down didn't scroll as much as they should.

Fix both of these problems by checking for these corner cases explicitly.

Closes #13454.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69180 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-09-21 15:08:10 +00:00
parent d7b3992a5f
commit 7d0cf3f9be
2 changed files with 11 additions and 3 deletions

View File

@@ -31,6 +31,8 @@
#include "wx/vscroll.h"
#include "wx/utils.h" // For wxMin/wxMax().
// ============================================================================
// wxVarScrollHelperEvtHandler declaration
// ============================================================================
@@ -308,14 +310,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 )
{