summaryrefslogtreecommitdiff
path: root/gtk/gtkcellrenderertext.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/gtkcellrenderertext.c
parent872efdd9a527e472e5f2724138344fdef3839df4 (diff)
downloadgdk-pixbuf-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/gtkcellrenderertext.c')
-rw-r--r--gtk/gtkcellrenderertext.c38
1 files changed, 25 insertions, 13 deletions
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));