summaryrefslogtreecommitdiff
path: root/gtk/gtkimage.c
diff options
context:
space:
mode:
authorPaolo Borelli <pborelli@gnome.org>2011-12-04 13:55:51 +0100
committerPaolo Borelli <pborelli@gnome.org>2012-01-22 13:36:47 +0100
commite34589ddeab1419a9124062a93ff483c3843a218 (patch)
treee544ef6a3b7eeb98d2f3a06542ae8d8205ac75f1 /gtk/gtkimage.c
parentbf7779bfb71b6e27c90bf4bde246276f014107e7 (diff)
downloadgtk+-e34589ddeab1419a9124062a93ff483c3843a218.tar.gz
Factor out _gtk_misc_get_padding_and_border
The new semi-private function will allow to implement support for css padding and border in widgets inheriting from GtkMisc. Use the new function for GtkLabel, GtkArrow and GtkImage.
Diffstat (limited to 'gtk/gtkimage.c')
-rw-r--r--gtk/gtkimage.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c
index 442e9cb8ff..45a8bba3a7 100644
--- a/gtk/gtkimage.c
+++ b/gtk/gtkimage.c
@@ -1349,15 +1349,16 @@ gtk_image_get_preferred_size (GtkImage *image,
gint *height_out)
{
GtkImagePrivate *priv = image->priv;
- gint xpad, ypad, width, height;
+ gint width, height;
+ GtkBorder border;
GtkStyleContext *context;
context = gtk_widget_get_style_context (GTK_WIDGET (image));
- gtk_misc_get_padding (GTK_MISC (image), &xpad, &ypad);
_gtk_icon_helper_get_size (priv->icon_helper, context, &width, &height);
+ _gtk_misc_get_padding_and_border (GTK_MISC (image), &border);
- width += 2 * xpad;
- height += 2 * ypad;
+ width += border.left + border.right;
+ height += border.top + border.bottom;
if (width_out)
*width_out = width;
@@ -1374,8 +1375,8 @@ gtk_image_draw (GtkWidget *widget,
GtkMisc *misc;
GtkStyleContext *context;
gint x, y, width, height;
- gint xpad, ypad;
gfloat xalign, yalign;
+ GtkBorder border;
g_return_val_if_fail (GTK_IS_IMAGE (widget), FALSE);
@@ -1386,14 +1387,19 @@ gtk_image_draw (GtkWidget *widget,
context = gtk_widget_get_style_context (widget);
gtk_misc_get_alignment (misc, &xalign, &yalign);
- gtk_misc_get_padding (misc, &xpad, &ypad);
gtk_image_get_preferred_size (image, &width, &height);
+ _gtk_misc_get_padding_and_border (misc, &border);
if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
xalign = 1.0 - xalign;
- x = floor (xpad + ((gtk_widget_get_allocated_width (widget) - width) * xalign));
- y = floor (ypad + ((gtk_widget_get_allocated_height (widget) - height) * yalign));
+ x = floor ((gtk_widget_get_allocated_width (widget) - width) * xalign);
+ y = floor ((gtk_widget_get_allocated_height (widget) - height) * yalign);
+
+ gtk_render_frame (context, cr, x, y, width, height);
+
+ x += border.left;
+ y += border.top;
if (gtk_image_get_storage_type (image) == GTK_IMAGE_ANIMATION)
{