X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtkarrow.c;h=fedf544b5e9e59fc6c2297ae12f7d1b7cd3f1d8b;hb=32bd10bf74cd2b7f2d16432d4198dca82c386133;hp=c0c4ccfa7732601b0e5ae77f1da9dc1118517e90;hpb=16877b4d7bef813a42643ae50c14b13dc8302b36;p=~andy%2Fgtk diff --git a/gtk/gtkarrow.c b/gtk/gtkarrow.c index c0c4ccfa7..fedf544b5 100644 --- a/gtk/gtkarrow.c +++ b/gtk/gtkarrow.c @@ -12,9 +12,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * License along with this library. If not, see . */ /* @@ -52,6 +50,8 @@ #include "gtkprivate.h" #include "gtkintl.h" +#include "a11y/gtkarrowaccessible.h" + #define MIN_ARROW_SIZE 15 struct _GtkArrowPrivate @@ -130,6 +130,8 @@ gtk_arrow_class_init (GtkArrowClass *class) GTK_PARAM_READABLE)); g_type_class_add_private (class, sizeof (GtkArrowPrivate)); + + gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_ARROW_ACCESSIBLE); } static void @@ -203,15 +205,15 @@ gtk_arrow_get_preferred_width (GtkWidget *widget, gint *minimum_size, gint *natural_size) { - gint xpad; + GtkBorder border; - gtk_misc_get_padding (GTK_MISC (widget), &xpad, NULL); + _gtk_misc_get_padding_and_border (GTK_MISC (widget), &border); if (minimum_size) - *minimum_size = MIN_ARROW_SIZE + xpad * 2; + *minimum_size = MIN_ARROW_SIZE + border.left + border.right; if (natural_size) - *natural_size = MIN_ARROW_SIZE + xpad * 2; + *natural_size = MIN_ARROW_SIZE + border.left + border.right; } static void @@ -219,18 +221,17 @@ gtk_arrow_get_preferred_height (GtkWidget *widget, gint *minimum_size, gint *natural_size) { - gint ypad; + GtkBorder border; - gtk_misc_get_padding (GTK_MISC (widget), NULL, &ypad); + _gtk_misc_get_padding_and_border (GTK_MISC (widget), &border); if (minimum_size) - *minimum_size = MIN_ARROW_SIZE + ypad * 2; + *minimum_size = MIN_ARROW_SIZE + border.top + border.bottom; if (natural_size) - *natural_size = MIN_ARROW_SIZE + ypad * 2; + *natural_size = MIN_ARROW_SIZE + border.top + border.bottom; } - /** * gtk_arrow_new: * @arrow_type: a valid #GtkArrowType. @@ -302,19 +303,17 @@ gtk_arrow_set (GtkArrow *arrow, } } - static gboolean gtk_arrow_draw (GtkWidget *widget, cairo_t *cr) { GtkArrow *arrow = GTK_ARROW (widget); GtkArrowPrivate *priv = arrow->priv; - GtkMisc *misc = GTK_MISC (widget); GtkStyleContext *context; - GtkStateFlags state; - gint x, y, width, height; + gdouble x, y; + gint width, height; gint extent; - gint xpad, ypad; + GtkBorder border; gfloat xalign, yalign; GtkArrowType effective_arrow_type; gfloat arrow_scaling; @@ -326,13 +325,13 @@ gtk_arrow_draw (GtkWidget *widget, context = gtk_widget_get_style_context (widget); gtk_widget_style_get (widget, "arrow-scaling", &arrow_scaling, NULL); - gtk_misc_get_padding (misc, &xpad, &ypad); - gtk_misc_get_alignment (misc, &xalign, &yalign); + _gtk_misc_get_padding_and_border (GTK_MISC (widget), &border); + gtk_misc_get_alignment (GTK_MISC (widget), &xalign, &yalign); - width = gtk_widget_get_allocated_width (widget); - height = gtk_widget_get_allocated_height (widget); + width = gtk_widget_get_allocated_width (widget) - border.left - border.right; + height = gtk_widget_get_allocated_height (widget) - border.top - border.bottom; - extent = MIN (width - 2 * xpad, height - 2 * ypad) * arrow_scaling; + extent = MIN (width, height) * arrow_scaling; effective_arrow_type = priv->arrow_type; if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR) @@ -344,8 +343,8 @@ gtk_arrow_draw (GtkWidget *widget, effective_arrow_type = GTK_ARROW_LEFT; } - x = floor (xpad + ((width - extent) * xalign)); - y = floor (ypad + ((height - extent) * yalign)); + x = border.left + ((width - extent) * xalign); + y = border.top + ((height - extent) * yalign); switch (effective_arrow_type) { @@ -364,13 +363,7 @@ gtk_arrow_draw (GtkWidget *widget, break; } - gtk_style_context_save (context); - - state = gtk_widget_get_state_flags (widget); - gtk_style_context_set_state (context, state); gtk_render_arrow (context, cr, angle, x, y, extent); - gtk_style_context_restore (context); - return FALSE; }