GtkAda Reference Manual - Package Gtk.Box

[Contents] [Back] [Prev] [Up] [Next] [Forward]

# Package Gtk.Box

A box is a container that can have multiple children, organized either horizontally or vertically. Two subtypes are provided, Gtk_Hbox and Gtk_Vbox, to conform to the C API. In Ada, you do not need to distinguish between the two, but note that the Gtk_Box type is conceptually an abstract type: there is no way to create a "Gtk_Box", only ways to create either an horizontal box, or a vertical box.

Children can be added to one of two positions in the box, either at the beginning (ie left or top) or at the end (ie right or bottom). Each of these positions can contain multiple widgets.

Every time a child is added to the start, it is placed to the right (resp. the bottom) of the previous widget added to the start.

Every time a child is added to the end, it is placed to the left (resp. the top) of the previous widget added to the end.

There are a number of parameters to specify the behavior of the box when it is resized, and how the children should be reorganized and/or resized.

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

- Gtk.Box Widget Hierarchy
- Gtk.Box Subprograms

## Widget Hierarchy

    GObject                       (see section Package Glib.Object)
    Gtk_Object                    (see section Package Gtk.Object)
       \___ Gtk_Widget            (see section Package Gtk.Widget)
          \___ Gtk_Container      (see section Package Gtk.Container)
             \___ Gtk_Box         (see section Package Gtk.Box)

## Subprograms

    procedure Gtk_New_Vbox
      (Box                : out    Gtk_Box;
       Homogeneous        :        Boolean := False;
       Spacing            :        Gint := 0);
| Create a new vertical box. Its children will be placed one above the other. If Homogeneous is True, all the children will be allocated exactly the same screen real-estate, whereas if it is False, each child can have its own size. Spacing is the space left between two adjacent children.
    procedure Gtk_New_Hbox
      (Box                : out    Gtk_Box;
       Homogeneous        :        Boolean := False;
       Spacing            :        Gint := 0);
| Create a new horizontal box. Its children will be placed one besides the other. If Homogeneous is True, all the children will be allocated exactly the same screen real-estate, whereas if it is False, each child can have its own size. Spacing is the space left between two adjacent children.
    procedure Initialize_Vbox
      (Box                : access Gtk_Box_Record'Class;
       Homogeneous        :        Boolean := False;
       Spacing            :        Gint := 0);
| Internal initialization function. See the section "Creating your own widgets" in the documentation.
    procedure Initialize_Hbox
      (Box                : access Gtk_Box_Record'Class;
       Homogeneous        :        Boolean := False;
       Spacing            :        Gint := 0);
| Internal initialization function. See the section "Creating your own widgets" in the documentation.
    function Get_Type              return Gtk.Gtk_Type;
| Return the internal value associated with a Gtk_Box.
    function Get_Hbox_Type         return Gtk.Gtk_Type;
| Return the internal value associated with a Gtk_HBox.
    function Get_Vbox_Type         return Gtk.Gtk_Type;
| Return the internal value associated with a Gtk_VBox.
    procedure Pack_Start
      (In_Box             : access Gtk_Box_Record;
       Child              : access Gtk.Widget.Gtk_Widget_Record'Class;
       Expand             :        Boolean := True;
       Fill               :        Boolean := True;
       Padding            :        Gint := 0);
| Add a new child to the beginning of the box (ie left or top part). It is added to the right (resp. the bottom) of the previous child added to the beginning of the box. Note that a child added to the beginning of the box will always remain on the left (resp. top) of all the children added to the end of the box. If Expand is False, the size allocated for each size will be the one requested by the widget (or the largest child if Homogeneous was set to true when the box was created). Otherwise, the total size of the box is divided between all the children. Note that this does not mean that the children have to occupy all the space given to them... If Fill is True, then the widget will be resized so as to occupy all the space allocated to them. This is only relevant if Expand is True, since otherwise the space allocated is the same one as the child's size. Padding is the amount of space left around the widget when it is drawn.
    procedure Pack_End
      (In_Box             : access Gtk_Box_Record;
       Child              : access Gtk.Widget.Gtk_Widget_Record'Class;
       Expand             :        Boolean := True;
       Fill               :        Boolean := True;
       Padding            :        Gint := 0);
| Add a new child to the end of the box (ie right or bottom part). It is added to the left (resp. top) of the previous child added to the end of the box. Note that a child added to the end of the box will always remain on the right (resp. bottom) of all the children added to the beginning of the box. See Pack_Start for an explanation of all the parameters.
    procedure Pack_Start_Defaults
      (In_Box             : access Gtk_Box_Record;
       Child              : access Gtk.Widget.Gtk_Widget_Record'Class);
| This is the same as Pack_Start if you use the default parameter values. It is provided for backward compatibility only.
    procedure Pack_End_Defaults
      (In_Box             : access Gtk_Box_Record;
       Child              : access Gtk.Widget.Gtk_Widget_Record'Class);
| This is the same as Pack_End if you use the default parameter values. It is provided for backward compatibility only.
    procedure Set_Homogeneous
      (In_Box             : access Gtk_Box_Record;
       Homogeneous        :        Boolean);
| Modify the homogeneous parameter for the box. If the box is homogeneous, then all its children will be allocated the same amount of space, even if they are not resized to occupy it (depending on the parameters given to Pack_Start and Pack_End).
    function Get_Homogeneous
      (In_Box             : access Gtk_Box_Record)
       return Boolean;
| Return the homogeneous parameter of the box.
    procedure Set_Spacing
      (In_Box             : access Gtk_Box_Record;
       Spacing            :        Gint);
| Modify the spacing for the box. I.e. the amount of space left between two adjacent children.
    function Get_Spacing
      (In_Box             : access Gtk_Box_Record)
       return Gint;
| Return the spacing of the box.
    procedure Reorder_Child
      (In_Box             : access Gtk_Box_Record;
       Child              : access Gtk.Widget.Gtk_Widget_Record'Class;
       Pos                :        Guint);
| Move the Child to a new position. Nothing is done if Child is not in the box. Pos starts at 0, and indicates the position of the child relative to all other children, no matter where they were packed (the beginning or the end of the box).
    procedure Query_Child_Packing
      (In_Box             : access Gtk_Box_Record;
       Child              : access Gtk.Widget.Gtk_Widget_Record'Class;
       Expand             : out    Boolean;
       Fill               : out    Boolean;
       Padding            : out    Gint;
       PackType           : out    Gtk.Enums.Gtk_Pack_Type);
| Get information on how the child was packed in the box. The results are undefined if Child is not in the box.
    procedure Set_Child_Packing
      (In_Box             : access Gtk_Box_Record;
       Child              : access Gtk.Widget.Gtk_Widget_Record'Class;
       Expand             :        Boolean;
       Fill               :        Boolean;
       Padding            :        Gint;
       Pack_Type          :        Gtk.Enums.Gtk_Pack_Type);
| Modify the packing for a child.
    function Get_Child
      (Box                : access Gtk_Box_Record;
       Num                :        Gint)
       return Gtk.Widget.Gtk_Widget;
| Return the Num-th child of the box, or null if there is no such child.

[Contents] [Back] [Prev] [Up] [Next] [Forward]