Gtk.Box

Entities

Tagged Types

Access Types

Subtypes

Constants

Subprograms

Generic Instantiations

Description

The GtkBox widget arranges child widgets into a single row or column, depending upon the value of its Gtk.Orientable.Gtk_Orientable:orientation property. Within the other dimension, all children are allocated the same size. Of course, the Gtk.Widget.Gtk_Widget:halign and Gtk.Widget.Gtk_Widget:valign properties can be used on the children to influence their allocation.

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

Use repeated calls to Gtk.Box.Pack_Start to pack widgets into a GtkBox from start to end. Use Gtk.Box.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 Gtk.Container.Gtk_Container, you may also use Gtk.Container.Add to insert widgets into the box, and they will be packed with the default values for expand and fill child properties. Use Gtk.Container.Remove to remove widgets from the GtkBox.

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

Use Gtk.Box.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 Gtk.Box.Pack_Start or Gtk.Box.Pack_End is added on either side of the widget it belongs to.

Use Gtk.Box.Reorder_Child to move a GtkBox child to a different place in the box.

Use Gtk.Box.Set_Child_Packing to reset the expand, fill and padding child properties. Use Gtk.Box.Query_Child_Packing to query these fields.

# 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 :first-child will always select the leftmost child, regardless of text direction.

See the testgtk example in the GtkAda distribution to see concrete examples on how all the parameters for the boxes work.

<screenshot>gtk-box</screenshot> <group>Layout containers</group> <testgtk>create_box.adb</testgtk>

"+"

