Gtk.LayoutManager¶
- Subclasses:
Gtk.BinLayout
,Gtk.BoxLayout
,Gtk.CenterLayout
,Gtk.ConstraintLayout
,Gtk.CustomLayout
,Gtk.FixedLayout
,Gtk.GridLayout
,Gtk.OverlayLayout
Methods¶
- Inherited:
- Structs:
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
|
|
|
|
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Gtk.LayoutManager(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
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 aGtkLayoutManager
instance associated to it at any given time; it is possible, though, to replace the layout manager instance using [method`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 [class`Gtk`.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 [method`Gtk`.LayoutManager.get_layout_child] method; aGtkLayoutManager
controls the creation of itsGtkLayoutChild
instances by overriding theGtk.LayoutManager.do_create_layout_child
() virtual function. The typical implementation should look like:``c static GtkLayoutChild * create_layout_child (GtkLayoutManager *manager,
- {
- 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
GtkLayoutChild
instance are mandatory. TheGtkLayoutManager
will cache the newly createdGtkLayoutChild
instance until the widget is removed from its parent, or the parent removes the layout manager.Each
GtkLayoutManager
instance creating aGtkLayoutChild
should use [method`Gtk`.LayoutManager.get_layout_child] every time it needs to query the layout properties; eachGtkLayoutChild
instance should call [method`Gtk`.LayoutManager.layout_changed] every time a property is updated, in order to queue a new size measuring and allocation.- allocate(widget, width, height, baseline)[source]¶
- Parameters:
widget (
Gtk.Widget
) – theGtkWidget
using selfwidth (
int
) – the new width of the widgetheight (
int
) – the new height of the widgetbaseline (
int
) – the baseline position of the widget, or -1
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 self.
- get_layout_child(child)[source]¶
- Parameters:
child (
Gtk.Widget
) – aGtkWidget
- Returns:
a
GtkLayoutChild
- Return type:
Retrieves a
GtkLayoutChild
instance for theGtkLayoutManager
, creating one if necessary.The child widget must be a child of the widget using self.
The
GtkLayoutChild
instance is owned by theGtkLayoutManager
, and is guaranteed to exist as long as child is a child of theGtkWidget
using the givenGtkLayoutManager
.
- get_request_mode()[source]¶
- Returns:
a
GtkSizeRequestMode
- Return type:
Retrieves the request mode of self.
- get_widget()[source]¶
- Returns:
a
GtkWidget
- Return type:
Gtk.Widget
orNone
Retrieves the
GtkWidget
using the givenGtkLayoutManager
.
- layout_changed()[source]¶
Queues a resize on the
GtkWidget
using self, if any.This function should be called by subclasses of
GtkLayoutManager
in response to changes to their layout management policies.
- measure(widget, orientation, for_size)[source]¶
- Parameters:
widget (
Gtk.Widget
) – theGtkWidget
using selforientation (
Gtk.Orientation
) – the orientation to measurefor_size (
int
) – Size for the opposite of orientation; for instance, if the orientation isGtk.Orientation.HORIZONTAL
, this is the height of the widget; if the orientation isGtk.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
- Returns:
- minimum:
the minimum size for the given size and orientation
- natural:
the natural, or preferred size for the given size and orientation
- minimum_baseline:
the baseline position for the minimum size
- natural_baseline:
the baseline position for the natural size
- Return type:
(minimum:
int
, natural:int
, minimum_baseline:int
, natural_baseline:int
)
Measures the size of the widget using self, for the given orientation and size.
See the [class`Gtk`.Widget] documentation on layout management for more details.
- do_allocate(widget, width, height, baseline) virtual¶
- Parameters:
widget (
Gtk.Widget
) – theGtkWidget
using managerwidth (
int
) – the new width of the widgetheight (
int
) – the new height of the widgetbaseline (
int
) – the baseline position of the widget, or -1
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.
- do_create_layout_child(widget, for_child) virtual¶
- Parameters:
widget (
Gtk.Widget
) – the widget using the managerfor_child (
Gtk.Widget
) – the child of widget
- Returns:
a
GtkLayoutChild
- Return type:
Create a
GtkLayoutChild
instance for the given for_child widget.
- do_get_request_mode(widget) virtual¶
- Parameters:
widget (
Gtk.Widget
) –- Return type:
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
- do_measure(widget, orientation, for_size) virtual¶
- Parameters:
widget (
Gtk.Widget
) – theGtkWidget
using managerorientation (
Gtk.Orientation
) – the orientation to measurefor_size (
int
) – Size for the opposite of orientation; for instance, if the orientation isGtk.Orientation.HORIZONTAL
, this is the height of the widget; if the orientation isGtk.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
- Returns:
- minimum:
the minimum size for the given size and orientation
- natural:
the natural, or preferred size for the given size and orientation
- minimum_baseline:
the baseline position for the minimum size
- natural_baseline:
the baseline position for the natural size
- Return type:
(minimum:
int
, natural:int
, minimum_baseline:int
, natural_baseline:int
)
Measures the size of the widget using manager, for the given orientation and size.
See the [class`Gtk`.Widget] documentation on layout management for more details.
- do_root() virtual¶
a virtual function, called when the widget using the layout manager is attached to a
GtkRoot
- do_unroot() virtual¶
a virtual function, called when the widget using the layout manager is detached from a
GtkRoot