class Gtk::CellAreaContext

Overview

Stores geometrical information for a series of rows in a Gtk::CellArea

The Gtk::CellAreaContext object is created by a given Gtk::CellArea implementation via its Gtk::CellAreaClass.create_context() virtual method and is used to store cell sizes and alignments for a series of Gtk::TreeModel rows that are requested and rendered in the same context.

Gtk::CellLayout widgets can create any number of contexts in which to request and render groups of data rows. However, it’s important that the same context which was used to request sizes for a given Gtk::TreeModel row also be used for the same row when calling other Gtk::CellArea APIs such as gtk_cell_area_render() and gtk_cell_area_event().

Defined in:

lib/gi-crystal/src/auto/gtk-4.0/cell_area_context.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class GObject::Object

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)? data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, 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)? qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void)?) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void)? steal_data, steal_qdata(quark : UInt32) : Pointer(Void)? 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, 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

compat_control(what : UInt64, data : Pointer(Void)?) : 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

Constructor Detail

def self.new #

Initialize a new CellAreaContext.


def self.new(*, area : Gtk::CellArea? = nil, minimum_height : Int32? = nil, minimum_width : Int32? = nil, natural_height : Int32? = nil, natural_width : Int32? = nil) #

Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


Instance Method Detail

def allocate(width : Int32, height : Int32) : Nil #

Allocates a width and/or a height for all rows which are to be rendered with @context.

Usually allocation is performed only horizontally or sometimes vertically since a group of rows are usually rendered side by side vertically or horizontally and share either the same width or the same height. Sometimes they are allocated in both horizontal and vertical orientations producing a homogeneous effect of the rows. This is generally the case for Gtk::TreeView when Gtk::TreeView:fixed-height-mode is enabled.


def allocation : Nil #

Fetches the current allocation size for @context.

If the context was not allocated in width or height, or if the context was recently reset with gtk_cell_area_context_reset(), the returned value will be -1.


def area : Gtk::CellArea #

Fetches the Gtk::CellArea this @context was created by.

This is generally unneeded by layouting widgets; however, it is important for the context implementation itself to fetch information about the area it is being used for.

For instance at Gtk::CellAreaContextClass.allocate() time it’s important to know details about any cell spacing that the Gtk::CellArea is configured with in order to compute a proper allocation.


def area=(value : Gtk::CellArea?) : Gtk::CellArea? #

def minimum_height : Int32 #

def minimum_width : Int32 #

def natural_height : Int32 #

def natural_width : Int32 #

def preferred_height : Nil #

Gets the accumulative preferred height for all rows which have been requested with this context.

After gtk_cell_area_context_reset() is called and/or before ever requesting the size of a Gtk::CellArea, the returned values are 0.


def preferred_height_for_width(width : Int32) : Nil #

Gets the accumulative preferred height for @width for all rows which have been requested for the same said @width with this context.

After gtk_cell_area_context_reset() is called and/or before ever requesting the size of a Gtk::CellArea, the returned values are -1.


def preferred_width : Nil #

Gets the accumulative preferred width for all rows which have been requested with this context.

After gtk_cell_area_context_reset() is called and/or before ever requesting the size of a Gtk::CellArea, the returned values are 0.


def preferred_width_for_height(height : Int32) : Nil #

Gets the accumulative preferred width for @height for all rows which have been requested for the same said @height with this context.

After gtk_cell_area_context_reset() is called and/or before ever requesting the size of a Gtk::CellArea, the returned values are -1.


def push_preferred_height(minimum_height : Int32, natural_height : Int32) : Nil #

Causes the minimum and/or natural height to grow if the new proposed sizes exceed the current minimum and natural height.

This is used by Gtk::CellAreaContext implementations during the request process over a series of Gtk::TreeModel rows to progressively push the requested height over a series of gtk_cell_area_get_preferred_height() requests.


def push_preferred_width(minimum_width : Int32, natural_width : Int32) : Nil #

Causes the minimum and/or natural width to grow if the new proposed sizes exceed the current minimum and natural width.

This is used by Gtk::CellAreaContext implementations during the request process over a series of Gtk::TreeModel rows to progressively push the requested width over a series of gtk_cell_area_get_preferred_width() requests.


def reset : Nil #

Resets any previously cached request and allocation data.

When underlying Gtk::TreeModel data changes its important to reset the context if the content size is allowed to shrink. If the content size is only allowed to grow (this is usually an option for views rendering large data stores as a measure of optimization), then only the row that changed or was inserted needs to be (re)requested with gtk_cell_area_get_preferred_width().

When the new overall size of the context requires that the allocated size changes (or whenever this allocation changes at all), the variable row sizes need to be re-requested for every row.

For instance, if the rows are displayed all with the same width from top to bottom then a change in the allocated width necessitates a recalculation of all the displayed row heights using gtk_cell_area_get_preferred_height_for_width().