+ if (m_strings)
+ delete m_strings;
+}
+
+void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
+{
+ wxCHECK_RET( m_list != NULL, 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
+
+ // code elsewhere supposes we have as many items in m_clientList as items
+ // in the listbox
+ wxASSERT_MSG( m_clientList.GetCount() == (size_t)GetCount(),
+ wxT("bug in client data management") );
+
+ GList *children = m_list->children;
+ int length = g_list_length(children);
+
+ wxCHECK_RET( pos <= length, wxT("invalid index in wxListBox::InsertItems") );
+
+ size_t nItems = items.GetCount();
+ int index;
+
+ if (m_strings)
+ {
+ for (size_t n = 0; n < nItems; n++)
+ {
+ index = m_strings->Add( items[n] );
+
+ if (index != GetCount())
+ {
+ GtkAddItem( items[n], index );
+ wxNode *node = m_clientList.Nth( index );
+ m_clientList.Insert( node, (wxObject*) NULL );
+ }
+ else
+ {
+ GtkAddItem( items[n] );
+ m_clientList.Append( (wxObject*) NULL );
+ }
+ }
+ }
+ else
+ {
+ if (pos == length)
+ {
+ for ( size_t n = 0; n < nItems; n++ )
+ {
+ GtkAddItem( items[n] );
+
+ m_clientList.Append((wxObject *)NULL);
+ }
+ }
+ else
+ {
+ wxNode *node = m_clientList.Nth( pos );
+ for ( size_t n = 0; n < nItems; n++ )
+ {
+ GtkAddItem( items[n], pos+n );
+
+ m_clientList.Insert( node, (wxObject *)NULL );
+ }
+ }
+ }
+
+ wxASSERT_MSG( m_clientList.GetCount() == (size_t)GetCount(),
+ wxT("bug in client data management") );
+}
+
+int wxListBox::DoAppend( const wxString& item )
+{
+ if (m_strings)
+ {
+ // need to determine the index
+ int index = m_strings->Add( item );
+
+ // only if not at the end anyway
+ if (index != GetCount())
+ {
+ GtkAddItem( item, index );
+
+ wxNode *node = m_clientList.Nth( index );
+ m_clientList.Insert( node, (wxObject *)NULL );
+
+ return index;
+ }
+ }
+
+ GtkAddItem(item);
+
+ m_clientList.Append((wxObject *)NULL);
+
+ return GetCount() - 1;
+}
+
+void wxListBox::GtkAddItem( const wxString &item, int pos )
+{
+ wxCHECK_RET( m_list != NULL, wxT("invalid listbox") );
+
+ GtkWidget *list_item;
+
+ wxString label(item);
+#if wxUSE_CHECKLISTBOX
+ if (m_hasCheckBoxes)
+ {
+ label.Prepend(wxCHECKLBOX_STRING);
+ }
+#endif // wxUSE_CHECKLISTBOX
+
+ list_item = gtk_list_item_new_with_label( label.mbc_str() );
+
+ GList *gitem_list = g_list_alloc ();
+ gitem_list->data = list_item;
+
+ if (pos == -1)
+ gtk_list_append_items( GTK_LIST (m_list), gitem_list );
+ else
+ gtk_list_insert_items( GTK_LIST (m_list), gitem_list, pos );
+
+ gtk_signal_connect( GTK_OBJECT(list_item), "select",