# Box Widget

    Application Header file	<X11/Xaw/Box.h>

    Class Header file	<X11/Xaw/BoxP.h>

    Class		boxWidgetClass

    Class Name	Box

    Superclass	Composite

The Box widget provides geometry management of arbitrary widgets in a box of a specified dimension. The children are rearranged when resizing events occur either on the Box or its children, or when children are managed or unmanaged. The Box widget always attempts to pack its children as tightly as possible within the geometry allowed by its parent.

Box widgets are commonly used to manage a related set of buttons and are often called ButtonBox widgets, but the children are not limited to buttons. The Box's children are arranged on a background that has its own specified dimensions and color.

## Resources

When creating a Box widget instance, the following resources are retrieved from the argument list or from the resource database:

Name | Class | Type | Notes | Default Value
--- | --- | --- | --- | ---
accelerators | Accelerators | AcceleratorTable |  | NULL
ancestorSensitive | AncestorSensitive | Boolean | D | True
background | Background | Pixel |  | XtDefaultBackground
backgroundPixmap | Pixmap | Pixmap |  | XtUnspecifiedPixmap
borderColor | BorderColor | Pixel |  | XtDefaultForeground
borderPixmap | Pixmap | Pixmap |  | XtUnspecifiedPixmap
borderWidth | BorderWidth | Dimension |  | 1
children | ReadOnly | WidgetList | R | NULL
colormap | Colormap | Colormap |  | Parent's Colormap
depth | Depth | int | C | Parent's Depth
destroyCallback | Callback | XtCallbackList |  | NULL
height | Height | Dimension | A | see `Layout Semantics`
hSpace | HSpace | Dimension |  | 4
mappedWhenManaged | MappedWhenManaged | Boolean |  | True
numChildren | ReadOnly | Cardinal | R | 0
orientation | Orientation | Orientation |  | XtorientVertical
screen | Screen | Screen | R | Parent's Screen
sensitive | Sensitive | Boolean |  | True
vSpace | VSpace | Dimension |  | 4
translations | Translations | TranslationTable |  | NULL
width | Width | Dimension | A | see `Layout Semantics`
x | Position | Position |  | 0
y | Position | Position |  | 0
_

`hSpace`

`vSpace`

  The amount of space, in pixels, to leave between the children. This resource specifies the amount of space left between the outermost children and the edge of the box.

`orientation`

  Specifies whether the preferred shape of the box (i.e. the result returned by the query_geometry class method) is tall and narrow `XtorientVertical` or short and wide `XtorientHorizontal`. When the Box is a child of a parent which enforces width constraints, it is usually better to specify `XtorientVertical` (the default). When the parent enforces height constraints, it is usually better to specify `XtorientHorizontal`.

## Layout Semantics

Each time a child is managed or unmanaged, the Box widget will attempt to reposition the remaining children to compact the box. Children are positioned in order left to right, top to bottom. The packing algorithm used depends on the `orientation` of the Box.

`XtorientVertical`

  When the next child does not fit on the current row, a new row is started. If a child is wider than the width of the box, the box will request a larger width from its parent and will begin the layout process from the beginning if a new width is granted.

`XtorientHorizontal`

  When the next child does not fit on the current row, the Box widens if possible (so as to keep children on a single row); otherwise a new row is started.

After positioning all children, the Box widget attempts to shrink its own size to the minimum dimensions required for the layout.