From 9ff4f05ff997cbe66020d6f55bd7bacc2eb88e8c Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Fri, 9 Nov 2007 15:06:52 +0000 Subject: [PATCH] Colour change event now sent on wxGTK git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@49747 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/dlgcmn.cpp | 9 ++++-- src/gtk/window.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp index 74af36254e..e723242e78 100644 --- a/src/common/dlgcmn.cpp +++ b/src/common/dlgcmn.cpp @@ -555,8 +555,11 @@ void wxDialogBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) closing.DeleteObject(this); } -void wxDialogBase::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event)) +void wxDialogBase::OnSysColourChanged(wxSysColourChangedEvent& event) { - SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); - Refresh(); +#ifndef __WXGTK__ + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); + Refresh(); +#endif + event.Skip(); } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 1bd821d9f5..f87f5acc1e 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -52,6 +52,8 @@ #define GTK_DISABLE_DEPRECATED #endif +#define USE_STYLE_SET_CALLBACK 1 + #include "wx/gtk/private.h" #include "wx/gtk/win_gtk.h" #include @@ -2148,8 +2150,66 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), } } +//----------------------------------------------------------------------------- +// "style_set" +//----------------------------------------------------------------------------- + +static +void gtk_window_style_set_callback( GtkWidget *widget, + GtkStyle *previous_style, + wxWindow* win ) +{ + if (win && previous_style) + { + wxSysColourChangedEvent event; + event.SetEventObject(win); + + win->GTKProcessEvent( event ); + } +} + } // extern "C" +// Connect/disconnect style-set + +void wxConnectStyleSet(wxWindow* win) +{ + if (win->m_wxwindow) + g_signal_connect (win->m_wxwindow, "style_set", + G_CALLBACK (gtk_window_style_set_callback), win); +} + +void wxDisconnectStyleSet(wxWindow* win) +{ + if (win->m_wxwindow) + g_signal_handlers_disconnect_by_func (win->m_wxwindow, + (gpointer) gtk_window_style_set_callback, + win); +} + +// Helper to suspend colour change event event processing while we change a widget's style +class wxSuspendStyleEvents +{ +public: + wxSuspendStyleEvents(wxWindow* win) + { + m_win = win; +#if USE_STYLE_SET_CALLBACK + if (win->IsTopLevel()) + wxDisconnectStyleSet(win); +#endif + } + ~wxSuspendStyleEvents() + { +#if USE_STYLE_SET_CALLBACK + if (m_win->IsTopLevel()) + wxConnectStyleSet(m_win); +#endif + } + + wxWindow* m_win; +}; + // ---------------------------------------------------------------------------- // this wxWindowBase function is implemented here (in platform-specific file) // because it is static and so couldn't be made virtual @@ -2588,6 +2648,12 @@ void wxWindowGTK::ConnectWidget( GtkWidget *widget ) G_CALLBACK (gtk_window_enter_callback), this); g_signal_connect (widget, "leave_notify_event", G_CALLBACK (gtk_window_leave_callback), this); + +#if USE_STYLE_SET_CALLBACK + if (IsTopLevel() && m_wxwindow) + g_signal_connect (m_wxwindow, "style_set", + G_CALLBACK (gtk_window_style_set_callback), this); +#endif } bool wxWindowGTK::Destroy() @@ -3939,6 +4005,8 @@ void wxWindowGTK::ApplyWidgetStyle(bool forceStyle) void wxWindowGTK::DoApplyWidgetStyle(GtkRcStyle *style) { + wxSuspendStyleEvents s(this); + if (m_wxwindow) gtk_widget_modify_style(m_wxwindow, style); else