From 861a14e13cb65044f629cc824648f121d67ec0d5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 12 Mar 2007 20:29:34 +0000 Subject: [PATCH] fix window repainting when SetLineCount() is called (patch 1667599; closes bug 1639629) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44785 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/vscroll.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/generic/vscroll.cpp b/src/generic/vscroll.cpp index a7d388a9bf..ec48cb9103 100644 --- a/src/generic/vscroll.cpp +++ b/src/generic/vscroll.cpp @@ -169,6 +169,13 @@ void wxVScrolledWindow::RemoveScrollbar() void wxVScrolledWindow::UpdateScrollbar() { + // if there is nothing to scroll, remove the scrollbar + if ( !m_lineMax ) + { + RemoveScrollbar(); + return; + } + // see how many lines can we fit on screen const wxCoord hWindow = GetClientSize().y; @@ -228,15 +235,15 @@ void wxVScrolledWindow::SetLineCount(size_t count) // and our estimate for their total height m_heightTotal = EstimateTotalHeight(); - // recalculate the scrollbars parameters - if ( count ) + // ScrollToLine() will update the scrollbar itself if it changes the line + // we pass to it because it's out of [new] range + size_t oldScrollPos = m_lineFirst; + ScrollToLine(m_lineFirst); + if ( oldScrollPos == m_lineFirst ) { - m_lineFirst = 1; // make sure it is != 0 - ScrollToLine(0); - } - else // no items - { - RemoveScrollbar(); + // but if it didn't do it, we still need to update the scrollbar to + // reflect the changed number of lines ourselves + UpdateScrollbar(); } }