int curSelection = combo->GetSelection();
- if (combo->m_prevSelection != curSelection)
- {
- GtkWidget *list = GTK_COMBO(combo->m_widget)->list;
- gtk_list_unselect_item( GTK_LIST(list), combo->m_prevSelection );
- }
+ if (combo->m_prevSelection == curSelection) return;
+
+ GtkWidget *list = GTK_COMBO(combo->m_widget)->list;
+ gtk_list_unselect_item( GTK_LIST(list), combo->m_prevSelection );
+
combo->m_prevSelection = curSelection;
wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() );
event.SetInt( curSelection );
event.SetString( combo->GetStringSelection() );
event.SetEventObject( combo );
-
+
combo->GetEventHandler()->ProcessEvent( event );
}
{
gtk_widget_realize( list_item );
gtk_widget_realize( GTK_BIN(list_item)->child );
+ }
- if (m_widgetStyle) ApplyWidgetStyle();
+ // Apply current widget style to the new list_item
+ GtkRcStyle *style = CreateWidgetStyle();
+ if (style)
+ {
+ gtk_widget_modify_style( GTK_WIDGET( list_item ), style );
+ GtkBin *bin = GTK_BIN( list_item );
+ GtkWidget *label = GTK_WIDGET( bin->child );
+ gtk_widget_modify_style( label, style );
+ gtk_rc_style_unref( style );
}
gtk_widget_show( list_item );
EnableEvents();
+ InvalidateBestSize();
+
return count - 1;
}
gtk_widget_realize( list_item );
gtk_widget_realize( GTK_BIN(list_item)->child );
- if (m_widgetStyle)
- ApplyWidgetStyle();
+ ApplyWidgetStyle();
}
gtk_widget_show( list_item );
m_clientObjectList.Insert( pos, (wxObject*) NULL );
EnableEvents();
+
+ InvalidateBestSize();
return pos;
}
m_clientDataList.Clear();
EnableEvents();
+
+ InvalidateBestSize();
}
void wxComboBox::Delete( int n )
m_clientDataList.Erase( node );
EnableEvents();
+
+ InvalidateBestSize();
}
void wxComboBox::SetString(int n, const wxString &text)
{
wxFAIL_MSG( wxT("wxComboBox: wrong index") );
}
+
+ InvalidateBestSize();
}
int wxComboBox::FindString( const wxString &item ) const
wxString tmp = wxT("");
if (!value.IsNull()) tmp = value;
gtk_entry_set_text( GTK_ENTRY(entry), wxGTK_CONV( tmp ) );
+
+ InvalidateBestSize();
}
void wxComboBox::Copy()
void wxComboBox::OnSize( wxSizeEvent &event )
{
- event.Skip();
-
-#if 0
- int w = 21;
- gtk_widget_set_usize( GTK_COMBO(m_widget)->entry, m_width-w-1, m_height );
+ // NB: In some situations (e.g. on non-first page of a wizard, if the
+ // size used is default size), GtkCombo widget is resized correctly,
+ // but it's look is not updated, it's rendered as if it was much wider.
+ // No other widgets are affected, so it looks like a bug in GTK+.
+ // Manually requesting resize calculation (as gtk_pizza_set_size does)
+ // fixes it.
+ if (GTK_WIDGET_VISIBLE(m_widget))
+ gtk_widget_queue_resize(m_widget);
- gtk_widget_set_uposition( GTK_COMBO(m_widget)->button, m_x+m_width-w, m_y );
- gtk_widget_set_usize( GTK_COMBO(m_widget)->button, w, m_height );
-#endif // 0
+ event.Skip();
}
-void wxComboBox::ApplyWidgetStyle()
+void wxComboBox::DoApplyWidgetStyle(GtkRcStyle *style)
{
- SetWidgetStyle();
+// gtk_widget_modify_style( GTK_COMBO(m_widget)->button, syle );
-// 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 );
+ gtk_widget_modify_style( GTK_COMBO(m_widget)->entry, style );
+ gtk_widget_modify_style( GTK_COMBO(m_widget)->list, style );
GtkList *list = GTK_LIST( GTK_COMBO(m_widget)->list );
GList *child = list->children;
while (child)
{
- gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle );
+ gtk_widget_modify_style( GTK_WIDGET(child->data), style );
GtkBin *bin = GTK_BIN(child->data);
- gtk_widget_set_style( bin->child, m_widgetStyle );
+ gtk_widget_modify_style( bin->child, style );
child = child->next;
}
// we know better our horizontal extent: it depends on the longest string
// in the combobox
- ret.x = 0;
if ( m_widget )
{
int width;
// empty combobox should have some reasonable default size too
if ( ret.x < 100 )
ret.x = 100;
+
+ CacheBestSize(ret);
return ret;
}
+// static
+wxVisualAttributes
+wxComboBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+ return GetDefaultAttributesFromGTKWidget(gtk_combo_new, true);
+}
+
#endif