### Class

# GtkLayoutManager

#### Description [src]

    abstract class Gtk.LayoutManager : GObject.Object
    {
      /* No available fields */
    }

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 `gtk_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 `GtkLayoutChild` 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 `gtk_layout_manager_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 `GtkLayoutChild:layout-manager` and `GtkLayoutChild: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 `gtk_layout_manager_get_layout_child()` every time it needs to query the layout properties; each `GtkLayoutChild` instance should call `gtk_layout_manager_layout_changed()` every time a property is updated, in order to queue a new size measuring and allocation.

#### Hierarchy

#### Ancestors

- GObject

#### Descendants

- GtkBinLayout
- GtkBoxLayout
- GtkCenterLayout
- GtkConstraintLayout
- GtkCustomLayout
- GtkFixedLayout
- GtkGridLayout
- GtkOverlayLayout

#### Instance methods

###### gtk_layout_manager_allocate

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_manager_get_layout_child

Retrieves a `GtkLayoutChild` instance for the `GtkLayoutManager`, creating one if necessary.

###### gtk_layout_manager_get_request_mode

Retrieves the request mode of `manager`.

###### gtk_layout_manager_get_widget

Retrieves the `GtkWidget` using the given `GtkLayoutManager`.

###### gtk_layout_manager_layout_changed

Queues a resize on the `GtkWidget` using `manager`, if any.

###### gtk_layout_manager_measure

Measures the size of the `widget` using `manager`, for the given `orientation` and size.

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Signals

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct GtkLayoutManagerClass {
      GtkSizeRequestMode (* get_request_mode) (
        GtkLayoutManager* manager,
        GtkWidget* widget
      );
      void (* measure) (
        GtkLayoutManager* manager,
        GtkWidget* widget,
        GtkOrientation orientation,
        int for_size,
        int* minimum,
        int* natural,
        int* minimum_baseline,
        int* natural_baseline
      );
      void (* allocate) (
        GtkLayoutManager* manager,
        GtkWidget* widget,
        int width,
        int height,
        int baseline
      );
      GType layout_child_type;
      GtkLayoutChild* (* create_layout_child) (
        GtkLayoutManager* manager,
        GtkWidget* widget,
        GtkWidget* for_child
      );
      void (* root) (
        GtkLayoutManager* manager
      );
      void (* unroot) (
        GtkLayoutManager* manager
      );

    }

The `GtkLayoutManagerClass` structure contains only private data, and should only be accessed through the provided API, or when subclassing `GtkLayoutManager`.

###### Class members

`get_request_mode: GtkSizeRequestMode (* get_request_mode) ( GtkLayoutManager* manager, GtkWidget* widget )`

  A virtual function, used to return the preferred request mode for the layout manager; for instance, “width for height” or “height for width”; see `GtkSizeRequestMode`

`measure: void (* measure) ( GtkLayoutManager* manager, GtkWidget* widget, GtkOrientation orientation, int for_size, int* minimum, int* natural, int* minimum_baseline, int* natural_baseline )`

  A virtual function, used to measure the minimum and preferred sizes of the widget using the layout manager for a given orientation.

`allocate: void (* allocate) ( GtkLayoutManager* manager, GtkWidget* widget, int width, int height, int baseline )`

  A virtual function, used to allocate the size of the widget using the layout manager.

`layout_child_type: GType`

  The type of `GtkLayoutChild` used by this layout manager.

`create_layout_child: GtkLayoutChild* (* create_layout_child) ( GtkLayoutManager* manager, GtkWidget* widget, GtkWidget* for_child )`

  A virtual function, used to create a `GtkLayoutChild` meta object for the layout properties.

`root: void (* root) ( GtkLayoutManager* manager )`

  A virtual function, called when the widget using the layout manager is attached to a `GtkRoot`

`unroot: void (* unroot) ( GtkLayoutManager* manager )`

  A virtual function, called when the widget using the layout manager is detached from a `GtkRoot`

#### Virtual methods

###### Gtk.LayoutManagerClass.allocate

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.LayoutManagerClass.create_layout_child

Create a `GtkLayoutChild` instance for the given `for_child` widget.

###### Gtk.LayoutManagerClass.get_request_mode

A virtual function, used to return the preferred request mode for the layout manager; for instance, “width for height” or “height for width”; see `GtkSizeRequestMode`

###### Gtk.LayoutManagerClass.measure

Measures the size of the `widget` using `manager`, for the given `orientation` and size.

###### Gtk.LayoutManagerClass.root

A virtual function, called when the widget using the layout manager is attached to a `GtkRoot`

###### Gtk.LayoutManagerClass.unroot

A virtual function, called when the widget using the layout manager is detached from a `GtkRoot`