]> git.saurik.com Git - wxWidgets.git/commitdiff
remove the vertical scrollbar completely if the control is empty
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 26 Apr 2006 00:17:52 +0000 (00:17 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 26 Apr 2006 00:17:52 +0000 (00:17 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38917 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/vscroll.h
src/generic/vscroll.cpp

index 1d29f56405f55492674aaa098e5aa2a466b008f3..33fc7aa1f89eb31760e4bc0a2ce2a27f2e31fa6a 100644 (file)
@@ -188,6 +188,9 @@ protected:
     // update the thumb size shown by the scrollbar
     void UpdateScrollbar();
 
+    // remove the scrollbar completely because we don't need it
+    void RemoveScrollbar();
+
 private:
     // common part of all ctors
     void Init();
index 609d6e0f52fb41ef74da72cce9b1d5dc1ee8f0b6..59a65f856e03ac1c86b0782809873b8b938f67bb 100644 (file)
@@ -160,6 +160,13 @@ size_t wxVScrolledWindow::FindFirstFromBottom(size_t lineLast, bool full)
     return lineFirst;
 }
 
+void wxVScrolledWindow::RemoveScrollbar()
+{
+    m_lineFirst = 0;
+    m_nVisible = m_lineMax;
+    SetScrollbar(wxVERTICAL, 0, 0, 0);
+}
+
 void wxVScrolledWindow::UpdateScrollbar()
 {
     // see how many lines can we fit on screen
@@ -189,8 +196,8 @@ void wxVScrolledWindow::UpdateScrollbar()
         if ( hAll < hWindow )
         {
             // we don't need scrollbar at all
-            m_lineFirst = 0;
-            SetScrollbar(wxVERTICAL, 0, 0, 0);
+            RemoveScrollbar();
+            return;
         }
     }
 
@@ -222,8 +229,15 @@ void wxVScrolledWindow::SetLineCount(size_t count)
     m_heightTotal = EstimateTotalHeight();
 
     // recalculate the scrollbars parameters
-    m_lineFirst = 1;    // make sure it is != 0
-    ScrollToLine(0);
+    if ( count )
+    {
+        m_lineFirst = 1;    // make sure it is != 0
+        ScrollToLine(0);
+    }
+    else // no items
+    {
+        RemoveScrollbar();
+    }
 }
 
 void wxVScrolledWindow::RefreshLine(size_t line)