X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/acfd422afac254f4356904275656c0c15685fa1e..2b2edbedb47a54bea26df1bede371bf761e3a233:/src/gtk1/combobox.cpp diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index cb5a74135a..efbe51763d 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -13,6 +13,10 @@ #include "wx/combobox.h" +#if wxUSE_COMBOBOX + +#include "wx/settings.h" + #include #include "gdk/gdk.h" @@ -40,7 +44,7 @@ gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) { if (g_isIdle) wxapp_install_idle_handler(); - if (!combo->HasVMT()) return; + if (!combo->m_hasVMT) return; if (g_blockEventsOnDrag) return; @@ -69,6 +73,8 @@ gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) { if (g_isIdle) wxapp_install_idle_handler(); + if (!combo->m_hasVMT) return; + wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() ); event.SetString( combo->GetValue() ); event.SetEventObject( combo ); @@ -98,7 +104,9 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, PreCreation( parent, id, pos, size, style, name ); +#if wxUSE_VALIDATORS SetValidator( validator ); +#endif m_widget = gtk_combo_new(); @@ -116,6 +124,10 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, for (int i = 0; i < n; i++) { + /* don't send first event, which GTK sends aways when + inserting the first item */ + m_alreadySent = TRUE; + GtkWidget *list_item = gtk_list_item_new_with_label( choices[i].mbc_str() ); m_clientDataList.Append( (wxObject*)NULL ); @@ -123,15 +135,13 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, gtk_container_add( GTK_CONTAINER(list), list_item ); - gtk_widget_show( list_item ); - gtk_signal_connect( GTK_OBJECT(list_item), "select", - GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this ); - } + GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this ); - m_parent->AddChild( this ); + gtk_widget_show( list_item ); + } - (m_parent->m_insertCallback)( m_parent, this ); + m_parent->DoAddChild( this ); PostCreation(); @@ -145,7 +155,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, gtk_signal_connect( GTK_OBJECT(GTK_COMBO(m_widget)->entry), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - SetBackgroundColour( parent->GetBackgroundColour() ); + SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_WINDOW ) ); SetForegroundColour( parent->GetForegroundColour() ); SetFont( parent->GetFont() ); @@ -321,7 +331,7 @@ int wxComboBox::FindString( const wxString &item ) { GtkBin *bin = GTK_BIN( child->data ); GtkLabel *label = GTK_LABEL( bin->child ); - if (item == label->label) + if (item == wxString(label->label,*wxConvCurrent)) return count; count++; child = child->next; @@ -366,7 +376,7 @@ wxString wxComboBox::GetString( int n ) const { GtkBin *bin = GTK_BIN( child->data ); GtkLabel *label = GTK_LABEL( bin->child ); - str = label->label; + str = wxString(label->label,*wxConvCurrent); } else { @@ -386,7 +396,7 @@ wxString wxComboBox::GetStringSelection() const if (selection) { GtkBin *bin = GTK_BIN( selection->data ); - wxString tmp = GTK_LABEL( bin->child )->label; + wxString tmp = wxString(GTK_LABEL( bin->child )->label,*wxConvCurrent); return tmp; } @@ -427,7 +437,7 @@ void wxComboBox::SetStringSelection( const wxString &string ) wxString wxComboBox::GetValue() const { GtkWidget *entry = GTK_COMBO(m_widget)->entry; - wxString tmp = gtk_entry_get_text( GTK_ENTRY(entry) ); + wxString tmp = wxString(gtk_entry_get_text( GTK_ENTRY(entry) ),*wxConvCurrent); return tmp; } @@ -577,7 +587,9 @@ void wxComboBox::OnChar( wxKeyEvent &event ) void wxComboBox::OnSize( wxSizeEvent &event ) { - wxControl::OnSize( event ); + event.Skip(); + + return; int w = 21; gtk_widget_set_usize( GTK_COMBO(m_widget)->entry, m_width-w-1, m_height ); @@ -590,7 +602,7 @@ void wxComboBox::ApplyWidgetStyle() { SetWidgetStyle(); - gtk_widget_set_style( GTK_COMBO(m_widget)->button, m_widgetStyle ); +// gtk_widget_set_style( GTK_COMBO(m_widget)->button, m_widgetStyle ); gtk_widget_set_style( GTK_COMBO(m_widget)->entry, m_widgetStyle ); gtk_widget_set_style( GTK_COMBO(m_widget)->list, m_widgetStyle ); @@ -618,3 +630,4 @@ bool wxComboBox::IsOwnGtkWindow( GdkWindow *window ) (window == GTK_COMBO(m_widget)->button->window ) ); } +#endif