GridProtocol

public protocol GridProtocol : ContainerProtocol, OrientableProtocol

GtkGrid is a container which arranges its child widgets in rows and columns, with arbitrary positions and horizontal/vertical spans.

Children are added using gtk_grid_attach(). They can span multiple rows or columns. It is also possible to add a child next to an existing child, using gtk_grid_attach_next_to(). The behaviour of GtkGrid when several children occupy the same grid cell is undefined.

GtkGrid can be used like a GtkBox by just using gtk_container_add(), which will place children next to each other in the direction determined by the GtkOrientable:orientation property. However, if all you want is a single row or column, then GtkBox is the preferred widget.

CSS nodes

GtkGrid uses a single CSS node with name grid.

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

  • ptr

    Untyped pointer to the underlying GtkGrid instance.

    Declaration

    Swift

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

    Typed pointer to the underlying GtkGrid instance.

    Default Implementation

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

    Declaration

    Swift

    var grid_ptr: UnsafeMutablePointer<GtkGrid>! { get }
  • Required Initialiser for types conforming to GridProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

Grid Class

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

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: GridPropertyName, 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 Grid property

    Declaration

    Swift

    @inlinable
    func get(property: GridPropertyName) -> 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 Grid property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

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

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

Grid Class: GridProtocol extension (methods and fields)

  • Adds a widget to the grid.

    The position of child is determined by left and top. The number of “cells” that child will occupy is determined by width and height.

    Declaration

    Swift

    @inlinable
    func attach<WidgetT>(child: WidgetT, left: Int, top: Int, width: Int, height: Int) where WidgetT : WidgetProtocol
  • Adds a widget to the grid.

    The widget is placed next to sibling, on the side determined by side. When sibling is nil, the widget is placed in row (for left or right placement) or column 0 (for top or bottom placement), at the end indicated by side.

    Attaching widgets labeled [1], [2], [3] with sibling == nil and side == GTK_POS_LEFT yields a layout of 3(#1).

    Declaration

    Swift

    @inlinable
    func attachNextTo<WidgetT>(child: WidgetT, sibling: WidgetT?, side: GtkPositionType, width: Int, height: Int) where WidgetT : WidgetProtocol
  • getBaselineRow() Extension method

    Returns which row defines the global baseline of grid.

    Declaration

    Swift

    @inlinable
    func getBaselineRow() -> Int
  • getChildAt(left:top:) Extension method

    Gets the child of grid whose area covers the grid cell whose upper left corner is at left, top.

    Declaration

    Swift

    @inlinable
    func getChildAt(left: Int, top: Int) -> WidgetRef!
  • getColumnHomogeneous() Extension method

    Returns whether all columns of grid have the same width.

    Declaration

    Swift

    @inlinable
    func getColumnHomogeneous() -> Bool
  • getColumnSpacing() Extension method

    Returns the amount of space between the columns of grid.

    Declaration

    Swift

    @inlinable
    func getColumnSpacing() -> Int
  • getRowBaselinePosition(row:) Extension method

    Returns the baseline position of row as set by gtk_grid_set_row_baseline_position() or the default value GTK_BASELINE_POSITION_CENTER.

    Declaration

    Swift

    @inlinable
    func getRowBaselinePosition(row: Int) -> GtkBaselinePosition
  • getRowHomogeneous() Extension method

    Returns whether all rows of grid have the same height.

    Declaration

    Swift

    @inlinable
    func getRowHomogeneous() -> Bool
  • getRowSpacing() Extension method

    Returns the amount of space between the rows of grid.

    Declaration

    Swift

    @inlinable
    func getRowSpacing() -> Int
  • insertColumn(position:) Extension method

    Inserts a column at the specified position.

    Children which are attached at or to the right of this position are moved one column to the right. Children which span across this position are grown to span the new column.

    Declaration

    Swift

    @inlinable
    func insertColumn(position: Int)
  • insertNextTo(sibling:side:) Extension method

    Inserts a row or column at the specified position.

    The new row or column is placed next to sibling, on the side determined by side. If side is GTK_POS_TOP or GTK_POS_BOTTOM, a row is inserted. If side is GTK_POS_LEFT of GTK_POS_RIGHT, a column is inserted.

    Declaration

    Swift

    @inlinable
    func insertNextTo<WidgetT>(sibling: WidgetT, side: GtkPositionType) where WidgetT : WidgetProtocol
  • insertRow(position:) Extension method

    Inserts a row at the specified position.

    Children which are attached at or below this position are moved one row down. Children which span across this position are grown to span the new row.

    Declaration

    Swift

    @inlinable
    func insertRow(position: Int)
  • removeColumn(position:) Extension method

    Removes a column from the grid.

    Children that are placed in this column are removed, spanning children that overlap this column have their width reduced by one, and children after the column are moved to the left.

    Declaration

    Swift

    @inlinable
    func removeColumn(position: Int)
  • removeRow(position:) Extension method

    Removes a row from the grid.

    Children that are placed in this row are removed, spanning children that overlap this row have their height reduced by one, and children below the row are moved up.

    Declaration

    Swift

    @inlinable
    func removeRow(position: Int)
  • setBaseline(row:) Extension method

    Sets which row defines the global baseline for the entire grid. Each row in the grid can have its own local baseline, but only one of those is global, meaning it will be the baseline in the parent of the grid.

    Declaration

    Swift

    @inlinable
    func setBaseline(row: Int)
  • setColumn(homogeneous:) Extension method

    Sets whether all columns of grid will have the same width.

    Declaration

    Swift

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

    Sets the amount of space between columns of grid.

    Declaration

    Swift

    @inlinable
    func setColumn(spacing: Int)
  • Sets how the baseline should be positioned on row of the grid, in case that row is assigned more space than is requested.

    Declaration

    Swift

    @inlinable
    func setRowBaselinePosition(row: Int, pos: GtkBaselinePosition)
  • setRow(homogeneous:) Extension method

    Sets whether all rows of grid will have the same height.

    Declaration

    Swift

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

    Sets the amount of space between rows of grid.

    Declaration

    Swift

    @inlinable
    func setRow(spacing: Int)
  • baselineRow Extension method

    Returns which row defines the global baseline of grid.

    Declaration

    Swift

    @inlinable
    var baselineRow: Int { get nonmutating set }
  • columnHomogeneous Extension method

    Returns whether all columns of grid have the same width.

    Declaration

    Swift

    @inlinable
    var columnHomogeneous: Bool { get nonmutating set }
  • columnSpacing Extension method

    Returns the amount of space between the columns of grid.

    Declaration

    Swift

    @inlinable
    var columnSpacing: Int { get nonmutating set }
  • rowHomogeneous Extension method

    Returns whether all rows of grid have the same height.

    Declaration

    Swift

    @inlinable
    var rowHomogeneous: Bool { get nonmutating set }
  • rowSpacing Extension method

    Returns the amount of space between the rows of grid.

    Declaration

    Swift

    @inlinable
    var rowSpacing: Int { get nonmutating set }