extern "C" {
static gboolean
-gtk_window_expose_callback( GtkWidget* widget,
+gtk_window_expose_callback( GtkWidget*,
GdkEventExpose *gdk_event,
wxWindow *win )
{
- if (gdk_event->window == widget->window)
+ if (gdk_event->window == win->GTKGetDrawingWindow())
{
win->GetUpdateRegion() = wxRegion( gdk_event->region );
win->GtkSendPaintEvents();
static gboolean
expose_event_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win)
{
- if (gdk_event->window != widget->window)
+ if (gdk_event->window != gtk_widget_get_parent_window(win->m_wxwindow))
return false;
const GtkAllocation& alloc = win->m_wxwindow->allocation;
if (win->m_imData)
{
gtk_im_context_set_client_window( win->m_imData->context,
- widget->window);
+ win->m_wxwindow ? win->GTKGetDrawingWindow() : widget->window);
}
// We cannot set colours and fonts before the widget
} // extern "C"
-// 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
gtk_widget_set_size_request(
child->m_widget, child->m_width, child->m_height);
- gtk_fixed_put(
- GTK_FIXED(m_wxwindow), child->m_widget, child->m_x, child->m_y);
+ pizza->put(child->m_widget, child->m_x, child->m_y);
}
//-----------------------------------------------------------------------------
#endif
- m_wxwindow = wxPizza::New(m_windowStyle,this);
+ m_wxwindow = wxPizza::New(m_windowStyle);
#ifndef __WXUNIVERSAL__
if (HasFlag(wxPizza::BORDER_STYLES))
{
G_CALLBACK(size_allocate), this);
}
- if (m_wxwindow)
- {
#if GTK_CHECK_VERSION(2, 8, 0)
- if (!gtk_check_version(2,8,0))
+ if ( gtk_check_version(2,8,0) == NULL )
+ {
+ // Make sure we can notify the app when mouse capture is lost
+ if ( m_wxwindow )
{
- // Make sure we can notify the app when mouse capture is lost
g_signal_connect (m_wxwindow, "grab_broken_event",
G_CALLBACK (gtk_window_grab_broken), this);
}
-#endif
- }
- if ( connect_widget != m_wxwindow )
- {
-#if GTK_CHECK_VERSION(2, 8, 0)
- if (!gtk_check_version(2,8,0))
+ if ( connect_widget != m_wxwindow )
{
- // Make sure we can notify app code when mouse capture is lost
g_signal_connect (connect_widget, "grab_broken_event",
G_CALLBACK (gtk_window_grab_broken), this);
}
-#endif
}
+#endif // GTK+ >= 2.8
if ( GTKShouldConnectSizeRequest() )
{
gtk_widget_show( m_widget );
}
+gulong wxWindowGTK::GTKConnectWidget(const char *signal, void (*callback)())
+{
+ return g_signal_connect(m_widget, signal, callback, this);
+}
+
void wxWindowGTK::ConnectWidget( GtkWidget *widget )
{
g_signal_connect (widget, "key_press_event",
if (m_wxwindow && (m_wxwindow != m_widget))
{
- GdkWindow *window = m_wxwindow->window;
+ GdkWindow* window = GTKGetDrawingWindow();
if (window)
gdk_window_set_cursor( window, cursor.GetCursor() );
if (!GTK_WIDGET_MAPPED (w))
return;
+ GdkWindow* window = GTKGetDrawingWindow();
if (rect)
{
int x = rect->x;
r.y = rect->y;
r.width = rect->width;
r.height = rect->height;
- gdk_window_invalidate_rect( m_wxwindow->window, &r, TRUE );
+ gdk_window_invalidate_rect(window, &r, true);
}
else
- gdk_window_invalidate_rect( m_wxwindow->window, NULL, TRUE );
+ gdk_window_invalidate_rect(window, NULL, true);
}
}
void wxWindowGTK::Update()
{
- if (m_widget && m_widget->window)
+ if (m_widget && GTK_WIDGET_MAPPED(m_widget))
{
GdkDisplay* display = gtk_widget_get_display(m_widget);
// Flush everything out to the server, and wait for it to finish.
// This ensures nothing will overwrite the drawing we are about to do.
gdk_display_sync(display);
- gdk_window_process_updates(m_widget->window, TRUE);
+ GdkWindow* window = GTKGetDrawingWindow();
+ if (window == NULL)
+ window = m_widget->window;
+ gdk_window_process_updates(window, true);
// Flush again, but no need to wait for it to finish
gdk_display_flush(display);
rect.height = upd.GetHeight();
gtk_paint_flat_box( parent->m_widget->style,
- m_wxwindow->window,
+ GTKGetDrawingWindow(),
(GtkStateType)GTK_WIDGET_STATE(m_wxwindow),
GTK_SHADOW_NONE,
&rect,
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);
+ }
- if (m_wxwindow)
gtk_widget_modify_style(m_wxwindow, style);
+
+ if ( unblock )
+ {
+ g_signal_handlers_unblock_by_func(
+ m_wxwindow, (void *)gtk_window_style_set_callback, this);
+ }
+ }
else
+ {
gtk_widget_modify_style(m_widget, style);
+ }
}
bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style)
GdkWindow *window;
if ( m_wxwindow )
{
- window = m_wxwindow->window;
+ window = GTKGetDrawingWindow();
}
else
{
GdkWindow *wxWindowGTK::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{
- return m_wxwindow ? m_wxwindow->window : m_widget->window;
+ return m_wxwindow ? GTKGetDrawingWindow() : m_widget->window;
}
bool wxWindowGTK::SetFont( const wxFont &font )
GdkWindow *window = NULL;
if (m_wxwindow)
- window = m_wxwindow->window;
+ window = GTKGetDrawingWindow();
else
window = GetConnectWidget()->window;
GdkWindow *window = NULL;
if (m_wxwindow)
- window = m_wxwindow->window;
+ window = GTKGetDrawingWindow();
else
window = GetConnectWidget()->window;
{
GdkWindow* window = NULL;
if (m_wxwindow)
- window = m_wxwindow->window;
+ window = WX_PIZZA(m_wxwindow)->m_draw_window;
return window;
}
// this is called if we attempted to freeze unrealized widget when it finally
// is realized (and so can be frozen):
-static void wx_frozen_widget_realize(GtkWidget* w, void* WXUNUSED(data))
+static void wx_frozen_widget_realize(GtkWidget* w, wxWindowGTK* win)
{
wxASSERT( w && !GTK_WIDGET_NO_WINDOW(w) );
wxASSERT( GTK_WIDGET_REALIZED(w) );
(
w,
(void*)wx_frozen_widget_realize,
- NULL
+ win
);
- gdk_window_freeze_updates(w->window);
+ GdkWindow* window = win->GTKGetDrawingWindow();
+ if (window == NULL)
+ window = w->window;
+ gdk_window_freeze_updates(window);
}
} // extern "C"
w,
"realize",
G_CALLBACK(wx_frozen_widget_realize),
- NULL
+ this
);
return;
}
- gdk_window_freeze_updates(w->window);
+ GdkWindow* window = GTKGetDrawingWindow();
+ if (window == NULL)
+ window = w->window;
+ gdk_window_freeze_updates(window);
}
void wxWindowGTK::GTKThawWidget(GtkWidget *w)
(
w,
(void*)wx_frozen_widget_realize,
- NULL
+ this
);
return;
}
- gdk_window_thaw_updates(w->window);
+ GdkWindow* window = GTKGetDrawingWindow();
+ if (window == NULL)
+ window = w->window;
+ gdk_window_thaw_updates(window);
}
void wxWindowGTK::DoFreeze()