From a978bcef2229b9d7d8ce57a95d10f8cf90f66a1d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 9 Oct 2000 17:07:23 +0000 Subject: [PATCH] 1. wxListBox::Delete() refresh bug fixed 2. wxScrollBar::HitTest() fixed (=> fixing refresh problem) for scrollbars without range git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8500 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/listbox/lboxtest.cpp | 1 + src/univ/listbox.cpp | 25 +++++++++++++++++++++++-- src/univ/renderer.cpp | 4 ++-- src/univ/themes/gtk.cpp | 4 ++-- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/samples/listbox/lboxtest.cpp b/samples/listbox/lboxtest.cpp index f204ec9ddf..c9172febc9 100644 --- a/samples/listbox/lboxtest.cpp +++ b/samples/listbox/lboxtest.cpp @@ -226,6 +226,7 @@ bool LboxTestApp::OnInit() frame->Show(); //wxLog::AddTraceMask(_T("listbox")); + wxLog::AddTraceMask(_T("scrollbar")); return TRUE; } diff --git a/src/univ/listbox.cpp b/src/univ/listbox.cpp index d73dd34d91..f201134eb0 100644 --- a/src/univ/listbox.cpp +++ b/src/univ/listbox.cpp @@ -276,6 +276,19 @@ void wxListBox::Delete(int n) m_itemsClientData.RemoveAt(n); + // when the item disappears we must not keep using its index + if ( n == m_current ) + { + m_current = -1; + } + else if ( n < m_current ) + { + m_current--; + } + //else: current item may stay + + m_selections.Remove(n); + m_updateScrollbarY = TRUE; } @@ -340,9 +353,16 @@ int wxListBox::GetSelection() const return m_selections.IsEmpty() ? -1 : m_selections[0]; } +int wxCMPFUNC_CONV wxCompareInts(int *n, int *m) +{ + return *n - *m; +} + int wxListBox::GetSelections(wxArrayInt& selections) const { + // always return sorted array to the user selections = m_selections; + selections.Sort(wxCompareInts); return m_selections.GetCount(); } @@ -393,9 +413,10 @@ void wxListBox::RefreshItems(int from, int count) } else // m_updateFrom >= from { - m_updateCount = wxMax(m_updateCount, - from + count - m_updateFrom); + int updateLast = wxMax(m_updateFrom + m_updateCount, + from + count); m_updateFrom = from; + m_updateCount = updateLast - m_updateFrom; } } } diff --git a/src/univ/renderer.cpp b/src/univ/renderer.cpp index 63cb3aa07b..56f831b07f 100644 --- a/src/univ/renderer.cpp +++ b/src/univ/renderer.cpp @@ -275,8 +275,8 @@ wxHitTest wxRenderer::StandardHitTestScrollbar(const wxScrollBar *scrollbar, int range = scrollbar->GetRange(); if ( !range ) { - thumbStart = - thumbEnd = 0; + // clicking the scrollbar without range has no effect + return wxHT_NOWHERE; } else { diff --git a/src/univ/themes/gtk.cpp b/src/univ/themes/gtk.cpp index 7294f012e7..35d3809fc6 100644 --- a/src/univ/themes/gtk.cpp +++ b/src/univ/themes/gtk.cpp @@ -158,10 +158,10 @@ public: virtual wxRect GetTextTotalArea(const wxTextCtrl *text, const wxRect& rect) - { wxRect rectTotal = rect; rectTotal.Inflate(10); return rectTotal; } + { wxRect rectTotal = rect; rectTotal.Inflate(2); return rectTotal; } virtual wxRect GetTextClientArea(const wxTextCtrl *text, const wxRect& rect) - { wxRect rectText = rect; rectText.Inflate(-10); return rectText; } + { wxRect rectText = rect; rectText.Inflate(-2); return rectText; } // helpers for "wxBitmap wxColourScheme::Get()" void DrawCheckBitmap(wxDC& dc, const wxRect& rect);