### Class

# GtkCellRenderer

deprecated: 4.10

#### Description [src]

    abstract class Gtk.CellRenderer : GObject.InitiallyUnowned
    {
      /* No available fields */
    }

An object for rendering a single cell

The `GtkCellRenderer` is a base class of a set of objects used for rendering a cell to a `cairo_t`. These objects are used primarily by the `GtkTreeView` widget, though they aren’t tied to them in any specific way. It is worth noting that `GtkCellRenderer` is not a `GtkWidget` and cannot be treated as such.

The primary use of a `GtkCellRenderer` is for drawing a certain graphical elements on a `cairo_t`. Typically, one cell renderer is used to draw many cells on the screen. To this extent, it isn’t expected that a CellRenderer keep any permanent state around. Instead, any state is set just prior to use using `GObject`s property system. Then, the cell is measured using gtk_cell_renderer_get_preferred_size(). Finally, the cell is rendered in the correct location using gtk_cell_renderer_snapshot().

There are a number of rules that must be followed when writing a new `GtkCellRenderer`. First and foremost, it’s important that a certain set of properties will always yield a cell renderer of the same size, barring a style change. The `GtkCellRenderer` 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 `GtkCellRenderer`Toggle, which toggles when it gets activated by a mouse click, or it can be “editable” like `GtkCellRenderer`Text, which allows the user to edit the text using a widget implementing the `GtkCellEditable` interface, e.g. `GtkEntry`. To make a cell renderer activatable or editable, you have to implement the `GtkCellRenderer`Class.activate or `GtkCellRenderer`Class.start_editing virtual functions, respectively.

Many properties of `GtkCellRenderer` and its subclasses have a corresponding “set” property, e.g. “cell-background-set” corresponds to “cell-background”. These “set” properties reflect whether a property has been set or not. You should not set them independently.

Deprecated since: 4.10

List views use widgets for displaying their contents.

#### Hierarchy

#### Ancestors

- GInitiallyUnowned
- GObject

#### Descendants

- GtkCellRendererPixbuf
- GtkCellRendererProgress
- GtkCellRendererSpinner
- GtkCellRendererText
- GtkCellRendererToggle

#### Instance methods

###### gtk_cell_renderer_activate

Passes an activate event to the cell renderer for possible processing. Some cell renderers may use events; for example, `GtkCellRendererToggle` toggles when it gets a mouse click.

deprecated: 4.10

###### gtk_cell_renderer_get_aligned_area

Gets the aligned area used by `cell` inside `cell_area`. Used for finding the appropriate edit and focus rectangle.

deprecated: 4.10

###### gtk_cell_renderer_get_alignment

Fills in `xalign` and `yalign` with the appropriate values of `cell`.

deprecated: 4.10

###### gtk_cell_renderer_get_fixed_size

Fills in `width` and `height` with the appropriate size of `cell`.

deprecated: 4.10

###### gtk_cell_renderer_get_is_expanded

Checks whether the given `GtkCellRenderer` is expanded.

deprecated: 4.10

###### gtk_cell_renderer_get_is_expander

Checks whether the given `GtkCellRenderer` is an expander.

deprecated: 4.10

###### gtk_cell_renderer_get_padding

Fills in `xpad` and `ypad` with the appropriate values of `cell`.

deprecated: 4.10

###### gtk_cell_renderer_get_preferred_height

Retrieves a renderer’s natural size when rendered to `widget`.

deprecated: 4.10

###### gtk_cell_renderer_get_preferred_height_for_width

Retrieves a cell renderers’s minimum and natural height if it were rendered to `widget` with the specified `width`.

deprecated: 4.10

###### gtk_cell_renderer_get_preferred_size

Retrieves the minimum and natural size of a cell taking into account the widget’s preference for height-for-width management.

deprecated: 4.10

###### gtk_cell_renderer_get_preferred_width

Retrieves a renderer’s natural size when rendered to `widget`.

deprecated: 4.10

###### gtk_cell_renderer_get_preferred_width_for_height

Retrieves a cell renderers’s minimum and natural width if it were rendered to `widget` with the specified `height`.

deprecated: 4.10

###### gtk_cell_renderer_get_request_mode

Gets whether the cell renderer prefers a height-for-width layout or a width-for-height layout.

deprecated: 4.10

###### gtk_cell_renderer_get_sensitive

Returns the cell renderer’s sensitivity.

deprecated: 4.10

###### gtk_cell_renderer_get_state

Translates the cell renderer state to `GtkStateFlags`, based on the cell renderer and widget sensitivity, and the given `GtkCellRenderer`State.

deprecated: 4.10

###### gtk_cell_renderer_get_visible

Returns the cell renderer’s visibility.

deprecated: 4.10

###### gtk_cell_renderer_is_activatable

Checks whether the cell renderer can do something when activated.

deprecated: 4.10

###### gtk_cell_renderer_set_alignment

Sets the renderer’s alignment within its available space.

deprecated: 4.10

