From e4d1660042a437b041422ac442ee4845fbf7e6b6 Mon Sep 17 00:00:00 2001 From: Jonathan Blandford Date: Thu, 15 Mar 2001 23:21:39 +0000 Subject: Changed prototype to allow for getting the location of the cell relative Thu Mar 15 18:22:44 2001 Jonathan Blandford * 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 * gtk/gtktreeview.c (gtk_tree_view_set_model): Ref the model. (gtk_tree_view_finalize): actually unref the model. Thanks to Jamie Strachan for noticing this error. --- gtk/gtkcellrenderertext.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'gtk/gtkcellrenderertext.c') diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c index 8e297cd84..c3a0e52cd 100644 --- a/gtk/gtkcellrenderertext.c +++ b/gtk/gtkcellrenderertext.c @@ -35,6 +35,9 @@ static void gtk_cell_renderer_text_set_property (GObject *obje GParamSpec *pspec); static void gtk_cell_renderer_text_get_size (GtkCellRenderer *cell, GtkWidget *widget, + GdkRectangle *cell_area, + gint *x_offset, + gint *y_offset, gint *width, gint *height); static void gtk_cell_renderer_text_render (GtkCellRenderer *cell, @@ -1048,6 +1051,9 @@ get_layout (GtkCellRendererText *celltext, static void gtk_cell_renderer_text_get_size (GtkCellRenderer *cell, GtkWidget *widget, + GdkRectangle *cell_area, + gint *x_offset, + gint *y_offset, gint *width, gint *height) { @@ -1056,7 +1062,6 @@ gtk_cell_renderer_text_get_size (GtkCellRenderer *cell, PangoLayout *layout; layout = get_layout (celltext, widget, FALSE, 0); - pango_layout_get_pixel_extents (layout, NULL, &rect); if (width) @@ -1065,6 +1070,20 @@ gtk_cell_renderer_text_get_size (GtkCellRenderer *cell, if (height) *height = GTK_CELL_RENDERER (celltext)->ypad * 2 + rect.height; + if (cell_area) + { + if (x_offset) + { + *x_offset = cell->xalign * (cell_area->width - rect.width - (2 * cell->xpad)); + *x_offset = MAX (*x_offset, 0) + cell->xpad; + } + if (y_offset) + { + *y_offset = cell->yalign * (cell_area->height - rect.height - (2 * cell->ypad)); + *y_offset = MAX (*y_offset, 0) + cell->ypad; + } + } + g_object_unref (G_OBJECT (layout)); } @@ -1079,21 +1098,14 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell, { GtkCellRendererText *celltext = (GtkCellRendererText *) cell; - PangoRectangle rect; PangoLayout *layout; GtkStateType state; - - gint real_xoffset; - gint real_yoffset; + gint x_offset; + gint y_offset; layout = get_layout (celltext, widget, TRUE, flags); - pango_layout_get_pixel_extents (layout, NULL, &rect); - - real_xoffset = cell->xalign * (cell_area->width - rect.width - (2 * cell->xpad)); - real_xoffset = MAX (real_xoffset, 0) + cell->xpad; - real_yoffset = cell->yalign * (cell_area->height - rect.height - (2 * cell->ypad)); - real_yoffset = MAX (real_yoffset, 0) + cell->ypad; + gtk_cell_renderer_text_get_size (cell, widget, cell_area, &x_offset, &y_offset, NULL, NULL); if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED) state = GTK_STATE_SELECTED; @@ -1130,8 +1142,8 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell, cell_area, widget, "cellrenderertext", - cell_area->x + real_xoffset, - cell_area->y + real_yoffset, + cell_area->x + x_offset, + cell_area->y + y_offset, layout); g_object_unref (G_OBJECT (layout)); -- cgit v1.2.1