arrow: Port to draw vfunc

This commit is contained in:
Benjamin Otte 2010-09-04 19:28:22 +02:00
parent 9233a08991
commit 1d5796c95b

View File

@ -74,8 +74,8 @@ 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);
static void gtk_arrow_size_request_init (GtkSizeRequestIface *iface);
static void gtk_arrow_get_width (GtkSizeRequest *widget,
@ -102,7 +102,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,19 +311,15 @@ gtk_arrow_set (GtkArrow *arrow,
static gboolean
gtk_arrow_expose (GtkWidget *widget,
GdkEventExpose *event)
{
if (gtk_widget_is_drawable (widget))
gtk_arrow_draw (GtkWidget *widget,
cairo_t *cr)
{
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 x, y, width, height;
gint extent;
gint xpad, ypad;
gfloat xalign, yalign;
@ -332,13 +328,13 @@ gtk_arrow_expose (GtkWidget *widget,
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;
width = gtk_widget_get_allocated_width (widget);
height = gtk_widget_get_allocated_height (widget);
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)
@ -350,11 +346,10 @@ gtk_arrow_expose (GtkWidget *widget,
effective_arrow_type = GTK_ARROW_LEFT;
}
x = floor (allocation.x + xpad + ((allocation.width - extent) * xalign));
y = floor (allocation.y + ypad + ((allocation.height - extent) * yalign));
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)
@ -369,13 +364,11 @@ gtk_arrow_expose (GtkWidget *widget,
shadow_type = GTK_SHADOW_ETCHED_IN;
}
gtk_paint_arrow (gtk_widget_get_style (widget),
gtk_widget_get_window (widget),
gtk_cairo_paint_arrow (gtk_widget_get_style (widget), cr,
state, shadow_type,
&event->area, widget, "arrow",
widget, "arrow",
effective_arrow_type, TRUE,
x, y, extent, extent);
}
return FALSE;
}