###### gtk_cell_renderer_set_fixed_size

Sets the renderer size to be explicit, independent of the properties set.

deprecated: 4.10

###### gtk_cell_renderer_set_is_expanded

Sets whether the given `GtkCellRenderer` is expanded.

deprecated: 4.10

###### gtk_cell_renderer_set_is_expander

Sets whether the given `GtkCellRenderer` is an expander.

deprecated: 4.10

###### gtk_cell_renderer_set_padding

Sets the renderer’s padding.

deprecated: 4.10

###### gtk_cell_renderer_set_sensitive

Sets the cell renderer’s sensitivity.

deprecated: 4.10

###### gtk_cell_renderer_set_visible

Sets the cell renderer’s visibility.

deprecated: 4.10

###### gtk_cell_renderer_snapshot

Invokes the virtual render function of the `GtkCellRenderer`. The three passed-in rectangles are areas in `cr`. Most renderers will draw within `cell_area`; the xalign, yalign, xpad, and ypad fields of the `GtkCellRenderer` should be honored with respect to `cell_area`. `background_area` includes the blank space around the cell, and also the area containing the tree expander; so the `background_area` rectangles for all cells tile to cover the entire `window`.

deprecated: 4.10

###### gtk_cell_renderer_start_editing

Starts editing the contents of this `cell`, through a new `GtkCellEditable` widget created by the `GtkCellRenderer`Class.start_editing virtual function.

deprecated: 4.10

###### gtk_cell_renderer_stop_editing

Informs the cell renderer that the editing is stopped. If `canceled` is `TRUE`, the cell renderer will emit the `GtkCellRenderer`::editing-canceled signal.

deprecated: 4.10

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Properties

###### Gtk.CellRenderer:cell-background

No description available.

###### Gtk.CellRenderer:cell-background-rgba

Cell background as a `GdkRGBA`

###### Gtk.CellRenderer:cell-background-set

No description available.

###### Gtk.CellRenderer:editing

No description available.

###### Gtk.CellRenderer:height

No description available.

###### Gtk.CellRenderer:is-expanded

No description available.

###### Gtk.CellRenderer:is-expander

No description available.

###### Gtk.CellRenderer:mode

No description available.

###### Gtk.CellRenderer:sensitive

No description available.

###### Gtk.CellRenderer:visible

No description available.

###### Gtk.CellRenderer:width

No description available.

###### Gtk.CellRenderer:xalign

No description available.

###### Gtk.CellRenderer:xpad

No description available.

###### Gtk.CellRenderer:yalign

No description available.

###### Gtk.CellRenderer:ypad

No description available.

#### Signals

###### Gtk.CellRenderer::editing-canceled

This signal gets emitted when the user cancels the process of editing a cell. For example, an editable cell renderer could be written to cancel editing when the user presses Escape.

###### Gtk.CellRenderer::editing-started

This signal gets emitted when a cell starts to be edited. The intended use of this signal is to do special setup on `editable`, e.g. adding a `GtkEntryCompletion` or setting up additional columns in a `GtkComboBox`.

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct GtkCellRendererClass {
      GtkSizeRequestMode (* get_request_mode) (
        GtkCellRenderer* cell
      );
      void (* get_preferred_width) (
        GtkCellRenderer* cell,
        GtkWidget* widget,
        int* minimum_size,
        int* natural_size
      );
      void (* get_preferred_height_for_width) (
        GtkCellRenderer* cell,
        GtkWidget* widget,
        int width,
        int* minimum_height,
        int* natural_height
      );
      void (* get_preferred_height) (
        GtkCellRenderer* cell,
        GtkWidget* widget,
        int* minimum_size,
        int* natural_size
      );
      void (* get_preferred_width_for_height) (
        GtkCellRenderer* cell,
        GtkWidget* widget,
        int height,
        int* minimum_width,
        int* natural_width
      );
      void (* get_aligned_area) (
        GtkCellRenderer* cell,
        GtkWidget* widget,
        GtkCellRendererState flags,
        const GdkRectangle* cell_area,
        GdkRectangle* aligned_area
      );
      void (* snapshot) (
        GtkCellRenderer* cell,
        GtkSnapshot* snapshot,
        GtkWidget* widget,
        const GdkRectangle* background_area,
        const GdkRectangle* cell_area,
        GtkCellRendererState flags
      );
      gboolean (* activate) (
        GtkCellRenderer* cell,
        GdkEvent* event,
        GtkWidget* widget,
        const char* path,
        const GdkRectangle* background_area,
        const GdkRectangle* cell_area,
        GtkCellRendererState flags
      );
      GtkCellEditable* (* start_editing) (
        GtkCellRenderer* cell,
        GdkEvent* event,
        GtkWidget* widget,
        const char* path,
        const GdkRectangle* background_area,
        const GdkRectangle* cell_area,
        GtkCellRendererState flags
      );
      void (* editing_canceled) (
        GtkCellRenderer* cell
      );
      void (* editing_started) (
        GtkCellRenderer* cell,
        GtkCellEditable* editable,
        const char* path
      );

    }

