]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/vscroll.cpp
Added 'Go' button for quickly saving setup or configure file
[wxWidgets.git] / src / generic / vscroll.cpp
index e7cb8cfa06c9d7d4afc6747edbefbff5bd735dbd..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;
         }
@@ -164,8 +170,8 @@ void wxVScrolledWindow::SetLineCount(size_t count)
                                    count/2 + NUM_LINES_TO_SAMPLE/2);
 
         // use the height of the lines we looked as the average
-        m_heightTotal = ((float)m_heightTotal / (3*NUM_LINES_TO_SAMPLE)) *
-                            m_lineMax;
+        m_heightTotal = (wxCoord)
+                (((float)m_heightTotal / (3*NUM_LINES_TO_SAMPLE)) * m_lineMax);
     }
 
 
@@ -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;
 
@@ -354,5 +396,9 @@ void wxVScrolledWindow::OnScroll(wxScrollWinEvent& event)
     }
 
     ScrollToLine(lineFirstNew);
+
+#ifdef __WXMAC__
+    Update();
+#endif // __WXMAC__
 }