]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/vscroll.cpp
typo fix
[wxWidgets.git] / src / generic / vscroll.cpp
index 0d71a2fc67a72eb4f7758a15e69ab299644c274d..f0c58c61b89aff92f5844ef3aa972c15ef2d9398 100644 (file)
@@ -74,7 +74,7 @@ wxCoord wxVScrolledWindow::GetLinesHeight(size_t lineMin, size_t lineMax) const
     return height;
 }
 
-size_t wxVScrolledWindow::FindFirstFromBottom(size_t lineLast)
+size_t wxVScrolledWindow::FindFirstFromBottom(size_t lineLast, bool full)
 {
     const wxCoord hWindow = GetClientSize().y;
 
@@ -88,7 +88,13 @@ size_t wxVScrolledWindow::FindFirstFromBottom(size_t lineLast)
 
         if ( h > hWindow )
         {
-            lineFirst++;
+            // for this line to be fully visible we need to go one line
+            // down, but if it is enough for it to be only partly visible then
+            // this line will do as well
+            if ( full )
+            {
+                lineFirst++;
+            }
 
             break;
         }
@@ -196,6 +202,42 @@ void wxVScrolledWindow::RefreshLine(size_t line)
     RefreshRect(rect);
 }
 
+void wxVScrolledWindow::RefreshLines(size_t from, size_t to)
+{
+    wxASSERT_MSG( from <= to, _T("RefreshLines(): empty range") );
+
+    // clump the range to just the visible lines -- it is useless to refresh
+    // the other ones
+    if ( from < GetFirstVisibleLine() )
+        from = GetFirstVisibleLine();
+
+    if ( to > GetLastVisibleLine() )
+        to = GetLastVisibleLine();
+
+    // calculate the rect occupied by these lines on screen
+    wxRect rect;
+    rect.width = GetClientSize().x;
+    for ( size_t nBefore = GetFirstVisibleLine(); nBefore < from; nBefore++ )
+    {
+        rect.y += OnGetLineHeight(nBefore);
+    }
+
+    for ( size_t nBetween = from; nBetween <= to; nBetween++ )
+    {
+        rect.height += OnGetLineHeight(nBetween);
+    }
+
+    // do refresh it
+    RefreshRect(rect);
+}
+
+void wxVScrolledWindow::RefreshAll()
+{
+    UpdateScrollbar();
+
+    Refresh();
+}
+
 int wxVScrolledWindow::HitTest(wxCoord WXUNUSED(x), wxCoord y) const
 {
     const size_t lineMax = GetLastVisibleLine();
@@ -223,7 +265,7 @@ bool wxVScrolledWindow::ScrollToLine(size_t line)
 
     // determine the real first line to scroll to: we shouldn't scroll beyond
     // the end
-    size_t lineFirstLast = FindFirstFromBottom(m_lineMax - 1);
+    size_t lineFirstLast = FindFirstFromBottom(m_lineMax - 1, true);
     if ( line > lineFirstLast )
         line = lineFirstLast;