[gtk+/rendering-cleanup-next: 26/153] arrow: Port to draw vfunc
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/rendering-cleanup-next: 26/153] arrow: Port to draw vfunc
- Date: Sat, 11 Sep 2010 04:53:37 +0000 (UTC)
commit c5a346dc0a70a1f8e5fe7878c0b65b366a29dd78
Author: Benjamin Otte <otte redhat com>
Date: Sat Sep 4 19:28:22 2010 +0200
arrow: Port to draw vfunc
gtk/gtkarrow.c | 124 ++++++++++++++++++++++++++-----------------------------
1 files changed, 59 insertions(+), 65 deletions(-)
---
diff --git a/gtk/gtkarrow.c b/gtk/gtkarrow.c
index 414fc18..4ba9a16 100644
--- a/gtk/gtkarrow.c
+++ b/gtk/gtkarrow.c
@@ -74,8 +74,10 @@ static void gtk_arrow_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
-static gboolean gtk_arrow_expose (GtkWidget *widget,
- GdkEventExpose *event);
+static gboolean gtk_arrow_draw (GtkWidget *widget,
+ cairo_t *cr,
+ int width,
+ int height);
static void gtk_arrow_size_request_init (GtkSizeRequestIface *iface);
static void gtk_arrow_get_width (GtkSizeRequest *widget,
@@ -102,7 +104,7 @@ gtk_arrow_class_init (GtkArrowClass *class)
gobject_class->set_property = gtk_arrow_set_property;
gobject_class->get_property = gtk_arrow_get_property;
- widget_class->expose_event = gtk_arrow_expose;
+ widget_class->draw = gtk_arrow_draw;
g_object_class_install_property (gobject_class,
PROP_ARROW_TYPE,
@@ -311,71 +313,63 @@ gtk_arrow_set (GtkArrow *arrow,
static gboolean
-gtk_arrow_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gtk_arrow_draw (GtkWidget *widget,
+ cairo_t *cr,
+ int width,
+ int height)
{
- if (gtk_widget_is_drawable (widget))
+ GtkArrow *arrow = GTK_ARROW (widget);
+ GtkArrowPrivate *priv = arrow->priv;
+ GtkMisc *misc = GTK_MISC (widget);
+ GtkShadowType shadow_type;
+ GtkStateType state;
+ gint x, y;
+ gint extent;
+ gint xpad, ypad;
+ gfloat xalign, yalign;
+ GtkArrowType effective_arrow_type;
+ gfloat arrow_scaling;
+
+ gtk_widget_style_get (widget, "arrow-scaling", &arrow_scaling, NULL);
+
+ gtk_misc_get_padding (misc, &xpad, &ypad);
+ gtk_misc_get_alignment (misc, &xalign, &yalign);
+
+ extent = MIN (width - 2 * xpad, height - 2 * ypad) * arrow_scaling;
+ effective_arrow_type = priv->arrow_type;
+
+ if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
{
- GtkArrow *arrow = GTK_ARROW (widget);
- GtkArrowPrivate *priv = arrow->priv;
- GtkAllocation allocation;
- GtkMisc *misc = GTK_MISC (widget);
- GtkShadowType shadow_type;
- GtkStateType state;
- gint width, height;
- gint x, y;
- gint extent;
- gint xpad, ypad;
- gfloat xalign, yalign;
- GtkArrowType effective_arrow_type;
- gfloat arrow_scaling;
-
- gtk_widget_style_get (widget, "arrow-scaling", &arrow_scaling, NULL);
-
- gtk_widget_get_allocation (widget, &allocation);
- gtk_misc_get_padding (misc, &xpad, &ypad);
- gtk_misc_get_alignment (misc, &xalign, &yalign);
-
- width = allocation.width - xpad * 2;
- height = allocation.height - ypad * 2;
- extent = MIN (width, height) * arrow_scaling;
- effective_arrow_type = priv->arrow_type;
-
- if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
- {
- xalign = 1.0 - xalign;
- if (priv->arrow_type == GTK_ARROW_LEFT)
- effective_arrow_type = GTK_ARROW_RIGHT;
- else if (priv->arrow_type == GTK_ARROW_RIGHT)
- effective_arrow_type = GTK_ARROW_LEFT;
- }
-
- x = floor (allocation.x + xpad + ((allocation.width - extent) * xalign));
- y = floor (allocation.y + ypad + ((allocation.height - extent) * yalign));
-
- shadow_type = priv->shadow_type;
-
- state = gtk_widget_get_state (widget);
-
- if (state == GTK_STATE_ACTIVE)
- {
- if (shadow_type == GTK_SHADOW_IN)
- shadow_type = GTK_SHADOW_OUT;
- else if (shadow_type == GTK_SHADOW_OUT)
- shadow_type = GTK_SHADOW_IN;
- else if (shadow_type == GTK_SHADOW_ETCHED_IN)
- shadow_type = GTK_SHADOW_ETCHED_OUT;
- else if (shadow_type == GTK_SHADOW_ETCHED_OUT)
- shadow_type = GTK_SHADOW_ETCHED_IN;
- }
-
- gtk_paint_arrow (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
- state, shadow_type,
- &event->area, widget, "arrow",
- effective_arrow_type, TRUE,
- x, y, extent, extent);
+ xalign = 1.0 - xalign;
+ if (priv->arrow_type == GTK_ARROW_LEFT)
+ effective_arrow_type = GTK_ARROW_RIGHT;
+ else if (priv->arrow_type == GTK_ARROW_RIGHT)
+ effective_arrow_type = GTK_ARROW_LEFT;
}
+ x = floor (xpad + ((width - extent) * xalign));
+ y = floor (ypad + ((height - extent) * yalign));
+
+ shadow_type = priv->shadow_type;
+ state = gtk_widget_get_state (widget);
+
+ if (state == GTK_STATE_ACTIVE)
+ {
+ if (shadow_type == GTK_SHADOW_IN)
+ shadow_type = GTK_SHADOW_OUT;
+ else if (shadow_type == GTK_SHADOW_OUT)
+ shadow_type = GTK_SHADOW_IN;
+ else if (shadow_type == GTK_SHADOW_ETCHED_IN)
+ shadow_type = GTK_SHADOW_ETCHED_OUT;
+ else if (shadow_type == GTK_SHADOW_ETCHED_OUT)
+ shadow_type = GTK_SHADOW_ETCHED_IN;
+ }
+
+ gtk_cairo_paint_arrow (gtk_widget_get_style (widget), cr,
+ state, shadow_type,
+ widget, "arrow",
+ effective_arrow_type, TRUE,
+ x, y, extent, extent);
+
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]