summaryrefslogtreecommitdiff
path: root/gtk/gtkcellrendererpixbuf.c
diff options
context:
space:
mode:
authorJonathan Blandford <jrb@redhat.com>2001-03-15 23:21:39 +0000
committerJonathan Blandford <jrb@src.gnome.org>2001-03-15 23:21:39 +0000
commite4d1660042a437b041422ac442ee4845fbf7e6b6 (patch)
tree10b09bc64b280eb911725d9060d0e721419b961d /gtk/gtkcellrendererpixbuf.c
parent872efdd9a527e472e5f2724138344fdef3839df4 (diff)
downloadgtk+-e4d1660042a437b041422ac442ee4845fbf7e6b6.tar.gz
Changed prototype to allow for getting the location of the cell relative
Thu Mar 15 18:22:44 2001 Jonathan Blandford <jrb@redhat.com> * gtk/gtkcellrenderer.h: Changed prototype to allow for getting the location of the cell relative to its area. * gtk/gtkcell*: modified for above change * gtk/gtktreeview.c: modified for above change. Wed Mar 14 13:58:32 2001 Jonathan Blandford <jrb@redhat.com> * gtk/gtktreeview.c (gtk_tree_view_set_model): Ref the model. (gtk_tree_view_finalize): actually unref the model. Thanks to Jamie Strachan <frostfreek@yahoo.com> for noticing this error.
Diffstat (limited to 'gtk/gtkcellrendererpixbuf.c')
-rw-r--r--gtk/gtkcellrendererpixbuf.c60
1 files changed, 44 insertions, 16 deletions
diff --git a/gtk/gtkcellrendererpixbuf.c b/gtk/gtkcellrendererpixbuf.c
index 67db583562..36ead4e08b 100644
--- a/gtk/gtkcellrendererpixbuf.c
+++ b/gtk/gtkcellrendererpixbuf.c
@@ -33,6 +33,9 @@ static void gtk_cell_renderer_pixbuf_init (GtkCellRendererPixbuf *cel
static void gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class);
static void gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *rectangle,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height);
static void gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell,
@@ -172,18 +175,47 @@ gtk_cell_renderer_pixbuf_new (void)
static void
gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height)
{
GtkCellRendererPixbuf *cellpixbuf = (GtkCellRendererPixbuf *) cell;
+ GdkPixbuf *pixbuf;
+ gint calc_width;
+ gint calc_height;
+
+ pixbuf = cellpixbuf->pixbuf;
+
+ calc_width = (gint) GTK_CELL_RENDERER (cellpixbuf)->xpad * 2 +
+ (cellpixbuf->pixbuf ? gdk_pixbuf_get_width (cellpixbuf->pixbuf) : 0);
- if (width)
- *width = (gint) GTK_CELL_RENDERER (cellpixbuf)->xpad * 2 +
- (cellpixbuf->pixbuf ? gdk_pixbuf_get_width (cellpixbuf->pixbuf) : 0);
+ calc_height = (gint) GTK_CELL_RENDERER (cellpixbuf)->ypad * 2 +
+ (cellpixbuf->pixbuf ? gdk_pixbuf_get_height (cellpixbuf->pixbuf) : 0);
+
+ if (x_offset) *x_offset = 0;
+ if (y_offset) *y_offset = 0;
+
+ if (cell_area && pixbuf)
+ {
+ if (x_offset)
+ {
+ *x_offset = GTK_CELL_RENDERER (cellpixbuf)->xalign * (cell_area->width - calc_width - (2 * GTK_CELL_RENDERER (cellpixbuf)->xpad));
+ *x_offset = MAX (*x_offset, 0) + GTK_CELL_RENDERER (cellpixbuf)->xpad;
+ }
+ if (y_offset)
+ {
+ *y_offset = GTK_CELL_RENDERER (cellpixbuf)->yalign * (cell_area->height - calc_height - (2 * GTK_CELL_RENDERER (cellpixbuf)->ypad));
+ *y_offset = MAX (*y_offset, 0) + GTK_CELL_RENDERER (cellpixbuf)->ypad;
+ }
+ }
+
+ if (calc_width)
+ *width = calc_width;
if (height)
- *height = (gint) GTK_CELL_RENDERER (cellpixbuf)->ypad * 2 +
- (cellpixbuf->pixbuf ? gdk_pixbuf_get_height (cellpixbuf->pixbuf) : 0);
+ *height = calc_height;
}
static void
@@ -200,8 +232,6 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell,
GdkPixbuf *pixbuf;
guchar *pixels;
gint rowstride;
- gint real_xoffset;
- gint real_yoffset;
GdkRectangle pix_rect;
GdkRectangle draw_rect;
@@ -213,15 +243,13 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell,
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
pixels = gdk_pixbuf_get_pixels (pixbuf);
- real_xoffset = GTK_CELL_RENDERER (cellpixbuf)->xalign * (cell_area->width - gdk_pixbuf_get_width (pixbuf) - (2 * GTK_CELL_RENDERER (cellpixbuf)->xpad));
- real_xoffset = MAX (real_xoffset, 0) + GTK_CELL_RENDERER (cellpixbuf)->xpad;
- real_yoffset = GTK_CELL_RENDERER (cellpixbuf)->yalign * (cell_area->height - gdk_pixbuf_get_height (pixbuf) - (2 * GTK_CELL_RENDERER (cellpixbuf)->ypad));
- real_yoffset = MAX (real_yoffset, 0) + GTK_CELL_RENDERER (cellpixbuf)->ypad;
-
- pix_rect.x = cell_area->x + real_xoffset;
- pix_rect.y = cell_area->y + real_yoffset;
- pix_rect.width = gdk_pixbuf_get_width (pixbuf);
- pix_rect.height = gdk_pixbuf_get_height (pixbuf);
+ gtk_cell_renderer_pixbuf_get_size (cell, widget, cell_area,
+ &pix_rect.x,
+ &pix_rect.x,
+ &pix_rect.width,
+ &pix_rect.height);
+ pix_rect.x += cell_area->x;
+ pix_rect.y += cell_area->y;
if (gdk_rectangle_intersect (cell_area, &pix_rect, &draw_rect))
gdk_pixbuf_render_to_drawable_alpha (pixbuf,