Next: , Previous: builder, Up: Gtk+ Objects

6.4.8 cell-renderer

— Class: cell-renderer

Superclass: gtk-object

Subclasses: cell-renderer-toggle cell-renderer-progress cell-renderer-pixbuf cell-renderer-text

The cell-renderer is a base class of a set of objects used for rendering a cell to a drawable. These objects are used primarily by the tree-view widget, though they aren't tied to them in any specific way. It is worth noting that cell-renderer is not a widget and cannot be treated as such.

The primary use of a cell-renderer is for drawing a certain graphical elements on a drawable. Typically, one cell renderer is used to draw many cells on the screen. To this extent, it isn't expected that a cell-renderer keep any permanent state around. Instead, any state is set just prior to use. Then, the cell is measured using gtk_cell_renderer_get_size(). Finally, the cell is rendered in the correct location using gtk_cell_renderer_render().

There are a number of rules that must be followed when writing a new cell-renderer. First and formost, it's important that a certain set of properties will always yield a cell renderer of the same size, barring a style change. The cell-renderer also has a number of generic properties that are expected to be honored by all children.

Beyond merely rendering a cell, cell renderers can optionally provide active user interface elements. A cell renderer can be activatable like cell-renderer-toggle, which toggles when it gets activated by a mouse click, or it can be editable like cell-renderer-text, which allows the user to edit the text using a entry. To make a cell renderer activatable or editable, you have to implement the activate or start_editing virtual functions, respectively.