From 631a05be911d510e256bf75819ca7a46e38fe203 Mon Sep 17 00:00:00 2001 From: Ron Lee Date: Sun, 5 Sep 2004 10:08:19 +0000 Subject: [PATCH] GTK Combobox and Listbox aren't realized until actually visible, so a list_item created before that would receive a default style instead of the control's style. Instead of calling ApplyWidgetStyle() which would iterate all items, only the newly created item will receive the current style to speed things up. Thanks to Andreas Pflug. Closes 984861 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29032 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/combobox.cpp | 11 ++++++++++- src/gtk/listbox.cpp | 22 +++++++++++----------- src/gtk1/combobox.cpp | 11 ++++++++++- src/gtk1/listbox.cpp | 22 +++++++++++----------- 4 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index acf403570b..557d3e1b5d 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -238,8 +238,17 @@ int wxComboBox::DoAppend( const wxString &item ) { gtk_widget_realize( list_item ); gtk_widget_realize( GTK_BIN(list_item)->child ); + } - 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 ); diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index b2d8307151..4df5e56479 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -578,21 +578,21 @@ void wxListBox::GtkAddItem( const wxString &item, int pos ) gtk_widget_realize( list_item ); gtk_widget_realize( GTK_BIN(list_item)->child ); - // 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 ); - } - #if wxUSE_TOOLTIPS if (m_tooltip) m_tooltip->Apply( this ); #endif } + + // 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 ); + } } void wxListBox::DoSetItems( const wxArrayString& items, diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index acf403570b..557d3e1b5d 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -238,8 +238,17 @@ int wxComboBox::DoAppend( const wxString &item ) { gtk_widget_realize( list_item ); gtk_widget_realize( GTK_BIN(list_item)->child ); + } - 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 ); diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index b2d8307151..4df5e56479 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -578,21 +578,21 @@ void wxListBox::GtkAddItem( const wxString &item, int pos ) gtk_widget_realize( list_item ); gtk_widget_realize( GTK_BIN(list_item)->child ); - // 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 ); - } - #if wxUSE_TOOLTIPS if (m_tooltip) m_tooltip->Apply( this ); #endif } + + // 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 ); + } } void wxListBox::DoSetItems( const wxArrayString& items, -- 2.45.2