- gtk_entry_set_editable( entry, FALSE );
-
- // "show" and "hide" events are generated when user click on the combobox button which popups a list
- // this list is the "popwin" gtk widget
- g_signal_connect (GTK_COMBO(combo)->popwin, "hide",
- G_CALLBACK (gtkcombo_popup_hide_callback), this);
- g_signal_connect (GTK_COMBO(combo)->popwin, "show",
- G_CALLBACK (gtkcombo_popup_show_callback), this);
- g_signal_connect_after (combo->list, "select-child",
- G_CALLBACK (gtkcombo_combo_select_child_callback),
- this);
- g_signal_connect_after (entry, "changed",
- G_CALLBACK (gtkcombo_text_changed_callback), this);
- }
-
- SetInitialSize(size); // need this too because this is a wxControlWithItems
-
- return true;
-}
-
-GtkEditable *wxComboBox::GetEditable() const
-{
-#ifdef __WXGTK24__
- if ( !gtk_check_version(2,4,0) )
- return GTK_EDITABLE( GTK_BIN(m_widget)->child );
- else
-#endif
- return GTK_EDITABLE( GTK_COMBO(m_widget)->entry );
-}
-
-wxComboBox::~wxComboBox()
-{
- Clear();
-
- delete m_strings;
-}
-
-void wxComboBox::SetFocus()
-{
- if ( m_hasFocus )
- {
- // don't do anything if we already have focus
- return;
- }
-
- gtk_widget_grab_focus( m_focusWidget );
-}
-
-int wxComboBox::DoInsertItems(const wxArrayStringsAdapter & items,
- unsigned int pos,
- void **clientData, wxClientDataType type)
-{
- wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") );
-
- wxASSERT_MSG( !IsSorted() || (pos == GetCount()),
- _T("In a sorted combobox data could only be appended"));
-
- const int count = items.GetCount();
-
- int n = wxNOT_FOUND;
-
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
- for( int i = 0; i < count; ++i )
- {
- n = pos + i;
- // If sorted, use this wxSortedArrayStrings to determine
- // the right insertion point
- if(m_strings)
- n = m_strings->Add(items[i]);
-
- gtk_combo_box_insert_text( combobox, n, wxGTK_CONV( items[i] ) );
-
- m_clientData.Insert( NULL, n );
- AssignNewItemClientData(n, clientData, i, type);
- }
- }
- else
-#endif
- {
- DisableEvents();
-
- GtkWidget *list = GTK_COMBO(m_widget)->list;
- for( int i = 0; i < count; ++i )
- {
- n = pos + i;
- // If sorted, use this wxSortedArrayStrings to determine
- // the right insertion point
- if(m_strings)
- n = m_strings->Add(items[i]);
-
- GtkWidget *list_item = gtk_list_item_new_with_label( wxGTK_CONV( items[i] ) );
-
- // TODO construct a list with all items and call gtk_list_insert_items once?
- GList *gitem_list = g_list_alloc ();
- gitem_list->data = list_item;
- gtk_list_insert_items( GTK_LIST (list), gitem_list, n );
-
- m_clientData.Insert( NULL, n );
- AssignNewItemClientData(n, clientData, i, type);
-
- if (GTK_WIDGET_REALIZED(m_widget))
- {
- gtk_widget_realize( list_item );
- gtk_widget_realize( GTK_BIN(list_item)->child );
-
- ApplyWidgetStyle();
- }
-
- gtk_widget_show( list_item );
- }
-
- EnableEvents();
- }
-
- InvalidateBestSize();
-
- return n;
-}
-
-void wxComboBox::DoSetItemClientData(unsigned int n, void* clientData)
-{
- m_clientData[n] = clientData;
-}
-
-void* wxComboBox::DoGetItemClientData(unsigned int n) const
-{
- return m_clientData[n];
-}
-
-void wxComboBox::DoClear()
-{
- wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
-
- DisableEvents();
-
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
- 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
-#endif // __WXGTK24__
- {
- GtkWidget *list = GTK_COMBO(m_widget)->list;
- gtk_list_clear_items( GTK_LIST(list), 0, GetCount() );
- }
-
- m_clientData.Clear();
-
- if(m_strings)
- m_strings->Clear();
-
- EnableEvents();
-
- InvalidateBestSize();
-}
-
-void wxComboBox::DoDeleteOneItem(unsigned int n)
-{
- wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
-
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- {
- wxCHECK_RET( IsValid(n), wxT("invalid index") );
-
- GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
- gtk_combo_box_remove_text( combobox, n );
- }
- else
-#endif
- {
- GtkList *listbox = GTK_LIST( GTK_COMBO(m_widget)->list );
-
- GList *child = g_list_nth( listbox->children, n );
-
- if (!child)