many wxItemContainer-related changes:
1. the main function for item insertion is now DoInsertItems() which allows for much more efficient addition of many new items at once 2. the items client data management is done entirely in wxItemContainer itself, the derived classes don't have to distinguish between void and object client data 3. many fixes for sorted controls, in particular implemented wxCB_SORT support in wxGTK combobox git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47730 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -126,7 +126,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
|
||||
|
||||
if ( style & wxCB_SORT )
|
||||
{
|
||||
// if our m_strings != NULL, DoAppend() will check for it and insert
|
||||
// if our m_strings != NULL, Append() will check for it and insert
|
||||
// items in the correct order
|
||||
m_strings = new wxSortedArrayString;
|
||||
}
|
||||
@@ -158,33 +158,33 @@ wxChoice::~wxChoice()
|
||||
delete m_strings;
|
||||
}
|
||||
|
||||
int wxChoice::DoAppend( const wxString &item )
|
||||
int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items,
|
||||
unsigned int pos,
|
||||
void **clientData, wxClientDataType type)
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid choice control") );
|
||||
|
||||
GtkWidget *menu = gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) );
|
||||
|
||||
return GtkAddHelper(menu, GetCount(), item);
|
||||
}
|
||||
|
||||
int wxChoice::DoInsert( const wxString &item, unsigned int pos )
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid choice control") );
|
||||
wxCHECK_MSG( IsValidInsert(pos), -1, wxT("invalid index"));
|
||||
|
||||
if (pos == GetCount())
|
||||
return DoAppend(item);
|
||||
const unsigned int count = items.GetCount();
|
||||
|
||||
GtkWidget *menu = gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) );
|
||||
|
||||
for ( unsigned int i = 0; i < count; ++i, ++pos )
|
||||
{
|
||||
int n = GtkAddHelper(menu, pos, items[i]);
|
||||
if ( n == wxNOT_FOUND )
|
||||
return n;
|
||||
|
||||
AssignNewItemClientData(n, clientData, i, type);
|
||||
}
|
||||
|
||||
// if the item to insert is at or before the selection, and the selection is valid
|
||||
if (((int)pos <= m_selection_hack) && (m_selection_hack != wxNOT_FOUND))
|
||||
{
|
||||
// move the selection forward one
|
||||
m_selection_hack++;
|
||||
// move the selection forward
|
||||
m_selection_hack += count;
|
||||
}
|
||||
|
||||
return GtkAddHelper(menu, pos, item);
|
||||
return pos - 1;
|
||||
}
|
||||
|
||||
void wxChoice::DoSetItemClientData(unsigned int n, void* clientData)
|
||||
@@ -207,30 +207,7 @@ void* wxChoice::DoGetItemClientData(unsigned int n) const
|
||||
return node->GetData();
|
||||
}
|
||||
|
||||
void wxChoice::DoSetItemClientObject(unsigned int n, wxClientData* clientData)
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, wxT("invalid choice control") );
|
||||
|
||||
wxList::compatibility_iterator node = m_clientList.Item( n );
|
||||
wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetItemClientObject") );
|
||||
|
||||
// wxItemContainer already deletes data for us
|
||||
|
||||
node->SetData( (wxObject*) clientData );
|
||||
}
|
||||
|
||||
wxClientData* wxChoice::DoGetItemClientObject(unsigned int n) const
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, wxT("invalid choice control") );
|
||||
|
||||
wxList::compatibility_iterator node = m_clientList.Item( n );
|
||||
wxCHECK_MSG( node, (wxClientData *)NULL,
|
||||
wxT("invalid index in wxChoice::DoGetItemClientObject") );
|
||||
|
||||
return (wxClientData*) node->GetData();
|
||||
}
|
||||
|
||||
void wxChoice::Clear()
|
||||
void wxChoice::DoClear()
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, wxT("invalid choice") );
|
||||
|
||||
@@ -238,18 +215,6 @@ void wxChoice::Clear()
|
||||
GtkWidget *menu = gtk_menu_new();
|
||||
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
|
||||
|
||||
if ( HasClientObjectData() )
|
||||
{
|
||||
// destroy the data (due to Robert's idea of using wxList<wxObject>
|
||||
// and not wxList<wxClientData> we can't just say
|
||||
// m_clientList.DeleteContents(true) - this would crash!
|
||||
wxList::compatibility_iterator node = m_clientList.GetFirst();
|
||||
while ( node )
|
||||
{
|
||||
delete (wxClientData *)node->GetData();
|
||||
node = node->GetNext();
|
||||
}
|
||||
}
|
||||
m_clientList.Clear();
|
||||
|
||||
if ( m_strings )
|
||||
@@ -259,15 +224,10 @@ void wxChoice::Clear()
|
||||
m_selection_hack = wxNOT_FOUND;
|
||||
}
|
||||
|
||||
void wxChoice::Delete(unsigned int n)
|
||||
void wxChoice::DoDeleteOneItem(unsigned int n)
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, wxT("invalid choice") );
|
||||
|
||||
// VZ: apparently GTK+ doesn't have a built-in function to do it (not even
|
||||
// in 2.0), hence this dumb implementation -- still better than nothing
|
||||
unsigned int i;
|
||||
unsigned int count = GetCount();
|
||||
|
||||
wxCHECK_RET( IsValid(n), _T("invalid index in wxChoice::Delete") );
|
||||
|
||||
// if the item to delete is before the selection, and the selection is valid
|
||||
@@ -282,56 +242,31 @@ void wxChoice::Delete(unsigned int n)
|
||||
m_selection_hack = wxNOT_FOUND;
|
||||
}
|
||||
|
||||
const bool hasClientData = m_clientDataItemsType != wxClientData_None;
|
||||
const bool hasObjectData = m_clientDataItemsType == wxClientData_Object;
|
||||
// VZ: apparently GTK+ doesn't have a built-in function to do it (not even
|
||||
// in 2.0), hence this dumb implementation -- still better than nothing
|
||||
const unsigned int count = GetCount();
|
||||
|
||||
wxList::compatibility_iterator node = m_clientList.GetFirst();
|
||||
|
||||
wxArrayString items;
|
||||
wxArrayPtrVoid itemsData;
|
||||
items.Alloc(count);
|
||||
for ( i = 0; i < count; i++ )
|
||||
for ( unsigned i = 0; i < count; i++, node = node->GetNext() )
|
||||
{
|
||||
if ( i != n )
|
||||
{
|
||||
items.Add(GetString(i));
|
||||
if ( hasClientData )
|
||||
{
|
||||
// also save the client data
|
||||
itemsData.Add(node->GetData());
|
||||
}
|
||||
}
|
||||
else // need to delete the client object too
|
||||
{
|
||||
if ( hasObjectData )
|
||||
{
|
||||
delete (wxClientData *)node->GetData();
|
||||
}
|
||||
}
|
||||
|
||||
if ( hasClientData )
|
||||
{
|
||||
node = node->GetNext();
|
||||
itemsData.Add(node->GetData());
|
||||
}
|
||||
}
|
||||
|
||||
if ( hasObjectData )
|
||||
{
|
||||
// prevent Clear() from destroying all client data
|
||||
m_clientDataItemsType = wxClientData_None;
|
||||
}
|
||||
wxChoice::DoClear();
|
||||
|
||||
Clear();
|
||||
|
||||
for ( i = 0; i < count - 1; i++ )
|
||||
{
|
||||
Append(items[i]);
|
||||
|
||||
if ( hasObjectData )
|
||||
SetClientObject(i, (wxClientData *)itemsData[i]);
|
||||
else if ( hasClientData )
|
||||
SetClientData(i, itemsData[i]);
|
||||
}
|
||||
void ** const data = &itemsData[0];
|
||||
if ( HasClientObjectData() )
|
||||
Append(items, wx_reinterpret_cast(wxClientData **, data));
|
||||
else
|
||||
Append(items, data);
|
||||
}
|
||||
|
||||
int wxChoice::FindString( const wxString &string, bool bCase ) const
|
||||
|
||||
@@ -317,7 +317,10 @@ void wxComboBox::SetFocus()
|
||||
gtk_widget_grab_focus( m_focusWidget );
|
||||
}
|
||||
|
||||
int wxComboBox::DoAppend( const wxString &item )
|
||||
int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items,
|
||||
unsigned int pos,
|
||||
void **clientData,
|
||||
wxClientDataType type)
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") );
|
||||
|
||||
@@ -325,87 +328,58 @@ int wxComboBox::DoAppend( const wxString &item )
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
GtkWidget *list_item = gtk_list_item_new_with_label( wxGTK_CONV( item ) );
|
||||
|
||||
gtk_container_add( GTK_CONTAINER(list), list_item );
|
||||
|
||||
if (GTK_WIDGET_REALIZED(m_widget))
|
||||
{
|
||||
gtk_widget_realize( list_item );
|
||||
gtk_widget_realize( GTK_BIN(list_item)->child );
|
||||
}
|
||||
|
||||
// Apply current widget style to the new list_item
|
||||
GtkRcStyle *style = CreateWidgetStyle();
|
||||
if (style)
|
||||
|
||||
const unsigned int count = items.GetCount();
|
||||
for( unsigned int i = 0; i < count; ++i, ++pos )
|
||||
{
|
||||
gtk_widget_modify_style( GTK_WIDGET( list_item ), style );
|
||||
GtkBin *bin = GTK_BIN( list_item );
|
||||
GtkWidget *label = GTK_WIDGET( bin->child );
|
||||
gtk_widget_modify_style( label, style );
|
||||
GtkWidget *
|
||||
list_item = gtk_list_item_new_with_label( wxGTK_CONV( items[i] ) );
|
||||
|
||||
if ( pos == GetCount() )
|
||||
{
|
||||
gtk_container_add( GTK_CONTAINER(list), list_item );
|
||||
}
|
||||
else // insert, not append
|
||||
{
|
||||
GList *gitem_list = g_list_alloc ();
|
||||
gitem_list->data = list_item;
|
||||
gtk_list_insert_items( GTK_LIST (list), gitem_list, pos );
|
||||
}
|
||||
|
||||
if (GTK_WIDGET_REALIZED(m_widget))
|
||||
{
|
||||
gtk_widget_realize( list_item );
|
||||
gtk_widget_realize( GTK_BIN(list_item)->child );
|
||||
|
||||
if (style)
|
||||
{
|
||||
gtk_widget_modify_style( GTK_WIDGET( list_item ), style );
|
||||
GtkBin *bin = GTK_BIN( list_item );
|
||||
GtkWidget *label = GTK_WIDGET( bin->child );
|
||||
gtk_widget_modify_style( label, style );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
|
||||
if ( m_clientDataList.GetCount() < GetCount() )
|
||||
m_clientDataList.Insert( pos, (wxObject*) NULL );
|
||||
if ( m_clientObjectList.GetCount() < GetCount() )
|
||||
m_clientObjectList.Insert( pos, (wxObject*) NULL );
|
||||
|
||||
AssignNewItemClientData(pos, clientData, i, type);
|
||||
}
|
||||
|
||||
if ( style )
|
||||
gtk_rc_style_unref( style );
|
||||
}
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
|
||||
const unsigned int count = GetCount();
|
||||
|
||||
if ( m_clientDataList.GetCount() < count )
|
||||
m_clientDataList.Append( (wxObject*) NULL );
|
||||
if ( m_clientObjectList.GetCount() < count )
|
||||
m_clientObjectList.Append( (wxObject*) NULL );
|
||||
|
||||
EnableEvents();
|
||||
|
||||
InvalidateBestSize();
|
||||
|
||||
return count - 1;
|
||||
}
|
||||
|
||||
int wxComboBox::DoInsert( const wxString &item, unsigned int pos )
|
||||
{
|
||||
wxCHECK_MSG( !(GetWindowStyle() & wxCB_SORT), -1,
|
||||
wxT("can't insert into sorted list"));
|
||||
|
||||
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") );
|
||||
|
||||
wxCHECK_MSG( IsValidInsert(pos), -1, wxT("invalid index") );
|
||||
|
||||
if (pos == GetCount())
|
||||
return Append(item);
|
||||
|
||||
DisableEvents();
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
GtkWidget *list_item = gtk_list_item_new_with_label( wxGTK_CONV( item ) );
|
||||
|
||||
GList *gitem_list = g_list_alloc ();
|
||||
gitem_list->data = list_item;
|
||||
gtk_list_insert_items( GTK_LIST (list), gitem_list, pos );
|
||||
|
||||
if (GTK_WIDGET_REALIZED(m_widget))
|
||||
{
|
||||
gtk_widget_realize( list_item );
|
||||
gtk_widget_realize( GTK_BIN(list_item)->child );
|
||||
|
||||
ApplyWidgetStyle();
|
||||
}
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
|
||||
const unsigned int count = GetCount();
|
||||
|
||||
if ( m_clientDataList.GetCount() < count )
|
||||
m_clientDataList.Insert( pos, (wxObject*) NULL );
|
||||
if ( m_clientObjectList.GetCount() < count )
|
||||
m_clientObjectList.Insert( pos, (wxObject*) NULL );
|
||||
|
||||
EnableEvents();
|
||||
|
||||
InvalidateBestSize();
|
||||
|
||||
return pos;
|
||||
return pos - 1;
|
||||
}
|
||||
|
||||
void wxComboBox::DoSetItemClientData(unsigned int n, void* clientData)
|
||||
@@ -427,28 +401,7 @@ void* wxComboBox::DoGetItemClientData(unsigned int n) const
|
||||
return node ? node->GetData() : NULL;
|
||||
}
|
||||
|
||||
void wxComboBox::DoSetItemClientObject(unsigned int n, wxClientData* clientData)
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
|
||||
|
||||
wxList::compatibility_iterator node = m_clientObjectList.Item( n );
|
||||
if (!node) return;
|
||||
|
||||
// wxItemContainer already deletes data for us
|
||||
|
||||
node->SetData( (wxObject*) clientData );
|
||||
}
|
||||
|
||||
wxClientData* wxComboBox::DoGetItemClientObject(unsigned int n) const
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, wxT("invalid combobox") );
|
||||
|
||||
wxList::compatibility_iterator node = m_clientObjectList.Item( n );
|
||||
|
||||
return node ? (wxClientData*) node->GetData() : NULL;
|
||||
}
|
||||
|
||||
void wxComboBox::Clear()
|
||||
void wxComboBox::DoClear()
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
|
||||
|
||||
@@ -457,13 +410,6 @@ void wxComboBox::Clear()
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
gtk_list_clear_items( GTK_LIST(list), 0, (int)GetCount() );
|
||||
|
||||
wxList::compatibility_iterator node = m_clientObjectList.GetFirst();
|
||||
while (node)
|
||||
{
|
||||
wxClientData *cd = (wxClientData*)node->GetData();
|
||||
if (cd) delete cd;
|
||||
node = node->GetNext();
|
||||
}
|
||||
m_clientObjectList.Clear();
|
||||
|
||||
m_clientDataList.Clear();
|
||||
@@ -473,7 +419,7 @@ void wxComboBox::Clear()
|
||||
InvalidateBestSize();
|
||||
}
|
||||
|
||||
void wxComboBox::Delete(unsigned int n)
|
||||
void wxComboBox::DoDeleteOneItem(unsigned int n)
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
|
||||
|
||||
@@ -496,8 +442,6 @@ void wxComboBox::Delete(unsigned int n)
|
||||
wxList::compatibility_iterator node = m_clientObjectList.Item( n );
|
||||
if (node)
|
||||
{
|
||||
wxClientData *cd = (wxClientData*)node->GetData();
|
||||
if (cd) delete cd;
|
||||
m_clientObjectList.Erase( node );
|
||||
}
|
||||
|
||||
|
||||
@@ -541,7 +541,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
|
||||
|
||||
if ( style & wxLB_SORT )
|
||||
{
|
||||
// this will change DoAppend() behaviour
|
||||
// this will change Append() behaviour
|
||||
m_strings = new wxSortedArrayString;
|
||||
}
|
||||
else
|
||||
@@ -549,11 +549,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
|
||||
m_strings = (wxSortedArrayString *)NULL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
// add one by one
|
||||
DoAppend(choices[i]);
|
||||
}
|
||||
Append(n, choices);
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
@@ -577,101 +573,44 @@ wxListBox::~wxListBox()
|
||||
// adding items
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxListBox::DoInsertItems(const wxArrayString& items, unsigned int pos)
|
||||
int wxListBox::DoInsertItems(const wxArrayStringsAdapter& items,
|
||||
unsigned int pos,
|
||||
void **clientData,
|
||||
wxClientDataType type)
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, wxT("invalid listbox") );
|
||||
wxCHECK_MSG( m_list != NULL, wxNOT_FOUND, wxT("invalid listbox") );
|
||||
|
||||
// VZ: notice that InsertItems knows nothing about sorting, so calling it
|
||||
// from outside (and not from our own Append) is likely to break
|
||||
// everything
|
||||
const unsigned count = GetCount();
|
||||
wxCHECK_MSG( pos <= count, wxNOT_FOUND,
|
||||
wxT("invalid index in wxListBox::InsertItems") );
|
||||
|
||||
// code elsewhere supposes we have as many items in m_clientList as items
|
||||
// in the listbox
|
||||
wxASSERT_MSG( m_clientList.GetCount() == GetCount(),
|
||||
wxT("bug in client data management") );
|
||||
wxASSERT_MSG( m_clientList.GetCount() == count,
|
||||
wxT("bug in client data management") );
|
||||
|
||||
InvalidateBestSize();
|
||||
|
||||
GList *children = m_list->children;
|
||||
unsigned int length = g_list_length(children);
|
||||
const unsigned numItems = items.GetCount();
|
||||
|
||||
wxCHECK_RET( pos <= length, wxT("invalid index in wxListBox::InsertItems") );
|
||||
|
||||
unsigned int nItems = items.GetCount();
|
||||
int index;
|
||||
|
||||
if (m_strings)
|
||||
for ( unsigned int n = 0; n < numItems; ++n, ++pos )
|
||||
{
|
||||
for (unsigned int n = 0; n < nItems; n++)
|
||||
{
|
||||
index = m_strings->Add( items[n] );
|
||||
const wxString& item = items[n];
|
||||
|
||||
if (index != (int)GetCount())
|
||||
{
|
||||
GtkAddItem( items[n], index );
|
||||
wxList::compatibility_iterator node = m_clientList.Item( index );
|
||||
m_clientList.Insert( node, (wxObject*) NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkAddItem( items[n] );
|
||||
m_clientList.Append( (wxObject*) NULL );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pos == length)
|
||||
{
|
||||
for ( unsigned int n = 0; n < nItems; n++ )
|
||||
{
|
||||
GtkAddItem( items[n] );
|
||||
const unsigned idx = m_strings ? m_strings->Add(item)
|
||||
: pos;
|
||||
|
||||
m_clientList.Append((wxObject *)NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wxList::compatibility_iterator node = m_clientList.Item( pos );
|
||||
for ( unsigned int n = 0; n < nItems; n++ )
|
||||
{
|
||||
GtkAddItem( items[n], pos+n );
|
||||
GtkAddItem(item, idx == GetCount() ? -1 : idx);
|
||||
|
||||
m_clientList.Insert( node, (wxObject *)NULL );
|
||||
}
|
||||
}
|
||||
m_clientList.Insert(idx, NULL);
|
||||
|
||||
AssignNewItemClientData(idx, clientData, n, type);
|
||||
}
|
||||
|
||||
wxASSERT_MSG( m_clientList.GetCount() == GetCount(),
|
||||
wxT("bug in client data management") );
|
||||
}
|
||||
|
||||
int wxListBox::DoAppend( const wxString& item )
|
||||
{
|
||||
InvalidateBestSize();
|
||||
|
||||
if (m_strings)
|
||||
{
|
||||
// need to determine the index
|
||||
int index = m_strings->Add( item );
|
||||
|
||||
// only if not at the end anyway
|
||||
if (index != (int)GetCount())
|
||||
{
|
||||
GtkAddItem( item, index );
|
||||
|
||||
wxList::compatibility_iterator node = m_clientList.Item( index );
|
||||
m_clientList.Insert( node, (wxObject *)NULL );
|
||||
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
GtkAddItem(item);
|
||||
|
||||
m_clientList.Append((wxObject *)NULL);
|
||||
|
||||
return GetCount() - 1;
|
||||
return pos - 1;
|
||||
}
|
||||
|
||||
void wxListBox::GtkAddItem( const wxString &item, int pos )
|
||||
@@ -752,28 +691,11 @@ void wxListBox::GtkAddItem( const wxString &item, int pos )
|
||||
}
|
||||
}
|
||||
|
||||
void wxListBox::DoSetItems( const wxArrayString& items,
|
||||
void **clientData)
|
||||
{
|
||||
Clear();
|
||||
|
||||
DoInsertItems(items, 0);
|
||||
|
||||
if ( clientData )
|
||||
{
|
||||
unsigned int count = items.GetCount();
|
||||
for ( unsigned int n = 0; n < count; n++ )
|
||||
{
|
||||
SetClientData(n, clientData[n]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// deleting items
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxListBox::Clear()
|
||||
void wxListBox::DoClear()
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, wxT("invalid listbox") );
|
||||
|
||||
@@ -785,25 +707,13 @@ void wxListBox::Clear()
|
||||
GTK_LIST(m_list)->last_focus_child = NULL;
|
||||
}
|
||||
|
||||
if ( HasClientObjectData() )
|
||||
{
|
||||
// destroy the data (due to Robert's idea of using wxList<wxObject>
|
||||
// and not wxList<wxClientData> we can't just say
|
||||
// m_clientList.DeleteContents(true) - this would crash!
|
||||
wxList::compatibility_iterator node = m_clientList.GetFirst();
|
||||
while ( node )
|
||||
{
|
||||
delete (wxClientData *)node->GetData();
|
||||
node = node->GetNext();
|
||||
}
|
||||
}
|
||||
m_clientList.Clear();
|
||||
|
||||
if ( m_strings )
|
||||
m_strings->Clear();
|
||||
}
|
||||
|
||||
void wxListBox::Delete(unsigned int n)
|
||||
void wxListBox::DoDeleteOneItem(unsigned int n)
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, wxT("invalid listbox") );
|
||||
|
||||
@@ -818,12 +728,6 @@ void wxListBox::Delete(unsigned int n)
|
||||
wxList::compatibility_iterator node = m_clientList.Item( n );
|
||||
if ( node )
|
||||
{
|
||||
if ( m_clientDataItemsType == wxClientData_Object )
|
||||
{
|
||||
wxClientData *cd = (wxClientData*)node->GetData();
|
||||
delete cd;
|
||||
}
|
||||
|
||||
m_clientList.Erase( node );
|
||||
}
|
||||
|
||||
@@ -855,29 +759,6 @@ void* wxListBox::DoGetItemClientData(unsigned int n) const
|
||||
return node->GetData();
|
||||
}
|
||||
|
||||
void wxListBox::DoSetItemClientObject(unsigned int n, wxClientData* clientData)
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, wxT("invalid listbox control") );
|
||||
|
||||
wxList::compatibility_iterator node = m_clientList.Item( n );
|
||||
wxCHECK_RET( node, wxT("invalid index in wxListBox::DoSetItemClientObject") );
|
||||
|
||||
// wxItemContainer already deletes data for us
|
||||
|
||||
node->SetData( (wxObject*) clientData );
|
||||
}
|
||||
|
||||
wxClientData* wxListBox::DoGetItemClientObject(unsigned int n) const
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, wxT("invalid listbox control") );
|
||||
|
||||
wxList::compatibility_iterator node = m_clientList.Item( n );
|
||||
wxCHECK_MSG( node, (wxClientData *)NULL,
|
||||
wxT("invalid index in wxListBox::DoGetItemClientObject") );
|
||||
|
||||
return (wxClientData*) node->GetData();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// string list access
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user