Handles the preferred size and allocation for children of a widget.
You typically subclass GtkLayoutManager if you want to implement a layout policy for the children of a widget, or if you want to determine the size of a widget depending on its contents.
Each GtkWidget can only have a GtkLayoutManager instance associated to it at any given time; it is possible, though, to replace the layout manager instance using [methodGtk.Widget.set_layout_manager].
## Layout properties
A layout manager can expose properties for controlling the layout of each child, by creating an object type derived from [classGtk.LayoutChild] and installing the properties on it as normal GObject properties.
Each GtkLayoutChild instance storing the layout properties for a specific child is created through the [methodGtk.LayoutManager.get_layout_child] method; a GtkLayoutManager controls the creation of its GtkLayoutChild instances by overriding the GtkLayoutManagerClass.create_layout_child virtual function. The typical implementation should look like:
*manager, GtkWidget *container, GtkWidget *child) { return g_object_new
(your_layout_child_get_type (), "layout-manager", manager, "child-widget",
child, NULL); } ```
The [propertyGtk.LayoutChild:layout-manager] and
[propertyGtk.LayoutChild:child-widget] properties on the newly created
`GtkLayoutChild` instance are mandatory. The `GtkLayoutManager` will cache
the newly created `GtkLayoutChild` instance until the widget is removed
from its parent, or the parent removes the layout manager.
Each `GtkLayoutManager` instance creating a `GtkLayoutChild` should use
[methodGtk.LayoutManager.get_layout_child] every time it needs to query the
layout properties; each `GtkLayoutChild` instance should call
[methodGtk.LayoutManager.layout_changed] every time a property is updated,
in order to queue a new size measuring and allocation.
<group>Layout containers</group>
procedure Allocate
(Manager : not null access Gtk_Layout_Manager_Record;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class;
Width : Glib.Gint;
Height : Glib.Gint;
Baseline : Glib.Gint)
Assigns the given Width, Height, and Baseline to a Widget, and computes the position and sizes of the children of the Widget using the layout management policy of Manager.
the GtkWidget using Manager
the new width of the Widget
the new height of the Widget
the baseline position of the Widget, or -1
Child_Widget_Property : constant Glib.Properties.Property_Object;
Type: Gtk.Widget.Gtk_Widget The widget that is associated to the GtkLayoutChild instance.
function Get_Child_Widget
(Layout_Child : not null access Gtk_Layout_Child_Record)
return Gtk.Widget.Gtk_Widget
Retrieves the GtkWidget associated to the given Layout_Child.
a GtkWidget. Has transfer-ownership='none'.
function Get_Layout_Child
(Manager : not null access Gtk_Layout_Manager_Record;
Child : not null access Gtk.Widget.Gtk_Widget_Record'Class)
return Gtk_Layout_Child
Retrieves a GtkLayoutChild instance for the GtkLayoutManager, creating one if necessary. The Child widget must be a child of the widget using Manager. The GtkLayoutChild instance is owned by the GtkLayoutManager, and is guaranteed to exist as long as Child is a child of the GtkWidget using the given GtkLayoutManager.
a GtkWidget
a GtkLayoutChild. Has transfer-ownership='none'.
function Get_Layout_Manager
(Layout_Child : not null access Gtk_Layout_Child_Record)
return Gtk_Layout_Manager
Retrieves the GtkLayoutManager instance that created the given Layout_Child.
a GtkLayoutManager. Has transfer-ownership='none'.
function Get_Request_Mode
(Manager : not null access Gtk_Layout_Manager_Record)
return Gtk.Enums.Gtk_Size_Request_Mode
Retrieves the request mode of Manager.
a GtkSizeRequestMode
function Get_Type return Glib.GType
function Get_Widget
(Manager : not null access Gtk_Layout_Manager_Record)
return Gtk.Widget.Gtk_Widget
Retrieves the GtkWidget using the given GtkLayoutManager.
a GtkWidget. Has transfer-ownership='none'.
type Gtk_Layout_Child is access all Gtk_Layout_Child_Record'Class;
type Gtk_Layout_Child_Record is new GObject_Record with null record;
type Gtk_Layout_Manager is access all Gtk_Layout_Manager_Record'Class;
type Gtk_Layout_Manager_Record is new GObject_Record with null record;
procedure Layout_Changed
(Manager : not null access Gtk_Layout_Manager_Record)
Queues a resize on the GtkWidget using Manager, if any. This function should be called by subclasses of GtkLayoutManager in response to changes to their layout management policies.
function Layout_Child_Get_Type return Glib.GType
Layout_Manager_Property : constant Glib.Properties.Property_Object;
Type: Gtk_Layout_Manager The layout manager that created the GtkLayoutChild instance.
procedure Measure
(Manager : not null access Gtk_Layout_Manager_Record;
Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class;
Orientation : Gtk.Enums.Gtk_Orientation;
For_Size : Glib.Gint;
Minimum : out Glib.Gint;
Natural : out Glib.Gint;
Minimum_Baseline : out Glib.Gint;
Natural_Baseline : out Glib.Gint)
Measures the size of the Widget using Manager, for the given Orientation and size. See the [classGtk.Widget] documentation on layout management for more details.
the GtkWidget using Manager
the orientation to measure
Size for the opposite of Orientation; for instance, if the Orientation is Gtk.Enums.Orientation_Horizontal, this is the height of the widget; if the Orientation is Gtk.Enums.Orientation_Vertical, this is the width of the widget. This allows to measure the height for the given width, and the width for the given height. Use -1 if the size is not known
the minimum size for the given size and orientation
the natural, or preferred size for the given size and orientation
the baseline position for the minimum size
the baseline position for the natural size