Warning: CellRenderer is deprecated since 4.10.
An object for rendering a single cell
Note:
List views use widgets for displaying their contents
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
get_preferred_size. Finally, the cell is rendered in the correct
location using 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.
- public virtual bool activate (Event event, Widget widget, string path, Rectangle background_area, Rectangle cell_area, CellRendererState flags)
Passes an activate event to the cell renderer for possible processing.
- public virtual Rectangle get_aligned_area (Widget widget, CellRendererState flags, Rectangle cell_area)
Gets the aligned area used by this inside
cell_area
.
- public void get_alignment (out float xalign, out float yalign)
Fills in xalign
and yalign
with the appropriate
values of this.
- public void get_fixed_size (out int width, out int height)
Fills in width
and height
with the appropriate
size of this.
- public bool get_is_expanded ()
Checks whether the given `GtkCellRenderer` is expanded.
- public bool get_is_expander ()
Checks whether the given `GtkCellRenderer` is an expander.
- public void get_padding (out int xpad, out int ypad)
Fills in xpad
and ypad
with the appropriate values
of this.
- public virtual void get_preferred_height (Widget widget, out int minimum_size, out int natural_size)
Retrieves a renderer’s natural size when rendered to widget
.
- public virtual void get_preferred_height_for_width (Widget widget, int width, out int minimum_height, out int natural_height)
Retrieves a cell renderers’s minimum and natural height if it were
rendered to widget
with the specified width
.
- public void get_preferred_size (Widget widget, out Requisition minimum_size, out Requisition natural_size)
Retrieves the minimum and natural size of a cell taking into account the
widget’s preference for height-for-width management.
- public virtual void get_preferred_width (Widget widget, out int minimum_size, out int natural_size)
Retrieves a renderer’s natural size when rendered to widget
.
- public virtual void get_preferred_width_for_height (Widget widget, int height, out int minimum_width, out int natural_width)
Retrieves a cell renderers’s minimum and natural width if it were rendered
to widget
with the specified height
.
- public virtual SizeRequestMode get_request_mode ()
Gets whether the cell renderer prefers a height-for-width layout or a
width-for-height layout.
- public bool get_sensitive ()
Returns the cell renderer’s sensitivity.
- public StateFlags get_state (Widget? widget, CellRendererState cell_state)
Translates the cell renderer state to `GtkStateFlags`, based on the cell
renderer and widget sensitivity, and the given `GtkCellRenderer`State.
- public bool get_visible ()
Returns the cell renderer’s visibility.
- public bool is_activatable ()
Checks whether the cell renderer can do something when activated.
- public void set_alignment (float xalign, float yalign)
Sets the renderer’s alignment within its available space.
- public void set_fixed_size (int width, int height)
Sets the renderer size to be explicit, independent of the properties set.
- public void set_is_expanded (bool is_expanded)
Sets whether the given `GtkCellRenderer` is expanded.
- public void set_is_expander (bool is_expander)
Sets whether the given `GtkCellRenderer` is an expander.
- public void set_padding (int xpad, int ypad)
Sets the renderer’s padding.
- public void set_sensitive (bool sensitive)
Sets the cell renderer’s sensitivity.
- public void set_visible (bool visible)
Sets the cell renderer’s visibility.
- public virtual void snapshot (Snapshot snapshot, Widget widget, Rectangle background_area, Rectangle cell_area, CellRendererState flags)
Invokes the virtual render function of the `GtkCellRenderer`.
- public virtual unowned CellEditable? start_editing (Event? event, Widget widget, string path, Rectangle background_area, Rectangle cell_area, CellRendererState flags)
Starts editing the contents of this this,
through a new `GtkCellEditable` widget created by the `GtkCellRenderer`Class.
- public void stop_editing (bool canceled)
Informs the cell renderer that the editing is stopped.