diff options
author | Benjamin Otte <otte@redhat.com> | 2010-09-11 00:08:54 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-09-26 15:11:42 +0200 |
commit | 45836db7a5934f500dabb20d8342a2069a7ba6a6 (patch) | |
tree | 61eb8f0500ff6054faa56fa9254ae92d52e11921 /tests/gtkoffscreenbox.c | |
parent | 8aa402b610a4f383f99b40a880bcf17502ea3a69 (diff) | |
download | gtk+-45836db7a5934f500dabb20d8342a2069a7ba6a6.tar.gz |
test: Port offscreen test to draw vfunc
Diffstat (limited to 'tests/gtkoffscreenbox.c')
-rw-r--r-- | tests/gtkoffscreenbox.c | 145 |
1 files changed, 65 insertions, 80 deletions
diff --git a/tests/gtkoffscreenbox.c b/tests/gtkoffscreenbox.c index a889296135..5374c07484 100644 --- a/tests/gtkoffscreenbox.c +++ b/tests/gtkoffscreenbox.c @@ -17,8 +17,8 @@ static void gtk_offscreen_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static gboolean gtk_offscreen_box_damage (GtkWidget *widget, GdkEventExpose *event); -static gboolean gtk_offscreen_box_expose (GtkWidget *widget, - GdkEventExpose *offscreen); +static gboolean gtk_offscreen_box_draw (GtkWidget *widget, + cairo_t *cr); static void gtk_offscreen_box_add (GtkContainer *container, GtkWidget *child); @@ -117,7 +117,7 @@ gtk_offscreen_box_class_init (GtkOffscreenBoxClass *klass) widget_class->unrealize = gtk_offscreen_box_unrealize; widget_class->size_request = gtk_offscreen_box_size_request; widget_class->size_allocate = gtk_offscreen_box_size_allocate; - widget_class->expose_event = gtk_offscreen_box_expose; + widget_class->draw = gtk_offscreen_box_draw; g_signal_override_class_closure (g_signal_lookup ("damage-event", GTK_TYPE_WIDGET), GTK_TYPE_OFFSCREEN_BOX, @@ -586,88 +586,73 @@ gtk_offscreen_box_damage (GtkWidget *widget, } static gboolean -gtk_offscreen_box_expose (GtkWidget *widget, - GdkEventExpose *event) +gtk_offscreen_box_draw (GtkWidget *widget, + cairo_t *cr) { GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget); GdkWindow *window; - if (gtk_widget_is_drawable (widget)) + window = gtk_widget_get_window (widget); + if (gtk_cairo_should_draw_window (cr, window)) { - window = gtk_widget_get_window (widget); - if (event->window == window) - { - cairo_surface_t *surface; - GtkAllocation child_area; - cairo_t *cr; - int start_y = 0; - - if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1)) - { - surface = gdk_offscreen_window_get_surface (offscreen_box->offscreen_window1); - gtk_widget_get_allocation (offscreen_box->child1, &child_area); - - cr = gdk_cairo_create (window); - - cairo_set_source_surface (cr, surface, 0, 0); - cairo_paint (cr); - - cairo_destroy (cr); - - start_y += child_area.height; - } - - if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2)) - { - gint w, h; - - surface = gdk_offscreen_window_get_surface (offscreen_box->offscreen_window2); - gtk_widget_get_allocation (offscreen_box->child2, &child_area); - - cr = gdk_cairo_create (window); - - /* transform */ - cairo_translate (cr, 0, start_y); - cairo_translate (cr, child_area.width / 2, child_area.height / 2); - cairo_rotate (cr, offscreen_box->angle); - cairo_translate (cr, -child_area.width / 2, -child_area.height / 2); - - /* clip */ - gdk_drawable_get_size (offscreen_box->offscreen_window2, &w, &h); - cairo_rectangle (cr, 0, 0, w, h); - cairo_clip (cr); - - /* paint */ - cairo_set_source_surface (cr, surface, 0, 0); - cairo_paint (cr); - - cairo_destroy (cr); - } - } - else if (event->window == offscreen_box->offscreen_window1) - { - gtk_paint_flat_box (gtk_widget_get_style (widget), event->window, - GTK_STATE_NORMAL, GTK_SHADOW_NONE, - &event->area, widget, "blah", - 0, 0, -1, -1); - - if (offscreen_box->child1) - gtk_container_propagate_expose (GTK_CONTAINER (widget), - offscreen_box->child1, - event); - } - else if (event->window == offscreen_box->offscreen_window2) - { - gtk_paint_flat_box (gtk_widget_get_style (widget), event->window, - GTK_STATE_NORMAL, GTK_SHADOW_NONE, - &event->area, widget, "blah", - 0, 0, -1, -1); - - if (offscreen_box->child2) - gtk_container_propagate_expose (GTK_CONTAINER (widget), - offscreen_box->child2, - event); - } + cairo_surface_t *surface; + GtkAllocation child_area; + + if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1)) + { + surface = gdk_offscreen_window_get_surface (offscreen_box->offscreen_window1); + + cairo_set_source_surface (cr, surface, 0, 0); + cairo_paint (cr); + + gtk_widget_get_allocation (offscreen_box->child1, &child_area); + cairo_translate (cr, 0, child_area.height); + } + + if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2)) + { + surface = gdk_offscreen_window_get_surface (offscreen_box->offscreen_window2); + gtk_widget_get_allocation (offscreen_box->child2, &child_area); + + /* transform */ + cairo_translate (cr, child_area.width / 2, child_area.height / 2); + cairo_rotate (cr, offscreen_box->angle); + cairo_translate (cr, -child_area.width / 2, -child_area.height / 2); + + /* paint */ + cairo_set_source_surface (cr, surface, 0, 0); + cairo_paint (cr); + } + } + else if (gtk_cairo_should_draw_window (cr, offscreen_box->offscreen_window1)) + { + gint w, h; + + gdk_drawable_get_size (offscreen_box->offscreen_window1, &w, &h); + gtk_cairo_paint_flat_box (gtk_widget_get_style (widget), cr, + GTK_STATE_NORMAL, GTK_SHADOW_NONE, + widget, "blah", + 0, 0, w, h); + + if (offscreen_box->child1) + gtk_container_propagate_draw (GTK_CONTAINER (widget), + offscreen_box->child1, + cr); + } + else if (gtk_cairo_should_draw_window (cr, offscreen_box->offscreen_window2)) + { + gint w, h; + + gdk_drawable_get_size (offscreen_box->offscreen_window2, &w, &h); + gtk_cairo_paint_flat_box (gtk_widget_get_style (widget), cr, + GTK_STATE_NORMAL, GTK_SHADOW_NONE, + widget, "blah", + 0, 0, w, h); + + if (offscreen_box->child2) + gtk_container_propagate_draw (GTK_CONTAINER (widget), + offscreen_box->child2, + cr); } return FALSE; |