diff options
author | Matthias Clasen <mclasen@redhat.com> | 2010-10-21 11:41:20 +0200 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2010-10-21 11:41:20 +0200 |
commit | 331323e5c747646b6deb983b8bb61c4ea145f344 (patch) | |
tree | 7acd1ed752702f86f8ab8c083816c3088155cd58 /gtk/gtkspinbutton.c | |
parent | f4d57dbe98bf92ee03f015230c8252f38a50caf8 (diff) | |
download | gtk+-331323e5c747646b6deb983b8bb61c4ea145f344.tar.gz |
Make GtkSpinButton a no-window widget
We still retain an input-only window here for now, but all
the painting is done to the parent window.
Diffstat (limited to 'gtk/gtkspinbutton.c')
-rw-r--r-- | gtk/gtkspinbutton.c | 59 |
1 files changed, 26 insertions, 33 deletions
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index dcda50ceca..849c593aef 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -135,7 +135,7 @@ static void gtk_spin_button_state_changed (GtkWidget *widget, GtkStateType previous_state); static void gtk_spin_button_style_set (GtkWidget *widget, GtkStyle *previous_style); -static void gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, +static void gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, cairo_t *cr, GtkArrowType arrow_type); static gboolean gtk_spin_button_timer (GtkSpinButton *spin_button); @@ -598,7 +598,7 @@ gtk_spin_button_realize (GtkWidget *widget) GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->realize (widget); attributes.window_type = GDK_WINDOW_CHILD; - attributes.wclass = GDK_INPUT_OUTPUT; + attributes.wclass = GDK_INPUT_ONLY; attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK @@ -616,9 +616,6 @@ gtk_spin_button_realize (GtkWidget *widget) &attributes, attributes_mask); gdk_window_set_user_data (priv->panel, widget); - gtk_style_set_background (style, - priv->panel, GTK_STATE_NORMAL); - return_val = FALSE; g_signal_emit (spin_button, spinbutton_signals[OUTPUT], 0, &return_val); if (return_val == FALSE) @@ -784,36 +781,32 @@ gtk_spin_button_draw (GtkWidget *widget, { GtkSpinButton *spin = GTK_SPIN_BUTTON (widget); GtkSpinButtonPrivate *priv = spin->priv; + GtkShadowType shadow_type; + GtkStateType state; GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->draw (widget, cr); - if (gtk_cairo_should_draw_window (cr, priv->panel)) - { - GtkShadowType shadow_type; + cairo_save (cr); - shadow_type = spin_button_get_shadow_type (spin); + shadow_type = spin_button_get_shadow_type (spin); - gtk_cairo_transform_to_window (cr, widget, priv->panel); + state = gtk_widget_has_focus (widget) ? + GTK_STATE_ACTIVE : gtk_widget_get_state (widget); - if (shadow_type != GTK_SHADOW_NONE) - { - GtkStateType state; + gtk_cairo_transform_to_window (cr, widget, priv->panel); - state = gtk_widget_has_focus (widget) ? - GTK_STATE_ACTIVE : gtk_widget_get_state (widget); + gtk_paint_box (gtk_widget_get_style (widget), cr, + state, shadow_type, + widget, "spinbutton", + 0, 0, + gdk_window_get_width (priv->panel), + gdk_window_get_height (priv->panel)); - gtk_paint_box (gtk_widget_get_style (widget), cr, - state, shadow_type, - widget, "spinbutton", - 0, 0, - gdk_window_get_width (priv->panel), - gdk_window_get_height (priv->panel)); - } + gtk_spin_button_draw_arrow (spin, cr, GTK_ARROW_UP); + gtk_spin_button_draw_arrow (spin, cr, GTK_ARROW_DOWN); + + cairo_restore (cr); - gtk_spin_button_draw_arrow (spin, cr, GTK_ARROW_UP); - gtk_spin_button_draw_arrow (spin, cr, GTK_ARROW_DOWN); - } - return FALSE; } @@ -844,18 +837,18 @@ spin_button_at_limit (GtkSpinButton *spin_button, } static void -gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, +gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, cairo_t *cr, GtkArrowType arrow_type) { GtkSpinButtonPrivate *priv; - GtkRequisition requisition; GtkStateType state_type; GtkShadowType shadow_type; GtkStyle *style; GtkWidget *widget; gint x; gint y; + gint panel_height; gint height; gint width; gint h, w; @@ -866,23 +859,23 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, widget = GTK_WIDGET (spin_button); style = gtk_widget_get_style (widget); - gtk_widget_get_preferred_size (widget, &requisition, NULL); width = spin_button_get_arrow_size (spin_button) + 2 * style->xthickness; + panel_height = gdk_window_get_height (priv->panel); if (arrow_type == GTK_ARROW_UP) { x = 0; y = 0; - height = requisition.height / 2; + height = panel_height / 2; } else { x = 0; - y = requisition.height / 2; + y = panel_height / 2; - height = (requisition.height + 1) / 2; + height = (panel_height + 1) / 2; } if (spin_button_at_limit (spin_button, arrow_type)) @@ -919,7 +912,7 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, (arrow_type == GTK_ARROW_UP)? "spinbutton_up" : "spinbutton_down", x, y, width, height); - height = requisition.height; + height = panel_height; if (arrow_type == GTK_ARROW_DOWN) { |