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 GObjects 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 GtkCellRendererToggle, which toggles when it gets activated by a mouse click, or it can be "editable" like GtkCellRendererText, 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 GtkCellRendererClass.activate or GtkCellRendererClass.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.
<group>Trees and Lists</group>
function Activate
(Cell : not null access Gtk_Cell_Renderer_Record;
Event : Gdk.Event.Gdk_Event;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class;
Path : UTF8_String;
Background_Area : Gdk.Rectangle.Gdk_Rectangle;
Cell_Area : Gdk.Rectangle.Gdk_Rectangle;
Flags : Gtk_Cell_Renderer_State) return Boolean
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 since 4.10, 1
a GdkEvent
widget that received the event
widget-dependent string representation of the event location; e.g. for GtkTreeView, a string representation of GtkTreePath
background area as passed to gtk_cell_renderer_render
cell area as passed to gtk_cell_renderer_render
render flags
True if the event was consumed/handled
type Cb_GObject_Gtk_Cell_Editable_UTF8_String_Void is not null access procedure
(Self : access Glib.Object.GObject_Record'Class;
Editable : Gtk.Cell_Editable.Gtk_Cell_Editable;
Path : UTF8_String);
type Cb_GObject_Void is not null access procedure
(Self : access Glib.Object.GObject_Record'Class);
type Cb_Gtk_Cell_Renderer_Gtk_Cell_Editable_UTF8_String_Void is not null access procedure
(Self : access Gtk_Cell_Renderer_Record'Class;
Editable : Gtk.Cell_Editable.Gtk_Cell_Editable;
Path : UTF8_String);
type Cb_Gtk_Cell_Renderer_Void is not null access procedure
(Self : access Gtk_Cell_Renderer_Record'Class);
Cell_Background_Property : constant Glib.Properties.Property_String;
Flags: write
Cell_Background_Rgba_Property : constant Gdk.RGBA.Property_RGBA;
Type: Gdk.RGBA.Gdk_RGBA Cell background as a GdkRGBA
Cell_Background_Set_Property : constant Glib.Properties.Property_Boolean;
Cell_Renderer_Expandable : constant Gtk_Cell_Renderer_State := 32;
Cell_Renderer_Expanded : constant Gtk_Cell_Renderer_State := 64;
Cell_Renderer_Focused : constant Gtk_Cell_Renderer_State := 16;
Cell_Renderer_Insensitive : constant Gtk_Cell_Renderer_State := 4;
package Cell_Renderer_List is new Generic_List (Gtk.Cell_Renderer.Gtk_Cell_Renderer);
Cell_Renderer_Prelit : constant Gtk_Cell_Renderer_State := 2;
Cell_Renderer_Selected : constant Gtk_Cell_Renderer_State := 1;
Cell_Renderer_Sorted : constant Gtk_Cell_Renderer_State := 8;
function Convert (R : Gtk.Cell_Renderer.Gtk_Cell_Renderer) return System.Address
function Convert (R : System.Address) return Gtk.Cell_Renderer.Gtk_Cell_Renderer
Editing_Property : constant Glib.Properties.Property_Boolean;
procedure Get_Aligned_Area
(Cell : not null access Gtk_Cell_Renderer_Record;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class;
Flags : Gtk_Cell_Renderer_State;
Cell_Area : Gdk.Rectangle.Gdk_Rectangle;
Aligned_Area : out Gdk.Rectangle.Gdk_Rectangle)
Gets the aligned area used by Cell inside Cell_Area. Used for finding the appropriate edit and focus rectangle. Deprecated since 4.10, 1
the GtkWidget this cell will be rendering to
render flags
cell area which would be passed to gtk_cell_renderer_render
the return location for the space inside Cell_Area that would actually be used to render.
procedure Get_Alignment
(Cell : not null access Gtk_Cell_Renderer_Record;
Xalign : out Interfaces.C.C_float;
Yalign : out Interfaces.C.C_float)
Fills in Xalign and Yalign with the appropriate values of Cell. Deprecated since 4.10, 1
location to fill in with the x alignment of the cell
location to fill in with the y alignment of the cell
procedure Get_Fixed_Size
(Cell : not null access Gtk_Cell_Renderer_Record;
Width : out Glib.Gint;
Height : out Glib.Gint)
Fills in Width and Height with the appropriate size of Cell. Deprecated since 4.10, 1
location to fill in with the fixed width of the cell
location to fill in with the fixed height of the cell
function Get_Is_Expanded
(Cell : not null access Gtk_Cell_Renderer_Record) return Boolean
Checks whether the given GtkCellRenderer is expanded. Deprecated since 4.10, 1
True if the cell renderer is expanded
function Get_Is_Expander
(Cell : not null access Gtk_Cell_Renderer_Record) return Boolean
Checks whether the given GtkCellRenderer is an expander. Deprecated since 4.10, 1
True if Cell is an expander, and False otherwise
procedure Get_Padding
(Cell : not null access Gtk_Cell_Renderer_Record;
Xpad : out Glib.Gint;
Ypad : out Glib.Gint)
Fills in Xpad and Ypad with the appropriate values of Cell. Deprecated since 4.10, 1
location to fill in with the x padding of the cell
location to fill in with the y padding of the cell
procedure Get_Preferred_Height
(Cell : not null access Gtk_Cell_Renderer_Record;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class;
Minimum_Size : out Glib.Gint;
Natural_Size : out Glib.Gint)
Retrieves a renderer's natural size when rendered to Widget. Deprecated since 4.10, 1
the GtkWidget this cell will be rendering to
location to store the minimum size
location to store the natural size
procedure Get_Preferred_Height_For_Width
(Cell : not null access Gtk_Cell_Renderer_Record;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class;
Width : Glib.Gint;
Minimum_Height : out Glib.Gint;
Natural_Height : out Glib.Gint)
Retrieves a cell renderers's minimum and natural height if it were rendered to Widget with the specified Width. Deprecated since 4.10, 1
the GtkWidget this cell will be rendering to
the size which is available for allocation
location for storing the minimum size
location for storing the preferred size
procedure Get_Preferred_Size
(Cell : not null access Gtk_Cell_Renderer_Record;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class;
Minimum_Size : out Gtk.Widget.Gtk_Requisition;
Natural_Size : out Gtk.Widget.Gtk_Requisition)
Retrieves the minimum and natural size of a cell taking into account the widget's preference for height-for-width management. Deprecated since 4.10, 1
the GtkWidget this cell will be rendering to
location for storing the minimum size
location for storing the natural size
procedure Get_Preferred_Width
(Cell : not null access Gtk_Cell_Renderer_Record;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class;
Minimum_Size : out Glib.Gint;
Natural_Size : out Glib.Gint)
Retrieves a renderer's natural size when rendered to Widget. Deprecated since 4.10, 1
the GtkWidget this cell will be rendering to
location to store the minimum size
location to store the natural size
procedure Get_Preferred_Width_For_Height
(Cell : not null access Gtk_Cell_Renderer_Record;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class;
Height : Glib.Gint;
Minimum_Width : out Glib.Gint;
Natural_Width : out Glib.Gint)
Retrieves a cell renderers's minimum and natural width if it were rendered to Widget with the specified Height. Deprecated since 4.10, 1
the GtkWidget this cell will be rendering to
the size which is available for allocation
location for storing the minimum size
location for storing the preferred size
function Get_Request_Mode
(Cell : not null access Gtk_Cell_Renderer_Record)
return Gtk.Enums.Gtk_Size_Request_Mode
Gets whether the cell renderer prefers a height-for-width layout or a width-for-height layout. Deprecated since 4.10, 1
The GtkSizeRequestMode preferred by this renderer.
function Get_Sensitive
(Cell : not null access Gtk_Cell_Renderer_Record) return Boolean
Returns the cell renderer's sensitivity. Deprecated since 4.10, 1
True if the cell renderer is sensitive
function Get_State
(Cell : access Gtk_Cell_Renderer_Record'Class;
Widget : access Gtk.Widget.Gtk_Widget_Record'Class;
Cell_State : Gtk_Cell_Renderer_State)
return Gtk.Enums.Gtk_State_Flags
Translates the cell renderer state to GtkStateFlags, based on the cell renderer and widget sensitivity, and the given GtkCellRendererState. Deprecated since 4.10, 1
a GtkWidget
cell renderer state
the widget state flags applying to Cell
function Get_Type return Glib.GType
function Get_Visible
(Cell : not null access Gtk_Cell_Renderer_Record) return Boolean
Returns the cell renderer's visibility. Deprecated since 4.10, 1
True if the cell renderer is visible
type Gtk_Cell_Renderer is access all Gtk_Cell_Renderer_Record'Class;
type Gtk_Cell_Renderer_Mode is (
Cell_Renderer_Mode_Inert,
Cell_Renderer_Mode_Activatable,
Cell_Renderer_Mode_Editable);
Identifies how the user can interact with a particular cell.
package Gtk_Cell_Renderer_Mode_Properties is
new Generic_Internal_Discrete_Property (Gtk_Cell_Renderer_Mode);
type Gtk_Cell_Renderer_Record is new GObject_Record with null record;
type Gtk_Cell_Renderer_State is mod 2 ** Integer'Size;
Tells how a cell is to be rendered.
package Gtk_Cell_Renderer_State_Properties is
new Generic_Internal_Flags_Property (Gtk_Cell_Renderer_State);
Height_Property : constant Glib.Properties.Property_Int;
function Is_Activatable
(Cell : not null access Gtk_Cell_Renderer_Record) return Boolean
Checks whether the cell renderer can do something when activated. Deprecated since 4.10, 1
True if the cell renderer can do anything when activated
Is_Expanded_Property : constant Glib.Properties.Property_Boolean;
Is_Expander_Property : constant Glib.Properties.Property_Boolean;
Mode_Property : constant Gtk.Cell_Renderer.Property_Gtk_Cell_Renderer_Mode;
Type: Gtk_Cell_Renderer_Mode
procedure On_Editing_Canceled
(Self : not null access Gtk_Cell_Renderer_Record;
Call : Cb_GObject_Void;
Slot : not null access Glib.Object.GObject_Record'Class;
After : Boolean := False)
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.
See also: Gtk.Cell_Renderer.Stop_Editing.
procedure On_Editing_Canceled
(Self : not null access Gtk_Cell_Renderer_Record;
Call : Cb_Gtk_Cell_Renderer_Void;
After : Boolean := False)
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.
See also: Gtk.Cell_Renderer.Stop_Editing.
procedure On_Editing_Started
(Self : not null access Gtk_Cell_Renderer_Record;
Call : Cb_GObject_Gtk_Cell_Editable_UTF8_String_Void;
Slot : not null access Glib.Object.GObject_Record'Class;
After : Boolean := False)
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.
See Gtk.Cell_Editable.Start_Editing for information on the lifecycle of the Editable and a way to do setup that doesn't depend on the Renderer.
Note that GTK doesn't guarantee that cell renderers will continue to use the same kind of widget for editing in future releases, therefore you should check the type of Editable before doing any specific setup, as in the following example:
GtkCellEditable *editable, const char *path, gpointer data) { if
(GTK_IS_ENTRY (editable)) { GtkEntry *entry = GTK_ENTRY (editable);
// ... create a GtkEntryCompletion
gtk_entry_set_completion (entry, completion); } } ```
Callback parameters:
-- @param Editable the `GtkCellEditable`
-- @param Path the path identifying the edited cell
procedure On_Editing_Started
(Self : not null access Gtk_Cell_Renderer_Record;
Call : Cb_Gtk_Cell_Renderer_Gtk_Cell_Editable_UTF8_String_Void;
After : Boolean := False)
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.
See Gtk.Cell_Editable.Start_Editing for information on the lifecycle of the Editable and a way to do setup that doesn't depend on the Renderer.
Note that GTK doesn't guarantee that cell renderers will continue to use the same kind of widget for editing in future releases, therefore you should check the type of Editable before doing any specific setup, as in the following example:
GtkCellEditable *editable, const char *path, gpointer data) { if
(GTK_IS_ENTRY (editable)) { GtkEntry *entry = GTK_ENTRY (editable);
// ... create a GtkEntryCompletion
gtk_entry_set_completion (entry, completion); } } ```
Callback parameters:
-- @param Editable the `GtkCellEditable`
-- @param Path the path identifying the edited cell
type Property_Gtk_Cell_Renderer_Mode is new Gtk_Cell_Renderer_Mode_Properties.Property;
type Property_Gtk_Cell_Renderer_State is new Gtk_Cell_Renderer_State_Properties.Property;
Sensitive_Property : constant Glib.Properties.Property_Boolean;
procedure Set_Alignment
(Cell : not null access Gtk_Cell_Renderer_Record;
Xalign : Interfaces.C.C_float;
Yalign : Interfaces.C.C_float)
Sets the renderer's alignment within its available space. Deprecated since 4.10, 1
the x alignment of the cell renderer
the y alignment of the cell renderer
procedure Set_Fixed_Size
(Cell : not null access Gtk_Cell_Renderer_Record;
Width : Glib.Gint;
Height : Glib.Gint)
Sets the renderer size to be explicit, independent of the properties set. Deprecated since 4.10, 1
the width of the cell renderer, or -1
the height of the cell renderer, or -1
procedure Set_Is_Expanded
(Cell : not null access Gtk_Cell_Renderer_Record;
Is_Expanded : Boolean)
Sets whether the given GtkCellRenderer is expanded. Deprecated since 4.10, 1
whether Cell should be expanded
procedure Set_Is_Expander
(Cell : not null access Gtk_Cell_Renderer_Record;
Is_Expander : Boolean)
Sets whether the given GtkCellRenderer is an expander. Deprecated since 4.10, 1
whether Cell is an expander
procedure Set_Padding
(Cell : not null access Gtk_Cell_Renderer_Record;
Xpad : Glib.Gint;
Ypad : Glib.Gint)
Sets the renderer's padding. Deprecated since 4.10, 1
the x padding of the cell renderer
the y padding of the cell renderer
procedure Set_Sensitive
(Cell : not null access Gtk_Cell_Renderer_Record;
Sensitive : Boolean)
Sets the cell renderer's sensitivity. Deprecated since 4.10, 1
the sensitivity of the cell
procedure Set_Visible
(Cell : not null access Gtk_Cell_Renderer_Record;
Visible : Boolean)
Sets the cell renderer's visibility. Deprecated since 4.10, 1
the visibility of the cell
Signal_Editing_Canceled : constant Glib.Signal_Name := "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.
See also: Gtk.Cell_Renderer.Stop_Editing.
Signal_Editing_Started : constant Glib.Signal_Name := "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.
See Gtk.Cell_Editable.Start_Editing for information on the lifecycle of the Editable and a way to do setup that doesn't depend on the Renderer.
Note that GTK doesn't guarantee that cell renderers will continue to use the same kind of widget for editing in future releases, therefore you should check the type of Editable before doing any specific setup, as in the following example:
GtkCellEditable *editable, const char *path, gpointer data) { if
(GTK_IS_ENTRY (editable)) { GtkEntry *entry = GTK_ENTRY (editable);
// ... create a GtkEntryCompletion
gtk_entry_set_completion (entry, completion); } } ```
Callback parameters:
-- @param Editable the `GtkCellEditable`
-- @param Path the path identifying the edited cell
procedure Snapshot
(Cell : not null access Gtk_Cell_Renderer_Record;
Snapshot : not null access Gtk.Snapshot.Gtk_Snapshot_Record'Class;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class;
Background_Area : Gdk.Rectangle.Gdk_Rectangle;
Cell_Area : Gdk.Rectangle.Gdk_Rectangle;
Flags : Gtk_Cell_Renderer_State)
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 since 4.10, 1
a GtkSnapshot to draw to
the widget owning Window
entire cell area (including tree expanders and maybe padding on the sides)
area normally rendered by a cell renderer
flags that affect rendering
function Start_Editing
(Cell : not null access Gtk_Cell_Renderer_Record;
Event : Gdk.Event.Gdk_Event;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class;
Path : UTF8_String;
Background_Area : Gdk.Rectangle.Gdk_Rectangle;
Cell_Area : Gdk.Rectangle.Gdk_Rectangle;
Flags : Gtk_Cell_Renderer_State)
return Gtk.Cell_Editable.Gtk_Cell_Editable
Starts editing the contents of this Cell, through a new GtkCellEditable widget created by the GtkCellRendererClass.start_editing virtual function. Deprecated since 4.10, 1
a GdkEvent
widget that received the event
widget-dependent string representation of the event location; e.g. for GtkTreeView, a string representation of GtkTreePath
background area as passed to gtk_cell_renderer_render
cell area as passed to gtk_cell_renderer_render
render flags
A new GtkCellEditable for editing this Cell, or null if editing is not possible
procedure Stop_Editing
(Cell : not null access Gtk_Cell_Renderer_Record;
Canceled : Boolean)
Informs the cell renderer that the editing is stopped. If Canceled is True, the cell renderer will emit the GtkCellRenderer::editing-canceled signal. This function should be called by cell renderer implementations in response to the GtkCellEditable::editing-done signal of GtkCellEditable. Deprecated since 4.10, 1
True if the editing has been canceled
Visible_Property : constant Glib.Properties.Property_Boolean;
Width_Property : constant Glib.Properties.Property_Int;
Xalign_Property : constant Glib.Properties.Property_Float;
Xpad_Property : constant Glib.Properties.Property_Uint;
Yalign_Property : constant Glib.Properties.Property_Float;
Ypad_Property : constant Glib.Properties.Property_Uint;