X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4cfcb00f0076acc87833f52ecde7c9fdbfc16f78..8a28cd66a63ce30c75173e10948e9d49d366d218:/src/generic/selstore.cpp diff --git a/src/generic/selstore.cpp b/src/generic/selstore.cpp index 2422bd8057..9aece14443 100644 --- a/src/generic/selstore.cpp +++ b/src/generic/selstore.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: generic/selstore.cpp +// Name: src/generic/selstore.cpp // Purpose: wxSelectionStore implementation // Author: Vadim Zeitlin // Modified by: @@ -84,7 +84,7 @@ bool wxSelectionStore::SelectRange(unsigned itemFrom, unsigned itemTo, // change state static const unsigned MANY_ITEMS = 100; - wxASSERT_MSG( itemFrom <= itemTo, _T("should be in order") ); + wxASSERT_MSG( itemFrom <= itemTo, wxT("should be in order") ); // are we going to have more [un]selected items than the other ones? if ( itemTo - itemFrom > m_count/2 ) @@ -208,9 +208,25 @@ void wxSelectionStore::OnItemDelete(unsigned item) while ( i < count ) { // all following elements must be greater than the one we deleted - wxASSERT_MSG( m_itemsSel[i] > item, _T("logic error") ); + wxASSERT_MSG( m_itemsSel[i] > item, wxT("logic error") ); m_itemsSel[i++]--; } } +void wxSelectionStore::SetItemCount(unsigned count) +{ + // forget about all items whose indices are now invalid if the size + // decreased + if ( count < m_count ) + { + for ( size_t i = m_itemsSel.GetCount(); i > 0; i-- ) + { + if ( m_itemsSel[i - 1] >= count ) + m_itemsSel.RemoveAt(i - 1); + } + } + + // remember the new number of items + m_count = count; +}