gtk.layout_manager

Module for [LayoutManager] class

Types 3

Layout managers are delegate classes that handle the preferred size and the allocation of a widget.

You typically subclass [gtk.layout_manager.LayoutManager] 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 [gtk.widget.Widget] can only have a [gtk.layout_manager.LayoutManager] instance associated to it at any given time; it is possible, though, to replace the layout manager instance using [gtk.widget.Widget.setLayoutManager].

Layout properties

A layout manager can expose properties for controlling the layout of each child, by creating an object type derived from [gtk.layout_child.LayoutChild] and installing the properties on it as normal [gobject.object.ObjectWrap] properties.

Each [gtk.layout_child.LayoutChild] instance storing the layout properties for a specific child is created through the [gtk.layout_manager.LayoutManager.getLayoutChild] method; a [gtk.layout_manager.LayoutManager] controls the creation of its [gtk.layout_child.LayoutChild] instances by overriding the GtkLayoutManagerClass.create_layout_child() virtual function. The typical implementation should look like:

static GtkLayoutChild *
create_layout_child (GtkLayoutManager *manager,
                    GtkWidget        *container,
                    GtkWidget        *child)
{
 return g_object_new (your_layout_child_get_type (),
                      "layout-manager", manager,
                      "child-widget", child,
                      NULL);
}

The property@Gtk.LayoutChild:layout-manager and property@Gtk.LayoutChild:child-widget properties on the newly created [gtk.layout_child.LayoutChild] instance are mandatory. The [gtk.layout_manager.LayoutManager] will cache the newly created [gtk.layout_child.LayoutChild] instance until the widget is removed from its parent, or the parent removes the layout manager.

Each [gtk.layout_manager.LayoutManager] instance creating a [gtk.layout_child.LayoutChild] should use [gtk.layout_manager.LayoutManager.getLayoutChild] every time it needs to query the layout properties; each [gtk.layout_child.LayoutChild] instance should call [gtk.layout_manager.LayoutManager.layoutChanged] every time a property is updated, in order to queue a new size measuring and allocation.

Methods
GType _gType() @property
LayoutManager self()Returns `this`, for use in `with` statements.
LayoutManagerGidBuilder builder()Get builder for [gtk.layout_manager.LayoutManager] Returns: New builder object
void allocate(gtk.widget.Widget widget, int width, int height, int baseline)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.
gtk.layout_child.LayoutChild getLayoutChild(gtk.widget.Widget child)Retrieves a [gtk.layoutchild.LayoutChild] instance for the [gtk.layoutmanager.LayoutManager], creating one if necessary.
gtk.types.SizeRequestMode getRequestMode()Retrieves the request mode of manager. Returns: a [gtk.types.SizeRequestMode]
gtk.widget.Widget getWidget()Retrieves the [gtk.widget.Widget] using the given [gtk.layout_manager.LayoutManager]. Returns: a [gtk.widget.Widget]
void layoutChanged()Queues a resize on the [gtk.widget.Widget] using manager, if any.
void measure(gtk.widget.Widget widget, gtk.types.Orientation orientation, int forSize, out int minimum, out int natural, out int minimumBaseline, out int naturalBaseline)Measures the size of the widget using manager, for the given orientation and size.
Constructors
this(void * ptr, Flag!"Take" take)

Fluent builder for [gtk.layout_manager.LayoutManager]