Box


Object Hierarchy:

Object hierarchy for Box

Description:

public class Box : Container, Implementor, Buildable, Orientable

The GtkBox widget organizes child widgets into a rectangular area.

The rectangular area of a GtkBox is organized into either a single row or a single column of child widgets depending upon the orientation. Thus, all children of a GtkBox are allocated one dimension in common, which is the height of a row, or the width of a column.

GtkBox uses a notion of packing. Packing refers to adding widgets with reference to a particular position in a Container. For a GtkBox, there are two reference positions: the start and the end of the box. For a vertical Box, the start is defined as the top of the box and the end is defined as the bottom. For a horizontal Box the start is defined as the left side and the end is defined as the right side.

Use repeated calls to pack_start to pack widgets into a GtkBox from start to end. Use pack_end to add widgets from end to start. You may intersperse these calls and add widgets from both ends of the same GtkBox.

Because GtkBox is a Container, you may also use add to insert widgets into the box, and they will be packed with the default values for expand and fill child properties. Use remove to remove widgets from the GtkBox.

Use set_homogeneous to specify whether or not all children of the GtkBox are forced to get the same amount of space.

Use set_spacing to determine how much space will be minimally placed between all children in the GtkBox. Note that spacing is added between the children, while padding added by pack_start or pack_end is added on either side of the widget it belongs to.

Use reorder_child to move a GtkBox child to a different place in the box.

Use set_child_packing to reset the expand, fill and padding child properties. Use query_child_packing to query these fields.

Note that a single-row or single-column Grid provides exactly the same functionality as Box.

CSS nodes

GtkBox uses a single CSS node with name box.

In horizontal orientation, the nodes of the children are always arranged from left to right. So GtkBox:first-child will always select the leftmost child, regardless of text direction.

Example: Box:

public class Application : Gtk.Window {
public Application () {
// Prepare Gtk.Window:
this.title = "My Gtk.Box";
this.window_position = Gtk.WindowPosition.CENTER;
this.destroy.connect (Gtk.main_quit);
this.set_default_size (350, 70);

// The Box:
Gtk.Box box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
box.pack_start (new Gtk.Label ("1"), false, false, 0);
box.pack_start (new Gtk.Label ("2"), false, false, 0);
box.pack_start (new Gtk.Label ("3"), true, false, 0);
this.add (box);
}

public static int main (string[] args) {
Gtk.init (ref args);

Application app = new Application ();
app.show_all ();
Gtk.main ();
return 0;
}
}

valac --pkg gtk+-3.0 Gtk.Box.vala


Namespace: Gtk
Package: gtk+-3.0

Content:

Properties:

Creation methods:

Methods:

Inherited Members:

All known members inherited from class Gtk.Widget
All known members inherited from interface Atk.Implementor
All known members inherited from interface Gtk.Orientable