No description available.

###### Class members

`get_request_mode: GtkSizeRequestMode (* get_request_mode) ( GtkCellRenderer* cell )`

  Called to gets whether the cell renderer prefers a height-for-width layout or a width-for-height layout.

`get_preferred_width: void (* get_preferred_width) ( GtkCellRenderer* cell, GtkWidget* widget, int* minimum_size, int* natural_size )`

  Called to get a renderer’s natural width.

`get_preferred_height_for_width: void (* get_preferred_height_for_width) ( GtkCellRenderer* cell, GtkWidget* widget, int width, int* minimum_height, int* natural_height )`

  Called to get a renderer’s natural height for width.

`get_preferred_height: void (* get_preferred_height) ( GtkCellRenderer* cell, GtkWidget* widget, int* minimum_size, int* natural_size )`

  Called to get a renderer’s natural height.

`get_preferred_width_for_height: void (* get_preferred_width_for_height) ( GtkCellRenderer* cell, GtkWidget* widget, int height, int* minimum_width, int* natural_width )`

  Called to get a renderer’s natural width for height.

`get_aligned_area: void (* get_aligned_area) ( GtkCellRenderer* cell, GtkWidget* widget, GtkCellRendererState flags, const GdkRectangle* cell_area, GdkRectangle* aligned_area )`

  Called to get the aligned area used by `cell` inside `cell_area`.

`snapshot: void (* snapshot) ( GtkCellRenderer* cell, GtkSnapshot* snapshot, GtkWidget* widget, const GdkRectangle* background_area, const GdkRectangle* cell_area, GtkCellRendererState flags )`

  Called to snapshot the content of the `GtkCellRenderer`.

`activate: gboolean (* activate) ( GtkCellRenderer* cell, GdkEvent* event, GtkWidget* widget, const char* path, const GdkRectangle* background_area, const GdkRectangle* cell_area, GtkCellRendererState flags )`

  Called to activate the content of the `GtkCellRenderer`.

`start_editing: GtkCellEditable* (* start_editing) ( GtkCellRenderer* cell, GdkEvent* event, GtkWidget* widget, const char* path, const GdkRectangle* background_area, const GdkRectangle* cell_area, GtkCellRendererState flags )`

  Called to initiate editing the content of the `GtkCellRenderer`.

`editing_canceled: void (* editing_canceled) ( GtkCellRenderer* cell )`

  Signal gets emitted when the user cancels the process of editing a cell.

`editing_started: void (* editing_started) ( GtkCellRenderer* cell, GtkCellEditable* editable, const char* path )`

  Signal gets emitted when a cell starts to be edited.

#### Virtual methods

###### Gtk.CellRendererClass.activate

Passes an activate event to the cell renderer for possible processing. Some cell renderers may use events; for example, `GtkCellRendererToggle` toggles when it gets a mouse click.

deprecated: 4.10

###### Gtk.CellRendererClass.editing_canceled

Signal gets emitted when the user cancels the process of editing a cell.

###### Gtk.CellRendererClass.editing_started

Signal gets emitted when a cell starts to be edited.

###### Gtk.CellRendererClass.get_aligned_area

Gets the aligned area used by `cell` inside `cell_area`. Used for finding the appropriate edit and focus rectangle.

deprecated: 4.10

###### Gtk.CellRendererClass.get_preferred_height

Retrieves a renderer’s natural size when rendered to `widget`.

deprecated: 4.10

###### Gtk.CellRendererClass.get_preferred_height_for_width

Retrieves a cell renderers’s minimum and natural height if it were rendered to `widget` with the specified `width`.

deprecated: 4.10

###### Gtk.CellRendererClass.get_preferred_width

Retrieves a renderer’s natural size when rendered to `widget`.

deprecated: 4.10

###### Gtk.CellRendererClass.get_preferred_width_for_height

Retrieves a cell renderers’s minimum and natural width if it were rendered to `widget` with the specified `height`.

deprecated: 4.10

###### Gtk.CellRendererClass.get_request_mode

Gets whether the cell renderer prefers a height-for-width layout or a width-for-height layout.

deprecated: 4.10

###### Gtk.CellRendererClass.snapshot

Invokes the virtual render function of the `GtkCellRenderer`. The three passed-in rectangles are areas in `cr`. Most renderers will draw within `cell_area`; the xalign, yalign, xpad, and ypad fields of the `GtkCellRenderer` should be honored with respect to `cell_area`. `background_area` includes the blank space around the cell, and also the area containing the tree expander; so the `background_area` rectangles for all cells tile to cover the entire `window`.

deprecated: 4.10

###### Gtk.CellRendererClass.start_editing

Starts editing the contents of this `cell`, through a new `GtkCellEditable` widget created by the `GtkCellRenderer`Class.start_editing virtual function.

deprecated: 4.10