GtkTable::attach

void attach(GtkWidget child, int left_attach, int right_attach, int top_attach, int bottom_attach [, GtkAttachOptions xoptions = Gtk::EXPAND|Gtk::FILL [, GtkAttachOptions yoptions = Gtk::EXPAND|Gtk::FILL [, int xpadding = Gtk::EXPAND|Gtk::FILL [, int ypadding = Gtk::EXPAND|Gtk::FILL]]]]);

attach() is the way of adding widgets to a GtkTable. It takes up to nine arguments, but only five are required.

The first argument (child) refers to the child widget to be attached. The two following arguments ( left_attach, right_attach) denote the starting point that the child will be drawn from, at the left hand side, and the end point that the child will be drawn to, to the right. These parameters are given in terms of columns, with the start point being 0. The next two arguments (top_attach, bottom_attach) do the same thing, the only difference beeing that they relate to rows instead of columns, controlling the vertical positioning.

As with all container widgets, the GtkTable itself takes up no screen space until it contains child widgets. If you attach only one child with parameters that should set it in the bottom right corner and set homogeneous to false, the resulting effect will not be that of a table with only one entry in the bottom right corner, but of a container with a single widget in it - regardless of the number of columns and rows specified in the table's constructor. Child settings always take precedence in a non-homogeneous table, and so all table attachments are relative to the other child widgets. This is in line with the behaviour of other multiple-child capable containers where the child widget can have its own packing parameters set.

The behaviour is very different when a regular grid is in position, which happens when the GtkTable has its homogeneous parameter set to true. The table works out the dimensions of the grid from the the largest child widget's size request, and positions its children accordingly.

The final four optional parameters determine the way in which the child widget will respond to the area available to it (expand, shrink, fill) in each direction, and the padding between the child and its nearest border, in each direction.

See the constructor entry for an usage example.