X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ce00f59b5b169752d2f05ce3bb1a88ddc1b38b4c..7d6a4d96961eac84d05db8bb24c64d39003f6e54:/src/gtk/choice.cpp diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index 3932eed912..32afd94246 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -17,8 +17,9 @@ #include "wx/arrstr.h" #endif +#include #include "wx/gtk/private.h" - +#include "wx/gtk/private/gtk2-compat.h" // ---------------------------------------------------------------------------- // GTK callbacks @@ -38,8 +39,6 @@ gtk_choice_changed_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice ) // wxChoice //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControlWithItems) - void wxChoice::Init() { m_strings = NULL; @@ -78,7 +77,11 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, m_strings = new wxGtkCollatedArrayString; } +#ifdef __WXGTK3__ + m_widget = gtk_combo_box_text_new(); +#else m_widget = gtk_combo_box_new_text(); +#endif g_object_ref(m_widget); Append(n, choices); @@ -119,7 +122,11 @@ void wxChoice::SendSelectionChangedEvent(wxEventType evt_type) void wxChoice::GTKInsertComboBoxTextItem( unsigned int n, const wxString& text ) { +#ifdef __WXGTK3__ + gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(m_widget), n, wxGTK_CONV(text)); +#else gtk_combo_box_insert_text( GTK_COMBO_BOX( m_widget ), n, wxGTK_CONV( text ) ); +#endif } int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items, @@ -168,7 +175,7 @@ void wxChoice::DoClear() { wxCHECK_RET( m_widget != NULL, wxT("invalid control") ); - DisableEvents(); + GTKDisableEvents(); GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); GtkTreeModel* model = gtk_combo_box_get_model( combobox ); @@ -179,7 +186,7 @@ void wxChoice::DoClear() if (m_strings) m_strings->Clear(); - EnableEvents(); + GTKEnableEvents(); InvalidateBestSize(); } @@ -299,12 +306,12 @@ void wxChoice::SetSelection( int n ) { wxCHECK_RET( m_widget != NULL, wxT("invalid control") ); - DisableEvents(); + GTKDisableEvents(); GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); gtk_combo_box_set_active( combobox, n ); - EnableEvents(); + GTKEnableEvents(); } void wxChoice::SetColumns(int n) @@ -321,13 +328,13 @@ int wxChoice::GetColumns() const } -void wxChoice::DisableEvents() +void wxChoice::GTKDisableEvents() { g_signal_handlers_block_by_func(m_widget, (gpointer) gtk_choice_changed_callback, this); } -void wxChoice::EnableEvents() +void wxChoice::GTKEnableEvents() { g_signal_handlers_unblock_by_func(m_widget, (gpointer) gtk_choice_changed_callback, this); @@ -336,7 +343,7 @@ void wxChoice::EnableEvents() GdkWindow *wxChoice::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const { - return m_widget->window; + return gtk_widget_get_window(m_widget); } // Notice that this method shouldn't be necessary, because GTK calculates @@ -372,8 +379,8 @@ wxSize wxChoice::DoGetBestSize() const void wxChoice::DoApplyWidgetStyle(GtkRcStyle *style) { - gtk_widget_modify_style(m_widget, style); - gtk_widget_modify_style(GTK_BIN(m_widget)->child, style); + GTKApplyStyle(m_widget, style); + GTKApplyStyle(gtk_bin_get_child(GTK_BIN(m_widget)), style); }