]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
Fixed problem with label resize cursor not resetting
[wxWidgets.git] / src / generic / listctrl.cpp
index ac31cb7f6900f64b155c03971615948d29e1837e..6421ecff5205a17fb1ea19e4114d842deb01f612 100644 (file)
@@ -1171,6 +1171,8 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent, wxWindowID id,
 
 wxListMainWindow::~wxListMainWindow()
 {
+    DeleteEverything();
+
     if (m_hilightBrush) delete m_hilightBrush;
 
     delete m_renameTimer;
@@ -1467,13 +1469,13 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
         }
         else
         {
-            if (event.ShiftDown())
+            if (event.ControlDown())
             {
                 m_current = line;
                 m_current->ReverseHilight();
                 RefreshLine( m_current );
             }
-            else if (event.ControlDown())
+            else if (event.ShiftDown())
             {
                 m_current = line;
 
@@ -2335,14 +2337,23 @@ long wxListMainWindow::GetNextItem( long item,
                                     int WXUNUSED(geometry),
                                     int state )
 {
-    long ret = item;
-    wxCHECK_MSG( (ret == -1) || ((int)ret < GetItemCount()), -1,
+    long ret = item,
+         max = GetItemCount();
+    wxCHECK_MSG( (ret == -1) || (ret < max), -1,
                  _T("invalid listctrl index in GetNextItem()") );
 
     // notice that we start with the next item (or the first one if item == -1)
     // and this is intentional to allow writing a simple loop to iterate over
     // all selected items
-    wxNode *node = m_lines.Nth( (size_t)++ret );
+    ret++;
+    if ( ret == max )
+    {
+        // this is not an error because the index was ok initially, just no
+        // such item
+        return -1;
+    }
+
+    wxNode *node = m_lines.Nth( (size_t)ret );
     while (node)
     {
         wxListLineData *line = (wxListLineData*)node->Data();
@@ -2383,7 +2394,7 @@ void wxListMainWindow::DeleteColumn( int col )
     if (node) m_columns.DeleteNode( node );
 }
 
-void wxListMainWindow::DeleteAllItems( void )
+void wxListMainWindow::DeleteAllItems()
 {
     m_dirty = TRUE;
     m_current = (wxListLineData *) NULL;
@@ -2391,34 +2402,18 @@ void wxListMainWindow::DeleteAllItems( void )
     // to make the deletion of all items faster, we don't send the
     // notifications in this case: this is compatible with wxMSW and
     // documented in DeleteAllItems() description
-#if 0
-    wxNode *node = m_lines.First();
-    while (node)
-    {
-        wxListLineData *line = (wxListLineData*)node->Data();
-
-        DeleteLine( line );
 
-        node = node->Next();
-    }
-#endif // 0
+    wxListEvent event( wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, GetParent()->GetId() );
+    event.SetEventObject( GetParent() );
+    GetParent()->GetEventHandler()->ProcessEvent( event );
 
     m_lines.Clear();
 }
 
-void wxListMainWindow::DeleteEverything( void )
+void wxListMainWindow::DeleteEverything()
 {
-    m_dirty = TRUE;
-    m_current = (wxListLineData *) NULL;
-    wxNode *node = m_lines.First();
-    while (node)
-    {
-        wxListLineData *line = (wxListLineData*)node->Data();
-        DeleteLine( line );
-        node = node->Next();
-    }
-    m_lines.Clear();
-    m_current = (wxListLineData *) NULL;
+    DeleteAllItems();
+    
     m_columns.Clear();
 }