[gtk+/rendering-cleanup-next: 86/153] handlebox: Port to draw vfunc
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/rendering-cleanup-next: 86/153] handlebox: Port to draw vfunc
- Date: Sat, 11 Sep 2010 04:58:40 +0000 (UTC)
commit 4f8554985b36cd0afb5ea27e15c89140ef75c444
Author: Benjamin Otte <otte redhat com>
Date: Wed Sep 8 14:54:15 2010 +0200
handlebox: Port to draw vfunc
gtk/gtkhandlebox.c | 120 ++++++++++++++++++++++++++++------------------------
1 files changed, 65 insertions(+), 55 deletions(-)
---
diff --git a/gtk/gtkhandlebox.c b/gtk/gtkhandlebox.c
index b42dcd6..9ff1aae 100644
--- a/gtk/gtkhandlebox.c
+++ b/gtk/gtkhandlebox.c
@@ -147,11 +147,10 @@ static void gtk_handle_box_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_handle_box_remove (GtkContainer *container,
GtkWidget *widget);
-static void gtk_handle_box_draw_ghost (GtkHandleBox *hb);
-static void gtk_handle_box_paint (GtkWidget *widget,
- GdkEventExpose *event);
-static gboolean gtk_handle_box_expose (GtkWidget *widget,
- GdkEventExpose *event);
+static gboolean gtk_handle_box_draw (GtkWidget *widget,
+ cairo_t *cr,
+ int width,
+ int height);
static gboolean gtk_handle_box_button_press (GtkWidget *widget,
GdkEventButton *event);
static gboolean gtk_handle_box_motion (GtkWidget *widget,
@@ -230,7 +229,7 @@ gtk_handle_box_class_init (GtkHandleBoxClass *class)
widget_class->style_set = gtk_handle_box_style_set;
widget_class->size_request = gtk_handle_box_size_request;
widget_class->size_allocate = gtk_handle_box_size_allocate;
- widget_class->expose_event = gtk_handle_box_expose;
+ widget_class->draw = gtk_handle_box_draw;
widget_class->button_press_event = gtk_handle_box_button_press;
widget_class->delete_event = gtk_handle_box_delete_event;
@@ -722,9 +721,11 @@ gtk_handle_box_size_allocate (GtkWidget *widget,
}
static void
-gtk_handle_box_draw_ghost (GtkHandleBox *hb)
+gtk_handle_box_draw_ghost (GtkHandleBox *hb,
+ cairo_t *cr,
+ int allocation_width,
+ int allocation_height)
{
- GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (hb);
GtkStateType state;
GtkStyle *style;
@@ -735,22 +736,20 @@ gtk_handle_box_draw_ghost (GtkHandleBox *hb)
guint height;
gint handle_position;
- gtk_widget_get_allocation (widget, &allocation);
-
handle_position = effective_handle_position (hb);
if (handle_position == GTK_POS_LEFT ||
handle_position == GTK_POS_RIGHT)
{
- x = handle_position == GTK_POS_LEFT ? 0 : allocation.width - DRAG_HANDLE_SIZE;
+ x = handle_position == GTK_POS_LEFT ? 0 : allocation_width - DRAG_HANDLE_SIZE;
y = 0;
width = DRAG_HANDLE_SIZE;
- height = allocation.height;
+ height = allocation_height;
}
else
{
x = 0;
- y = handle_position == GTK_POS_TOP ? 0 : allocation.height - DRAG_HANDLE_SIZE;
- width = allocation.width;
+ y = handle_position == GTK_POS_TOP ? 0 : allocation_height - DRAG_HANDLE_SIZE;
+ width = allocation_width;
height = DRAG_HANDLE_SIZE;
}
@@ -758,28 +757,32 @@ gtk_handle_box_draw_ghost (GtkHandleBox *hb)
window = gtk_widget_get_window (widget);
state = gtk_widget_get_state (widget);
- gtk_paint_shadow (style, window,
- state, GTK_SHADOW_ETCHED_IN,
- NULL, widget, "handle",
+ gtk_cairo_paint_shadow (style,
+ cr,
+ state,
+ GTK_SHADOW_ETCHED_IN,
+ widget, "handle",
x,
y,
width,
height);
if (handle_position == GTK_POS_LEFT ||
handle_position == GTK_POS_RIGHT)
- gtk_paint_hline (style, window,
- state,
- NULL, widget, "handlebox",
+ gtk_cairo_paint_hline (style,
+ cr,
+ state,
+ widget, "handlebox",
handle_position == GTK_POS_LEFT ? DRAG_HANDLE_SIZE : 0,
- handle_position == GTK_POS_LEFT ? allocation.width : allocation.width - DRAG_HANDLE_SIZE,
- allocation.height / 2);
+ handle_position == GTK_POS_LEFT ? allocation_width : allocation_width - DRAG_HANDLE_SIZE,
+ allocation_height / 2);
else
- gtk_paint_vline (style, window,
- state,
- NULL, widget, "handlebox",
+ gtk_cairo_paint_vline (style,
+ cr,
+ state,
+ widget, "handlebox",
handle_position == GTK_POS_TOP ? DRAG_HANDLE_SIZE : 0,
- handle_position == GTK_POS_TOP ? allocation.height : allocation.height - DRAG_HANDLE_SIZE,
- allocation.width / 2);
+ handle_position == GTK_POS_TOP ? allocation_height : allocation_height - DRAG_HANDLE_SIZE,
+ allocation_width / 2);
}
void
@@ -911,27 +914,36 @@ gtk_handle_box_get_child_detached (GtkHandleBox *handle_box)
static void
gtk_handle_box_paint (GtkWidget *widget,
- GdkEventExpose *event)
+ cairo_t *cr,
+ int w,
+ int h)
{
GtkHandleBox *hb = GTK_HANDLE_BOX (widget);
GtkHandleBoxPrivate *priv = hb->priv;
GtkBin *bin = GTK_BIN (widget);
GtkWidget *child;
- gint width, height;
+ gint x, y, width, height;
GdkRectangle rect;
gint handle_position;
GtkOrientation handle_orientation;
handle_position = effective_handle_position (hb);
+ cairo_save (cr);
+
+ gdk_window_get_origin (gtk_widget_get_window (widget), &x, &y);
+ cairo_translate (cr, -x, -y);
+ gdk_window_get_origin (priv->bin_window, &x, &y);
+ cairo_translate (cr, x, y);
+
gdk_drawable_get_size (priv->bin_window, &width, &height);
- gtk_paint_box (gtk_widget_get_style (widget),
- priv->bin_window,
+ gtk_cairo_paint_box (gtk_widget_get_style (widget),
+ cr,
gtk_widget_get_state (widget),
priv->shadow_type,
- &event->area, widget, "handlebox_bin",
- 0, 0, -1, -1);
+ widget, "handlebox_bin",
+ 0, 0, width, height);
switch (handle_position)
{
@@ -968,38 +980,36 @@ gtk_handle_box_paint (GtkWidget *widget,
break;
}
- if (gdk_rectangle_intersect (&event->area, &rect, NULL))
- gtk_paint_handle (gtk_widget_get_style (widget), priv->bin_window,
- GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- &event->area, widget, "handlebox",
- rect.x, rect.y, rect.width, rect.height,
- handle_orientation);
+ gtk_cairo_paint_handle (gtk_widget_get_style (widget), cr,
+ GTK_STATE_NORMAL, GTK_SHADOW_OUT,
+ widget, "handlebox",
+ rect.x, rect.y, rect.width, rect.height,
+ handle_orientation);
+
+ cairo_restore (cr);
child = gtk_bin_get_child (bin);
if (child != NULL && gtk_widget_get_visible (child))
- GTK_WIDGET_CLASS (gtk_handle_box_parent_class)->expose_event (widget, event);
+ GTK_WIDGET_CLASS (gtk_handle_box_parent_class)->draw (widget, cr, w, h);
}
static gboolean
-gtk_handle_box_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gtk_handle_box_draw (GtkWidget *widget,
+ cairo_t *cr,
+ int width,
+ int height)
{
- GtkHandleBox *hb;
- GtkHandleBoxPrivate *priv;
+ GtkHandleBox *hb = GTK_HANDLE_BOX (widget);
+ GtkHandleBoxPrivate *priv = hb->priv;
- if (gtk_widget_is_drawable (widget))
+ if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
{
- hb = GTK_HANDLE_BOX (widget);
- priv = hb->priv;
-
- if (event->window == gtk_widget_get_window (widget))
- {
- if (priv->child_detached)
- gtk_handle_box_draw_ghost (hb);
- }
- else
- gtk_handle_box_paint (widget, event);
+ if (priv->child_detached)
+ gtk_handle_box_draw_ghost (hb, cr, width, height);
}
+
+ if (gtk_cairo_should_draw_window (cr, priv->bin_window))
+ gtk_handle_box_paint (widget, cr, width, height);
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]