]> git.saurik.com Git - wxWidgets.git/commitdiff
allow adding/removing columns dynamically (based on patch 763540)
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 10 Jul 2003 15:51:47 +0000 (15:51 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 10 Jul 2003 15:51:47 +0000 (15:51 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21869 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
src/generic/listctrl.cpp

index 955902973e0f77095722dbfd831c18028f9c0811..aa62b91f4db7546c19b4b3918a70d5e08c8bbd4e 100644 (file)
@@ -131,6 +131,11 @@ Unix:
 - added support for GNU/Hurd in configure
 - wxLocale::Init now tries to set .utf8 locale in Unicode mode (Andreas Pflug)
 
+Generic controls:
+
+- implemented wxListCtrl::Refresh() (Norbert Berzen)
+- support adding/removing columns dynamically (Donald C. Taylor)
+
 wxGTK:
 
 - added support for label mnemonics to GTK+2 build (Michael Moss)
@@ -145,7 +150,6 @@ wxGTK:
 - added wxTextCtrl::SetSelection implementation for GTK+ 2
 - fixed wxTextCtrl::IsEditable() for GTK+ 2
 - don't consume 100% CPU when showing a poup menu
-- implemented wxListCtrl::Refresh() (Norbert Berzen)
 
 wxMac:
 
index 17ae8faab93fe86bf6fcb64872bcaa8f46223296..cb767bfccc84961864a4d1320a3e3d2983d83d75 100644 (file)
@@ -4113,6 +4113,17 @@ void wxListMainWindow::DeleteColumn( int col )
     m_dirty = TRUE;
     m_columns.DeleteNode( node );
 
+    if ( !IsVirtual() )
+    {
+        // update all the items
+        for ( size_t i = 0; i < m_lines.GetCount(); i++ )
+        {
+            wxListLineData * const line = GetLine(i);
+            wxListItemDataList::Node *n = line->m_items.Item( col );
+            line->m_items.DeleteNode(n);
+        }
+    }
+
     // invalidate it as it has to be recalculated
     m_headerWidth = 0;
 }
@@ -4305,8 +4316,10 @@ void wxListMainWindow::InsertColumn( long col, wxListItem &item )
     {
         if (item.m_width == wxLIST_AUTOSIZE_USEHEADER)
             item.m_width = GetTextLength( item.m_text );
+
         wxListHeaderData *column = new wxListHeaderData( item );
-        if ((col >= 0) && (col < (int)m_columns.GetCount()))
+        bool insert = (col >= 0) && ((size_t)col < m_columns.GetCount());
+        if ( insert )
         {
             wxListHeaderDataList::Node *node = m_columns.Item( col );
             m_columns.Insert( node, column );
@@ -4316,6 +4329,20 @@ void wxListMainWindow::InsertColumn( long col, wxListItem &item )
             m_columns.Append( column );
         }
 
+        if ( !IsVirtual() )
+        {
+            // update all the items
+            for ( size_t i = 0; i < m_lines.GetCount(); i++ )
+            {
+                wxListLineData * const line = GetLine(i);
+                wxListItemData * const data = new wxListItemData(this);
+                if ( insert )
+                    line->m_items.Insert(col, data);
+                else
+                    line->m_items.Append(data);
+            }
+        }
+
         // invalidate it as it has to be recalculated
         m_headerWidth = 0;
     }