class Gtk::CellRenderer
- Gtk::CellRenderer
- GObject::InitiallyUnowned
- GObject::Object
- Reference
- Object
Overview
An object for rendering a single cell
The Gtk::CellRenderer
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 Gtk::TreeView
widget, though they aren’t tied to them in any
specific way. It is worth noting that Gtk::CellRenderer
is not a
Gtk::Widget
and cannot be treated as such.
The primary use of a Gtk::CellRenderer
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
Gtk::CellRenderer
. 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 Gtk::CellRenderer
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 Gtk::CellRenderer
Toggle,
which toggles when it gets activated by a mouse click, or it can be
“editable” like Gtk::CellRenderer
Text, which
allows the user to edit the text using a widget implementing the
Gtk::CellEditable
interface, e.g. Gtk::Entry
.
To make a cell renderer activatable or editable, you have to
implement the Gtk::CellRenderer
Class.activate or
Gtk::CellRenderer
Class.start_editing virtual functions, respectively.
Many properties of Gtk::CellRenderer
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.
Direct Known Subclasses
- Gtk::CellRendererPixbuf
- Gtk::CellRendererProgress
- Gtk::CellRendererSpinner
- Gtk::CellRendererText
- Gtk::CellRendererToggle
Defined in:
lib/gi-crystal/src/auto/gtk-4.0/cell_renderer.crConstructors
-
.new
Initialize a new
CellRenderer
. - .new(*, cell_background : String | Nil = nil, cell_background_rgba : Gdk::RGBA | Nil = nil, cell_background_set : Bool | Nil = nil, editing : Bool | Nil = nil, height : Int32 | Nil = nil, is_expanded : Bool | Nil = nil, is_expander : Bool | Nil = nil, mode : Gtk::CellRendererMode | Nil = nil, sensitive : Bool | Nil = nil, visible : Bool | Nil = nil, width : Int32 | Nil = nil, xalign : Float32 | Nil = nil, xpad : UInt32 | Nil = nil, yalign : Float32 | Nil = nil, ypad : UInt32 | Nil = nil)
Class Method Summary
-
.g_type : UInt64
Returns the type id (GType) registered in GLib type system.
Instance Method Summary
-
#==(other : self)
Returns
true
if this reference is the same as other. -
#activate(event : Gdk::Event, widget : Gtk::Widget, path : String, background_area : Gdk::Rectangle, cell_area : Gdk::Rectangle, flags : Gtk::CellRendererState) : Bool
Passes an activate event to the cell renderer for possible processing.
-
#aligned_area(widget : Gtk::Widget, flags : Gtk::CellRendererState, cell_area : Gdk::Rectangle) : Gdk::Rectangle
Gets the aligned area used by cell inside cell_area.
-
#alignment : Nil
Fills in xalign and yalign with the appropriate values of cell.
- #cell_background=(value : String) : String
-
#cell_background=(value : Nil) : Nil
Set
#cell_background
property to nil. - #cell_background_rgba : Gdk::RGBA | Nil
- #cell_background_rgba=(value : Gdk::RGBA | Nil) : Gdk::RGBA | Nil
- #cell_background_set=(value : Bool) : Bool
- #cell_background_set? : Bool
- #editing? : Bool
- #editing_canceled_signal
- #editing_started_signal
-
#fixed_size : Nil
Fills in width and height with the appropriate size of cell.
-
#hash(hasher)
See
Object#hash(hasher)
- #height : Int32
- #height=(value : Int32) : Int32
-
#is_activatable : Bool
Checks whether the cell renderer can do something when activated.
-
#is_expanded : Bool
Checks whether the given
Gtk::CellRenderer
is expanded. -
#is_expanded=(is_expanded : Bool) : Nil
Sets whether the given
Gtk::CellRenderer
is expanded. - #is_expanded? : Bool
-
#is_expander : Bool
Checks whether the given
Gtk::CellRenderer
is an expander. -
#is_expander=(is_expander : Bool) : Nil
Sets whether the given
Gtk::CellRenderer
is an expander. - #is_expander? : Bool
- #mode : Gtk::CellRendererMode
- #mode=(value : Gtk::CellRendererMode) : Gtk::CellRendererMode
-
#padding : Nil
Fills in xpad and ypad with the appropriate values of cell.
-
#preferred_height(widget : Gtk::Widget) : Nil
Retrieves a renderer’s natural size when rendered to widget.
-
#preferred_height_for_width(widget : Gtk::Widget, width : Int32) : Nil
Retrieves a cell renderers’s minimum and natural height if it were rendered to widget with the specified width.
-
#preferred_size(widget : 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.
-
#preferred_width(widget : Gtk::Widget) : Nil
Retrieves a renderer’s natural size when rendered to widget.
-
#preferred_width_for_height(widget : Gtk::Widget, height : Int32) : Nil
Retrieves a cell renderers’s minimum and natural width if it were rendered to widget with the specified height.
-
#request_mode : Gtk::SizeRequestMode
Gets whether the cell renderer prefers a height-for-width layout or a width-for-height layout.
-
#sensitive : Bool
Returns the cell renderer’s sensitivity.
-
#sensitive=(sensitive : Bool) : Nil
Sets the cell renderer’s sensitivity.
- #sensitive? : Bool
-
#set_alignment(xalign : Float32, yalign : Float32) : Nil
Sets the renderer’s alignment within its available space.
-
#set_fixed_size(width : Int32, height : Int32) : Nil
Sets the renderer size to be explicit, independent of the properties set.
-
#set_padding(xpad : Int32, ypad : Int32) : Nil
Sets the renderer’s padding.
-
#snapshot(snapshot : Gtk::Snapshot, widget : Gtk::Widget, background_area : Gdk::Rectangle, cell_area : Gdk::Rectangle, flags : Gtk::CellRendererState) : Nil
Invokes the virtual render function of the
Gtk::CellRenderer
. -
#start_editing(event : Gdk::Event | Nil, widget : Gtk::Widget, path : String, background_area : Gdk::Rectangle, cell_area : Gdk::Rectangle, flags : Gtk::CellRendererState) : Gtk::CellEditable | Nil
Starts editing the contents of this cell, through a new
Gtk::CellEditable
widget created by theGtk::CellRenderer
Class.start_editing virtual function. -
#state(widget : Gtk::Widget | Nil, cell_state : Gtk::CellRendererState) : Gtk::StateFlags
Translates the cell renderer state to
Gtk::StateFlags
, based on the cell renderer and widget sensitivity, and the givenGtk::CellRenderer
State. -
#stop_editing(canceled : Bool) : Nil
Informs the cell renderer that the editing is stopped.
-
#visible : Bool
Returns the cell renderer’s visibility.
-
#visible=(visible : Bool) : Nil
Sets the cell renderer’s visibility.
- #visible? : Bool
- #width : Int32
- #width=(value : Int32) : Int32
- #xalign : Float32
- #xalign=(value : Float32) : Float32
- #xpad : UInt32
- #xpad=(value : UInt32) : UInt32
- #yalign : Float32
- #yalign=(value : Float32) : Float32
- #ypad : UInt32
- #ypad=(value : UInt32) : UInt32
Instance methods inherited from class GObject::InitiallyUnowned
==(other : self)
==,
hash(hasher)
hash
Constructor methods inherited from class GObject::InitiallyUnowned
new
new
Class methods inherited from class GObject::InitiallyUnowned
g_type : UInt64
g_type
Instance methods inherited from class GObject::Object
==(other : self)
==,
bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding
bind_property,
bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding
bind_property_full,
data(key : String) : Pointer(Void) | Nil
data,
finalize
finalize,
freeze_notify : Nil
freeze_notify,
getv(names : Enumerable(String), values : Enumerable(_)) : Nil
getv,
hash(hasher)
hash,
notify(property_name : String) : Nil
notify,
notify_by_pspec(pspec : GObject::ParamSpec) : Nil
notify_by_pspec,
notify_signal
notify_signal,
property(property_name : String, value : _) : Nil
property,
qdata(quark : UInt32) : Pointer(Void) | Nil
qdata,
ref_count : UInt32
ref_count,
run_dispose : Nil
run_dispose,
set_data(key : String, data : Pointer(Void) | Nil) : Nil
set_data,
set_property(property_name : String, value : _) : Nil
set_property,
steal_data(key : String) : Pointer(Void) | Nil
steal_data,
steal_qdata(quark : UInt32) : Pointer(Void) | Nil
steal_qdata,
thaw_notify : Nil
thaw_notify,
to_unsafe : Pointer(Void)
to_unsafe,
watch_closure(closure : GObject::Closure) : Nil
watch_closure
Constructor methods inherited from class GObject::Object
cast(obj : GObject::Object) : self
cast,
new(pointer : Pointer(Void), transfer : GICrystal::Transfer)new new, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv
Class methods inherited from class GObject::Object
cast?(obj : GObject::Object) : self | Nil
cast?,
compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64
compat_control,
g_type : UInt64
g_type,
interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec
interface_find_property,
interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec)
interface_list_properties
Macros inherited from class GObject::Object
previous_vfunc(*args)
previous_vfunc,
previous_vfunc!(*args)
previous_vfunc!,
signal(signature)
signal
Constructor Detail
Class Method Detail
Returns the type id (GType) registered in GLib type system.
Instance Method Detail
Returns true
if this reference is the same as other. Invokes same?
.
Passes an activate event to the cell renderer for possible processing.
Some cell renderers may use events; for example, Gtk::CellRendererToggle
toggles when it gets a mouse click.
Gets the aligned area used by cell inside cell_area. Used for finding the appropriate edit and focus rectangle.
Checks whether the cell renderer can do something when activated.
Sets whether the given Gtk::CellRenderer
is expanded.
Sets whether the given Gtk::CellRenderer
is an expander.
Retrieves a renderer’s natural size when rendered to widget.
Retrieves a cell renderers’s minimum and natural height if it were rendered to widget with the specified width.
Retrieves the minimum and natural size of a cell taking into account the widget’s preference for height-for-width management.
Retrieves a renderer’s natural size when rendered to widget.
Retrieves a cell renderers’s minimum and natural width if it were rendered to widget with the specified height.
Gets whether the cell renderer prefers a height-for-width layout or a width-for-height layout.
Sets the renderer’s alignment within its available space.
Sets the renderer size to be explicit, independent of the properties set.
Invokes the virtual render function of the Gtk::CellRenderer
. 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 Gtk::CellRenderer
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.
Starts editing the contents of this cell, through a new Gtk::CellEditable
widget created by the Gtk::CellRenderer
Class.start_editing virtual function.
Translates the cell renderer state to Gtk::StateFlags
,
based on the cell renderer and widget sensitivity, and
the given Gtk::CellRenderer
State.
Informs the cell renderer that the editing is stopped.
If canceled is true
, the cell renderer will emit the
Gtk::CellRenderer
::editing-canceled signal.
This function should be called by cell renderer implementations
in response to the Gtk::CellEditable::editing-done
signal of
Gtk::CellEditable
.