]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/combobox.cpp
Removed wxFont::Set/GetNoAntiAliasing() implementations.
[wxWidgets.git] / src / gtk / combobox.cpp
index b94d1f983b341429a83def8e8e4f1bc54ca5e408..e5a8a75d6d01fad8b3fe80043040dd63caf0cd27 100644 (file)
@@ -44,6 +44,20 @@ gtkcombobox_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
 {
     combo->SendSelectionChangedEvent(wxEVT_COMMAND_COMBOBOX_SELECTED);
 }
+
+static void
+gtkcombobox_popupshown_callback(GObject *WXUNUSED(gobject),
+                                GParamSpec *WXUNUSED(param_spec),
+                                wxComboBox *combo)
+{
+    gboolean isShown;
+    g_object_get( combo->m_widget, "popup-shown", &isShown, NULL );
+    wxCommandEvent event( isShown ? wxEVT_COMMAND_COMBOBOX_DROPDOWN
+                                  : wxEVT_COMMAND_COMBOBOX_CLOSEUP,
+                          combo->GetId() );
+    event.SetEventObject( combo );
+    combo->HandleWindowEvent( event );
+}
 }
 
 //-----------------------------------------------------------------------------
@@ -136,10 +150,20 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
 
     if ( entry )
     {
-        gtk_entry_set_text( entry, wxGTK_CONV(value) );
-
         if (style & wxCB_READONLY)
+        {
+            // this will assert and do nothing if the value is not in our list
+            // of strings which is the desired behaviour (for consistency with
+            // wxMSW and also because it doesn't make sense to have a string
+            // which is not a possible choice in a read-only combobox)
+            SetStringSelection(value);
             gtk_entry_set_editable( entry, FALSE );
+        }
+        else // editable combobox
+        {
+            // any value is accepted, even if it's not in our list
+            gtk_entry_set_text( entry, wxGTK_CONV(value) );
+        }
 
         g_signal_connect_after (entry, "changed",
                                 G_CALLBACK (gtkcombobox_text_changed_callback), this);
@@ -148,6 +172,12 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
     g_signal_connect_after (m_widget, "changed",
                         G_CALLBACK (gtkcombobox_changed_callback), this);
 
+    if ( !gtk_check_version(2,10,0) )
+    {
+        g_signal_connect (m_widget, "notify::popup-shown",
+                          G_CALLBACK (gtkcombobox_popupshown_callback), this);
+    }
+
     SetInitialSize(size); // need this too because this is a wxControlWithItems
 
     return true;
@@ -200,6 +230,8 @@ void wxComboBox::DisableEvents()
 
     g_signal_handlers_block_by_func(m_widget,
         (gpointer)gtkcombobox_changed_callback, this);
+    g_signal_handlers_block_by_func(m_widget,
+        (gpointer)gtkcombobox_popupshown_callback, this);
 }
 
 void wxComboBox::EnableEvents()
@@ -210,6 +242,8 @@ void wxComboBox::EnableEvents()
 
     g_signal_handlers_unblock_by_func(m_widget,
         (gpointer)gtkcombobox_changed_callback, this);
+    g_signal_handlers_unblock_by_func(m_widget,
+        (gpointer)gtkcombobox_popupshown_callback, this);
 }
 
 GtkWidget* wxComboBox::GetConnectWidget()