- 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);
- }
-
- 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();
-
- 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 );
-
- 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") );
-
- wxCHECK_RET( IsValid(n), wxT("invalid index") );
-
- GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
- gtk_combo_box_remove_text( combobox, n );
-
- m_clientData.RemoveAt( n );
- if(m_strings)
- m_strings->RemoveAt( n );
-
- InvalidateBestSize();
-}
-
-void wxComboBox::SetString(unsigned int n, const wxString &text)
-{
- wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
-
- GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
- wxCHECK_RET( IsValid(n), wxT("invalid index") );
+ if (style & wxCB_READONLY)
+ {
+ // this will assert and do nothing if the value is not in our list
+ // of strings which is the desired behaviour (for consistency with
+ // wxMSW and also because it doesn't make sense to have a string
+ // which is not a possible choice in a read-only combobox)
+ SetStringSelection(value);
+ gtk_editable_set_editable(GTK_EDITABLE(entry), false);
+ }
+ else // editable combobox
+ {
+ // any value is accepted, even if it's not in our list
+ gtk_entry_set_text( entry, wxGTK_CONV(value) );
+ }