From ae0f022346389cf69cc5bd9f8b1409a49d61358b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 11 Jun 2003 11:37:52 +0000 Subject: [PATCH] added RefreshLines() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21039 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/vscroll.h | 3 +++ src/generic/vscroll.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/wx/vscroll.h b/include/wx/vscroll.h index 8ba386cc2f..624d12187e 100644 --- a/include/wx/vscroll.h +++ b/include/wx/vscroll.h @@ -93,6 +93,9 @@ public: // redraw the specified line void RefreshLine(size_t line); + // redraw all lines in the specified range (inclusive) + void RefreshLines(size_t from, size_t to); + // return the item at the specified (in physical coordinates) position or // wxNOT_FOUND if none, i.e. if it is below the last item int HitTest(wxCoord x, wxCoord y) const; diff --git a/src/generic/vscroll.cpp b/src/generic/vscroll.cpp index 4a9cc64d7c..1b346e8077 100644 --- a/src/generic/vscroll.cpp +++ b/src/generic/vscroll.cpp @@ -202,6 +202,35 @@ 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(); -- 2.45.2