spinbutton: Port to draw vfunc

This commit is contained in:
Benjamin Otte 2010-09-09 21:22:43 +02:00
parent d13a2ad66a
commit 5228913f68

View File

@ -116,8 +116,8 @@ static void gtk_spin_button_size_request (GtkWidget *widget,
GtkRequisition *requisition); GtkRequisition *requisition);
static void gtk_spin_button_size_allocate (GtkWidget *widget, static void gtk_spin_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static gint gtk_spin_button_expose (GtkWidget *widget, static gint gtk_spin_button_draw (GtkWidget *widget,
GdkEventExpose *event); cairo_t *cr);
static gint gtk_spin_button_button_press (GtkWidget *widget, static gint gtk_spin_button_button_press (GtkWidget *widget,
GdkEventButton *event); GdkEventButton *event);
static gint gtk_spin_button_button_release (GtkWidget *widget, static gint gtk_spin_button_button_release (GtkWidget *widget,
@ -137,7 +137,7 @@ static void gtk_spin_button_state_changed (GtkWidget *widget,
static void gtk_spin_button_style_set (GtkWidget *widget, static void gtk_spin_button_style_set (GtkWidget *widget,
GtkStyle *previous_style); GtkStyle *previous_style);
static void gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, static void gtk_spin_button_draw_arrow (GtkSpinButton *spin_button,
GdkRectangle *area, cairo_t *cr,
GtkArrowType arrow_type); GtkArrowType arrow_type);
static gboolean gtk_spin_button_timer (GtkSpinButton *spin_button); static gboolean gtk_spin_button_timer (GtkSpinButton *spin_button);
static void gtk_spin_button_stop_spinning (GtkSpinButton *spin); static void gtk_spin_button_stop_spinning (GtkSpinButton *spin);
@ -206,7 +206,7 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
widget_class->unrealize = gtk_spin_button_unrealize; widget_class->unrealize = gtk_spin_button_unrealize;
widget_class->size_request = gtk_spin_button_size_request; widget_class->size_request = gtk_spin_button_size_request;
widget_class->size_allocate = gtk_spin_button_size_allocate; widget_class->size_allocate = gtk_spin_button_size_allocate;
widget_class->expose_event = gtk_spin_button_expose; widget_class->draw = gtk_spin_button_draw;
widget_class->scroll_event = gtk_spin_button_scroll; widget_class->scroll_event = gtk_spin_button_scroll;
widget_class->button_press_event = gtk_spin_button_button_press; widget_class->button_press_event = gtk_spin_button_button_press;
widget_class->button_release_event = gtk_spin_button_button_release; widget_class->button_release_event = gtk_spin_button_button_release;
@ -783,20 +783,24 @@ gtk_spin_button_size_allocate (GtkWidget *widget,
} }
static gint static gint
gtk_spin_button_expose (GtkWidget *widget, gtk_spin_button_draw (GtkWidget *widget,
GdkEventExpose *event) cairo_t *cr)
{ {
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget); GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin->priv; GtkSpinButtonPrivate *priv = spin->priv;
if (gtk_widget_is_drawable (widget)) GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->draw (widget, cr);
{
if (event->window == priv->panel) if (gtk_cairo_should_draw_window (cr, priv->panel))
{ {
GtkShadowType shadow_type; GtkShadowType shadow_type;
int x, y;
shadow_type = spin_button_get_shadow_type (spin); shadow_type = spin_button_get_shadow_type (spin);
gdk_window_get_position (priv->panel, &x, &y);
cairo_translate (cr, x, y);
if (shadow_type != GTK_SHADOW_NONE) if (shadow_type != GTK_SHADOW_NONE)
{ {
gint width, height; gint width, height;
@ -807,17 +811,14 @@ gtk_spin_button_expose (GtkWidget *widget,
gdk_drawable_get_size (priv->panel, &width, &height); gdk_drawable_get_size (priv->panel, &width, &height);
gtk_paint_box (gtk_widget_get_style (widget), priv->panel, gtk_cairo_paint_box (gtk_widget_get_style (widget), cr,
state, shadow_type, state, shadow_type,
&event->area, widget, "spinbutton", widget, "spinbutton",
0, 0, width, height); 0, 0, width, height);
} }
gtk_spin_button_draw_arrow (spin, &event->area, GTK_ARROW_UP); gtk_spin_button_draw_arrow (spin, cr, GTK_ARROW_UP);
gtk_spin_button_draw_arrow (spin, &event->area, GTK_ARROW_DOWN); gtk_spin_button_draw_arrow (spin, cr, GTK_ARROW_DOWN);
}
else
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->expose_event (widget, event);
} }
return FALSE; return FALSE;
@ -851,10 +852,11 @@ spin_button_at_limit (GtkSpinButton *spin_button,
static void static void
gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, gtk_spin_button_draw_arrow (GtkSpinButton *spin_button,
GdkRectangle *area, cairo_t *cr,
GtkArrowType arrow_type) GtkArrowType arrow_type)
{ {
GtkSpinButtonPrivate *priv; GtkSpinButtonPrivate *priv;
GtkRequisition requisition;
GtkStateType state_type; GtkStateType state_type;
GtkShadowType shadow_type; GtkShadowType shadow_type;
GtkStyle *style; GtkStyle *style;
@ -870,10 +872,6 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button,
priv = spin_button->priv; priv = spin_button->priv;
widget = GTK_WIDGET (spin_button); widget = GTK_WIDGET (spin_button);
if (gtk_widget_is_drawable (widget))
{
GtkRequisition requisition;
style = gtk_widget_get_style (widget); style = gtk_widget_get_style (widget);
gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), &requisition, NULL); gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), &requisition, NULL);
@ -922,9 +920,9 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button,
} }
} }
gtk_paint_box (style, priv->panel, gtk_cairo_paint_box (style, cr,
state_type, shadow_type, state_type, shadow_type,
area, widget, widget,
(arrow_type == GTK_ARROW_UP)? "spinbutton_up" : "spinbutton_down", (arrow_type == GTK_ARROW_UP)? "spinbutton_up" : "spinbutton_down",
x, y, width, height); x, y, width, height);
@ -958,13 +956,12 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button,
height = h; height = h;
width = w; width = w;
gtk_paint_arrow (style, priv->panel, gtk_cairo_paint_arrow (style, cr,
state_type, shadow_type, state_type, shadow_type,
area, widget, "spinbutton", widget, "spinbutton",
arrow_type, TRUE, arrow_type, TRUE,
x, y, width, height); x, y, width, height);
} }
}
static gint static gint
gtk_spin_button_enter_notify (GtkWidget *widget, gtk_spin_button_enter_notify (GtkWidget *widget,