GTK+ 3 Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties | Child Properties |
#include <gtk/gtk.h> struct GtkTable; GtkWidget * gtk_table_new (guint rows
,guint columns
,gboolean homogeneous
); void gtk_table_resize (GtkTable *table
,guint rows
,guint columns
); void gtk_table_get_size (GtkTable *table
,guint *rows
,guint *columns
); void gtk_table_attach (GtkTable *table
,GtkWidget *child
,guint left_attach
,guint right_attach
,guint top_attach
,guint bottom_attach
,GtkAttachOptions xoptions
,GtkAttachOptions yoptions
,guint xpadding
,guint ypadding
); void gtk_table_attach_defaults (GtkTable *table
,GtkWidget *widget
,guint left_attach
,guint right_attach
,guint top_attach
,guint bottom_attach
); void gtk_table_set_row_spacing (GtkTable *table
,guint row
,guint spacing
); void gtk_table_set_col_spacing (GtkTable *table
,guint column
,guint spacing
); void gtk_table_set_row_spacings (GtkTable *table
,guint spacing
); void gtk_table_set_col_spacings (GtkTable *table
,guint spacing
); void gtk_table_set_homogeneous (GtkTable *table
,gboolean homogeneous
); guint gtk_table_get_default_row_spacing (GtkTable *table
); gboolean gtk_table_get_homogeneous (GtkTable *table
); guint gtk_table_get_row_spacing (GtkTable *table
,guint row
); guint gtk_table_get_col_spacing (GtkTable *table
,guint column
); guint gtk_table_get_default_col_spacing (GtkTable *table
);
"column-spacing" guint : Read / Write "homogeneous" gboolean : Read / Write "n-columns" guint : Read / Write "n-rows" guint : Read / Write "row-spacing" guint : Read / Write
"bottom-attach" guint : Read / Write "left-attach" guint : Read / Write "right-attach" guint : Read / Write "top-attach" guint : Read / Write "x-options" GtkAttachOptions : Read / Write "x-padding" guint : Read / Write "y-options" GtkAttachOptions : Read / Write "y-padding" guint : Read / Write
The GtkTable 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. Note that spacing is added between the
children, while padding added by gtk_table_atach()
is added on
either side of the widget it belongs to.
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.
Note that GtkGrid provides the same capabilities as GtkTable for arranging widgets in a rectangular grid, and additionally supports height-for-width geometry management.
struct GtkTable;
The GtkTable structure holds the data for the actual table itself.
children
is a GList of all the widgets the table contains. rows
and columns
are pointers to GtkTableRowCol structures, which contain the default spacing and expansion details for the GtkTable's rows and columns, respectively.
nrows
and ncols
are 16bit integers storing the number of rows and columns the table has.
GtkWidget * gtk_table_new (guint rows
,guint columns
,gboolean homogeneous
);
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 1 .. 65535. For historical reasons, 0 is accepted
as well and is silently interpreted as 1.
|
The number of rows the new table should have. |
|
The number of columns the new table should have. |
|
If set to TRUE , all table cells are resized to the size of the cell
containing the largest widget. |
Returns : |
A pointer to the the newly created table widget. |
void gtk_table_resize (GtkTable *table
,guint rows
,guint columns
);
If you need to change a table's size after it has been created, this function allows you to do so.
|
The GtkTable you wish to change the size of. |
|
The new number of rows. |
|
The new number of columns. |
void gtk_table_get_size (GtkTable *table
,guint *rows
,guint *columns
);
Gets the number of rows and columns in the table.
|
a GtkTable |
|
return location for the number of
rows, or NULL . [out][allow-none]
|
|
return location for the number
of columns, or NULL . [out][allow-none]
|
Since 2.22
void gtk_table_attach (GtkTable *table
,GtkWidget *child
,guint left_attach
,guint right_attach
,guint top_attach
,guint bottom_attach
,GtkAttachOptions xoptions
,GtkAttachOptions yoptions
,guint xpadding
,guint ypadding
);
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).
To make a button occupy the lower right cell of a 2x2 table, use
1 2 3 4 5 |
gtk_table_attach (table, button, 1, 2, /* left, right attach */ 1, 2, /* top, bottom attach */ xoptions, yoptions, xpadding, ypadding); |
If you want to make the button span the entire bottom row, use left_attach
== 0 and right_attach
= 2 instead.
|
The GtkTable to add a new widget to. |
|
The widget to add. |
|
the column number to attach the left side of a child widget to. |
|
the column number to attach the right side of a child widget to. |
|
the row number to attach the top of a child widget to. |
|
the row number to attach the bottom of a child widget to. |
|
Used to specify the properties of the child widget when the table is resized. |
|
The same as xoptions, except this field determines behaviour of vertical resizing. |
|
An integer value specifying the padding on the left and right of the widget being added to the table. |
|
The amount of padding above and below the child widget. |
void gtk_table_attach_defaults (GtkTable *table
,GtkWidget *widget
,guint left_attach
,guint right_attach
,guint top_attach
,guint bottom_attach
);
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 GtkAttachOptions are GTK_EXPAND | GTK_FILL
, and the padding is set to 0.
|
The table to add a new child widget to. |
|
The child widget to add. |
|
The column number to attach the left side of the child widget to. |
|
The column number to attach the right side of the child widget to. |
|
The row number to attach the top of the child widget to. |
|
The row number to attach the bottom of the child widget to. |
void gtk_table_set_row_spacing (GtkTable *table
,guint row
,guint spacing
);
Changes the space between a given table row and the subsequent row.
|
a GtkTable containing the row whose properties you wish to change. |
|
row number whose spacing will be changed. |
|
number of pixels that the spacing should take up. |
void gtk_table_set_col_spacing (GtkTable *table
,guint column
,guint spacing
);
Alters the amount of space between a given table column and the following column.
|
a GtkTable. |
|
the column whose spacing should be changed. |
|
number of pixels that the spacing should take up. |
void gtk_table_set_row_spacings (GtkTable *table
,guint spacing
);
Sets the space between every row in table
equal to spacing
.
|
a GtkTable. |
|
the number of pixels of space to place between every row in the table. |
void gtk_table_set_col_spacings (GtkTable *table
,guint spacing
);
Sets the space between every column in table
equal to spacing
.
|
a GtkTable. |
|
the number of pixels of space to place between every column in the table. |
void gtk_table_set_homogeneous (GtkTable *table
,gboolean homogeneous
);
Changes the homogenous property of table cells, ie. whether all cells are an equal size or not.
guint gtk_table_get_default_row_spacing (GtkTable *table
);
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()
)
|
a GtkTable |
Returns : |
the default row spacing |
gboolean gtk_table_get_homogeneous (GtkTable *table
);
Returns whether the table cells are all constrained to the same
width and height. (See gtk_table_set_homogenous()
)
guint gtk_table_get_row_spacing (GtkTable *table
,guint row
);
Gets the amount of space between row row
, and
row row
+ 1. See gtk_table_set_row_spacing()
.
|
a GtkTable |
|
a row in the table, 0 indicates the first row |
Returns : |
the row spacing |
guint gtk_table_get_col_spacing (GtkTable *table
,guint column
);
Gets the amount of space between column col
, and
column col
+ 1. See gtk_table_set_col_spacing()
.
|
a GtkTable |
|
a column in the table, 0 indicates the first column |
Returns : |
the column spacing |
guint gtk_table_get_default_col_spacing (GtkTable *table
);
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()
)
|
a GtkTable |
Returns : |
the default column spacing |
"column-spacing"
property"column-spacing" guint : Read / Write
The amount of space between two consecutive columns.
Allowed values: <= 65535
Default value: 0
"homogeneous"
property"homogeneous" gboolean : Read / Write
If TRUE, the table cells are all the same width/height.
Default value: FALSE
"n-columns"
property"n-columns" guint : Read / Write
The number of columns in the table.
Allowed values: [1,65535]
Default value: 1
"n-rows"
property"n-rows" guint : Read / Write
The number of rows in the table.
Allowed values: [1,65535]
Default value: 1
"row-spacing"
property"row-spacing" guint : Read / Write
The amount of space between two consecutive rows.
Allowed values: <= 65535
Default value: 0
"bottom-attach"
child property"bottom-attach" guint : Read / Write
The row number to attach the bottom of the child to.
Allowed values: [1,65535]
Default value: 1
"left-attach"
child property"left-attach" guint : Read / Write
The column number to attach the left side of the child to.
Allowed values: <= 65535
Default value: 0
"right-attach"
child property"right-attach" guint : Read / Write
The column number to attach the right side of a child widget to.
Allowed values: [1,65535]
Default value: 1
"top-attach"
child property"top-attach" guint : Read / Write
The row number to attach the top of a child widget to.
Allowed values: <= 65535
Default value: 0
"x-options"
child property"x-options" GtkAttachOptions : Read / Write
Options specifying the horizontal behaviour of the child.
Default value: GTK_EXPAND|GTK_FILL
"x-padding"
child property"x-padding" guint : Read / Write
Extra space to put between the child and its left and right neighbors, in pixels.
Allowed values: <= 65535
Default value: 0
"y-options"
child property"y-options" GtkAttachOptions : Read / Write
Options specifying the vertical behaviour of the child.
Default value: GTK_EXPAND|GTK_FILL
"y-padding"
child property"y-padding" guint : Read / Write
Extra space to put between the child and its upper and lower neighbors, in pixels.
Allowed values: <= 65535
Default value: 0