wxSuspendStyleEvents helper class was used in one place only and the code is
more clear if its ctor and dtor are inlined directly into DoApplyWidgetStyle()
itself instead of being located far away from it.
Also, we only need to suppress the events for top level windows so don't
bother doing anything at all when changing styles for m_widget and not m_wxwindow.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62285
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
-// Helper to suspend colour change event event processing while we change a widget's style
-class wxSuspendStyleEvents
-{
-public:
- wxSuspendStyleEvents(wxWindow* win)
- {
- m_win = NULL;
- if (win->m_wxwindow && win->IsTopLevel())
- {
- m_win = win;
- g_signal_handlers_block_by_func(
- m_win->m_wxwindow, (void*)gtk_window_style_set_callback, m_win);
- }
- }
- ~wxSuspendStyleEvents()
- {
- if (m_win)
- g_signal_handlers_unblock_by_func(
- m_win->m_wxwindow, (void*)gtk_window_style_set_callback, m_win);
- }
-
- wxWindow* m_win;
-};
-
// ----------------------------------------------------------------------------
// this wxWindowBase function is implemented here (in platform-specific file)
// because it is static and so couldn't be made virtual
// ----------------------------------------------------------------------------
// this wxWindowBase function is implemented here (in platform-specific file)
// because it is static and so couldn't be made virtual
void wxWindowGTK::DoApplyWidgetStyle(GtkRcStyle *style)
{
void wxWindowGTK::DoApplyWidgetStyle(GtkRcStyle *style)
{
- wxSuspendStyleEvents s(static_cast<wxWindow*>(this));
+ if ( m_wxwindow )
+ {
+ // block the signal temporarily to avoid sending
+ // wxSysColourChangedEvents when we change the colours ourselves
+ bool unblock = false;
+ if ( IsTopLevel() )
+ {
+ unblock = true;
+ g_signal_handlers_block_by_func(
+ m_wxwindow, (void *)gtk_window_style_set_callback, this);
+ }
gtk_widget_modify_style(m_wxwindow, style);
gtk_widget_modify_style(m_wxwindow, style);
+
+ if ( unblock )
+ {
+ g_signal_handlers_unblock_by_func(
+ m_wxwindow, (void *)gtk_window_style_set_callback, this);
+ }
+ }
gtk_widget_modify_style(m_widget, style);
gtk_widget_modify_style(m_widget, style);
}
bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style)
}
bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style)