X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c1a3ff259eefe3d9ff85ee158dfb3af99e57ea62..16d17da6ca6d8c9eb1f5b2659a2c5b6dd42b26db:/src/gtk/combobox.cpp diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 1fa5e3336d..936f383894 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -14,11 +14,12 @@ #include "wx/combobox.h" -#include "wx/settings.h" -#include "wx/arrstr.h" -#include "wx/intl.h" - -#include "wx/textctrl.h" // for wxEVT_COMMAND_TEXT_UPDATED +#ifndef WX_PRECOMP + #include "wx/intl.h" + #include "wx/settings.h" + #include "wx/textctrl.h" // for wxEVT_COMMAND_TEXT_UPDATED + #include "wx/arrstr.h" +#endif // We use GtkCombo which has been deprecated since GTK+ 2.3.0 // in favour of GtkComboBox for m_hasVMT) return; + if (combo->GetSelection() == -1) + return; + wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() ); event.SetInt( combo->GetSelection() ); event.SetString( combo->GetStringSelection() ); @@ -292,7 +296,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, gtk_combo_set_case_sensitive( GTK_COMBO(m_widget), TRUE ); if (style & wxNO_BORDER) - g_object_set( GTK_ENTRY( combo->entry ), "has-frame", FALSE, NULL ); + g_object_set (combo->entry, "has-frame", FALSE, NULL ); GtkWidget *list = combo->list; @@ -374,7 +378,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, // gtk_widget_set_size_request( m_widget, setsize.x, setsize.y ); } - SetBestSize(size); // need this too because this is a wxControlWithItems + SetInitialSize(size); // need this too because this is a wxControlWithItems return true; @@ -447,7 +451,7 @@ int wxComboBox::DoAppend( const wxString &item ) EnableEvents(); } - const size_t count = GetCount(); + const unsigned int count = GetCount(); if ( m_clientDataList.GetCount() < count ) m_clientDataList.Append( (wxObject*) NULL ); @@ -459,7 +463,7 @@ int wxComboBox::DoAppend( const wxString &item ) return count - 1; } -int wxComboBox::DoInsert( const wxString &item, int pos ) +int wxComboBox::DoInsert(const wxString &item, unsigned int pos) { wxCHECK_MSG( !(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list")); @@ -467,9 +471,9 @@ int wxComboBox::DoInsert( const wxString &item, int pos ) wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") ); wxCHECK_MSG( IsValidInsert(pos), -1, wxT("invalid index") ); - size_t count = GetCount(); + unsigned int count = GetCount(); - if ((size_t)pos == count) + if (pos == count) return Append(item); #ifdef __WXGTK24__ @@ -515,7 +519,7 @@ int wxComboBox::DoInsert( const wxString &item, int pos ) return pos; } -void wxComboBox::DoSetItemClientData( int n, void* clientData ) +void wxComboBox::DoSetItemClientData(unsigned int n, void* clientData) { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); @@ -525,7 +529,7 @@ void wxComboBox::DoSetItemClientData( int n, void* clientData ) node->SetData( (wxObject*) clientData ); } -void* wxComboBox::DoGetItemClientData( int n ) const +void* wxComboBox::DoGetItemClientData(unsigned int n) const { wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid combobox") ); @@ -534,7 +538,7 @@ void* wxComboBox::DoGetItemClientData( int n ) const return node ? node->GetData() : NULL; } -void wxComboBox::DoSetItemClientObject( int n, wxClientData* clientData ) +void wxComboBox::DoSetItemClientObject(unsigned int n, wxClientData* clientData) { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); @@ -546,7 +550,7 @@ void wxComboBox::DoSetItemClientObject( int n, wxClientData* clientData ) node->SetData( (wxObject*) clientData ); } -wxClientData* wxComboBox::DoGetItemClientObject( int n ) const +wxClientData* wxComboBox::DoGetItemClientObject(unsigned int n) const { wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, wxT("invalid combobox") ); @@ -565,8 +569,8 @@ void wxComboBox::Clear() if (!gtk_check_version(2,4,0)) { GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); - const size_t count = GetCount(); - for (size_t i = 0; i < count; i++) + const unsigned int count = GetCount(); + for (unsigned int i = 0; i < count; i++) gtk_combo_box_remove_text( combobox, 0 ); } else // GTK+ < 2.4.0 @@ -592,7 +596,7 @@ void wxComboBox::Clear() InvalidateBestSize(); } -void wxComboBox::Delete( int n ) +void wxComboBox::Delete(unsigned int n) { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); @@ -641,7 +645,7 @@ void wxComboBox::Delete( int n ) InvalidateBestSize(); } -void wxComboBox::SetString(int n, const wxString &text) +void wxComboBox::SetString(unsigned int n, const wxString &text) { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); @@ -783,7 +787,7 @@ int wxComboBox::GetCurrentSelection() const return -1; } -wxString wxComboBox::GetString( int n ) const +wxString wxComboBox::GetString(unsigned int n) const { wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid combobox") ); @@ -836,7 +840,7 @@ wxString wxComboBox::GetStringSelection() const int sel = gtk_combo_box_get_active( combobox ); if (sel == -1) return wxEmptyString; - return GetString( sel ); + return GetString(sel); } else #endif @@ -858,7 +862,7 @@ wxString wxComboBox::GetStringSelection() const return wxEmptyString; } -size_t wxComboBox::GetCount() const +unsigned int wxComboBox::GetCount() const { wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid combobox") ); @@ -871,7 +875,7 @@ size_t wxComboBox::GetCount() const gtk_tree_model_get_iter_first( model, &iter ); if (!gtk_list_store_iter_is_valid(GTK_LIST_STORE(model), &iter )) return 0; - size_t ret = 1; + unsigned int ret = 1; while (gtk_tree_model_iter_next( model, &iter )) ret++; return ret; @@ -882,8 +886,12 @@ size_t wxComboBox::GetCount() const GtkWidget *list = GTK_COMBO(m_widget)->list; GList *child = GTK_LIST(list)->children; - size_t count = 0; - while (child) { count++; child = child->next; } + unsigned int count = 0; + while (child) + { + count++; + child = child->next; + } return count; } @@ -1320,21 +1328,23 @@ GtkWidget* wxComboBox::GetConnectWidget() return GTK_WIDGET( entry ); } -bool wxComboBox::IsOwnGtkWindow( GdkWindow *window ) +GdkWindow *wxComboBox::GTKGetWindow(wxArrayGdkWindows& windows) const { - GtkEntry *entry = NULL; #ifdef __WXGTK24__ if (!gtk_check_version(2,4,0)) { - entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); - return (window == entry->text_area); + wxUnusedVar(windows); + + return GTK_ENTRY(GTK_BIN(m_widget)->child)->text_area; } else -#endif +#endif // GTK+ 2.4 { - entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); - return ( (window == entry->text_area) || - (window == GTK_COMBO(m_widget)->button->window ) ); + windows.push_back(GTK_ENTRY(GTK_COMBO(m_widget)->entry)->text_area); + windows.push_back(GTK_COMBO(m_widget)->button->window); + + // indicate that we return multiple windows in the windows array + return NULL; } } @@ -1347,10 +1357,10 @@ wxSize wxComboBox::DoGetBestSize() const if ( m_widget ) { int width; - size_t count = GetCount(); - for ( size_t n = 0; n < count; n++ ) + unsigned int count = GetCount(); + for ( unsigned int n = 0; n < count; n++ ) { - GetTextExtent( GetString(n), &width, NULL, NULL, NULL ); + GetTextExtent(GetString(n), &width, NULL, NULL, NULL ); if ( width > ret.x ) ret.x = width; }