LayoutManager

open class LayoutManager : GLibObject.Object, LayoutManagerProtocol

Layout managers are delegate classes that handle the preferred size and the allocation 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:

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 [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.

The LayoutManager type acts as a reference-counted owner of an underlying GtkLayoutManager instance. It provides the methods that can operate on this data type through LayoutManagerProtocol conformance. Use LayoutManager as a strong reference or owner of a GtkLayoutManager instance.

  • Designated initialiser from the underlying `C` data type.
    

    This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the LayoutManager instance.

    Declaration

    Swift

    @inlinable
    public init(_ op: UnsafeMutablePointer<GtkLayoutManager>)

    Parameters

    op

    pointer to the underlying object

  • Designated initialiser from a constant pointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the LayoutManager instance.

    Declaration

    Swift

    @inlinable
    public init(_ op: UnsafePointer<GtkLayoutManager>)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from a non-mutating gpointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the LayoutManager instance.

    Declaration

    Swift

    @inlinable
    override public init!(gpointer op: gpointer?)

    Parameters

    op

    gpointer to the underlying object

  • Optional initialiser from a non-mutating gconstpointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the LayoutManager instance.

    Declaration

    Swift

    @inlinable
    override public init!(gconstpointer op: gconstpointer?)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from a constant pointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the LayoutManager instance.

    Declaration

    Swift

    @inlinable
    public init!(_ op: UnsafePointer<GtkLayoutManager>?)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the LayoutManager instance.

    Declaration

    Swift

    @inlinable
    public init!(_ op: UnsafeMutablePointer<GtkLayoutManager>?)

    Parameters

    op

    pointer to the underlying object

  • Designated initialiser from the underlying C data type. Will retain GtkLayoutManager. i.e., ownership is transferred to the LayoutManager instance.

    Declaration

    Swift

    @inlinable
    public init(retaining op: UnsafeMutablePointer<GtkLayoutManager>)

    Parameters

    op

    pointer to the underlying object

  • Reference intialiser for a related type that implements LayoutManagerProtocol Will retain GtkLayoutManager.

    Declaration

    Swift

    @inlinable
    public init<T>(layoutManager other: T) where T : LayoutManagerProtocol

    Parameters

    other

    an instance of a related type that implements LayoutManagerProtocol

  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to LayoutManagerProtocol.

    Declaration

    Swift

    @inlinable
    override public init<T>(cPointer p: UnsafeMutablePointer<T>)

    Parameters

    cPointer

    pointer to the underlying object

  • Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to LayoutManagerProtocol.

    Declaration

    Swift

    @inlinable
    override public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)

    Parameters

    cPointer

    pointer to the underlying object

  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to LayoutManagerProtocol.

    Declaration

    Swift

    @inlinable
    override public init(raw p: UnsafeRawPointer)

    Parameters

    p

    raw pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to LayoutManagerProtocol.

    Declaration

    Swift

    @inlinable
    override public init(retainingRaw raw: UnsafeRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to LayoutManagerProtocol.

    Declaration

    Swift

    @inlinable
    public required init(raw p: UnsafeMutableRawPointer)

    Parameters

    p

    mutable raw pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to LayoutManagerProtocol.

    Declaration

    Swift

    @inlinable
    required public init(retainingRaw raw: UnsafeMutableRawPointer)

    Parameters

    raw

    mutable raw pointer to the underlying object

  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to LayoutManagerProtocol.

    Declaration

    Swift

    @inlinable
    override public init(opaquePointer p: OpaquePointer)

    Parameters

    p

    opaque pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to LayoutManagerProtocol.

    Declaration

    Swift

    @inlinable
    override public init(retainingOpaquePointer p: OpaquePointer)

    Parameters

    p

    opaque pointer to the underlying object