]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/combobox.cpp
restore caching of WM frame extents
[wxWidgets.git] / src / gtk / combobox.cpp
index eb6ffdd4274573dd0740fa0d0b391c82b64ce2ba..e3feabd0114f63e0d52ce5a4ad37eba0f891919e 100644 (file)
@@ -36,7 +36,7 @@ gtkcombobox_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *comb
     wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
     event.SetString( combo->GetValue() );
     event.SetEventObject( combo );
-    combo->GetEventHandler()->ProcessEvent( event );
+    combo->HandleWindowEvent( event );
 }
 
 static void
@@ -51,7 +51,7 @@ gtkcombobox_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
     event.SetInt( combo->GetSelection() );
     event.SetString( combo->GetStringSelection() );
     event.SetEventObject( combo );
-    combo->GetEventHandler()->ProcessEvent( event );
+    combo->HandleWindowEvent( event );
 }
 }
 
@@ -116,6 +116,11 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
 
     m_widget = gtk_combo_box_entry_new_text();
 
+    // Set it up to trigger default item on enter key press 
+    GtkWidget *widget = gtk_bin_get_child(GTK_BIN(m_widget));
+    gtk_entry_set_activates_default(GTK_ENTRY(widget),
+                                    !HasFlag(wxTE_PROCESS_ENTER));
+    
     if (HasFlag(wxBORDER_NONE))
     {
         // Doesn't seem to work
@@ -170,17 +175,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)
@@ -386,7 +380,7 @@ void wxComboBox::OnChar( wxKeyEvent &event )
                 eventEnter.SetInt( GetSelection() );
                 eventEnter.SetEventObject( this );
 
-                if ( GetEventHandler()->ProcessEvent(eventEnter) )
+                if ( HandleWindowEvent(eventEnter) )
                 {
                     // Catch GTK event so that GTK doesn't open the drop
                     // down list upon RETURN.
@@ -431,25 +425,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;
@@ -493,15 +489,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)
@@ -536,7 +529,7 @@ void wxComboBox::OnUpdateDelete(wxUpdateUIEvent& event)
 
 void wxComboBox::OnUpdateSelectAll(wxUpdateUIEvent& event)
 {
-    event.Enable(GetLastPosition() > 0);
+    event.Enable(!wxTextEntry::IsEmpty());
 }
 
 #endif // wxUSE_COMBOBOX