]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/selstore.cpp
Change wxNotebook selection before sending page changed event in wxMSW.
[wxWidgets.git] / src / generic / selstore.cpp
index 2422bd8057f3388fefca039f2fb17ca3d55fdf79..9aece144435d328cfe43f83be426d245b6e70a8a 100644 (file)
@@ -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;
+}