From aead8a4eabecca466070be6a1ff0e911602d75d9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 2 Feb 2005 00:09:59 +0000 Subject: [PATCH] invalidate cache when RefreshLine[s]() is called git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31701 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/htmllbox.cpp | 42 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/src/generic/htmllbox.cpp b/src/generic/htmllbox.cpp index 377fb2b361..42b511279f 100644 --- a/src/generic/htmllbox.cpp +++ b/src/generic/htmllbox.cpp @@ -51,6 +51,15 @@ FORCE_WXHTML_MODULES() // the items to avoid doing it anew each time an item must be drawn class wxHtmlListBoxCache { +private: + // invalidate a single item, used by Clear() and InvalidateRange() + void InvalidateItem(size_t n) + { + m_items[n] = (size_t)-1; + delete m_cells[n]; + m_cells[n] = NULL; + } + public: wxHtmlListBoxCache() { @@ -76,9 +85,7 @@ public: { for ( size_t n = 0; n < SIZE; n++ ) { - m_items[n] = (size_t)-1; - delete m_cells[n]; - m_cells[n] = NULL; + InvalidateItem(n); } } @@ -109,6 +116,18 @@ public: m_next = 0; } + // forget the cached value of the item(s) between the given ones (inclusive) + void InvalidateRange(size_t from, size_t to) + { + for ( size_t n = 0; n < SIZE; n++ ) + { + if ( m_items[n] >= from && m_items[n] <= to ) + { + InvalidateItem(n); + } + } + } + private: // the max number of the items we cache enum { SIZE = 50 }; @@ -266,6 +285,20 @@ void wxHtmlListBox::OnSize(wxSizeEvent& event) event.Skip(); } +void wxHtmlListBox::RefreshLine(size_t line) +{ + m_cache->InvalidateRange(line, line); + + wxVListBox::RefreshLine(line); +} + +void wxHtmlListBox::RefreshLines(size_t from, size_t to) +{ + m_cache->InvalidateRange(from, to); + + wxVListBox::RefreshLines(from, to); +} + void wxHtmlListBox::RefreshAll() { m_cache->Clear(); @@ -321,4 +354,5 @@ wxCoord wxHtmlListBox::OnMeasureItem(size_t n) const return cell->GetHeight() + cell->GetDescent() + 4; } -#endif +#endif // wxUSE_HTML + -- 2.45.2