Gtk.Grid

Entities

Tagged Types

Access Types

Constants

Subprograms

Generic Instantiations

Description

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 Gtk.Box.Gtk_Box by just using Gtk.Container.Add, which will place children next to each other in the direction determined by the Gtk.Orientable.Gtk_Orientable:orientation property. However, if all you want is a single row or column, then Gtk.Box.Gtk_Box is the preferred widget.

# CSS nodes

GtkGrid uses a single CSS node with name grid.

"+"

function "+"
  (Widget : access Gtk_Grid_Record'Class)
return Gtk.Buildable.Gtk_Buildable
Parameters
Widget
Return Value

"+"

function "+"
  (Widget : access Gtk_Grid_Record'Class)
return Gtk.Orientable.Gtk_Orientable
Parameters
Widget
Return Value

"-"

function "-"
  (Interf : Gtk.Buildable.Gtk_Buildable)
return Gtk_Grid
Parameters
Interf
Return Value

"-"

function "-"
  (Interf : Gtk.Orientable.Gtk_Orientable)
return Gtk_Grid
Parameters
Interf
Return Value

Attach

procedure Attach
   (Self   : not null access Gtk_Grid_Record;
    Child  : not null access Gtk.Widget.Gtk_Widget_Record'Class;
    Left   : Glib.Gint;
    Top    : Glib.Gint;
    Width  : Glib.Gint := 1;
    Height : Glib.Gint := 1)

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.

Parameters
Self
Child

the widget to add

Left

the column number to attach the left side of Child to

Top

the row number to attach the top side of Child to

Width

the number of columns that Child will span

Height

the number of rows that Child will span

Attach_Next_To

procedure Attach_Next_To
   (Self    : not null access Gtk_Grid_Record;
    Child   : not null access Gtk.Widget.Gtk_Widget_Record'Class;
    Sibling : access Gtk.Widget.Gtk_Widget_Record'Class;
    Side    : Gtk.Enums.Gtk_Position_Type;
    Width   : Glib.Gint := 1;
    Height  : Glib.Gint := 1)

Adds a widget to the grid. The widget is placed next to Sibling, on the side determined by Side. When Sibling is null, 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 == null and Side == Gtk.Enums.Pos_Left yields a layout of [3][2][1].

Parameters
Self
Child

the widget to add

Sibling

the child of Grid that Child will be placed next to, or null to place Child at the beginning or end

Side

the side of Sibling that Child is positioned next to

Width

the number of columns that Child will span

Height

the number of rows that Child will span

Baseline_Row_Property

Baseline_Row_Property : constant Glib.Properties.Property_Int;

Column_Homogeneous_Property

Column_Homogeneous_Property : constant Glib.Properties.Property_Boolean;

Column_Spacing_Property

Column_Spacing_Property : constant Glib.Properties.Property_Int;

Get_Baseline_Row

function Get_Baseline_Row
   (Self : not null access Gtk_Grid_Record) return Glib.Gint

Returns which row defines the global baseline of Grid. Since: gtk+ 3.10

Parameters
Self
Return Value

the row index defining the global baseline

Get_Child_At

function Get_Child_At
   (Self : not null access Gtk_Grid_Record;
    Left : Glib.Gint;
    Top  : Glib.Gint) return Gtk.Widget.Gtk_Widget

Gets the child of Grid whose area covers the grid cell whose upper left corner is at Left, Top. Since: gtk+ 3.2

Parameters
Self
Left

the left edge of the cell

Top

the top edge of the cell

Return Value

the child at the given position, or null

Get_Column_Homogeneous

function Get_Column_Homogeneous
   (Self : not null access Gtk_Grid_Record) return Boolean

Returns whether all columns of Grid have the same width.

Parameters
Self
Return Value

whether all columns of Grid have the same width.

Get_Column_Spacing

function Get_Column_Spacing
   (Self : not null access Gtk_Grid_Record) return Guint

Returns the amount of space between the columns of Grid.

Parameters
Self
Return Value

the column spacing of Grid

Get_Orientation

function Get_Orientation
   (Self : not null access Gtk_Grid_Record)
    return Gtk.Enums.Gtk_Orientation
Parameters
Self
Return Value

Get_Row_Baseline_Position

function Get_Row_Baseline_Position
   (Self : not null access Gtk_Grid_Record;
    Row  : Glib.Gint) return Gtk.Enums.Gtk_Baseline_Position

Returns the baseline position of Row as set by Gtk.Grid.Set_Row_Baseline_Position or the default value Gtk.Enums.Baseline_Position_Center. Since: gtk+ 3.10

Parameters
Self
Row

a row index

Return Value

the baseline position of Row

Get_Row_Homogeneous

function Get_Row_Homogeneous
   (Self : not null access Gtk_Grid_Record) return Boolean

Returns whether all rows of Grid have the same height.

Parameters
Self
Return Value

whether all rows of Grid have the same height.

Get_Row_Spacing

function Get_Row_Spacing
   (Self : not null access Gtk_Grid_Record) return Guint

Returns the amount of space between the rows of Grid.

Parameters
Self
Return Value

the row spacing of Grid

Get_Type

function Get_Type return Glib.GType
Return Value

Gtk_Grid

type Gtk_Grid is access all Gtk_Grid_Record'Class;

Gtk_Grid_New

function Gtk_Grid_New return Gtk_Grid

Creates a new grid widget.

Return Value

Gtk_Grid_Record

type Gtk_Grid_Record is new Gtk_Container_Record with null record;

Gtk_New

procedure Gtk_New (Self : out Gtk_Grid)

Creates a new grid widget. Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Self

Implements_Gtk_Buildable

package Implements_Gtk_Buildable is new Glib.Types.Implements
  (Gtk.Buildable.Gtk_Buildable, Gtk_Grid_Record, Gtk_Grid);

Implements_Gtk_Orientable

package Implements_Gtk_Orientable is new Glib.Types.Implements
  (Gtk.Orientable.Gtk_Orientable, Gtk_Grid_Record, Gtk_Grid);

Initialize

procedure Initialize (Self : not null access Gtk_Grid_Record'Class)

Creates a new grid widget. Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Self

Insert_Column

procedure Insert_Column
   (Self     : not null access Gtk_Grid_Record;
    Position : Glib.Gint)

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. Since: gtk+ 3.2

Parameters
Self
Position

the position to insert the column at

Insert_Next_To

procedure Insert_Next_To
   (Self    : not null access Gtk_Grid_Record;
    Sibling : not null access Gtk.Widget.Gtk_Widget_Record'Class;
    Side    : Gtk.Enums.Gtk_Position_Type)

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.Enums.Pos_Top or Gtk.Enums.Pos_Bottom, a row is inserted. If Side is Gtk.Enums.Pos_Left of Gtk.Enums.Pos_Right, a column is inserted. Since: gtk+ 3.2

Parameters
Self
Sibling

the child of Grid that the new row or column will be placed next to

Side

the side of Sibling that Child is positioned next to

Insert_Row

procedure Insert_Row
   (Self     : not null access Gtk_Grid_Record;
    Position : Glib.Gint)

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. Since: gtk+ 3.2

Parameters
Self
Position

the position to insert the row at

Remove_Column

procedure Remove_Column
   (Self     : not null access Gtk_Grid_Record;
    Position : Glib.Gint)

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. Since: gtk+ 3.10

Parameters
Self
Position

the position of the column to remove

Remove_Row

procedure Remove_Row
   (Self     : not null access Gtk_Grid_Record;
    Position : Glib.Gint)

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. Since: gtk+ 3.10

Parameters
Self
Position

the position of the row to remove

Row_Homogeneous_Property

Row_Homogeneous_Property : constant Glib.Properties.Property_Boolean;

Row_Spacing_Property

Row_Spacing_Property : constant Glib.Properties.Property_Int;

Set_Baseline_Row

procedure Set_Baseline_Row
   (Self : not null access Gtk_Grid_Record;
    Row  : Glib.Gint)

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. Since: gtk+ 3.10

Parameters
Self
Row

the row index

Set_Column_Homogeneous

procedure Set_Column_Homogeneous
   (Self        : not null access Gtk_Grid_Record;
    Homogeneous : Boolean)

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

Parameters
Self
Homogeneous

True to make columns homogeneous

Set_Column_Spacing

procedure Set_Column_Spacing
   (Self    : not null access Gtk_Grid_Record;
    Spacing : Guint)

Sets the amount of space between columns of Grid.

Parameters
Self
Spacing

the amount of space to insert between columns

Set_Orientation

procedure Set_Orientation
   (Self        : not null access Gtk_Grid_Record;
    Orientation : Gtk.Enums.Gtk_Orientation)
Parameters
Self
Orientation

Set_Row_Baseline_Position

procedure Set_Row_Baseline_Position
   (Self : not null access Gtk_Grid_Record;
    Row  : Glib.Gint;
    Pos  : Gtk.Enums.Gtk_Baseline_Position)

Sets how the baseline should be positioned on Row of the grid, in case that row is assigned more space than is requested. Since: gtk+ 3.10

Parameters
Self
Row

a row index

Pos

a Gtk.Enums.Gtk_Baseline_Position

Set_Row_Homogeneous

procedure Set_Row_Homogeneous
   (Self        : not null access Gtk_Grid_Record;
    Homogeneous : Boolean)

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

Parameters
Self
Homogeneous

True to make rows homogeneous

Set_Row_Spacing

procedure Set_Row_Spacing
   (Self    : not null access Gtk_Grid_Record;
    Spacing : Guint)

Sets the amount of space between rows of Grid.

Parameters
Self
Spacing

the amount of space to insert between rows