Klasse Box

Alle implementierten Schnittstellen:
PointerInterface
Bekannte direkte Unterklassen:
ShortcutsGroup, ShortcutsSection

public class Box extends Widget
Arranges child widgets into a single row or column.

<picture>
<source srcset="box-dark.png" media="(prefers-color-scheme: dark)">
<img alt="An example GtkBox" src="box.png">
</picture>

Whether it is a row or column depends on the value of its
[property@Gtk.Orientable:orientation] property. Within the other
dimension, all children are allocated the same size. The
[property@Gtk.Widget:halign] and [property@Gtk.Widget:valign]
properties can be used on the children to influence their allocation.

Use repeated calls to [method@Gtk.Box.append] to pack widgets into a
`GtkBox` from start to end. Use [method@Gtk.Box.remove] to remove widgets
from the `GtkBox`. [method@Gtk.Box.insert_child_after] can be used to add
a child at a particular position.

Use [method@Gtk.Box.set_homogeneous] to specify whether or not all children
of the `GtkBox` are forced to get the same amount of space.

Use [method@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.

Use [method@Gtk.Box.reorder_child_after] to move a child to a different
place in the box.

# CSS nodes

`GtkBox` uses a single CSS node with name box.

# Accessibility

Until GTK 4.10, `GtkBox` used the [enum@Gtk.AccessibleRole.group] role.

Starting from GTK 4.12, `GtkBox` uses the [enum@Gtk.AccessibleRole.generic] role.

https://docs.gtk.org/gtk4/class.Box.html

  • Konstruktordetails

    • Box

      public Box(PointerContainer pointer)
    • Box

      public Box(int orientation, int spacing)
      Creates a new box.
      Parameter:
      orientation - the box’s orientation
      spacing - the number of pixels to place between children
  • Methodendetails

    • getClassHandler

      public static ClassHandler getClassHandler()
    • append

      public void append(@Nonnull Widget child)
      Adds a child at the end.
      Parameter:
      child - the widget to append
    • getBaselineChild

      public int getBaselineChild()
      Gets the value set by [method@Gtk.Box.set_baseline_child].
      Gibt zurück:
      the baseline child
    • getBaselinePosition

      public int getBaselinePosition()
      Gets the value set by [method@Gtk.Box.set_baseline_position].
      Gibt zurück:
      the baseline position
    • getHomogeneous

      public boolean getHomogeneous()
      Returns whether the box is homogeneous.

      In a homogeneous box all children are the same size.
      Gibt zurück:
      true if the box is homogeneous
    • getSpacing

      public int getSpacing()
      Gets the value set by [method@Gtk.Box.set_spacing].
      Gibt zurück:
      spacing between children
    • insertChildAfter

      public void insertChildAfter(@Nonnull Widget child, @Nullable Widget sibling)
      Inserts a child at a specific position.

      The child is added after @sibling in the list of @box children.

      If @sibling is `NULL`, the @child is placed at the beginning.
      Parameter:
      child - the widget to insert
      sibling - the sibling after which to insert @child
    • prepend

      public void prepend(@Nonnull Widget child)
      Adds a child at the beginning.
      Parameter:
      child - the widget to prepend
    • remove

      public void remove(@Nonnull Widget child)
      Removes a child widget from the box.

      The child must have been added before with
      [method@Gtk.Box.append], [method@Gtk.Box.prepend], or
      [method@Gtk.Box.insert_child_after].
      Parameter:
      child - the child to remove
    • reorderChildAfter

      public void reorderChildAfter(@Nonnull Widget child, @Nullable Widget sibling)
      Moves a child to a different position.

      The child is moved to the position after @sibling in the list
      of @box children.

      If @sibling is `NULL`, the child is placed at the beginning.
      Parameter:
      child - the widget to move, must be a child of @box
      sibling - the sibling to move @child after
    • setBaselineChild

      public void setBaselineChild(int child)
      Sets the baseline child of a box.

      This affects only vertical boxes.
      Parameter:
      child - a child position, or -1
    • setBaselinePosition

      public void setBaselinePosition(int 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 with respect to the
      extra space available.
      Parameter:
      position - the baseline position
    • setHomogeneous

      public void setHomogeneous(boolean homogeneous)
      Sets whether or not all children are given equal space
      in the box.
      Parameter:
      homogeneous - true to create equal allotments, false for variable allotments
    • setSpacing

      public void setSpacing(int spacing)
      Sets the number of pixels to place between children.
      Parameter:
      spacing - the number of pixels to put between children
    • asAccessible

      public Accessible asAccessible()
      Implements interface Accessible. Call this to get access to interface functions.
      Setzt außer Kraft:
      asAccessible in Klasse Widget
      Gibt zurück:
      Accessible
    • asBuildable

      public Buildable asBuildable()
      Implements interface Buildable. Call this to get access to interface functions.
      Setzt außer Kraft:
      asBuildable in Klasse Widget
      Gibt zurück:
      Buildable
    • asConstraintTarget

      public ConstraintTarget asConstraintTarget()
      Implements interface ConstraintTarget. Call this to get access to interface functions.
      Setzt außer Kraft:
      asConstraintTarget in Klasse Widget
      Gibt zurück:
      ConstraintTarget
    • asOrientable

      public Orientable asOrientable()
      Implements interface Orientable. Call this to get access to interface functions.
      Gibt zurück:
      Orientable
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()