# The MIT License (MIT)
#
# Copyright (C) 2026 Scott Duensing
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

.section Widgets
.topic widget.box
.title Box (VBox / HBox / Frame)
.toc 0 Layout Containers
.toc 0 Box (VBox / HBox / Frame)
.index VBox
.index HBox
.index Frame
.index wgtVBox
.index wgtHBox
.index wgtFrame
.index Layout

.h2 Box (VBox / HBox / Frame)

Container widgets that arrange their children in a vertical column (VBox), horizontal row (HBox), or a titled group box (Frame). These are the primary layout building blocks. Children are laid out using a weight-based algorithm with configurable spacing, padding, and alignment.

Frame is a labelled grouping container with a Motif-style beveled border. Its title text sits centered vertically on the top border line with a small background-filled gap behind the title, giving the classic Windows 3.1 / Motif group box appearance. Internally, Frame behaves like a VBox for layout purposes.

The widget DXE registers three separate interface entries ("vbox", "hbox", "frame") so the form designer can create each type independently.

Header: widgets/box.h

.h3 Creation

.code
WidgetT *row   = wgtHBox(parent);
WidgetT *col   = wgtVBox(parent);
WidgetT *group = wgtFrame(parent, "Options");
.endcode

.h3 API Functions

.table
  Function                                            Description
  --------                                            -----------
  WidgetT *wgtVBox(parent)                            Create a vertical box container. Children stack top-to-bottom.
  WidgetT *wgtHBox(parent)                            Create a horizontal box container. Children stack left-to-right.
  WidgetT *wgtFrame(parent, title)                    Create a titled group box. Children stack vertically inside the bordered frame. The title string may include a '&' prefix for an accelerator key.
.endtable

.h3 API Struct (wgtRegisterApi "box")

.table
  Slot     Function
  ----     --------
  vBox     wgtVBox
  hBox     wgtHBox
  frame    wgtFrame
.endtable

The designer also registers per-type APIs: "vbox", "hbox", and "frame" each expose a single create slot.

.h3 Properties

Box containers use the common WidgetT fields for layout control. There are no widget-specific properties registered with the interface system.

.table
  Field      Description
  -----      -----------
  align      Main-axis alignment of children. HBox: Start=left, Center=center, End=right. VBox: Start=top, Center=center, End=bottom.
  spacing    Gap between children (tagged size).
  padding    Internal padding around children (tagged size).
  weight     Controls how the box itself stretches within its parent.
.endtable

Frame text is managed via the standard wgtSetText() / wgtGetText() interface (the widget has WCLASS_HAS_TEXT). BASIC code can set its title via the generic "Caption" or "Text" property.

.h3 Events

Containers use the common events only. No widget-specific events or methods are registered.

.h3 Default Event

"Click" on all three types.
