]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/combobox.cpp
Add another missing #if wxUSE_MARKUP check.
[wxWidgets.git] / src / gtk / combobox.cpp
index 7b0fe35ba7d01987b94d94cd3cc6983bfefdce70..23f4becc49755e90ab41da9374a2566234b29be9 100644 (file)
@@ -44,14 +44,26 @@ 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 );
+}
 }
 
 //-----------------------------------------------------------------------------
 // wxComboBox
 //-----------------------------------------------------------------------------
 
-IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxChoice)
-
 BEGIN_EVENT_TABLE(wxComboBox, wxChoice)
     EVT_CHAR(wxComboBox::OnChar)
 
@@ -104,7 +116,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
     }
 
     if (HasFlag(wxCB_SORT))
-        m_strings = new wxSortedArrayString();
+        m_strings = new wxGtkCollatedArrayString();
 
     GTKCreateComboBoxWidget();
 
@@ -158,6 +170,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;
@@ -202,24 +220,41 @@ void wxComboBox::OnChar( wxKeyEvent &event )
     event.Skip();
 }
 
-void wxComboBox::DisableEvents()
+void wxComboBox::EnableTextChangedEvents(bool enable)
 {
-    if ( GetEntry() )
+    if ( !GetEntry() )
+        return;
+
+    if ( enable )
+    {
+        g_signal_handlers_unblock_by_func(GTK_BIN(m_widget)->child,
+            (gpointer)gtkcombobox_text_changed_callback, this);
+    }
+    else // disable
+    {
         g_signal_handlers_block_by_func(GTK_BIN(m_widget)->child,
             (gpointer)gtkcombobox_text_changed_callback, this);
+    }
+}
+
+void wxComboBox::GTKDisableEvents()
+{
+    EnableTextChangedEvents(false);
 
     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()
+void wxComboBox::GTKEnableEvents()
 {
-    if ( GetEntry() )
-        g_signal_handlers_unblock_by_func(GTK_BIN(m_widget)->child,
-            (gpointer)gtkcombobox_text_changed_callback, this);
+    EnableTextChangedEvents(true);
 
     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()
@@ -227,10 +262,8 @@ GtkWidget* wxComboBox::GetConnectWidget()
     return GTK_WIDGET( GetEntry() );
 }
 
-GdkWindow *wxComboBox::GTKGetWindow(wxArrayGdkWindows& windows) const
+GdkWindow* wxComboBox::GTKGetWindow(wxArrayGdkWindows& /* windows */) const
 {
-    wxUnusedVar(windows);
-
     return GetEntry()->text_area;
 }
 
@@ -241,6 +274,14 @@ wxComboBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
     return GetDefaultAttributesFromGTKWidget(gtk_combo_box_entry_new, true);
 }
 
+void wxComboBox::SetValue(const wxString& value)
+{
+    if ( HasFlag(wxCB_READONLY) )
+        SetStringSelection(value);
+    else
+        wxTextEntry::SetValue(value);
+}
+
 // ----------------------------------------------------------------------------
 // standard event handling
 // ----------------------------------------------------------------------------
@@ -315,4 +356,13 @@ void wxComboBox::OnUpdateSelectAll(wxUpdateUIEvent& event)
     event.Enable(!wxTextEntry::IsEmpty());
 }
 
+void wxComboBox::Popup()
+{
+     gtk_combo_box_popup( GTK_COMBO_BOX(m_widget) );
+}
+
+void wxComboBox::Dismiss()
+{
+    gtk_combo_box_popdown( GTK_COMBO_BOX(m_widget) );
+}
 #endif // wxUSE_COMBOBOX