]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/combobox.cpp
implement wxLIST_AUTOSIZE support in wxMac's wxListCtrl
[wxWidgets.git] / src / gtk / combobox.cpp
index 439408958bd89fb940c0b6692cfec3bf37dc9a86..6a7c62a6049af219835c583636c1e3fdf51605ee 100644 (file)
@@ -170,17 +170,6 @@ wxComboBox::~wxComboBox()
     delete m_strings;
 }
 
-void wxComboBox::SetFocus()
-{
-    if ( m_hasFocus )
-    {
-        // don't do anything if we already have focus
-        return;
-    }
-
-    gtk_widget_grab_focus( m_focusWidget );
-}
-
 int wxComboBox::DoInsertItems(const wxArrayStringsAdapter & items,
                               unsigned int pos,
                               void **clientData, wxClientDataType type)
@@ -442,25 +431,27 @@ GdkWindow *wxComboBox::GTKGetWindow(wxArrayGdkWindows& windows) const
 
 wxSize wxComboBox::DoGetBestSize() const
 {
+    // strangely, this returns a width of 188 pixels from GTK+ (?)
     wxSize ret( wxControl::DoGetBestSize() );
 
     // we know better our horizontal extent: it depends on the longest string
     // in the combobox
     if ( m_widget )
     {
+        ret.x = 60;  // start with something "sensible"
         int width;
         unsigned int count = GetCount();
         for ( unsigned int n = 0; n < count; n++ )
         {
             GetTextExtent(GetString(n), &width, NULL, NULL, NULL );
-            if ( width > ret.x )
-                ret.x = width;
+            if ( width + 40 > ret.x ) // 40 for drop down arrow and space around text
+                ret.x = width + 40;
         }
     }
 
     // empty combobox should have some reasonable default size too
-    if ( ret.x < 100 )
-        ret.x = 100;
+    if ((GetCount() == 0) && (ret.x < 80))
+        ret.x = 80;
 
     CacheBestSize(ret);
     return ret;
@@ -504,15 +495,12 @@ void wxComboBox::OnRedo(wxCommandEvent& WXUNUSED(event))
 
 void wxComboBox::OnDelete(wxCommandEvent& WXUNUSED(event))
 {
-    long from, to;
-    GetSelection(& from, & to);
-    if (from != -1 && to != -1)
-        Remove(from, to);
+    RemoveSelection();
 }
 
 void wxComboBox::OnSelectAll(wxCommandEvent& WXUNUSED(event))
 {
-    SetSelection(-1, -1);
+    SelectAll();
 }
 
 void wxComboBox::OnUpdateCut(wxUpdateUIEvent& event)
@@ -547,7 +535,7 @@ void wxComboBox::OnUpdateDelete(wxUpdateUIEvent& event)
 
 void wxComboBox::OnUpdateSelectAll(wxUpdateUIEvent& event)
 {
-    event.Enable(GetLastPosition() > 0);
+    event.Enable(!wxTextEntry::IsEmpty());
 }
 
 #endif // wxUSE_COMBOBOX