2 * Copyright (C) 2000 Red Hat, Inc. Jonathan Blandford
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 #include "gtkcellrenderer.h"
23 #include "gtkmarshalers.h"
24 #include "gtktypebuiltins.h"
25 #include "gtkprivate.h"
26 #include "gtktreeprivate.h"
27 #include "a11y/gtkrenderercellaccessible.h"
31 * SECTION:gtkcellrenderer
32 * @Short_description: An object for rendering a single cell
33 * @Title: GtkCellRenderer
34 * @See_also: #GtkCellRendererText, #GtkCellRendererPixbuf, #GtkCellRendererToggle
36 * The #GtkCellRenderer is a base class of a set of objects used for
37 * rendering a cell to a #cairo_t. These objects are used primarily by
38 * the #GtkTreeView widget, though they aren't tied to them in any
39 * specific way. It is worth noting that #GtkCellRenderer is not a
40 * #GtkWidget and cannot be treated as such.
42 * The primary use of a #GtkCellRenderer is for drawing a certain graphical
43 * elements on a #cairo_t. Typically, one cell renderer is used to
44 * draw many cells on the screen. To this extent, it isn't expected that a
45 * CellRenderer keep any permanent state around. Instead, any state is set
46 * just prior to use using #GObject<!-- -->s property system. Then, the
47 * cell is measured using gtk_cell_renderer_get_size(). Finally, the cell
48 * is rendered in the correct location using gtk_cell_renderer_render().
50 * There are a number of rules that must be followed when writing a new
51 * #GtkCellRenderer. First and formost, its important that a certain set
52 * of properties will always yield a cell renderer of the same size,
53 * barring a #GtkStyle change. The #GtkCellRenderer also has a number of
54 * generic properties that are expected to be honored by all children.
56 * Beyond merely rendering a cell, cell renderers can optionally
57 * provide active user interface elements. A cell renderer can be
58 * <firstterm>activatable</firstterm> like #GtkCellRendererToggle,
59 * which toggles when it gets activated by a mouse click, or it can be
60 * <firstterm>editable</firstterm> like #GtkCellRendererText, which
61 * allows the user to edit the text using a #GtkEntry.
62 * To make a cell renderer activatable or editable, you have to
63 * implement the #GtkCellRendererClass.activate or
64 * #GtkCellRendererClass.start_editing virtual functions, respectively.
68 #define DEBUG_CELL_SIZE_REQUEST 0
70 static void gtk_cell_renderer_init (GtkCellRenderer *cell);
71 static void gtk_cell_renderer_class_init (GtkCellRendererClass *class);
72 static void gtk_cell_renderer_get_property (GObject *object,
76 static void gtk_cell_renderer_set_property (GObject *object,
80 static void set_cell_bg_color (GtkCellRenderer *cell,
83 /* Fallback GtkCellRenderer implementation to use remaining ->get_size() implementations */
84 static GtkSizeRequestMode gtk_cell_renderer_real_get_request_mode(GtkCellRenderer *cell);
85 static void gtk_cell_renderer_real_get_preferred_width (GtkCellRenderer *cell,
89 static void gtk_cell_renderer_real_get_preferred_height (GtkCellRenderer *cell,
93 static void gtk_cell_renderer_real_get_preferred_height_for_width(GtkCellRenderer *cell,
97 gint *natural_height);
98 static void gtk_cell_renderer_real_get_preferred_width_for_height(GtkCellRenderer *cell,
102 gint *natural_width);
103 static void gtk_cell_renderer_real_get_aligned_area (GtkCellRenderer *cell,
105 GtkCellRendererState flags,
106 const GdkRectangle *cell_area,
107 GdkRectangle *aligned_area);
110 struct _GtkCellRendererPrivate
123 guint is_expander : 1;
124 guint is_expanded : 1;
125 guint cell_background_set : 1;
129 GdkRGBA cell_background;
132 struct _GtkCellRendererClassPrivate
134 GType accessible_type;
150 PROP_CELL_BACKGROUND,
151 PROP_CELL_BACKGROUND_GDK,
152 PROP_CELL_BACKGROUND_RGBA,
153 PROP_CELL_BACKGROUND_SET,
164 static guint cell_renderer_signals[LAST_SIGNAL] = { 0 };
167 gtk_cell_renderer_init (GtkCellRenderer *cell)
169 GtkCellRendererPrivate *priv;
171 cell->priv = G_TYPE_INSTANCE_GET_PRIVATE (cell,
172 GTK_TYPE_CELL_RENDERER,
173 GtkCellRendererPrivate);
176 priv->mode = GTK_CELL_RENDERER_MODE_INERT;
177 priv->visible = TRUE;
184 priv->sensitive = TRUE;
185 priv->is_expander = FALSE;
186 priv->is_expanded = FALSE;
187 priv->editing = FALSE;
191 gtk_cell_renderer_class_init (GtkCellRendererClass *class)
193 GObjectClass *object_class = G_OBJECT_CLASS (class);
195 object_class->get_property = gtk_cell_renderer_get_property;
196 object_class->set_property = gtk_cell_renderer_set_property;
198 class->render = NULL;
199 class->get_size = NULL;
200 class->get_request_mode = gtk_cell_renderer_real_get_request_mode;
201 class->get_preferred_width = gtk_cell_renderer_real_get_preferred_width;
202 class->get_preferred_height = gtk_cell_renderer_real_get_preferred_height;
203 class->get_preferred_width_for_height = gtk_cell_renderer_real_get_preferred_width_for_height;
204 class->get_preferred_height_for_width = gtk_cell_renderer_real_get_preferred_height_for_width;
205 class->get_aligned_area = gtk_cell_renderer_real_get_aligned_area;
208 * GtkCellRenderer::editing-canceled:
209 * @renderer: the object which received the signal
211 * This signal gets emitted when the user cancels the process of editing a
212 * cell. For example, an editable cell renderer could be written to cancel
213 * editing when the user presses Escape.
215 * See also: gtk_cell_renderer_stop_editing().
219 cell_renderer_signals[EDITING_CANCELED] =
220 g_signal_new (I_("editing-canceled"),
221 G_OBJECT_CLASS_TYPE (object_class),
223 G_STRUCT_OFFSET (GtkCellRendererClass, editing_canceled),
225 _gtk_marshal_VOID__VOID,
229 * GtkCellRenderer::editing-started:
230 * @renderer: the object which received the signal
231 * @editable: the #GtkCellEditable
232 * @path: the path identifying the edited cell
234 * This signal gets emitted when a cell starts to be edited.
235 * The intended use of this signal is to do special setup
236 * on @editable, e.g. adding a #GtkEntryCompletion or setting
237 * up additional columns in a #GtkComboBox.
239 * Note that GTK+ doesn't guarantee that cell renderers will
240 * continue to use the same kind of widget for editing in future
241 * releases, therefore you should check the type of @editable
242 * before doing any specific setup, as in the following example:
245 * text_editing_started (GtkCellRenderer *cell,
246 * GtkCellEditable *editable,
250 * if (GTK_IS_ENTRY (editable))
252 * GtkEntry *entry = GTK_ENTRY (editable);
254 * /* ... create a GtkEntryCompletion */
256 * gtk_entry_set_completion (entry, completion);
263 cell_renderer_signals[EDITING_STARTED] =
264 g_signal_new (I_("editing-started"),
265 G_OBJECT_CLASS_TYPE (object_class),
267 G_STRUCT_OFFSET (GtkCellRendererClass, editing_started),
269 _gtk_marshal_VOID__OBJECT_STRING,
271 GTK_TYPE_CELL_EDITABLE,
274 g_object_class_install_property (object_class,
276 g_param_spec_enum ("mode",
278 P_("Editable mode of the CellRenderer"),
279 GTK_TYPE_CELL_RENDERER_MODE,
280 GTK_CELL_RENDERER_MODE_INERT,
281 GTK_PARAM_READWRITE));
283 g_object_class_install_property (object_class,
285 g_param_spec_boolean ("visible",
287 P_("Display the cell"),
289 GTK_PARAM_READWRITE));
290 g_object_class_install_property (object_class,
292 g_param_spec_boolean ("sensitive",
294 P_("Display the cell sensitive"),
296 GTK_PARAM_READWRITE));
298 g_object_class_install_property (object_class,
300 g_param_spec_float ("xalign",
306 GTK_PARAM_READWRITE));
308 g_object_class_install_property (object_class,
310 g_param_spec_float ("yalign",
316 GTK_PARAM_READWRITE));
318 g_object_class_install_property (object_class,
320 g_param_spec_uint ("xpad",
326 GTK_PARAM_READWRITE));
328 g_object_class_install_property (object_class,
330 g_param_spec_uint ("ypad",
336 GTK_PARAM_READWRITE));
338 g_object_class_install_property (object_class,
340 g_param_spec_int ("width",
342 P_("The fixed width"),
346 GTK_PARAM_READWRITE));
348 g_object_class_install_property (object_class,
350 g_param_spec_int ("height",
352 P_("The fixed height"),
356 GTK_PARAM_READWRITE));
358 g_object_class_install_property (object_class,
360 g_param_spec_boolean ("is-expander",
362 P_("Row has children"),
364 GTK_PARAM_READWRITE));
367 g_object_class_install_property (object_class,
369 g_param_spec_boolean ("is-expanded",
371 P_("Row is an expander row, and is expanded"),
373 GTK_PARAM_READWRITE));
375 g_object_class_install_property (object_class,
376 PROP_CELL_BACKGROUND,
377 g_param_spec_string ("cell-background",
378 P_("Cell background color name"),
379 P_("Cell background color as a string"),
381 GTK_PARAM_WRITABLE));
383 g_object_class_install_property (object_class,
384 PROP_CELL_BACKGROUND_GDK,
385 g_param_spec_boxed ("cell-background-gdk",
386 P_("Cell background color"),
387 P_("Cell background color as a GdkColor"),
389 GTK_PARAM_READWRITE));
391 * GtkCellRenderer:cell-background-rgba:
393 * Cell background as a #GdkRGBA
397 g_object_class_install_property (object_class,
398 PROP_CELL_BACKGROUND_RGBA,
399 g_param_spec_boxed ("cell-background-rgba",
400 P_("Cell background RGBA color"),
401 P_("Cell background color as a GdkRGBA"),
403 GTK_PARAM_READWRITE));
405 g_object_class_install_property (object_class,
407 g_param_spec_boolean ("editing",
409 P_("Whether the cell renderer is currently in editing mode"),
411 GTK_PARAM_READABLE));
414 #define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (object_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, GTK_PARAM_READWRITE))
416 ADD_SET_PROP ("cell-background-set", PROP_CELL_BACKGROUND_SET,
417 P_("Cell background set"),
418 P_("Whether this tag affects the cell background color"));
420 g_type_class_add_private (class, sizeof (GtkCellRendererPrivate));
422 _gtk_cell_renderer_class_set_accessible_type (class, GTK_TYPE_RENDERER_CELL_ACCESSIBLE);
426 gtk_cell_renderer_base_class_init (gpointer g_class)
428 GtkCellRendererClass *klass = g_class;
430 klass->priv = G_TYPE_CLASS_GET_PRIVATE (g_class, GTK_TYPE_CELL_RENDERER, GtkCellRendererClassPrivate);
434 gtk_cell_renderer_get_type (void)
436 static GType cell_renderer_type = 0;
438 if (G_UNLIKELY (cell_renderer_type == 0))
440 const GTypeInfo cell_renderer_info =
442 sizeof (GtkCellRendererClass),
443 gtk_cell_renderer_base_class_init,
445 (GClassInitFunc) gtk_cell_renderer_class_init,
446 NULL, /* class_finalize */
447 NULL, /* class_init */
450 (GInstanceInitFunc) gtk_cell_renderer_init,
451 NULL, /* value_table */
453 cell_renderer_type = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, "GtkCellRenderer",
454 &cell_renderer_info, G_TYPE_FLAG_ABSTRACT);
456 g_type_add_class_private (cell_renderer_type, sizeof (GtkCellRendererClassPrivate));
459 return cell_renderer_type;
463 gtk_cell_renderer_get_property (GObject *object,
468 GtkCellRenderer *cell = GTK_CELL_RENDERER (object);
469 GtkCellRendererPrivate *priv = cell->priv;
474 g_value_set_enum (value, priv->mode);
477 g_value_set_boolean (value, priv->visible);
480 g_value_set_boolean (value, priv->sensitive);
483 g_value_set_boolean (value, priv->editing);
486 g_value_set_float (value, priv->xalign);
489 g_value_set_float (value, priv->yalign);
492 g_value_set_uint (value, priv->xpad);
495 g_value_set_uint (value, priv->ypad);
498 g_value_set_int (value, priv->width);
501 g_value_set_int (value, priv->height);
503 case PROP_IS_EXPANDER:
504 g_value_set_boolean (value, priv->is_expander);
506 case PROP_IS_EXPANDED:
507 g_value_set_boolean (value, priv->is_expanded);
509 case PROP_CELL_BACKGROUND_GDK:
513 color.red = (guint16) (priv->cell_background.red * 65535);
514 color.green = (guint16) (priv->cell_background.green * 65535);
515 color.blue = (guint16) (priv->cell_background.blue * 65535);
517 g_value_set_boxed (value, &color);
520 case PROP_CELL_BACKGROUND_RGBA:
521 g_value_set_boxed (value, &priv->cell_background);
523 case PROP_CELL_BACKGROUND_SET:
524 g_value_set_boolean (value, priv->cell_background_set);
526 case PROP_CELL_BACKGROUND:
528 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
535 gtk_cell_renderer_set_property (GObject *object,
540 GtkCellRenderer *cell = GTK_CELL_RENDERER (object);
541 GtkCellRendererPrivate *priv = cell->priv;
546 priv->mode = g_value_get_enum (value);
549 priv->visible = g_value_get_boolean (value);
552 priv->sensitive = g_value_get_boolean (value);
555 priv->editing = g_value_get_boolean (value);
558 priv->xalign = g_value_get_float (value);
561 priv->yalign = g_value_get_float (value);
564 priv->xpad = g_value_get_uint (value);
567 priv->ypad = g_value_get_uint (value);
570 priv->width = g_value_get_int (value);
573 priv->height = g_value_get_int (value);
575 case PROP_IS_EXPANDER:
576 priv->is_expander = g_value_get_boolean (value);
578 case PROP_IS_EXPANDED:
579 priv->is_expanded = g_value_get_boolean (value);
581 case PROP_CELL_BACKGROUND:
585 if (!g_value_get_string (value))
586 set_cell_bg_color (cell, NULL);
587 else if (gdk_rgba_parse (&rgba, g_value_get_string (value)))
588 set_cell_bg_color (cell, &rgba);
590 g_warning ("Don't know color `%s'", g_value_get_string (value));
592 g_object_notify (object, "cell-background-gdk");
595 case PROP_CELL_BACKGROUND_GDK:
599 color = g_value_get_boxed (value);
604 rgba.red = color->red / 65535.;
605 rgba.green = color->green / 65535.;
606 rgba.blue = color->blue / 65535.;
609 set_cell_bg_color (cell, &rgba);
613 set_cell_bg_color (cell, NULL);
617 case PROP_CELL_BACKGROUND_RGBA:
618 set_cell_bg_color (cell, g_value_get_boxed (value));
620 case PROP_CELL_BACKGROUND_SET:
621 priv->cell_background_set = g_value_get_boolean (value);
624 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
630 set_cell_bg_color (GtkCellRenderer *cell,
633 GtkCellRendererPrivate *priv = cell->priv;
637 if (!priv->cell_background_set)
639 priv->cell_background_set = TRUE;
640 g_object_notify (G_OBJECT (cell), "cell-background-set");
643 priv->cell_background = *rgba;
647 if (priv->cell_background_set)
649 priv->cell_background_set = FALSE;
650 g_object_notify (G_OBJECT (cell), "cell-background-set");
656 * gtk_cell_renderer_get_size:
657 * @cell: a #GtkCellRenderer
658 * @widget: the widget the renderer is rendering to
659 * @cell_area: (allow-none): The area a cell will be allocated, or %NULL
660 * @x_offset: (out) (allow-none): location to return x offset of cell relative to @cell_area, or %NULL
661 * @y_offset: (out) (allow-none): location to return y offset of cell relative to @cell_area, or %NULL
662 * @width: (out) (allow-none): location to return width needed to render a cell, or %NULL
663 * @height: (out) (allow-none): location to return height needed to render a cell, or %NULL
665 * Obtains the width and height needed to render the cell. Used by view
666 * widgets to determine the appropriate size for the cell_area passed to
667 * gtk_cell_renderer_render(). If @cell_area is not %NULL, fills in the
668 * x and y offsets (if set) of the cell relative to this location.
670 * Please note that the values set in @width and @height, as well as those
671 * in @x_offset and @y_offset are inclusive of the xpad and ypad properties.
674 * Deprecated: 3.0: Use gtk_cell_renderer_get_preferred_size() instead.
677 gtk_cell_renderer_get_size (GtkCellRenderer *cell,
679 const GdkRectangle *cell_area,
685 GtkRequisition request;
687 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
689 gtk_cell_renderer_get_preferred_size (cell, widget, &request, NULL);
692 *width = request.width;
695 *height = request.height;
698 _gtk_cell_renderer_calc_offset (cell, cell_area, gtk_widget_get_direction (widget),
699 request.width, request.height, x_offset, y_offset);
703 * gtk_cell_renderer_render:
704 * @cell: a #GtkCellRenderer
705 * @cr: a cairo context to draw to
706 * @widget: the widget owning @window
707 * @background_area: entire cell area (including tree expanders and maybe
708 * padding on the sides)
709 * @cell_area: area normally rendered by a cell renderer
710 * @flags: flags that affect rendering
712 * Invokes the virtual render function of the #GtkCellRenderer. The three
713 * passed-in rectangles are areas in @cr. Most renderers will draw within
714 * @cell_area; the xalign, yalign, xpad, and ypad fields of the #GtkCellRenderer
715 * should be honored with respect to @cell_area. @background_area includes the
716 * blank space around the cell, and also the area containing the tree expander;
717 * so the @background_area rectangles for all cells tile to cover the entire
721 gtk_cell_renderer_render (GtkCellRenderer *cell,
724 const GdkRectangle *background_area,
725 const GdkRectangle *cell_area,
726 GtkCellRendererState flags)
728 gboolean selected = FALSE;
729 GtkCellRendererPrivate *priv = cell->priv;
730 GtkStyleContext *context;
733 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
734 g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->render != NULL);
735 g_return_if_fail (cr != NULL);
737 selected = (flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED;
741 if (priv->cell_background_set && !selected)
743 gdk_cairo_rectangle (cr, background_area);
744 gdk_cairo_set_source_rgba (cr, &priv->cell_background);
748 gdk_cairo_rectangle (cr, background_area);
751 context = gtk_widget_get_style_context (widget);
753 gtk_style_context_save (context);
754 gtk_style_context_add_class (context, GTK_STYLE_CLASS_CELL);
756 state = gtk_cell_renderer_get_state (cell, widget, flags);
757 gtk_style_context_set_state (context, state);
759 GTK_CELL_RENDERER_GET_CLASS (cell)->render (cell,
765 gtk_style_context_restore (context);
770 * gtk_cell_renderer_activate:
771 * @cell: a #GtkCellRenderer
772 * @event: a #GdkEvent
773 * @widget: widget that received the event
774 * @path: widget-dependent string representation of the event location;
775 * e.g. for #GtkTreeView, a string representation of #GtkTreePath
776 * @background_area: background area as passed to gtk_cell_renderer_render()
777 * @cell_area: cell area as passed to gtk_cell_renderer_render()
778 * @flags: render flags
780 * Passes an activate event to the cell renderer for possible processing.
781 * Some cell renderers may use events; for example, #GtkCellRendererToggle
782 * toggles when it gets a mouse click.
784 * Return value: %TRUE if the event was consumed/handled
787 gtk_cell_renderer_activate (GtkCellRenderer *cell,
791 const GdkRectangle *background_area,
792 const GdkRectangle *cell_area,
793 GtkCellRendererState flags)
795 GtkCellRendererPrivate *priv;
797 g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), FALSE);
801 if (priv->mode != GTK_CELL_RENDERER_MODE_ACTIVATABLE)
804 if (GTK_CELL_RENDERER_GET_CLASS (cell)->activate == NULL)
807 return GTK_CELL_RENDERER_GET_CLASS (cell)->activate (cell,
811 (GdkRectangle *) background_area,
812 (GdkRectangle *) cell_area,
817 * gtk_cell_renderer_start_editing:
818 * @cell: a #GtkCellRenderer
819 * @event: a #GdkEvent
820 * @widget: widget that received the event
821 * @path: widget-dependent string representation of the event location;
822 * e.g. for #GtkTreeView, a string representation of #GtkTreePath
823 * @background_area: background area as passed to gtk_cell_renderer_render()
824 * @cell_area: cell area as passed to gtk_cell_renderer_render()
825 * @flags: render flags
827 * Passes an activate event to the cell renderer for possible processing.
829 * Return value: (transfer none): A new #GtkCellEditable, or %NULL
832 gtk_cell_renderer_start_editing (GtkCellRenderer *cell,
836 const GdkRectangle *background_area,
837 const GdkRectangle *cell_area,
838 GtkCellRendererState flags)
841 GtkCellRendererPrivate *priv;
842 GtkCellEditable *editable;
844 g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), NULL);
848 if (priv->mode != GTK_CELL_RENDERER_MODE_EDITABLE)
851 if (GTK_CELL_RENDERER_GET_CLASS (cell)->start_editing == NULL)
854 editable = GTK_CELL_RENDERER_GET_CLASS (cell)->start_editing (cell,
858 (GdkRectangle *) background_area,
859 (GdkRectangle *) cell_area,
863 cell_renderer_signals[EDITING_STARTED], 0,
866 priv->editing = TRUE;
872 * gtk_cell_renderer_set_fixed_size:
873 * @cell: A #GtkCellRenderer
874 * @width: the width of the cell renderer, or -1
875 * @height: the height of the cell renderer, or -1
877 * Sets the renderer size to be explicit, independent of the properties set.
880 gtk_cell_renderer_set_fixed_size (GtkCellRenderer *cell,
884 GtkCellRendererPrivate *priv;
886 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
887 g_return_if_fail (width >= -1 && height >= -1);
891 if ((width != priv->width) || (height != priv->height))
893 g_object_freeze_notify (G_OBJECT (cell));
895 if (width != priv->width)
898 g_object_notify (G_OBJECT (cell), "width");
901 if (height != priv->height)
903 priv->height = height;
904 g_object_notify (G_OBJECT (cell), "height");
907 g_object_thaw_notify (G_OBJECT (cell));
912 * gtk_cell_renderer_get_fixed_size:
913 * @cell: A #GtkCellRenderer
914 * @width: (out) (allow-none): location to fill in with the fixed width of the cell, or %NULL
915 * @height: (out) (allow-none): location to fill in with the fixed height of the cell, or %NULL
917 * Fills in @width and @height with the appropriate size of @cell.
920 gtk_cell_renderer_get_fixed_size (GtkCellRenderer *cell,
924 GtkCellRendererPrivate *priv;
926 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
931 *width = priv->width;
933 *height = priv->height;
937 * gtk_cell_renderer_set_alignment:
938 * @cell: A #GtkCellRenderer
939 * @xalign: the x alignment of the cell renderer
940 * @yalign: the y alignment of the cell renderer
942 * Sets the renderer's alignment within its available space.
947 gtk_cell_renderer_set_alignment (GtkCellRenderer *cell,
951 GtkCellRendererPrivate *priv;
953 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
954 g_return_if_fail (xalign >= 0.0 && xalign <= 1.0);
955 g_return_if_fail (yalign >= 0.0 && yalign <= 1.0);
959 if ((xalign != priv->xalign) || (yalign != priv->yalign))
961 g_object_freeze_notify (G_OBJECT (cell));
963 if (xalign != priv->xalign)
965 priv->xalign = xalign;
966 g_object_notify (G_OBJECT (cell), "xalign");
969 if (yalign != priv->yalign)
971 priv->yalign = yalign;
972 g_object_notify (G_OBJECT (cell), "yalign");
975 g_object_thaw_notify (G_OBJECT (cell));
980 * gtk_cell_renderer_get_alignment:
981 * @cell: A #GtkCellRenderer
982 * @xalign: (out) (allow-none): location to fill in with the x alignment of the cell, or %NULL
983 * @yalign: (out) (allow-none): location to fill in with the y alignment of the cell, or %NULL
985 * Fills in @xalign and @yalign with the appropriate values of @cell.
990 gtk_cell_renderer_get_alignment (GtkCellRenderer *cell,
994 GtkCellRendererPrivate *priv;
996 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
1001 *xalign = priv->xalign;
1003 *yalign = priv->yalign;
1007 * gtk_cell_renderer_set_padding:
1008 * @cell: A #GtkCellRenderer
1009 * @xpad: the x padding of the cell renderer
1010 * @ypad: the y padding of the cell renderer
1012 * Sets the renderer's padding.
1017 gtk_cell_renderer_set_padding (GtkCellRenderer *cell,
1021 GtkCellRendererPrivate *priv;
1023 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
1024 g_return_if_fail (xpad >= 0 && xpad >= 0);
1028 if ((xpad != priv->xpad) || (ypad != priv->ypad))
1030 g_object_freeze_notify (G_OBJECT (cell));
1032 if (xpad != priv->xpad)
1035 g_object_notify (G_OBJECT (cell), "xpad");
1038 if (ypad != priv->ypad)
1041 g_object_notify (G_OBJECT (cell), "ypad");
1044 g_object_thaw_notify (G_OBJECT (cell));
1049 * gtk_cell_renderer_get_padding:
1050 * @cell: A #GtkCellRenderer
1051 * @xpad: (out) (allow-none): location to fill in with the x padding of the cell, or %NULL
1052 * @ypad: (out) (allow-none): location to fill in with the y padding of the cell, or %NULL
1054 * Fills in @xpad and @ypad with the appropriate values of @cell.
1059 gtk_cell_renderer_get_padding (GtkCellRenderer *cell,
1063 GtkCellRendererPrivate *priv;
1065 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
1076 * gtk_cell_renderer_set_visible:
1077 * @cell: A #GtkCellRenderer
1078 * @visible: the visibility of the cell
1080 * Sets the cell renderer's visibility.
1085 gtk_cell_renderer_set_visible (GtkCellRenderer *cell,
1088 GtkCellRendererPrivate *priv;
1090 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
1094 if (priv->visible != visible)
1096 priv->visible = visible ? TRUE : FALSE;
1097 g_object_notify (G_OBJECT (cell), "visible");
1102 * gtk_cell_renderer_get_visible:
1103 * @cell: A #GtkCellRenderer
1105 * Returns the cell renderer's visibility.
1107 * Returns: %TRUE if the cell renderer is visible
1112 gtk_cell_renderer_get_visible (GtkCellRenderer *cell)
1114 g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), FALSE);
1116 return cell->priv->visible;
1120 * gtk_cell_renderer_set_sensitive:
1121 * @cell: A #GtkCellRenderer
1122 * @sensitive: the sensitivity of the cell
1124 * Sets the cell renderer's sensitivity.
1129 gtk_cell_renderer_set_sensitive (GtkCellRenderer *cell,
1132 GtkCellRendererPrivate *priv;
1134 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
1138 if (priv->sensitive != sensitive)
1140 priv->sensitive = sensitive ? TRUE : FALSE;
1141 g_object_notify (G_OBJECT (cell), "sensitive");
1146 * gtk_cell_renderer_get_sensitive:
1147 * @cell: A #GtkCellRenderer
1149 * Returns the cell renderer's sensitivity.
1151 * Returns: %TRUE if the cell renderer is sensitive
1156 gtk_cell_renderer_get_sensitive (GtkCellRenderer *cell)
1158 g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), FALSE);
1160 return cell->priv->sensitive;
1165 * gtk_cell_renderer_is_activatable:
1166 * @cell: A #GtkCellRenderer
1168 * Checks whether the cell renderer can do something when activated.
1170 * Returns: %TRUE if the cell renderer can do anything when activated
1175 gtk_cell_renderer_is_activatable (GtkCellRenderer *cell)
1177 GtkCellRendererPrivate *priv;
1179 g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), FALSE);
1183 return (priv->visible &&
1184 (priv->mode == GTK_CELL_RENDERER_MODE_EDITABLE ||
1185 priv->mode == GTK_CELL_RENDERER_MODE_ACTIVATABLE));
1190 * gtk_cell_renderer_stop_editing:
1191 * @cell: A #GtkCellRenderer
1192 * @canceled: %TRUE if the editing has been canceled
1194 * Informs the cell renderer that the editing is stopped.
1195 * If @canceled is %TRUE, the cell renderer will emit the
1196 * #GtkCellRenderer::editing-canceled signal.
1198 * This function should be called by cell renderer implementations
1199 * in response to the #GtkCellEditable::editing-done signal of
1205 gtk_cell_renderer_stop_editing (GtkCellRenderer *cell,
1208 GtkCellRendererPrivate *priv;
1210 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
1216 priv->editing = FALSE;
1218 g_signal_emit (cell, cell_renderer_signals[EDITING_CANCELED], 0);
1223 gtk_cell_renderer_real_get_preferred_size (GtkCellRenderer *cell,
1225 GtkOrientation orientation,
1229 GtkRequisition min_req;
1231 /* Fallback on the old API to get the size. */
1232 if (GTK_CELL_RENDERER_GET_CLASS (cell)->get_size)
1233 GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (GTK_CELL_RENDERER (cell), widget, NULL, NULL, NULL,
1234 &min_req.width, &min_req.height);
1241 if (orientation == GTK_ORIENTATION_HORIZONTAL)
1244 *minimum_size = min_req.width;
1247 *natural_size = min_req.width;
1252 *minimum_size = min_req.height;
1255 *natural_size = min_req.height;
1259 static GtkSizeRequestMode
1260 gtk_cell_renderer_real_get_request_mode (GtkCellRenderer *cell)
1262 /* By default cell renderers are height-for-width. */
1263 return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
1267 gtk_cell_renderer_real_get_preferred_width (GtkCellRenderer *cell,
1272 gtk_cell_renderer_real_get_preferred_size (cell, widget, GTK_ORIENTATION_HORIZONTAL,
1273 minimum_size, natural_size);
1277 gtk_cell_renderer_real_get_preferred_height (GtkCellRenderer *cell,
1282 gtk_cell_renderer_real_get_preferred_size (cell, widget, GTK_ORIENTATION_VERTICAL,
1283 minimum_size, natural_size);
1288 gtk_cell_renderer_real_get_preferred_height_for_width (GtkCellRenderer *cell,
1291 gint *minimum_height,
1292 gint *natural_height)
1294 /* Fall back on the height reported from ->get_size() */
1295 gtk_cell_renderer_get_preferred_height (cell, widget, minimum_height, natural_height);
1299 gtk_cell_renderer_real_get_preferred_width_for_height (GtkCellRenderer *cell,
1302 gint *minimum_width,
1303 gint *natural_width)
1305 /* Fall back on the width reported from ->get_size() */
1306 gtk_cell_renderer_get_preferred_width (cell, widget, minimum_width, natural_width);
1310 /* Default implementation assumes that a cell renderer will never use more
1311 * space than its natural size (this is fine for toggles and pixbufs etc
1312 * but needs to be overridden from wrapping/ellipsizing text renderers) */
1314 gtk_cell_renderer_real_get_aligned_area (GtkCellRenderer *cell,
1316 GtkCellRendererState flags,
1317 const GdkRectangle *cell_area,
1318 GdkRectangle *aligned_area)
1320 gint opposite_size, x_offset, y_offset;
1323 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
1324 g_return_if_fail (GTK_IS_WIDGET (widget));
1325 g_return_if_fail (cell_area != NULL);
1326 g_return_if_fail (aligned_area != NULL);
1328 *aligned_area = *cell_area;
1330 /* Trim up the aligned size */
1331 if (gtk_cell_renderer_get_request_mode (cell) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
1333 gtk_cell_renderer_get_preferred_width (cell, widget,
1334 NULL, &natural_size);
1336 aligned_area->width = MIN (aligned_area->width, natural_size);
1338 gtk_cell_renderer_get_preferred_height_for_width (cell, widget,
1339 aligned_area->width,
1340 NULL, &opposite_size);
1342 aligned_area->height = MIN (opposite_size, aligned_area->height);
1346 gtk_cell_renderer_get_preferred_height (cell, widget,
1347 NULL, &natural_size);
1349 aligned_area->height = MIN (aligned_area->width, natural_size);
1351 gtk_cell_renderer_get_preferred_width_for_height (cell, widget,
1352 aligned_area->height,
1353 NULL, &opposite_size);
1355 aligned_area->width = MIN (opposite_size, aligned_area->width);
1358 /* offset the cell position */
1359 _gtk_cell_renderer_calc_offset (cell, cell_area,
1360 gtk_widget_get_direction (widget),
1361 aligned_area->width,
1362 aligned_area->height,
1363 &x_offset, &y_offset);
1365 aligned_area->x += x_offset;
1366 aligned_area->y += y_offset;
1370 /* An internal convenience function for some containers to peek at the
1371 * cell alignment in a target allocation (used to draw focus and align
1372 * cells in the icon view).
1374 * Note this is only a trivial 'align * (allocation - request)' operation.
1377 _gtk_cell_renderer_calc_offset (GtkCellRenderer *cell,
1378 const GdkRectangle *cell_area,
1379 GtkTextDirection direction,
1385 GtkCellRendererPrivate *priv;
1387 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
1388 g_return_if_fail (cell_area != NULL);
1389 g_return_if_fail (x_offset || y_offset);
1395 *x_offset = (((direction == GTK_TEXT_DIR_RTL) ?
1396 (1.0 - priv->xalign) : priv->xalign) *
1397 (cell_area->width - width));
1398 *x_offset = MAX (*x_offset, 0);
1402 *y_offset = (priv->yalign *
1403 (cell_area->height - height));
1404 *y_offset = MAX (*y_offset, 0);
1409 * gtk_cell_renderer_get_request_mode:
1410 * @cell: a #GtkCellRenderer instance
1412 * Gets whether the cell renderer prefers a height-for-width layout
1413 * or a width-for-height layout.
1415 * Returns: The #GtkSizeRequestMode preferred by this renderer.
1420 gtk_cell_renderer_get_request_mode (GtkCellRenderer *cell)
1422 g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), FALSE);
1424 return GTK_CELL_RENDERER_GET_CLASS (cell)->get_request_mode (cell);
1428 * gtk_cell_renderer_get_preferred_width:
1429 * @cell: a #GtkCellRenderer instance
1430 * @widget: the #GtkWidget this cell will be rendering to
1431 * @minimum_size: (out) (allow-none): location to store the minimum size, or %NULL
1432 * @natural_size: (out) (allow-none): location to store the natural size, or %NULL
1434 * Retreives a renderer's natural size when rendered to @widget.
1439 gtk_cell_renderer_get_preferred_width (GtkCellRenderer *cell,
1444 GtkCellRendererClass *klass;
1447 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
1448 g_return_if_fail (GTK_IS_WIDGET (widget));
1449 g_return_if_fail (NULL != minimum_size || NULL != natural_size);
1451 gtk_cell_renderer_get_fixed_size (GTK_CELL_RENDERER (cell), &width, NULL);
1455 klass = GTK_CELL_RENDERER_GET_CLASS (cell);
1456 klass->get_preferred_width (cell, widget, minimum_size, natural_size);
1461 *minimum_size = width;
1463 *natural_size = width;
1466 #if DEBUG_CELL_SIZE_REQUEST
1467 g_message ("%s returning minimum width: %d and natural width: %d",
1468 G_OBJECT_TYPE_NAME (cell),
1469 minimum_size ? *minimum_size : 20000,
1470 natural_size ? *natural_size : 20000);
1476 * gtk_cell_renderer_get_preferred_height:
1477 * @cell: a #GtkCellRenderer instance
1478 * @widget: the #GtkWidget this cell will be rendering to
1479 * @minimum_size: (out) (allow-none): location to store the minimum size, or %NULL
1480 * @natural_size: (out) (allow-none): location to store the natural size, or %NULL
1482 * Retreives a renderer's natural size when rendered to @widget.
1487 gtk_cell_renderer_get_preferred_height (GtkCellRenderer *cell,
1492 GtkCellRendererClass *klass;
1495 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
1496 g_return_if_fail (GTK_IS_WIDGET (widget));
1497 g_return_if_fail (NULL != minimum_size || NULL != natural_size);
1499 gtk_cell_renderer_get_fixed_size (GTK_CELL_RENDERER (cell), NULL, &height);
1503 klass = GTK_CELL_RENDERER_GET_CLASS (cell);
1504 klass->get_preferred_height (cell, widget, minimum_size, natural_size);
1509 *minimum_size = height;
1511 *natural_size = height;
1514 #if DEBUG_CELL_SIZE_REQUEST
1515 g_message ("%s returning minimum height: %d and natural height: %d",
1516 G_OBJECT_TYPE_NAME (cell),
1517 minimum_size ? *minimum_size : 20000,
1518 natural_size ? *natural_size : 20000);
1524 * gtk_cell_renderer_get_preferred_width_for_height:
1525 * @cell: a #GtkCellRenderer instance
1526 * @widget: the #GtkWidget this cell will be rendering to
1527 * @height: the size which is available for allocation
1528 * @minimum_width: (out) (allow-none): location for storing the minimum size, or %NULL
1529 * @natural_width: (out) (allow-none): location for storing the preferred size, or %NULL
1531 * Retreives a cell renderers's minimum and natural width if it were rendered to
1532 * @widget with the specified @height.
1537 gtk_cell_renderer_get_preferred_width_for_height (GtkCellRenderer *cell,
1540 gint *minimum_width,
1541 gint *natural_width)
1543 GtkCellRendererClass *klass;
1546 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
1547 g_return_if_fail (GTK_IS_WIDGET (widget));
1548 g_return_if_fail (NULL != minimum_width || NULL != natural_width);
1550 gtk_cell_renderer_get_fixed_size (GTK_CELL_RENDERER (cell), &width, NULL);
1554 klass = GTK_CELL_RENDERER_GET_CLASS (cell);
1555 klass->get_preferred_width_for_height (cell, widget, height, minimum_width, natural_width);
1560 *minimum_width = width;
1562 *natural_width = width;
1565 #if DEBUG_CELL_SIZE_REQUEST
1566 g_message ("%s width for height: %d is minimum %d and natural: %d",
1567 G_OBJECT_TYPE_NAME (cell), height,
1568 minimum_width ? *minimum_width : 20000,
1569 natural_width ? *natural_width : 20000);
1574 * gtk_cell_renderer_get_preferred_height_for_width:
1575 * @cell: a #GtkCellRenderer instance
1576 * @widget: the #GtkWidget this cell will be rendering to
1577 * @width: the size which is available for allocation
1578 * @minimum_height: (out) (allow-none): location for storing the minimum size, or %NULL
1579 * @natural_height: (out) (allow-none): location for storing the preferred size, or %NULL
1581 * Retreives a cell renderers's minimum and natural height if it were rendered to
1582 * @widget with the specified @width.
1587 gtk_cell_renderer_get_preferred_height_for_width (GtkCellRenderer *cell,
1590 gint *minimum_height,
1591 gint *natural_height)
1593 GtkCellRendererClass *klass;
1596 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
1597 g_return_if_fail (GTK_IS_WIDGET (widget));
1598 g_return_if_fail (NULL != minimum_height || NULL != natural_height);
1600 gtk_cell_renderer_get_fixed_size (GTK_CELL_RENDERER (cell), NULL, &height);
1604 klass = GTK_CELL_RENDERER_GET_CLASS (cell);
1605 klass->get_preferred_height_for_width (cell, widget, width, minimum_height, natural_height);
1610 *minimum_height = height;
1612 *natural_height = height;
1615 #if DEBUG_CELL_SIZE_REQUEST
1616 g_message ("%s height for width: %d is minimum %d and natural: %d",
1617 G_OBJECT_TYPE_NAME (cell), width,
1618 minimum_height ? *minimum_height : 20000,
1619 natural_height ? *natural_height : 20000);
1624 * gtk_cell_renderer_get_preferred_size:
1625 * @cell: a #GtkCellRenderer instance
1626 * @widget: the #GtkWidget this cell will be rendering to
1627 * @minimum_size: (out) (allow-none): location for storing the minimum size, or %NULL
1628 * @natural_size: (out) (allow-none): location for storing the natural size, or %NULL
1630 * Retrieves the minimum and natural size of a cell taking
1631 * into account the widget's preference for height-for-width management.
1636 gtk_cell_renderer_get_preferred_size (GtkCellRenderer *cell,
1638 GtkRequisition *minimum_size,
1639 GtkRequisition *natural_size)
1641 gint min_width, nat_width;
1642 gint min_height, nat_height;
1644 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
1646 if (gtk_cell_renderer_get_request_mode (cell) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
1648 gtk_cell_renderer_get_preferred_width (cell, widget, &min_width, &nat_width);
1652 minimum_size->width = min_width;
1653 gtk_cell_renderer_get_preferred_height_for_width (cell, widget, min_width,
1654 &minimum_size->height, NULL);
1659 natural_size->width = nat_width;
1660 gtk_cell_renderer_get_preferred_height_for_width (cell, widget, nat_width,
1661 NULL, &natural_size->height);
1664 else /* GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT */
1666 gtk_cell_renderer_get_preferred_height (cell, widget, &min_height, &nat_height);
1670 minimum_size->height = min_height;
1671 gtk_cell_renderer_get_preferred_width_for_height (cell, widget, min_height,
1672 &minimum_size->width, NULL);
1677 natural_size->height = nat_height;
1678 gtk_cell_renderer_get_preferred_width_for_height (cell, widget, nat_height,
1679 NULL, &natural_size->width);
1685 * gtk_cell_renderer_get_aligned_area:
1686 * @cell: a #GtkCellRenderer instance
1687 * @widget: the #GtkWidget this cell will be rendering to
1688 * @flags: render flags
1689 * @cell_area: cell area which would be passed to gtk_cell_renderer_render()
1690 * @aligned_area: (out): the return location for the space inside @cell_area
1691 * that would acually be used to render.
1693 * Gets the aligned area used by @cell inside @cell_area. Used for finding
1694 * the appropriate edit and focus rectangle.
1699 gtk_cell_renderer_get_aligned_area (GtkCellRenderer *cell,
1701 GtkCellRendererState flags,
1702 const GdkRectangle *cell_area,
1703 GdkRectangle *aligned_area)
1705 GtkCellRendererClass *klass;
1707 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
1708 g_return_if_fail (GTK_IS_WIDGET (widget));
1709 g_return_if_fail (cell_area != NULL);
1710 g_return_if_fail (aligned_area != NULL);
1712 klass = GTK_CELL_RENDERER_GET_CLASS (cell);
1713 klass->get_aligned_area (cell, widget, flags, cell_area, aligned_area);
1715 g_assert (aligned_area->x >= cell_area->x && aligned_area->x <= cell_area->x + cell_area->width);
1716 g_assert (aligned_area->y >= cell_area->y && aligned_area->y <= cell_area->y + cell_area->height);
1717 g_assert ((aligned_area->x - cell_area->x) + aligned_area->width <= cell_area->width);
1718 g_assert ((aligned_area->y - cell_area->y) + aligned_area->height <= cell_area->height);
1722 * gtk_cell_renderer_get_state:
1723 * @cell: a #GtkCellRenderer, or %NULL
1724 * @widget: a #GtkWidget, or %NULL
1725 * @cell_state: cell renderer state
1727 * Translates the cell renderer state to #GtkStateFlags,
1728 * based on the cell renderer and widget sensitivity, and
1729 * the given #GtkCellRendererState.
1731 * Returns: the widget state flags applying to @cell
1736 gtk_cell_renderer_get_state (GtkCellRenderer *cell,
1738 GtkCellRendererState cell_state)
1740 GtkStateFlags state = 0;
1742 g_return_val_if_fail (!cell || GTK_IS_CELL_RENDERER (cell), 0);
1743 g_return_val_if_fail (!widget || GTK_IS_WIDGET (widget), 0);
1746 state |= gtk_widget_get_state_flags (widget);
1748 state &= ~(GTK_STATE_FLAG_FOCUSED | GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_SELECTED);
1750 if ((state & GTK_STATE_FLAG_INSENSITIVE) != 0 ||
1751 (cell && !gtk_cell_renderer_get_sensitive (cell)) ||
1752 (cell_state & GTK_CELL_RENDERER_INSENSITIVE) != 0)
1754 state |= GTK_STATE_FLAG_INSENSITIVE;
1758 if ((widget && gtk_widget_has_focus (widget)) &&
1759 (cell_state & GTK_CELL_RENDERER_FOCUSED) != 0)
1760 state |= GTK_STATE_FLAG_FOCUSED;
1762 if ((cell_state & GTK_CELL_RENDERER_PRELIT) != 0)
1763 state |= GTK_STATE_FLAG_PRELIGHT;
1766 if ((cell_state & GTK_CELL_RENDERER_SELECTED) != 0)
1767 state |= GTK_STATE_FLAG_SELECTED;
1773 * _gtk_cell_renderer_class_set_accessible_type:
1774 * @renderer_class: class to set the accessible type for
1775 * @type: The object type that implements the accessible for @widget_class.
1776 * The type must be a subtype of #GtkRendererCellAccessible
1778 * Sets the type to be used for creating accessibles for cells rendered by
1779 * cell renderers of @renderer_class. Note that multiple accessibles will
1782 * This function should only be called from class init functions of cell
1786 _gtk_cell_renderer_class_set_accessible_type (GtkCellRendererClass *renderer_class,
1789 GtkCellRendererClassPrivate *priv;
1791 g_return_if_fail (GTK_IS_CELL_RENDERER_CLASS (renderer_class));
1792 g_return_if_fail (g_type_is_a (type, GTK_TYPE_RENDERER_CELL_ACCESSIBLE));
1794 priv = renderer_class->priv;
1796 priv->accessible_type = type;
1800 _gtk_cell_renderer_get_accessible_type (GtkCellRenderer *renderer)
1802 g_return_val_if_fail (GTK_IS_CELL_RENDERER (renderer), GTK_TYPE_RENDERER_CELL_ACCESSIBLE);
1804 return GTK_CELL_RENDERER_GET_CLASS (renderer)->priv->accessible_type;