]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/combobox.cpp
Use checkbox if togglebutton not available.
[wxWidgets.git] / src / gtk / combobox.cpp
index a03df573b1ae36ffca69b4307e01d23c0a0a916e..ab4fa422edac764b002964f86c78a773dd09f06a 100644 (file)
@@ -209,6 +209,17 @@ wxComboBox::~wxComboBox()
     m_clientDataList.Clear();
 }
 
+void wxComboBox::SetFocus()
+{
+    if ( m_hasFocus )
+    {
+        // don't do anything if we already have focus
+        return;
+    }
+
+    gtk_widget_grab_focus( m_focusWidget );
+}
+
 void wxComboBox::AppendCommon( const wxString &item )
 {
     wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
@@ -364,8 +375,14 @@ int wxComboBox::FindString( const wxString &item )
     {
         GtkBin *bin = GTK_BIN( child->data );
         GtkLabel *label = GTK_LABEL( bin->child );
-        if (item == wxString(label->label,*wxConvCurrent))
+#ifdef __WXGTK20__
+        wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
+#else
+        wxString str( label->label );
+#endif
+        if (item == str)
             return count;
+            
         count++;
         child = child->next;
     }
@@ -408,7 +425,7 @@ wxString wxComboBox::GetString( int n ) const
         GtkBin *bin = GTK_BIN( child->data );
         GtkLabel *label = GTK_LABEL( bin->child );
 #ifdef __WXGTK20__
-        str = wxGTK_CONV_BACK( gtk_label_get_text( label) );
+        str = wxGTK_CONV_BACK( gtk_label_get_text(label) );
 #else
         str = wxString( label->label );
 #endif
@@ -431,7 +448,12 @@ wxString wxComboBox::GetStringSelection() const
     if (selection)
     {
         GtkBin *bin = GTK_BIN( selection->data );
-        wxString tmp = wxString(GTK_LABEL( bin->child )->label,*wxConvCurrent);
+        GtkLabel *label = GTK_LABEL( bin->child );
+#ifdef __WXGTK20__
+        wxString tmp( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
+#else
+        wxString tmp( label->label );
+#endif
         return tmp;
     }
 
@@ -592,7 +614,7 @@ void wxComboBox::SetEditable( bool editable )
 
 void wxComboBox::OnChar( wxKeyEvent &event )
 {
-    if ( event.KeyCode() == WXK_RETURN )
+    if ( event.GetKeyCode() == WXK_RETURN )
     {
         wxString value = GetValue();
 
@@ -728,13 +750,11 @@ wxSize wxComboBox::DoGetBestSize() const
     ret.x = 0;
     if ( m_widget )
     {
-        GdkFont *font = m_font.GetInternalFont();
-
-        wxCoord width;
-        size_t count = Number();
+        int width;
+        size_t count = GetCount();
         for ( size_t n = 0; n < count; n++ )
         {
-            width = (wxCoord)gdk_string_width(font, wxGTK_CONV( GetString(n) ) );
+            GetTextExtent( GetString(n), &width, NULL, NULL, NULL, &m_font );
             if ( width > ret.x )
                 ret.x = width;
         }