BoxProtocol

public protocol BoxProtocol : OrientableProtocol, WidgetProtocol

The GtkBox widget arranges child widgets into a single row or column.

An example GtkBox

Whether it is a row or column depends on the value of its [propertyGtk.Orientable:orientation] property. Within the other dimension, all children are allocated the same size. Of course, the [propertyGtk.Widget:halign] and [propertyGtk.Widget:valign] properties can be used on the children to influence their allocation.

Use repeated calls to [methodGtk.Box.append] to pack widgets into a GtkBox from start to end. Use [methodGtk.Box.remove] to remove widgets from the GtkBox. [methodGtk.Box.insert_child_after] can be used to add a child at a particular position.

Use [methodGtk.Box.set_homogeneous] to specify whether or not all children of the GtkBox are forced to get the same amount of space.

Use [methodGtk.Box.set_spacing] to determine how much space will be minimally placed between all children in the GtkBox. Note that spacing is added between the children.

Use [methodGtk.Box.reorder_child_after] to move a child to a different place in the box.

CSS nodes

GtkBox uses a single CSS node with name box.

Accessibility

GtkBox uses the GTK_ACCESSIBLE_ROLE_GROUP role.

The BoxProtocol protocol exposes the methods and properties of an underlying GtkBox 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 Box. Alternatively, use BoxRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying GtkBox instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • box_ptr Default implementation

    Typed pointer to the underlying GtkBox instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GtkBox instance.

    Declaration

    Swift

    var box_ptr: UnsafeMutablePointer<GtkBox>! { get }
  • Required Initialiser for types conforming to BoxProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)
  • append(children:) Extension method

    Append a list of children

    Declaration

    Swift

    @inlinable
    func append<S>(children: S) where S : Sequence, S.Element : WidgetProtocol

    Parameters

    children

    sequence of widgets to append

  • set(marginStart:) Extension method

    Set the start margin of the box

    Declaration

    Swift

    @inlinable
    func set(marginStart: Int)

    Parameters

    marginStart

    start margin

  • set(marginEnd:) Extension method

    Set the end margin of the box

    Declaration

    Swift

    @inlinable
    func set(marginEnd: Int)

    Parameters

    marginEnd

    end margin

Box Class

  • Bind a BoxPropertyName source property to a given target object.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: BoxPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol

    Parameters

    source_property

    the source property to bind

    target

    the target object to bind to

    target_property

    the target property to bind to

    flags

    the flags to pass to the Binding

    transform_from

    ValueTransformer to use for forward transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return Value

    binding reference or nil in case of an error

  • get(property:) Extension method

    Get the value of a Box property

    Declaration

    Swift

    @inlinable
    func get(property: BoxPropertyName) -> GLibObject.Value

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

  • set(property:value:) Extension method

    Set the value of a Box property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

    @inlinable
    func set(property: BoxPropertyName, value v: GLibObject.Value)

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

Box Class: BoxProtocol extension (methods and fields)

  • append(child:) Extension method

    Adds child as the last child to box.

    Declaration

    Swift

    @inlinable
    func append<WidgetT>(child: WidgetT) where WidgetT : WidgetProtocol
  • getBaselinePosition() Extension method

    Gets the value set by gtk_box_set_baseline_position().

    Declaration

    Swift

    @inlinable
    func getBaselinePosition() -> GtkBaselinePosition
  • getHomogeneous() Extension method

    Returns whether the box is homogeneous (all children are the same size).

    Declaration

    Swift

    @inlinable
    func getHomogeneous() -> Bool
  • getSpacing() Extension method

    Gets the value set by gtk_box_set_spacing().

    Declaration

    Swift

    @inlinable
    func getSpacing() -> Int
  • Inserts child in the position after sibling in the list of box children.

    If sibling is nil, insert child at the first position.

    Declaration

    Swift

    @inlinable
    func insertChildAfter<WidgetT>(child: WidgetT, sibling: WidgetT?) where WidgetT : WidgetProtocol
  • prepend(child:) Extension method

    Adds child as the first child to box.

    Declaration

    Swift

    @inlinable
    func prepend<WidgetT>(child: WidgetT) where WidgetT : WidgetProtocol
  • remove(child:) Extension method

    Removes a child widget from box.

    The child must have been added before with [methodGtk.Box.append], [methodGtk.Box.prepend], or [methodGtk.Box.insert_child_after].

    Declaration

    Swift

    @inlinable
    func remove<WidgetT>(child: WidgetT) where WidgetT : WidgetProtocol
  • Moves child to the position after sibling in the list of box children.

    If sibling is nil, move child to the first position.

    Declaration

    Swift

    @inlinable
    func reorderChildAfter<WidgetT>(child: WidgetT, sibling: WidgetT?) where WidgetT : WidgetProtocol
  • setBaseline(position:) Extension method

    Sets the baseline position of a box.

    This affects only horizontal boxes with at least one baseline aligned child. If there is more vertical space available than requested, and the baseline is not allocated by the parent then position is used to allocate the baseline with respect to the extra space available.

    Declaration

    Swift

    @inlinable
    func setBaseline(position: GtkBaselinePosition)
  • set(homogeneous:) Extension method

    Sets whether or not all children of box are given equal space in the box.

    Declaration

    Swift

    @inlinable
    func set(homogeneous: Bool)
  • set(spacing:) Extension method

    Sets the number of pixels to place between children of box.

    Declaration

    Swift

    @inlinable
    func set(spacing: Int)
  • baselinePosition Extension method

    Gets the value set by gtk_box_set_baseline_position().

    Declaration

    Swift

    @inlinable
    var baselinePosition: GtkBaselinePosition { get nonmutating set }
  • homogeneous Extension method

    Whether the children should all be the same size.

    Declaration

    Swift

    @inlinable
    var homogeneous: Bool { get nonmutating set }
  • spacing Extension method

    The amount of space between children.

    Declaration

    Swift

    @inlinable
    var spacing: Int { get nonmutating set }
  • parentInstance Extension method

    Undocumented

    Declaration

    Swift

    @inlinable
    var parentInstance: GtkWidget { get }