gi-gtk-4.0.8: Gtk bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Gtk.Objects.LayoutManager

Description

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

Layout properties

A layout manager can expose properties for controlling the layout of each child, by creating an object type derived from 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 layoutManagerGetLayoutChild 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:

c code

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 LayoutChild:layoutManager and LayoutChild:childWidget 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 layoutManagerGetLayoutChild every time it needs to query the layout properties; each GtkLayoutChild instance should call layoutManagerLayoutChanged every time a property is updated, in order to queue a new size measuring and allocation.

Synopsis

Exported types

newtype LayoutManager Source #

Memory-managed wrapper type.

Constructors

LayoutManager (ManagedPtr LayoutManager) 

Instances

Instances details
Eq LayoutManager Source # 
Instance details

Defined in GI.Gtk.Objects.LayoutManager

GObject LayoutManager Source # 
Instance details

Defined in GI.Gtk.Objects.LayoutManager

ManagedPtrNewtype LayoutManager Source # 
Instance details

Defined in GI.Gtk.Objects.LayoutManager

Methods

toManagedPtr :: LayoutManager -> ManagedPtr LayoutManager

TypedObject LayoutManager Source # 
Instance details

Defined in GI.Gtk.Objects.LayoutManager

Methods

glibType :: IO GType

HasParentTypes LayoutManager Source # 
Instance details

Defined in GI.Gtk.Objects.LayoutManager

IsGValue (Maybe LayoutManager) Source #

Convert LayoutManager to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Gtk.Objects.LayoutManager

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe LayoutManager -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe LayoutManager)

type ParentTypes LayoutManager Source # 
Instance details

Defined in GI.Gtk.Objects.LayoutManager

type ParentTypes LayoutManager = '[Object]

class (GObject o, IsDescendantOf LayoutManager o) => IsLayoutManager o Source #

Type class for types which can be safely cast to LayoutManager, for instance with toLayoutManager.

Instances

Instances details
(GObject o, IsDescendantOf LayoutManager o) => IsLayoutManager o Source # 
Instance details

Defined in GI.Gtk.Objects.LayoutManager

toLayoutManager :: (MonadIO m, IsLayoutManager o) => o -> m LayoutManager Source #

Cast to LayoutManager, for types for which this is known to be safe. For general casts, use castTo.

Methods

allocate

layoutManagerAllocate Source #

Arguments

:: (HasCallStack, MonadIO m, IsLayoutManager a, IsWidget b) 
=> a

manager: a GtkLayoutManager

-> b

widget: the GtkWidget using manager

-> Int32

width: the new width of the widget

-> Int32

height: the new height of the widget

-> Int32

baseline: the baseline position of the widget, or -1

-> m () 

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.

getLayoutChild

layoutManagerGetLayoutChild Source #

Arguments

:: (HasCallStack, MonadIO m, IsLayoutManager a, IsWidget b) 
=> a

manager: a GtkLayoutManager

-> b

child: a GtkWidget

-> m LayoutChild

Returns: a GtkLayoutChild

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

The child widget must be a child of the widget using manager.

The GtkLayoutChild instance is owned by the GtkLayoutManager, and is guaranteed to exist as long as child is a child of the GtkWidget using the given GtkLayoutManager.

getRequestMode

layoutManagerGetRequestMode Source #

Arguments

:: (HasCallStack, MonadIO m, IsLayoutManager a) 
=> a

manager: a GtkLayoutManager

-> m SizeRequestMode

Returns: a GtkSizeRequestMode

Retrieves the request mode of manager.

getWidget

layoutManagerGetWidget Source #

Arguments

:: (HasCallStack, MonadIO m, IsLayoutManager a) 
=> a

manager: a GtkLayoutManager

-> m (Maybe Widget)

Returns: a GtkWidget

Retrieves the GtkWidget using the given GtkLayoutManager.

layoutChanged

layoutManagerLayoutChanged Source #

Arguments

:: (HasCallStack, MonadIO m, IsLayoutManager a) 
=> a

manager: a GtkLayoutManager

-> m () 

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

This function should be called by subclasses of GtkLayoutManager in response to changes to their layout management policies.

measure

layoutManagerMeasure Source #

Arguments

:: (HasCallStack, MonadIO m, IsLayoutManager a, IsWidget b) 
=> a

manager: a GtkLayoutManager

-> b

widget: the GtkWidget using manager

-> Orientation

orientation: the orientation to measure

-> Int32

forSize: Size for the opposite of orientation; for instance, if the orientation is OrientationHorizontal, this is the height of the widget; if the orientation is OrientationVertical, 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

-> m (Int32, Int32, Int32, Int32) 

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

See the Widget documentation on layout management for more details.