Next: , Previous: GtkNotebook, Up: Top


101 GtkTable

Pack widgets in regular patterns

101.1 Overview

The <gtk-table> functions allow the programmer to arrange widgets in rows and columns, making it easy to align many widgets next to each other, horizontally and vertically.

Tables are created with a call to gtk-table-new, the size of which can later be changed with gtk-table-resize.

Widgets can be added to a table using gtk-table-attach or the more convenient (but slightly less flexible) gtk-table-attach-defaults.

To alter the space next to a specific row, use gtk-table-set-row-spacing, and for a column, gtk-table-set-col-spacing.

The gaps between all rows or columns can be changed by calling gtk-table-set-row-spacings or gtk-table-set-col-spacings respectively.

gtk-table-set-homogeneous, can be used to set whether all cells in the table will resize themselves to the size of the largest widget in the table.

101.2 Usage

— Class: <gtk-table>

Derives from <gtk-container>.

This class defines the following slots:

n-rows
The number of rows in the table
n-columns
The number of columns in the table
column-spacing
The amount of space between two consecutive columns
row-spacing
The amount of space between two consecutive rows
homogeneous
If TRUE, the table cells are all the same width/height
— Function: gtk-table-new (rows unsigned-int) (columns unsigned-int) (homogeneous bool) ⇒  (ret <gtk-widget>)

Used to create a new table widget. An initial size must be given by specifying how many rows and columns the table should have, although this can be changed later with gtk-table-resize. rows and columns must both be in the range 0 .. 65535.

rows
The number of rows the new table should have.
columns
The number of columns the new table should have.
homogeneous
If set to ‘#t’, all table cells are resized to the size of the cell containing the largest widget.
ret
A pointer to the the newly created table widget.
— Function: gtk-table-resize (self <gtk-table>) (rows unsigned-int) (columns unsigned-int)
— Method: resize

If you need to change a table's size after it has been created, this function allows you to do so.

table
The <gtk-table> you wish to change the size of.
rows
The new number of rows.
columns
The new number of columns.
— Function: gtk-table-attach (self <gtk-table>) (child <gtk-widget>) (left_attach unsigned-int) (right_attach unsigned-int) (top_attach unsigned-int) (bottom_attach unsigned-int) (xoptions <gtk-attach-options>) (yoptions <gtk-attach-options>) (xpadding unsigned-int) (ypadding unsigned-int)
— Method: attach

Adds a widget to a table. The number of 'cells' that a widget will occupy is specified by left-attach, right-attach, top-attach and bottom-attach. These each represent the leftmost, rightmost, uppermost and lowest column and row numbers of the table. (Columns and rows are indexed from zero).

table
The <gtk-table> to add a new widget to.
child
The widget to add.
left-attach
the column number to attach the left side of a child widget to.
right-attach
the column number to attach the right side of a child widget to.
top-attach
the row number to attach the top of a child widget to.
bottom-attach
the row number to attach the bottom of a child widget to.
xoptions
Used to specify the properties of the child widget when the table is resized.
yoptions
The same as xoptions, except this field determines behaviour of vertical resizing.
xpadding
An integer value specifying the padding on the left and right of the widget being added to the table.
ypadding
The amount of padding above and below the child widget.
— Function: gtk-table-attach-defaults (self <gtk-table>) (widget <gtk-widget>) (left_attach unsigned-int) (right_attach unsigned-int) (top_attach unsigned-int) (bottom_attach unsigned-int)
— Method: attach-defaults

As there are many options associated with gtk-table-attach, this convenience function provides the programmer with a means to add children to a table with identical padding and expansion options. The values used for the <gtk-attach-options> are ‘GTK_EXPAND | GTK_FILL’, and the padding is set to 0.

table
The table to add a new child widget to.
widget
The child widget to add.
left-attach
The column number to attach the left side of the child widget to.
right-attach
The column number to attach the right side of the child widget to.
top-attach
The row number to attach the top of the child widget to.
bottom-attach
The row number to attach the bottom of the child widget to.
— Function: gtk-table-set-row-spacing (self <gtk-table>) (row unsigned-int) (spacing unsigned-int)
— Method: set-row-spacing

Changes the space between a given table row and the subsequent row.

table
a <gtk-table> containing the row whose properties you wish to change.
row
row number whose spacing will be changed.
spacing
number of pixels that the spacing should take up.
— Function: gtk-table-set-col-spacing (self <gtk-table>) (column unsigned-int) (spacing unsigned-int)
— Method: set-col-spacing

Alters the amount of space between a given table column and the following column.

table
a <gtk-table>.
column
the column whose spacing should be changed.
spacing
number of pixels that the spacing should take up.
— Function: gtk-table-set-row-spacings (self <gtk-table>) (spacing unsigned-int)
— Method: set-row-spacings

Sets the space between every row in table equal to spacing.

table
a <gtk-table>.
spacing
the number of pixels of space to place between every row in the table.
— Function: gtk-table-set-col-spacings (self <gtk-table>) (spacing unsigned-int)
— Method: set-col-spacings

Sets the space between every column in table equal to spacing.

table
a <gtk-table>.
spacing
the number of pixels of space to place between every column in the table.
— Function: gtk-table-set-homogeneous (self <gtk-table>) (homogeneous bool)
— Method: set-homogeneous

Changes the homogenous property of table cells, ie. whether all cells are an equal size or not.

table
The <gtk-table> you wish to set the homogeneous properties of.
homogeneous
Set to ‘#t’ to ensure all table cells are the same size. Set to ‘#f’ if this is not your desired behaviour.
— Function: gtk-table-get-default-row-spacing (self <gtk-table>) ⇒  (ret unsigned-int)
— Method: get-default-row-spacing

Gets the default row spacing for the table. This is the spacing that will be used for newly added rows. (See gtk-table-set-row-spacings)

table
a <gtk-table>
ret
value: the default row spacing
— Function: gtk-table-get-homogeneous (self <gtk-table>) ⇒  (ret bool)
— Method: get-homogeneous

Returns whether the table cells are all constrained to the same width and height. (See gtk-table-set-homogenous)

table
a <gtk-table>
ret
#t’ if the cells are all constrained to the same size
— Function: gtk-table-get-row-spacing (self <gtk-table>) (row unsigned-int) ⇒  (ret unsigned-int)
— Method: get-row-spacing

Gets the amount of space between row row, and row row + 1. See gtk-table-set-row-spacing.

table
a <gtk-table>
row
a row in the table, 0 indicates the first row
ret
the row spacing
— Function: gtk-table-get-col-spacing (self <gtk-table>) (column unsigned-int) ⇒  (ret unsigned-int)
— Method: get-col-spacing

Gets the amount of space between column col, and column col + 1. See gtk-table-set-col-spacing.

table
a <gtk-table>
column
a column in the table, 0 indicates the first column
ret
the column spacing
— Function: gtk-table-get-default-col-spacing (self <gtk-table>) ⇒  (ret unsigned-int)
— Method: get-default-col-spacing

Gets the default column spacing for the table. This is the spacing that will be used for newly added columns. (See gtk-table-set-col-spacings)

table
a <gtk-table>
ret
value: the default column spacing