+ 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
+ if (((int)n < m_selection_hack) && (m_selection_hack != wxNOT_FOUND))
+ {
+ // move the selection back one
+ m_selection_hack--;
+ }
+ else if ((int)n == m_selection_hack)
+ {
+ // invalidate the selection
+ m_selection_hack = wxNOT_FOUND;
+ }
+
+ const bool hasClientData = m_clientDataItemsType != wxClientData_None;
+ const bool hasObjectData = m_clientDataItemsType == wxClientData_Object;
+
+ wxList::compatibility_iterator node = m_clientList.GetFirst();
+
+ wxArrayString items;
+ wxArrayPtrVoid itemsData;
+ items.Alloc(count);
+ for ( i = 0; i < count; i++ )
+ {
+ 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();
+ }
+ }
+
+ if ( hasObjectData )
+ {
+ // prevent Clear() from destroying all client data
+ m_clientDataItemsType = wxClientData_None;
+ }
+
+ 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]);
+ }