From a90c0600bb319326aa9b70ac4551fdd11684e223 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 4 Mar 2005 23:23:05 +0000 Subject: [PATCH] Try to catch theme change on the fly in button in order to resize buttons. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32605 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/button.cpp | 19 +++++++++++++++++++ src/gtk/window.cpp | 18 +++--------------- src/gtk1/button.cpp | 19 +++++++++++++++++++ src/gtk1/window.cpp | 18 +++--------------- 4 files changed, 44 insertions(+), 30 deletions(-) diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index a4cf62371a..e21402f843 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -59,6 +59,22 @@ static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton * button->GetEventHandler()->ProcessEvent(event); } +//----------------------------------------------------------------------------- +// "style_set" from m_widget +//----------------------------------------------------------------------------- + +static gint +gtk_button_style_set_callback( GtkWidget *m_widget, GtkStyle *WXUNUSED(style), wxButton *win ) +{ + if (g_isIdle) + wxapp_install_idle_handler(); + + if (GTK_WIDGET_REALIZED(m_widget)) + win->SetSize( win->m_x, win->m_y, win->m_width, win->m_height ); + + return FALSE; +} + //----------------------------------------------------------------------------- // wxButton //----------------------------------------------------------------------------- @@ -148,6 +164,9 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, gtk_signal_connect_after( GTK_OBJECT(m_widget), "clicked", GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this ); + gtk_signal_connect_after( GTK_OBJECT(m_widget), "style_set", + GTK_SIGNAL_FUNC(gtk_button_style_set_callback), (gpointer*) this ); + m_parent->DoAddChild( this ); PostCreation(size); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 969e4b655f..e6a12132c2 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -3111,22 +3111,10 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags if (GTK_WIDGET_CAN_DEFAULT(m_widget)) { #ifdef __WXGTK20__ -#if 0 - GtkBorder *default_border; - gtk_widget_style_get( m_widget, "default_border", &default_border, NULL ); - if (default_border) - { - left_border += default_border->left; - right_border += default_border->right; - top_border += default_border->top; - bottom_border += default_border->bottom; - g_free( default_border ); - - } -#endif - GtkBorder *default_outside_border; + GtkBorder *default_outside_border = NULL; + gtk_widget_style_get( m_widget, "default_outside_border", &default_outside_border, NULL ); + if (default_outside_border) { - gtk_widget_style_get( m_widget, "default_outside_border", &default_outside_border, NULL ); left_border += default_outside_border->left; right_border += default_outside_border->right; top_border += default_outside_border->top; diff --git a/src/gtk1/button.cpp b/src/gtk1/button.cpp index a4cf62371a..e21402f843 100644 --- a/src/gtk1/button.cpp +++ b/src/gtk1/button.cpp @@ -59,6 +59,22 @@ static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton * button->GetEventHandler()->ProcessEvent(event); } +//----------------------------------------------------------------------------- +// "style_set" from m_widget +//----------------------------------------------------------------------------- + +static gint +gtk_button_style_set_callback( GtkWidget *m_widget, GtkStyle *WXUNUSED(style), wxButton *win ) +{ + if (g_isIdle) + wxapp_install_idle_handler(); + + if (GTK_WIDGET_REALIZED(m_widget)) + win->SetSize( win->m_x, win->m_y, win->m_width, win->m_height ); + + return FALSE; +} + //----------------------------------------------------------------------------- // wxButton //----------------------------------------------------------------------------- @@ -148,6 +164,9 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, gtk_signal_connect_after( GTK_OBJECT(m_widget), "clicked", GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this ); + gtk_signal_connect_after( GTK_OBJECT(m_widget), "style_set", + GTK_SIGNAL_FUNC(gtk_button_style_set_callback), (gpointer*) this ); + m_parent->DoAddChild( this ); PostCreation(size); diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 969e4b655f..e6a12132c2 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -3111,22 +3111,10 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags if (GTK_WIDGET_CAN_DEFAULT(m_widget)) { #ifdef __WXGTK20__ -#if 0 - GtkBorder *default_border; - gtk_widget_style_get( m_widget, "default_border", &default_border, NULL ); - if (default_border) - { - left_border += default_border->left; - right_border += default_border->right; - top_border += default_border->top; - bottom_border += default_border->bottom; - g_free( default_border ); - - } -#endif - GtkBorder *default_outside_border; + GtkBorder *default_outside_border = NULL; + gtk_widget_style_get( m_widget, "default_outside_border", &default_outside_border, NULL ); + if (default_outside_border) { - gtk_widget_style_get( m_widget, "default_outside_border", &default_outside_border, NULL ); left_border += default_outside_border->left; right_border += default_outside_border->right; top_border += default_outside_border->top; -- 2.45.2