## GtkGrid

GtkGrid — Pack widgets in a rows and columns

## Synopsis

    #include <gtk/gtk.h>

    struct              GtkGrid;
    GtkWidget *         gtk_grid_new                        (void);
    void                gtk_grid_attach                     (GtkGrid *grid,
                                                             GtkWidget *child,
                                                             gint left,
                                                             gint top,
                                                             gint width,
                                                             gint height);
    void                gtk_grid_attach_next_to             (GtkGrid *grid,
                                                             GtkWidget *child,
                                                             GtkWidget *sibling,
                                                             GtkPositionType side,
                                                             gint width,
                                                             gint height);
    GtkWidget *         gtk_grid_get_child_at               (GtkGrid *grid,
                                                             gint left,
                                                             gint top);
    void                gtk_grid_insert_row                 (GtkGrid *grid,
                                                             gint position);
    void                gtk_grid_insert_column              (GtkGrid *grid,
                                                             gint position);
    void                gtk_grid_insert_next_to             (GtkGrid *grid,
                                                             GtkWidget *sibling,
                                                             GtkPositionType side);
    void                gtk_grid_set_row_homogeneous        (GtkGrid *grid,
                                                             gboolean homogeneous);
    gboolean            gtk_grid_get_row_homogeneous        (GtkGrid *grid);
    void                gtk_grid_set_row_spacing            (GtkGrid *grid,
                                                             guint spacing);
    guint               gtk_grid_get_row_spacing            (GtkGrid *grid);
    void                gtk_grid_set_column_homogeneous     (GtkGrid *grid,
                                                             gboolean homogeneous);
    gboolean            gtk_grid_get_column_homogeneous     (GtkGrid *grid);
    void                gtk_grid_set_column_spacing         (GtkGrid *grid,
                                                             guint spacing);
    guint               gtk_grid_get_column_spacing         (GtkGrid *grid);

## Object Hierarchy

      GObject
       +----GInitiallyUnowned
             +----GtkWidget
                   +----GtkContainer
                         +----GtkGrid

## Implemented Interfaces

GtkGrid implements AtkImplementorIface, GtkBuildable and GtkOrientable.

## Properties

      "column-homogeneous"       gboolean              : Read / Write
      "column-spacing"           gint                  : Read / Write
      "row-homogeneous"          gboolean              : Read / Write
      "row-spacing"              gint                  : Read / Write

## Child Properties

      "height"                   gint                  : Read / Write
      "left-attach"              gint                  : Read / Write
      "top-attach"               gint                  : Read / Write
      "width"                    gint                  : Read / Write

## Description

GtkGrid is a container which arranges its child widgets in rows and columns. It is a very similar to GtkTable and GtkBox, but it consistently uses GtkWidget's "margin" and "expand" properties instead of custom child properties, and it fully supports height-for-width geometry management.

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()`.

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 "orientation" property.

## Details

### struct GtkGrid

    struct GtkGrid;

### gtk_grid_new ()

    GtkWidget *         gtk_grid_new                        (void);

Creates a new grid widget.

Returns : | the new GtkGrid

### gtk_grid_attach ()

    void                gtk_grid_attach                     (GtkGrid *grid,
                                                             GtkWidget *child,
                                                             gint left,
                                                             gint top,
                                                             gint width,
                                                             gint height);

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`.

`grid` : | a GtkGrid
`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

### gtk_grid_attach_next_to ()

    void                gtk_grid_attach_next_to             (GtkGrid *grid,
                                                             GtkWidget *child,
                                                             GtkWidget *sibling,
                                                             GtkPositionType side,
                                                             gint width,
                                                             gint height);

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`.

`grid` : | a GtkGrid
`child` : | the widget to add `sibling` (allow-none): 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

### gtk_grid_get_child_at ()

    GtkWidget *         gtk_grid_get_child_at               (GtkGrid *grid,
                                                             gint left,
                                                             gint top);

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

`grid` : | a GtkGrid
`left` : | the left edge of the cell
`top` : | the top edge of the cell
Returns : | the child at the given position, or `NULL`

Since 3.2

