GtkGrid is a container which arranges its child widgets in rows and columns, with arbitrary positions and horizontal/vertical spans.
Children are added using attach. They can span multiple rows or columns. It is also
possible to add a child next to an existing child, using attach_next_to. The
behaviour of GtkGrid when several children occupy the same grid cell is undefined.
GtkGrid can be used like a Box by just using add
, which will place children next to each other in the direction determined by the
orientation property. However, if all you want is a single row or column,
then Box is the preferred widget.
CSS nodes
GtkGrid uses a single CSS node with name grid.
- public void attach (Widget child, int left, int top, int width = 1, int height = 1)
Adds a widget to the grid.
- public void attach_next_to (Widget child, Widget? sibling, PositionType side, int width = 1, int height = 1)
Adds a widget to the grid.
- public int get_baseline_row ()
Returns which row defines the global baseline of
this.
- public unowned Widget? get_child_at (int left, int top)
Gets the child of this whose area
covers the grid cell whose upper left corner is at left
, top
.
- public bool get_column_homogeneous ()
Returns whether all columns of this
have the same width.
- public uint get_column_spacing ()
Returns the amount of space between the columns of
this.
- public BaselinePosition get_row_baseline_position (int row)
- public bool get_row_homogeneous ()
Returns whether all rows of this
have the same height.
- public uint get_row_spacing ()
Returns the amount of space between the rows of
this.
- public void insert_column (int position)
Inserts a column at the specified position.
- public void insert_next_to (Widget sibling, PositionType side)
Inserts a row or column at the specified position.
- public void insert_row (int position)
Inserts a row at the specified position.
- public void remove_column (int position)
Removes a column from the grid.
- public void remove_row (int position)
Removes a row from the grid.
- public void set_baseline_row (int row)
Sets which row defines the global baseline for the entire grid.
- public void set_column_homogeneous (bool homogeneous)
Sets whether all columns of this
will have the same width.
- public void set_column_spacing (uint spacing)
Sets the amount of space between columns of
this.
- public void set_row_baseline_position (int row, BaselinePosition pos)
Sets how the baseline should be positioned on row
of the
grid, in case that row is assigned more space than is requested.
- public void set_row_homogeneous (bool homogeneous)
Sets whether all rows of this will
have the same height.
- public void set_row_spacing (uint spacing)
Sets the amount of space between rows of
this.