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
function "+"
(Widget : access Gtk_Grid_Record'Class)
return Gtk.Orientable.Gtk_Orientable
function "-"
(Interf : Gtk.Buildable.Gtk_Buildable)
return Gtk_Grid
function "-"
(Interf : Gtk.Orientable.Gtk_Orientable)
return Gtk_Grid
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.
the widget to add
the column number to attach the left side of Child to
the row number to attach the top side of Child to
the number of columns that Child will span
the number of rows that Child will span
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].
the widget to add
the child of Grid that Child will be placed next to, or null to place Child at the beginning or end
the side of Sibling that Child is positioned next to
the number of columns that Child will span
the number of rows that Child will span
Baseline_Row_Property : constant Glib.Properties.Property_Int;
Column_Homogeneous_Property : constant Glib.Properties.Property_Boolean;
Column_Spacing_Property : constant Glib.Properties.Property_Int;
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
the row index defining the global baseline
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
the left edge of the cell
the top edge of the cell
the child at the given position, or null
function Get_Column_Homogeneous
(Self : not null access Gtk_Grid_Record) return Boolean
Returns whether all columns of Grid have the same width.
whether all columns of Grid have the same width.
function Get_Column_Spacing
(Self : not null access Gtk_Grid_Record) return Guint
Returns the amount of space between the columns of Grid.
the column spacing of Grid
function Get_Orientation
(Self : not null access Gtk_Grid_Record)
return Gtk.Enums.Gtk_Orientation
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
a row index
the baseline position of Row
function Get_Row_Homogeneous
(Self : not null access Gtk_Grid_Record) return Boolean
Returns whether all rows of Grid have the same height.
whether all rows of Grid have the same height.
function Get_Row_Spacing
(Self : not null access Gtk_Grid_Record) return Guint
Returns the amount of space between the rows of Grid.
the row spacing of Grid
function Get_Type return Glib.GType
type Gtk_Grid is access all Gtk_Grid_Record'Class;
function Gtk_Grid_New return Gtk_Grid
Creates a new grid widget.
type Gtk_Grid_Record is new Gtk_Container_Record with null record;
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.
package Implements_Gtk_Buildable is new Glib.Types.Implements
(Gtk.Buildable.Gtk_Buildable, Gtk_Grid_Record, Gtk_Grid);
package Implements_Gtk_Orientable is new Glib.Types.Implements
(Gtk.Orientable.Gtk_Orientable, Gtk_Grid_Record, Gtk_Grid);
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.
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
the position to insert the column at
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
the child of Grid that the new row or column will be placed next to
the side of Sibling that Child is positioned next to
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
the position to insert the row at
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
the position of the column to remove
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
the position of the row to remove
Row_Homogeneous_Property : constant Glib.Properties.Property_Boolean;
Row_Spacing_Property : constant Glib.Properties.Property_Int;
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
the row index
procedure Set_Column_Homogeneous
(Self : not null access Gtk_Grid_Record;
Homogeneous : Boolean)
Sets whether all columns of Grid will have the same width.
True to make columns homogeneous
procedure Set_Column_Spacing
(Self : not null access Gtk_Grid_Record;
Spacing : Guint)
Sets the amount of space between columns of Grid.
the amount of space to insert between columns
procedure Set_Orientation
(Self : not null access Gtk_Grid_Record;
Orientation : Gtk.Enums.Gtk_Orientation)
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
a row index
a Gtk.Enums.Gtk_Baseline_Position
procedure Set_Row_Homogeneous
(Self : not null access Gtk_Grid_Record;
Homogeneous : Boolean)
Sets whether all rows of Grid will have the same height.
True to make rows homogeneous
procedure Set_Row_Spacing
(Self : not null access Gtk_Grid_Record;
Spacing : Guint)
Sets the amount of space between rows of Grid.
the amount of space to insert between rows