]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/choice.cpp
Fixed wxMSW's EVT_CHAR so it conforms to the docs and also what wxGTK
[wxWidgets.git] / src / gtk1 / choice.cpp
index 103ebf3901cd60fb5f12811f981d7b2d475d4192..c456577ce37c39197eb11bae31ef23abd986756c 100644 (file)
@@ -209,9 +209,31 @@ void wxChoice::Clear()
         m_strings->Clear();
 }
 
-void wxChoice::Delete( int WXUNUSED(n) )
+void wxChoice::Delete( int n )
 {
-    wxFAIL_MSG( wxT("wxChoice:Delete not implemented") );
+    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 dump implementation - still better than nothing
+    int i,
+        count = GetCount();
+
+    wxCHECK_RET( n >= 0 && n < count, _T("invalid index in wxChoice::Delete") );
+
+    wxArrayString items;
+    items.Alloc(count);
+    for ( i = 0; i < count; i++ )
+    {
+        if ( i != n )
+            items.Add(GetString(i));
+    }
+
+    Clear();
+
+    for ( i = 0; i < count - 1; i++ )
+    {
+        Append(items[i]);
+    }
 }
 
 int wxChoice::FindString( const wxString &string ) const
@@ -234,8 +256,9 @@ int wxChoice::FindString( const wxString &string ) const
             label = GTK_LABEL( BUTTON_CHILD(m_widget) );
 
         wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
-
-        if (string == wxString(label->label,*wxConvCurrent))
+        
+        wxString tmp( wxGTK_CONV_BACK( label->label ) );
+        if (string == tmp)
             return count;
 
         child = child->next;
@@ -290,7 +313,7 @@ wxString wxChoice::GetString( int n ) const
 
             wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
 
-            return wxString(label->label,*wxConvCurrent);
+            return wxString( wxGTK_CONV_BACK(label->label) );
         }
         child = child->next;
         count++;
@@ -353,7 +376,7 @@ void wxChoice::ApplyWidgetStyle()
 
 size_t wxChoice::GtkAppendHelper(GtkWidget *menu, const wxString& item)
 {
-    GtkWidget *menu_item = gtk_menu_item_new_with_label( item.mbc_str() );
+    GtkWidget *menu_item = gtk_menu_item_new_with_label( wxGTK_CONV( item ) );
 
     size_t index;
     if ( m_strings )
@@ -417,7 +440,8 @@ wxSize wxChoice::DoGetBestSize() const
         size_t count = GetCount();
         for ( size_t n = 0; n < count; n++ )
         {
-            width = (wxCoord)gdk_string_width(font, GetString(n).mbc_str());
+            // FIXME GTK 2.0
+            width = (wxCoord)gdk_string_width(font, wxGTK_CONV( GetString(n) ) );
             if ( width > ret.x )
                 ret.x = width;
         }
@@ -439,7 +463,7 @@ wxSize wxChoice::DoGetBestSize() const
     if ( ret.x < 80 )
         ret.x = 80;
 
-    ret.y = 16 + gdk_char_height(GET_STYLE_FONT( m_widget->style ), 'H');
+    ret.y = 16 + gdk_char_height(GET_STYLE_FONT( m_widget->style ), 'H' );
 
     return ret;
 }