]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix scrolling in small wxVListBox with tall items.
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 21 Sep 2011 15:08:10 +0000 (15:08 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 21 Sep 2011 15:08:10 +0000 (15:08 +0000)
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

src/generic/vlbox.cpp
src/generic/vscroll.cpp

index aa68ea17127a36b5e5d0f88a0f84f273dd02eee1..a4be49817cd791da694ac7de3c39fa29d2092b86 100644 (file)
@@ -249,7 +249,10 @@ bool wxVListBox::DoSetCurrent(int current)
         {
             // it is, indeed, only partly visible, so scroll it into view to
             // make it entirely visible
+            // BUT scrolling down when m_current is first visible makes it
+            // completely hidden, so that is even worse
             while ( (size_t)m_current + 1 == GetVisibleRowsEnd() &&
+                    (size_t)m_current != GetVisibleRowsBegin() &&
                     ScrollToRow(GetVisibleBegin() + 1) ) ;
 
             // but in any case refresh it as even if it was only partly visible
index c1b5a4071abd015a97a5819b31f905229523401f..0572b8e07b30596d9ea5713f9857a14fd618adb4 100644 (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 )
     {