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
This commit is contained in:
Julian Smart
2007-11-09 15:06:52 +00:00
parent 7bfe40662e
commit 9ff4f05ff9
2 changed files with 74 additions and 3 deletions

View File

@@ -555,8 +555,11 @@ void wxDialogBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
closing.DeleteObject(this); closing.DeleteObject(this);
} }
void wxDialogBase::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event)) void wxDialogBase::OnSysColourChanged(wxSysColourChangedEvent& event)
{ {
#ifndef __WXGTK__
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
Refresh(); Refresh();
#endif
event.Skip();
} }

View File

@@ -52,6 +52,8 @@
#define GTK_DISABLE_DEPRECATED #define GTK_DISABLE_DEPRECATED
#endif #endif
#define USE_STYLE_SET_CALLBACK 1
#include "wx/gtk/private.h" #include "wx/gtk/private.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
@@ -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" } // 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) // this wxWindowBase function is implemented here (in platform-specific file)
// because it is static and so couldn't be made virtual // 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_CALLBACK (gtk_window_enter_callback), this);
g_signal_connect (widget, "leave_notify_event", g_signal_connect (widget, "leave_notify_event",
G_CALLBACK (gtk_window_leave_callback), this); 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() bool wxWindowGTK::Destroy()
@@ -3939,6 +4005,8 @@ void wxWindowGTK::ApplyWidgetStyle(bool forceStyle)
void wxWindowGTK::DoApplyWidgetStyle(GtkRcStyle *style) void wxWindowGTK::DoApplyWidgetStyle(GtkRcStyle *style)
{ {
wxSuspendStyleEvents s(this);
if (m_wxwindow) if (m_wxwindow)
gtk_widget_modify_style(m_wxwindow, style); gtk_widget_modify_style(m_wxwindow, style);
else else