X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7a78a9378207266c55b7f4c72fbfb2ae11963d0b..a3b7db872925df2921f36637a84085ec04cf977a:/src/gtk/choice.cpp diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index 73ed8300b3..bbfa2480bb 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -30,7 +30,7 @@ extern "C" { static void gtk_choice_changed_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice ) { - choice->SendSelectionChangedEvent(wxEVT_COMMAND_CHOICE_SELECTED); + choice->SendSelectionChangedEvent(wxEVT_CHOICE); } } @@ -101,22 +101,6 @@ wxChoice::~wxChoice() delete m_strings; } -void wxChoice::SendSelectionChangedEvent(wxEventType evt_type) -{ - if (GetSelection() == -1) - return; - - wxCommandEvent event( evt_type, GetId() ); - - int n = GetSelection(); - event.SetInt( n ); - event.SetString( GetStringSelection() ); - event.SetEventObject( this ); - InitCommandEventWithItems( event, n ); - - HandleWindowEvent( event ); -} - void wxChoice::GTKInsertComboBoxTextItem( unsigned int n, const wxString& text ) { #ifdef __WXGTK3__ @@ -197,8 +181,12 @@ void wxChoice::DoDeleteOneItem(unsigned int n) GtkTreeModel* model = gtk_combo_box_get_model( combobox ); GtkListStore* store = GTK_LIST_STORE(model); GtkTreeIter iter; - gtk_tree_model_iter_nth_child( model, &iter, - NULL, (gint) n ); + if ( !gtk_tree_model_iter_nth_child(model, &iter, NULL, n) ) + { + // This is really not supposed to happen for a valid index. + wxFAIL_MSG(wxS("Item unexpectedly not found.")); + return; + } gtk_list_store_remove( store, &iter ); m_clientData.RemoveAt( n ); @@ -324,7 +312,6 @@ int wxChoice::GetColumns() const return intval; } - void wxChoice::GTKDisableEvents() { g_signal_handlers_block_by_func(m_widget, @@ -337,7 +324,6 @@ void wxChoice::GTKEnableEvents() (gpointer) gtk_choice_changed_callback, this); } - GdkWindow *wxChoice::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const { return gtk_widget_get_window(m_widget); @@ -366,7 +352,7 @@ wxSize wxChoice::DoGetSizeFromTextSize(int xlen, int ylen) const // We are interested in the difference of sizes between the whole contol // and its child part. I.e. arrow, separators, etc. GtkRequisition req; - gtk_widget_size_request(childPart, &req); + gtk_widget_get_preferred_size(childPart, NULL, &req); wxSize totalS = GTKGetPreferredSize(m_widget); wxSize tsize(xlen + totalS.x - req.width, totalS.y); @@ -388,13 +374,11 @@ void wxChoice::DoApplyWidgetStyle(GtkRcStyle *style) GTKApplyStyle(gtk_bin_get_child(GTK_BIN(m_widget)), style); } - // static wxVisualAttributes wxChoice::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) { - return GetDefaultAttributesFromGTKWidget(gtk_combo_box_new); + return GetDefaultAttributesFromGTKWidget(gtk_combo_box_new()); } - #endif // wxUSE_CHOICE || wxUSE_COMBOBOX