LayoutManagerProtocol
public protocol LayoutManagerProtocol : ObjectProtocol
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 LayoutManagerProtocol
protocol exposes the methods and properties of an underlying GtkLayoutManager
instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see LayoutManager
.
Alternatively, use LayoutManagerRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkLayoutManager
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
layout_manager_ptr
Default implementationTyped pointer to the underlying
GtkLayoutManager
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkLayoutManager
instance.Declaration
Swift
var layout_manager_ptr: UnsafeMutablePointer<GtkLayoutManager>! { get }
-
Required Initialiser for types conforming to
LayoutManagerProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
allocate(widget:
Extension methodwidth: height: baseline: ) Assigns the given
width
,height
, andbaseline
to awidget
, and computes the position and sizes of the children of thewidget
using the layout management policy ofmanager
.Declaration
Swift
@inlinable func allocate<WidgetT>(widget: WidgetT, width: Int, height: Int, baseline: Int) where WidgetT : WidgetProtocol
-
getLayout(child:
Extension method) Retrieves a
GtkLayoutChild
instance for theGtkLayoutManager
, creating one if necessary.The
child
widget must be a child of the widget usingmanager
.The
GtkLayoutChild
instance is owned by theGtkLayoutManager
, and is guaranteed to exist as long aschild
is a child of theGtkWidget
using the givenGtkLayoutManager
.Declaration
Swift
@inlinable func getLayout<WidgetT>(child: WidgetT) -> LayoutChildRef! where WidgetT : WidgetProtocol
-
getRequestMode()
Extension methodRetrieves the request mode of
manager
.Declaration
Swift
@inlinable func getRequestMode() -> GtkSizeRequestMode
-
getWidget()
Extension methodRetrieves the
GtkWidget
using the givenGtkLayoutManager
.Declaration
Swift
@inlinable func getWidget() -> WidgetRef!
-
layoutChanged()
Extension methodQueues a resize on the
GtkWidget
usingmanager
, if any.This function should be called by subclasses of
GtkLayoutManager
in response to changes to their layout management policies.Declaration
Swift
@inlinable func layoutChanged()
-
Measures the size of the
widget
usingmanager
, for the givenorientation
and size.See the [class
Gtk.Widget
] documentation on layout management for more details.Declaration
Swift
@inlinable func measure<WidgetT>(widget: WidgetT, orientation: GtkOrientation, for size: Int, minimum: UnsafeMutablePointer<gint>! = nil, natural: UnsafeMutablePointer<gint>! = nil, minimumBaseline: UnsafeMutablePointer<gint>! = nil, naturalBaseline: UnsafeMutablePointer<gint>! = nil) where WidgetT : WidgetProtocol
-
requestMode
Extension methodRetrieves the request mode of
manager
.Declaration
Swift
@inlinable var requestMode: GtkSizeRequestMode { get }
-
widget
Extension methodRetrieves the
GtkWidget
using the givenGtkLayoutManager
.Declaration
Swift
@inlinable var widget: WidgetRef! { get }
-
parentInstance
Extension methodUndocumented
Declaration
Swift
@inlinable var parentInstance: GObject { get }