allow adding/removing columns dynamically (based on patch 763540)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21869 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-07-10 15:51:47 +00:00
parent cea9c546c2
commit df6f82f048
2 changed files with 33 additions and 2 deletions

View File

@@ -131,6 +131,11 @@ Unix:
- added support for GNU/Hurd in configure - added support for GNU/Hurd in configure
- wxLocale::Init now tries to set .utf8 locale in Unicode mode (Andreas Pflug) - 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: wxGTK:
- added support for label mnemonics to GTK+2 build (Michael Moss) - added support for label mnemonics to GTK+2 build (Michael Moss)
@@ -145,7 +150,6 @@ wxGTK:
- added wxTextCtrl::SetSelection implementation for GTK+ 2 - added wxTextCtrl::SetSelection implementation for GTK+ 2
- fixed wxTextCtrl::IsEditable() for GTK+ 2 - fixed wxTextCtrl::IsEditable() for GTK+ 2
- don't consume 100% CPU when showing a poup menu - don't consume 100% CPU when showing a poup menu
- implemented wxListCtrl::Refresh() (Norbert Berzen)
wxMac: wxMac:

View File

@@ -4113,6 +4113,17 @@ void wxListMainWindow::DeleteColumn( int col )
m_dirty = TRUE; m_dirty = TRUE;
m_columns.DeleteNode( node ); 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 // invalidate it as it has to be recalculated
m_headerWidth = 0; m_headerWidth = 0;
} }
@@ -4305,8 +4316,10 @@ void wxListMainWindow::InsertColumn( long col, wxListItem &item )
{ {
if (item.m_width == wxLIST_AUTOSIZE_USEHEADER) if (item.m_width == wxLIST_AUTOSIZE_USEHEADER)
item.m_width = GetTextLength( item.m_text ); item.m_width = GetTextLength( item.m_text );
wxListHeaderData *column = new wxListHeaderData( item ); 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 ); wxListHeaderDataList::Node *node = m_columns.Item( col );
m_columns.Insert( node, column ); m_columns.Insert( node, column );
@@ -4316,6 +4329,20 @@ void wxListMainWindow::InsertColumn( long col, wxListItem &item )
m_columns.Append( column ); 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 // invalidate it as it has to be recalculated
m_headerWidth = 0; m_headerWidth = 0;
} }