CtkGrid

CtkGrid — Pack widgets in rows and columns

Functions

Properties

int baseline-row Read / Write
gboolean column-homogeneous Read / Write
int column-spacing Read / Write
gboolean row-homogeneous Read / Write
int row-spacing Read / Write

Types and Values

struct CtkGrid
struct CtkGridClass

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── CtkWidget
            ╰── CtkContainer
                ╰── CtkGrid

Implemented Interfaces

CtkGrid implements AtkImplementorIface, CtkBuildable and CtkOrientable.

Includes

#include <ctk/ctk.h>

Description

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

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

CtkGrid can be used like a CtkBox by just using ctk_container_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 CtkBox is the preferred widget.

CSS nodes

CtkGrid uses a single CSS node with name grid.

Functions

ctk_grid_new ()

CtkWidget *
ctk_grid_new (void);

Creates a new grid widget.

Returns

the new CtkGrid


ctk_grid_attach ()

void
ctk_grid_attach (CtkGrid *grid,
                 CtkWidget *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 .

Parameters

grid

a CtkGrid

 

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

 

ctk_grid_attach_next_to ()

void
ctk_grid_attach_next_to (CtkGrid *grid,
                         CtkWidget *child,
                         CtkWidget *sibling,
                         CtkPositionType 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 .

Attaching widgets labeled [1], [2], [3] with sibling == NULL and side == CTK_POS_LEFT yields a layout of 3[1].

Parameters

grid

a CtkGrid

 

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.

[allow-none]

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

 

ctk_grid_get_child_at ()

CtkWidget *
ctk_grid_get_child_at (CtkGrid *grid,
                       gint left,
                       gint top);

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

Parameters

grid

a CtkGrid

 

left

the left edge of the cell

 

top

the top edge of the cell

 

Returns

the child at the given position, or NULL.

[transfer none][nullable]

Since: 3.2


ctk_grid_insert_row ()

void
ctk_grid_insert_row (CtkGrid *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.

Parameters

grid

a CtkGrid

 

position

the position to insert the row at

 

Since: 3.2


ctk_grid_insert_column ()

void
ctk_grid_insert_column (CtkGrid *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.

Parameters

grid

a CtkGrid

 

position

the position to insert the column at

 

Since: 3.2


ctk_grid_remove_row ()

void
ctk_grid_remove_row (CtkGrid *grid,
                     gint position);

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.

Parameters

grid

a CtkGrid

 

position

the position of the row to remove

 

Since: 3.10


ctk_grid_remove_column ()

void
ctk_grid_remove_column (CtkGrid *grid,
                        gint position);

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.

Parameters

grid

a CtkGrid

 

position

the position of the column to remove

 

Since: 3.10


ctk_grid_insert_next_to ()

void
ctk_grid_insert_next_to (CtkGrid *grid,
                         CtkWidget *sibling,
                         CtkPositionType 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 CTK_POS_TOP or CTK_POS_BOTTOM, a row is inserted. If side is CTK_POS_LEFT of CTK_POS_RIGHT, a column is inserted.

Parameters

grid

a CtkGrid

 

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


ctk_grid_set_row_homogeneous ()

void
ctk_grid_set_row_homogeneous (CtkGrid *grid,
                              gboolean homogeneous);

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

Parameters

grid

a CtkGrid

 

homogeneous

TRUE to make rows homogeneous

 

ctk_grid_get_row_homogeneous ()

gboolean
ctk_grid_get_row_homogeneous (CtkGrid *grid);

Returns whether all rows of grid have the same height.

Parameters

grid

a CtkGrid

 

Returns

whether all rows of grid have the same height.


ctk_grid_set_row_spacing ()

void
ctk_grid_set_row_spacing (CtkGrid *grid,
                          guint spacing);

Sets the amount of space between rows of grid .

Parameters

grid

a CtkGrid

 

spacing

the amount of space to insert between rows

 

ctk_grid_get_row_spacing ()

guint
ctk_grid_get_row_spacing (CtkGrid *grid);

Returns the amount of space between the rows of grid .

Parameters

grid

a CtkGrid

 

Returns

the row spacing of grid


ctk_grid_set_column_homogeneous ()

void
ctk_grid_set_column_homogeneous (CtkGrid *grid,
                                 gboolean homogeneous);

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

Parameters

grid

a CtkGrid

 

homogeneous

TRUE to make columns homogeneous

 

ctk_grid_get_column_homogeneous ()

gboolean
ctk_grid_get_column_homogeneous (CtkGrid *grid);

Returns whether all columns of grid have the same width.

Parameters

grid

a CtkGrid

 

Returns

whether all columns of grid have the same width.


ctk_grid_set_column_spacing ()

void
ctk_grid_set_column_spacing (CtkGrid *grid,
                             guint spacing);

Sets the amount of space between columns of grid .

Parameters

grid

a CtkGrid

 

spacing

the amount of space to insert between columns

 

ctk_grid_get_column_spacing ()

guint
ctk_grid_get_column_spacing (CtkGrid *grid);

Returns the amount of space between the columns of grid .

Parameters

grid

a CtkGrid

 

Returns

the column spacing of grid


ctk_grid_get_baseline_row ()

gint
ctk_grid_get_baseline_row (CtkGrid *grid);

Returns which row defines the global baseline of grid .

Parameters

grid

a CtkGrid

 

Returns

the row index defining the global baseline

Since: 3.10


ctk_grid_set_baseline_row ()

void
ctk_grid_set_baseline_row (CtkGrid *grid,
                           gint row);

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 .

Parameters

grid

a CtkGrid

 

row

the row index

 

Since: 3.10


ctk_grid_get_row_baseline_position ()

CtkBaselinePosition
ctk_grid_get_row_baseline_position (CtkGrid *grid,
                                    gint row);

Returns the baseline position of row as set by ctk_grid_set_row_baseline_position() or the default value CTK_BASELINE_POSITION_CENTER.

Parameters

grid

a CtkGrid

 

row

a row index

 

Returns

the baseline position of row

Since: 3.10


ctk_grid_set_row_baseline_position ()

void
ctk_grid_set_row_baseline_position (CtkGrid *grid,
                                    gint row,
                                    CtkBaselinePosition pos);

Sets how the baseline should be positioned on row of the grid, in case that row is assigned more space than is requested.

Parameters

grid

a CtkGrid

 

row

a row index

 

pos

a CtkBaselinePosition

 

Since: 3.10

Types and Values

struct CtkGrid

struct CtkGrid;

struct CtkGridClass

struct CtkGridClass {
  CtkContainerClass parent_class;
};

Members

Property Details

The “baseline-row” property

  “baseline-row”             int

The row to align the to the baseline when valign is CTK_ALIGN_BASELINE.

Owner: CtkGrid

Flags: Read / Write

Allowed values: >= 0

Default value: 0


The “column-homogeneous” property

  “column-homogeneous”       gboolean

If TRUE, the columns are all the same width.

Owner: CtkGrid

Flags: Read / Write

Default value: FALSE


The “column-spacing” property

  “column-spacing”           int

The amount of space between two consecutive columns.

Owner: CtkGrid

Flags: Read / Write

Allowed values: [0,32767]

Default value: 0


The “row-homogeneous” property

  “row-homogeneous”          gboolean

If TRUE, the rows are all the same height.

Owner: CtkGrid

Flags: Read / Write

Default value: FALSE


The “row-spacing” property

  “row-spacing”              int

The amount of space between two consecutive rows.

Owner: CtkGrid

Flags: Read / Write

Allowed values: [0,32767]

Default value: 0

See Also

CtkBox