Commit e4d16600 authored by Jonathan Blandford's avatar Jonathan Blandford Committed by Jonathan Blandford

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.
parent 872efdd9
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.
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
......@@ -17,7 +30,7 @@
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
......
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.
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
......@@ -17,7 +30,7 @@
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
......
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.
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
......@@ -17,7 +30,7 @@
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
......
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.
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
......@@ -17,7 +30,7 @@
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
......
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.
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
......@@ -17,7 +30,7 @@
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
......
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.
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
......@@ -17,7 +30,7 @@
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
......
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.
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
......@@ -17,7 +30,7 @@
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
......
......@@ -34,6 +34,7 @@ static void gtk_cell_renderer_set_property (GObject *object,
enum {
PROP_ZERO,
PROP_CAN_ACTIVATE,
PROP_VISIBLE,
PROP_XALIGN,
PROP_YALIGN,
......@@ -75,6 +76,7 @@ gtk_cell_renderer_init (GtkCellRenderer *cell)
gtk_object_ref (GTK_OBJECT (cell));
gtk_object_sink (GTK_OBJECT (cell));
cell->can_activate = FALSE;
cell->visible = TRUE;
cell->xalign = 0.5;
cell->yalign = 0.5;
......@@ -93,6 +95,15 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
class->render = NULL;
class->get_size = NULL;
g_object_class_install_property (object_class,
PROP_CAN_ACTIVATE,
g_param_spec_boolean ("can_activate",
_("can_activate"),
_("Cell can get activate events."),
FALSE,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_VISIBLE,
g_param_spec_boolean ("visible",
......@@ -101,7 +112,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
TRUE,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_XALIGN,
g_param_spec_float ("xalign",
......@@ -112,7 +123,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
0.0,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_YALIGN,
g_param_spec_float ("yalign",
......@@ -123,7 +134,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
0.5,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_XPAD,
g_param_spec_uint ("xpad",
......@@ -134,7 +145,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
2,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_YPAD,
g_param_spec_uint ("ypad",
......@@ -157,6 +168,9 @@ gtk_cell_renderer_get_property (GObject *object,
switch (param_id)
{
case PROP_CAN_ACTIVATE:
g_value_set_boolean (value, cell->can_activate);
break;
case PROP_VISIBLE:
g_value_set_boolean (value, cell->visible);
break;
......@@ -189,6 +203,10 @@ gtk_cell_renderer_set_property (GObject *object,
switch (param_id)
{
case PROP_CAN_ACTIVATE:
cell->can_activate = g_value_get_boolean (value);
g_object_notify (object, "can_activate");
break;
case PROP_VISIBLE:
cell->visible = g_value_get_boolean (value);
g_object_notify (object, "visible");
......@@ -219,23 +237,30 @@ gtk_cell_renderer_set_property (GObject *object,
* gtk_cell_renderer_get_size:
* @cell: a #GtkCellRenderer
* @widget: the widget the renderer is rendering to
* @cell_area: The area a cell will be allocated, or %NULL
* @x_offset: location to return x offset of cell relative to @cell_area, or %NULL
* @y_offset: location to return y offset of cell relative to @cell_area, or %NULL
* @width: location to return width needed to render a cell, or %NULL
* @height: location to return height needed to render a cell, or %NULL
*
* Obtains the width and height needed to render the cell. Used by
* view widgets to determine the appropriate size for the cell_area
* passed to gtk_cell_renderer_render().
*
* Obtains the width and height needed to render the cell. Used by view widgets
* to determine the appropriate size for the cell_area passed to
* gtk_cell_renderer_render(). If @cell_area is not %NULL, fills in the x and y
* offsets (if set) of the cell relative to this location.
**/
void
gtk_cell_renderer_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
gint *width,
gint *height)
GtkWidget *widget,
GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height)
{
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->get_size != NULL);
GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (cell, widget, width, height);
GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (cell, widget, cell_area, x_offset, y_offset, width, height);
}
/**
......@@ -257,7 +282,7 @@ gtk_cell_renderer_get_size (GtkCellRenderer *cell,
* @background_area rectangles for all cells tile to cover the entire
* @window. Cell renderers can use the @background_area to draw custom expanders, for
* example. @expose_area is a clip rectangle.
*
*
**/
void
gtk_cell_renderer_render (GtkCellRenderer *cell,
......@@ -294,11 +319,11 @@ gtk_cell_renderer_render (GtkCellRenderer *cell,
* @background_area: background area as passed to gtk_cell_renderer_render()
* @cell_area: cell area as passed to gtk_cell_renderer_render()
* @flags: render flags
*
*
* Passes an event to the cell renderer for possible processing. Some
* cell renderers may use events; for example, #GtkCellRendererToggle
* toggles when it gets a mouse click.
*
*
* Return value: %TRUE if the event was consumed/handled
**/
gint
......
......@@ -51,6 +51,7 @@ struct _GtkCellRenderer
{
GtkObject parent;
gboolean can_activate;
gboolean visible;
gfloat xalign;
......@@ -67,6 +68,9 @@ struct _GtkCellRendererClass
/* vtable - not signals */
void (* get_size) (GtkCellRenderer *cell,
GtkWidget *widget,
GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height);
......@@ -90,6 +94,9 @@ struct _GtkCellRendererClass
GtkType gtk_cell_renderer_get_type (void);
void gtk_cell_renderer_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height);
void gtk_cell_renderer_render (GtkCellRenderer *cell,
......
......@@ -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,
......
......@@ -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));
......
......@@ -44,6 +44,9 @@ static void gtk_cell_renderer_text_pixbuf_init (GtkCellRendererTextPixbuf
static void gtk_cell_renderer_text_pixbuf_class_init (GtkCellRendererTextPixbufClass *class);
static void gtk_cell_renderer_text_pixbuf_get_size (GtkCellRenderer *cell,
GtkWidget *view,
GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height);
static void gtk_cell_renderer_text_pixbuf_render (GtkCellRenderer *cell,
......@@ -285,6 +288,9 @@ gtk_cell_renderer_text_pixbuf_new (void)
typedef void (* CellSizeFunc) (GtkCellRenderer *cell,
GtkWidget *widget,
GdkRectangle *rectangle,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height);
typedef void (* CellRenderFunc) (GtkCellRenderer *cell,
......@@ -298,6 +304,9 @@ typedef void (* CellRenderFunc) (GtkCellRenderer *cell,
static void
gtk_cell_renderer_text_pixbuf_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height)
{
......@@ -306,26 +315,44 @@ gtk_cell_renderer_text_pixbuf_get_size (GtkCellRenderer *cell,
gint pixbuf_height;
gint text_width;
gint text_height;
(* GTK_CELL_RENDERER_CLASS (parent_class)->get_size) (cell, widget, &text_width, &text_height);
gint calc_width;
gint calc_height;
(* GTK_CELL_RENDERER_CLASS (parent_class)->get_size) (cell, widget, NULL, NULL, NULL, &text_width, &text_height);
(* GTK_CELL_RENDERER_CLASS (G_OBJECT_GET_CLASS (celltextpixbuf->pixbuf))->get_size) (GTK_CELL_RENDERER (celltextpixbuf->pixbuf),
widget,
NULL, NULL, NULL,
&pixbuf_width,
&pixbuf_height);
if (celltextpixbuf->pixbuf_pos == GTK_POS_LEFT ||
celltextpixbuf->pixbuf_pos == GTK_POS_RIGHT)
{
if (width)
*width = pixbuf_width + text_width;
if (height)
*height = MAX (pixbuf_height, text_height);
calc_width = pixbuf_width + text_width;
calc_height = MAX (pixbuf_height, text_height);
}
else
{
if (width)
*width = MAX (pixbuf_width, text_width);
if (height)
*height = pixbuf_height + text_height;
calc_width = MAX (pixbuf_width, text_width);
calc_height = pixbuf_height + text_height;
}
if (width)
*width = calc_width;
if (height)
*height = calc_height;
if (cell_area)
{
if (x_offset)
{
*x_offset = cell->xalign * (cell_area->width - calc_width - (2 * cell->xpad));
*x_offset = MAX (*x_offset, 0) + cell->xpad;
}
if (y_offset)
{
*y_offset = cell->yalign * (cell_area->height - calc_height - (2 * cell->ypad));
*y_offset = MAX (*y_offset, 0) + cell->ypad;
}
}
}
......@@ -369,7 +396,7 @@ gtk_cell_renderer_text_pixbuf_render (GtkCellRenderer *cell,
cell2 = GTK_CELL_RENDERER (celltextpixbuf->pixbuf);
}
(size_func1) (cell1, widget, &tmp_width, &tmp_height);
(size_func1) (cell1, widget, NULL, NULL, NULL, &tmp_width, &tmp_height);
real_cell_area.x = cell_area->x;
real_cell_area.y = cell_area->y;
......
......@@ -34,6 +34,9 @@ static void gtk_cell_renderer_toggle_init (GtkCellRendererToggle *cel
static void gtk_cell_renderer_toggle_class_init (GtkCellRendererToggleClass *class);
static void gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height);
static void gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
......@@ -100,6 +103,7 @@ gtk_cell_renderer_toggle_init (GtkCellRendererToggle *celltoggle)
{
celltoggle->active = FALSE;
celltoggle->radio = FALSE;
GTK_CELL_RENDERER (celltoggle)->can_activate = TRUE;
GTK_CELL_RENDERER (celltoggle)->xpad = 2;
GTK_CELL_RENDERER (celltoggle)->ypad = 2;
}
......@@ -215,14 +219,37 @@ gtk_cell_renderer_toggle_new (void)
static void
gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height)
{
gint calc_width;
gint calc_height;
calc_width = (gint) cell->xpad * 2 + TOGGLE_WIDTH;
calc_height = (gint) cell->ypad * 2 + TOGGLE_WIDTH;
if (width)
*width = (gint) cell->xpad * 2 + TOGGLE_WIDTH;
*width = calc_width;
if (height)
*height = (gint) cell->ypad * 2 + TOGGLE_WIDTH;
*height = calc_height;
if (cell_area)
{
if (x_offset)
{
*x_offset = cell->xalign * (cell_area->width - calc_width - (2 * cell->xpad));
*x_offset = MAX (*x_offset, 0) + cell->xpad;
}
if (y_offset)
{
*y_offset = cell->yalign * (cell_area->height - calc_height - (2 * cell->ypad));
*y_offset = MAX (*y_offset, 0) + cell->ypad;
}
}
}
static void
......@@ -236,25 +263,26 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
{
GtkCellRendererToggle *celltoggle = (GtkCellRendererToggle *) cell;
gint width, height;
gint real_xoffset, real_yoffset;
gint x_offset, y_offset;
GtkShadowType shadow;
GtkStateType state;
width = MIN (TOGGLE_WIDTH, cell_area->width - cell->xpad * 2);
height = MIN (TOGGLE_WIDTH, cell_area->height - cell->ypad * 2);
gtk_cell_renderer_toggle_get_size (cell, widget, cell_area,
&x_offset, &y_offset,
&width, &height);
if (width <= 0 || height <= 0)
return;
real_xoffset = cell->xalign * (cell_area->width - width - (2 * cell->xpad));
real_xoffset = MAX (real_xoffset, 0) + cell->xpad;
real_yoffset = cell->yalign * (cell_area->height - height - (2 * cell->ypad));
real_yoffset = MAX (real_yoffset, 0) + cell->ypad;
shadow = celltoggle->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED)
state = GTK_STATE_SELECTED;
else if (! cell->can_activate)
state = GTK_STATE_INSENSITIVE;
else
state = GTK_STATE_NORMAL;
......@@ -264,8 +292,8 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
window,
state, shadow,
cell_area, widget, "cellradio",
cell_area->x + real_xoffset,
cell_area->y + real_yoffset,
cell_area->x + x_offset,
cell_area->y + y_offset,
width, height);
}
else
......@@ -274,8 +302,8 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
window,
state, shadow,
cell_area, widget, "cellcheck",
cell_area->x + real_xoffset,
cell_area->y + real_yoffset,
cell_area->x + x_offset,
cell_area->y + y_offset,
width, height);
}
}
......
......@@ -3326,6 +3326,19 @@ gtk_default_draw_focus (GtkStyle *style,
gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0);
gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
gdk_draw_rectangle (window,
style->black_gc, FALSE,
x, y, width, height);
gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_SOLID, 0, 0);
}