]> git.saurik.com Git - wxWidgets.git/commitdiff
implement wxListCtrl::ScrollList() (in report view and vertical direction only) ...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 22 Dec 2007 15:58:38 +0000 (15:58 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 22 Dec 2007 15:58:38 +0000 (15:58 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50902 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
src/generic/listctrl.cpp

index 9ed01b58af043000c09e1b2f9f4a7ae5ee13d1f3..8a29459d4faa27d835dd419f6da2a95a0799c437 100644 (file)
@@ -299,6 +299,7 @@ All (GUI):
 
 - Added wxWindow::GetNextSibling() and GetPrevSibling()
 - Improve wximage::ResampleBox() (Mihai Ciocarlie)
+- Implemented ScrollList() in generic wxListCtrl (Tim Kosse)
 
 wxMSW:
 
index a5b504235f51f4e8e13e38253b259cc18e0a5658..7a63129ecdfa40806c58caaca9db24c0859673d2 100644 (file)
@@ -580,6 +580,8 @@ public:
     // bring the selected item into view, scrolling to it if necessary
     void MoveToItem(size_t item);
 
+    bool ScrollList( int WXUNUSED(dx), int dy );
+
     // bring the current item into view
     void MoveToFocus() { MoveToItem(m_current); }
 
@@ -3314,6 +3316,34 @@ void wxListMainWindow::MoveToItem(size_t item)
     }
 }
 
+bool wxListMainWindow::ScrollList(int WXUNUSED(dx), int dy)
+{
+    if ( !InReportView() )
+    {
+        // TODO: this should work in all views but is not implemented now
+        return false;
+    }
+
+    size_t top, bottom;
+    GetVisibleLinesRange(&top, &bottom);
+
+    if ( bottom == (size_t)-1 )
+        return 0;
+
+    ResetVisibleLinesRange();
+
+    int hLine = GetLineHeight();
+
+    Scroll(-1, top + dy / hLine);
+
+#ifdef __WXMAC__
+    // see comment in MoveToItem() for why we do this
+    ResetVisibleLinesRange();
+#endif
+
+    return true;
+}
+
 // ----------------------------------------------------------------------------
 // keyboard handling
 // ----------------------------------------------------------------------------
@@ -5570,9 +5600,9 @@ long wxGenericListCtrl::InsertColumn( long col, const wxString &heading,
     return InsertColumn( col, item );
 }
 
-bool wxGenericListCtrl::ScrollList( int WXUNUSED(dx), int WXUNUSED(dy) )
+bool wxGenericListCtrl::ScrollList( int dx, int dy )
 {
-    return 0;
+    return m_mainWin->ScrollList(dx, dy);
 }
 
 // Sort items.