function "+"
  (Widget : access Gtk_Box_Record'Class)
return Gtk.Buildable.Gtk_Buildable
Parameters
Widget
Return Value

"+"

function "+"
  (Widget : access Gtk_Box_Record'Class)
return Gtk.Orientable.Gtk_Orientable
Parameters
Widget
Return Value

"-"

function "-"
  (Interf : Gtk.Buildable.Gtk_Buildable)
return Gtk_Box
Parameters
Interf
Return Value

"-"

function "-"
  (Interf : Gtk.Orientable.Gtk_Orientable)
return Gtk_Box
Parameters
Interf
Return Value

Baseline_Position_Property

Baseline_Position_Property : constant Gtk.Enums.Property_Gtk_Baseline_Position;

Get_Baseline_Position

function Get_Baseline_Position
   (Box : not null access Gtk_Box_Record)
    return Gtk.Enums.Gtk_Baseline_Position

Gets the value set by Gtk.Box.Set_Baseline_Position. Since: gtk+ 3.10

Parameters
Box
Return Value

the baseline position

Get_Center_Widget

function Get_Center_Widget
   (Box : not null access Gtk_Box_Record) return Gtk.Widget.Gtk_Widget

Retrieves the center widget of the box. Since: gtk+ 3.12

Parameters
Box
Return Value

the center widget or null in case no center widget is set.

Get_Child

function Get_Child
   (Box : not null access Gtk_Box_Record;
    Num : Glib.Gint) return Gtk.Widget.Gtk_Widget

Return the Num-th child of the box, or null if there is no such child Since: gtk+ GtkAda 1.0

Parameters
Box
Num
Return Value

Get_Hbox_Type

function Get_Hbox_Type return Glib.GType
Return Value

Get_Homogeneous

function Get_Homogeneous
   (Box : not null access Gtk_Box_Record) return Boolean

Returns whether the box is homogeneous (all children are the same size). See Gtk.Box.Set_Homogeneous.

Parameters
Box
Return Value

True if the box is homogeneous.

Get_Orientation

function Get_Orientation
   (Self : not null access Gtk_Box_Record)
    return Gtk.Enums.Gtk_Orientation
Parameters
Self
Return Value

Get_Spacing

function Get_Spacing
   (Box : not null access Gtk_Box_Record) return Glib.Gint

Gets the value set by Gtk.Box.Set_Spacing.

Parameters
Box
Return Value

spacing between children

Get_Type

function Get_Type return Glib.GType

Used with Glib.Object.G_New, this creates a horizontal box

Return Value

Get_Vbox_Type

function Get_Vbox_Type return Glib.GType
Return Value

Gtk_Box

type Gtk_Box is access all Gtk_Box_Record'Class;

Gtk_Box_New

function Gtk_Box_New
   (Orientation : Gtk.Enums.Gtk_Orientation;
    Spacing     : Glib.Gint) return Gtk_Box

Creates a new Gtk.Box.Gtk_Box. Since: gtk+ 3.0

Parameters
Orientation

the box's orientation.

Spacing

the number of pixels to place by default between children.

Return Value

Gtk_Box_Record

type Gtk_Box_Record is new Gtk_Container_Record with null record;

Gtk_Hbox

subtype Gtk_Hbox is Gtk_Box;

Gtk_Hbox_New

function Gtk_Hbox_New
   (Homogeneous : Boolean := False;
    Spacing     : Glib.Gint := 0) return Gtk_Hbox

Creates a new Gtk.Box.Gtk_Hbox.

Parameters
Homogeneous

True if all children are to be given equal space allotments.

Spacing

the number of pixels to place by default between children.

Return Value

Gtk_Hbox_Record

subtype Gtk_Hbox_Record is Gtk_Box_Record;

Gtk_New

procedure Gtk_New
   (Box         : out Gtk_Box;
    Orientation : Gtk.Enums.Gtk_Orientation;
    Spacing     : Glib.Gint)

Creates a new Gtk.Box.Gtk_Box. Since: gtk+ 3.0 Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Box
Orientation

the box's orientation.

Spacing

the number of pixels to place by default between children.

Gtk_New_Hbox

procedure Gtk_New_Hbox
   (Box         : out Gtk_Hbox;
    Homogeneous : Boolean := False;
    Spacing     : Glib.Gint := 0)

Creates a new Gtk.Box.Gtk_Hbox. Initialize_Hbox does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Box
Homogeneous

True if all children are to be given equal space allotments.

Spacing

the number of pixels to place by default between children.

Gtk_New_Vbox

procedure Gtk_New_Vbox
   (Box         : out Gtk_Vbox;
    Homogeneous : Boolean := False;
    Spacing     : Glib.Gint := 0)

Creates a new Gtk.Box.Gtk_Vbox. Initialize_Vbox does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Box
Homogeneous

True if all children are to be given equal space allotments.

Spacing

the number of pixels to place by default between children.

Gtk_Vbox

subtype Gtk_Vbox is Gtk_Box;

Gtk_Vbox_New

function Gtk_Vbox_New
   (Homogeneous : Boolean := False;
    Spacing     : Glib.Gint := 0) return Gtk_Vbox

Creates a new Gtk.Box.Gtk_Vbox.

Parameters
Homogeneous

True if all children are to be given equal space allotments.

Spacing

the number of pixels to place by default between children.

Return Value

Gtk_Vbox_Record

subtype Gtk_Vbox_Record is Gtk_Box_Record;

Homogeneous_Property

Homogeneous_Property : constant Glib.Properties.Property_Boolean;

Implements_Gtk_Buildable

package Implements_Gtk_Buildable is new Glib.Types.Implements
  (Gtk.Buildable.Gtk_Buildable, Gtk_Box_Record, Gtk_Box);

Implements_Gtk_Orientable

package Implements_Gtk_Orientable is new Glib.Types.Implements
  (Gtk.Orientable.Gtk_Orientable, Gtk_Box_Record, Gtk_Box);

Initialize

procedure Initialize
   (Box         : not null access Gtk_Box_Record'Class;
    Orientation : Gtk.Enums.Gtk_Orientation;
    Spacing     : Glib.Gint)

Creates a new Gtk.Box.Gtk_Box. Since: gtk+ 3.0 Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Box
Orientation

the box's orientation.

Spacing

the number of pixels to place by default between children.

Initialize_Hbox

procedure Initialize_Hbox
   (Box         : not null access Gtk_Hbox_Record'Class;
    Homogeneous : Boolean := False;
    Spacing     : Glib.Gint := 0)

Creates a new Gtk.Box.Gtk_Hbox. Initialize_Hbox does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Box
Homogeneous

True if all children are to be given equal space allotments.

Spacing

the number of pixels to place by default between children.

Initialize_Vbox

procedure Initialize_Vbox
   (Box         : not null access Gtk_Vbox_Record'Class;
    Homogeneous : Boolean := False;
    Spacing     : Glib.Gint := 0)

Creates a new Gtk.Box.Gtk_Vbox. Initialize_Vbox does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Box
Homogeneous

True if all children are to be given equal space allotments.

Spacing

the number of pixels to place by default between children.

Pack_End

procedure Pack_End
   (In_Box  : not null access Gtk_Box_Record;
    Child   : not null access Gtk.Widget.Gtk_Widget_Record'Class;
    Expand  : Boolean := True;
    Fill    : Boolean := True;
    Padding : Guint := 0)

Adds Child to Box, packed with reference to the end of Box. The Child is packed after (away from end of) any other child packed with reference to the end of Box.

Parameters
In_Box
Child

the Gtk.Widget.Gtk_Widget to be added to Box

Expand

True if the new child is to be given extra space allocated to Box. The extra space will be divided evenly between all children of Box that use this option

Fill

True if space given to Child by the Expand option is actually allocated to Child, rather than just padding it. This parameter has no effect if Expand is set to False. A child is always allocated the full height of a horizontal Gtk.Box.Gtk_Box and the full width of a vertical Gtk.Box.Gtk_Box. This option affects the other dimension

Padding

extra space in pixels to put between this child and its neighbors, over and above the global amount specified by Gtk.Box.Gtk_Box:spacing property. If Child is a widget at one of the reference ends of Box, then Padding pixels are also put between Child and the reference edge of Box

Pack_Start

procedure Pack_Start
   (In_Box  : not null access Gtk_Box_Record;
    Child   : not null access Gtk.Widget.Gtk_Widget_Record'Class;
    Expand  : Boolean := True;
    Fill    : Boolean := True;
    Padding : Guint := 0)

Adds Child to Box, packed with reference to the start of Box. The Child is packed after any other child packed with reference to the start of Box.

Parameters
In_Box
Child

the Gtk.Widget.Gtk_Widget to be added to Box

Expand

True if the new child is to be given extra space allocated to Box. The extra space will be divided evenly between all children that use this option

Fill

True if space given to Child by the Expand option is actually allocated to Child, rather than just padding it. This parameter has no effect if Expand is set to False. A child is always allocated the full height of a horizontal Gtk.Box.Gtk_Box and the full width of a vertical Gtk.Box.Gtk_Box. This option affects the other dimension

Padding

extra space in pixels to put between this child and its neighbors, over and above the global amount specified by Gtk.Box.Gtk_Box:spacing property. If Child is a widget at one of the reference ends of Box, then Padding pixels are also put between Child and the reference edge of Box

Query_Child_Packing

procedure Query_Child_Packing
   (Box       : not null access Gtk_Box_Record;
    Child     : not null access Gtk.Widget.Gtk_Widget_Record'Class;
    Expand    : out Boolean;
    Fill      : out Boolean;
    Padding   : out Guint;
    Pack_Type : out Gtk.Enums.Gtk_Pack_Type)

Obtains information about how Child is packed into Box.

Parameters
Box
Child

the Gtk.Widget.Gtk_Widget of the child to query

Expand

pointer to return location for expand child property

Fill

pointer to return location for fill child property

Padding

pointer to return location for padding child property

Pack_Type

pointer to return location for pack-type child property

Reorder_Child

procedure Reorder_Child
   (Box      : not null access Gtk_Box_Record;
    Child    : not null access Gtk.Widget.Gtk_Widget_Record'Class;
    Position : Glib.Gint)

Moves Child to a new Position in the list of Box children. The list contains widgets packed GTK_PACK_START as well as widgets packed GTK_PACK_END, in the order that these widgets were added to Box. A widget's position in the Box children list determines where the widget is packed into Box. A child widget at some position in the list will be packed just after all other widgets of the same packing type that appear earlier in the list.

Parameters
Box
Child

the Gtk.Widget.Gtk_Widget to move

Position

the new position for Child in the list of children of Box, starting from 0. If negative, indicates the end of the list

Set_Baseline_Position

procedure Set_Baseline_Position
   (Box      : not null access Gtk_Box_Record;
    Position : Gtk.Enums.Gtk_Baseline_Position)

Sets the baseline position of a box. This affects only horizontal boxes with at least one baseline aligned child. If there is more vertical space available than requested, and the baseline is not allocated by the parent then Position is used to allocate the baseline wrt the extra space available. Since: gtk+ 3.10

Parameters
Box
Position

a Gtk.Enums.Gtk_Baseline_Position

Set_Center_Widget

procedure Set_Center_Widget
   (Box    : not null access Gtk_Box_Record;
    Widget : access Gtk.Widget.Gtk_Widget_Record'Class)

Sets a center widget; that is a child widget that will be centered with respect to the full width of the box, even if the children at either side take up different amounts of space. Since: gtk+ 3.12

Parameters
Box
Widget

the widget to center

Set_Child_Packing

procedure Set_Child_Packing
   (Box       : not null access Gtk_Box_Record;
    Child     : not null access Gtk.Widget.Gtk_Widget_Record'Class;
    Expand    : Boolean;
    Fill      : Boolean;
    Padding   : Guint;
    Pack_Type : Gtk.Enums.Gtk_Pack_Type)

Sets the way Child is packed into Box.

Parameters
Box
Child

the Gtk.Widget.Gtk_Widget of the child to set

Expand

the new value of the expand child property

Fill

the new value of the fill child property

Padding

the new value of the padding child property

Pack_Type

the new value of the pack-type child property

Set_Homogeneous

procedure Set_Homogeneous
   (Box         : not null access Gtk_Box_Record;
    Homogeneous : Boolean)

Sets the Gtk.Box.Gtk_Box:homogeneous property of Box, controlling whether or not all children of Box are given equal space in the box.

Parameters
Box
Homogeneous

a boolean value, True to create equal allotments, False for variable allotments

Set_Orientation

procedure Set_Orientation
   (Self        : not null access Gtk_Box_Record;
    Orientation : Gtk.Enums.Gtk_Orientation)
Parameters
Self
Orientation

Set_Spacing

procedure Set_Spacing
   (Box     : not null access Gtk_Box_Record;
    Spacing : Glib.Gint)

Sets the Gtk.Box.Gtk_Box:spacing property of Box, which is the number of pixels to place between children of Box.

Parameters
Box
Spacing

the number of pixels to put between children

Spacing_Property

Spacing_Property : constant Glib.Properties.Property_Int;