### gtk_grid_insert_row ()

    void                gtk_grid_insert_row                 (GtkGrid *grid,
                                                             gint position);

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.

`grid` : | a GtkGrid
`position` : | the position to insert the row at

Since 3.2

### gtk_grid_insert_column ()

    void                gtk_grid_insert_column              (GtkGrid *grid,
                                                             gint position);

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.

`grid` : | a GtkGrid
`position` : | the position to insert the column at

Since 3.2

### gtk_grid_insert_next_to ()

    void                gtk_grid_insert_next_to             (GtkGrid *grid,
                                                             GtkWidget *sibling,
                                                             GtkPositionType side);

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.

`grid` : | a GtkGrid
`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

Since 3.2

### gtk_grid_set_row_homogeneous ()

    void                gtk_grid_set_row_homogeneous        (GtkGrid *grid,
                                                             gboolean homogeneous);

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

`grid` : | a GtkGrid
`homogeneous` : | `TRUE` to make rows homogeneous

### gtk_grid_get_row_homogeneous ()

    gboolean            gtk_grid_get_row_homogeneous        (GtkGrid *grid);

Returns whether all rows of `grid` have the same height.

`grid` : | a GtkGrid
Returns : | whether all rows of `grid` have the same height.

### gtk_grid_set_row_spacing ()

    void                gtk_grid_set_row_spacing            (GtkGrid *grid,
                                                             guint spacing);

Sets the amount of space between rows of `grid`.

`grid` : | a GtkGrid
`spacing` : | the amount of space to insert between rows

### gtk_grid_get_row_spacing ()

    guint               gtk_grid_get_row_spacing            (GtkGrid *grid);

Returns the amount of space between the rows of `grid`.

`grid` : | a GtkGrid
Returns : | the row spacing of `grid`

### gtk_grid_set_column_homogeneous ()

    void                gtk_grid_set_column_homogeneous     (GtkGrid *grid,
                                                             gboolean homogeneous);

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

`grid` : | a GtkGrid
`homogeneous` : | `TRUE` to make columns homogeneous

### gtk_grid_get_column_homogeneous ()

    gboolean            gtk_grid_get_column_homogeneous     (GtkGrid *grid);

Returns whether all columns of `grid` have the same width.

`grid` : | a GtkGrid
Returns : | whether all columns of `grid` have the same width.

### gtk_grid_set_column_spacing ()

    void                gtk_grid_set_column_spacing         (GtkGrid *grid,
                                                             guint spacing);

Sets the amount of space between columns of `grid`.

`grid` : | a GtkGrid
`spacing` : | the amount of space to insert between columns

### gtk_grid_get_column_spacing ()

    guint               gtk_grid_get_column_spacing         (GtkGrid *grid);

Returns the amount of space between the columns of `grid`.

`grid` : | a GtkGrid
Returns : | the column spacing of `grid`

## Property Details

### The `"column-homogeneous"` property

      "column-homogeneous"       gboolean              : Read / Write

If TRUE, the columns are all the same width.

Default value: FALSE

### The `"column-spacing"` property

      "column-spacing"           gint                  : Read / Write

The amount of space between two consecutive columns.

Allowed values: [0,32767]

Default value: 0

### The `"row-homogeneous"` property

      "row-homogeneous"          gboolean              : Read / Write

If TRUE, the rows are all the same height.

Default value: FALSE

### The `"row-spacing"` property

      "row-spacing"              gint                  : Read / Write

The amount of space between two consecutive rows.

Allowed values: [0,32767]

Default value: 0

## Child Property Details

### The `"height"` child property

      "height"                   gint                  : Read / Write

The number of rows that a child spans.

Allowed values: >= 1

Default value: 1

### The `"left-attach"` child property

      "left-attach"              gint                  : Read / Write

The column number to attach the left side of the child to.

Default value: 0

### The `"top-attach"` child property

      "top-attach"               gint                  : Read / Write

The row number to attach the top side of a child widget to.

Default value: 0

### The `"width"` child property

      "width"                    gint                  : Read / Write

The number of columns that a child spans.

Allowed values: >= 1

Default value: 1

## See Also

GtkTable, GtkHBox, GtkVBox