# 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.wrapbox
.title WrapBox
.toc 0 WrapBox
.index WrapBox
.index wgtWrapBox

.h2 WrapBox

A flow/wrap layout container that arranges children left-to-right, wrapping to the next row when the available width is exceeded. Each row's height is the maximum child height in that row. Supports configurable spacing between items and rows, and per-row alignment for short rows.

Header: widgets/wrapBox.h

.h3 Creation

.code
WidgetT *wrap = wgtWrapBox(parent);
wgtButton(wrap, "Tag 1");
wgtButton(wrap, "Tag 2");
wgtButton(wrap, "Tag 3");
.endcode

.h3 API Functions

.table
  Function               Description
  --------               -----------
  wgtWrapBox(parent)     Create a wrap box container. Macro that calls the registered "wrapbox" create slot.
.endtable

.h3 API Struct (wgtRegisterApi "wrapbox")

.table
  Slot       Function
  ----       --------
  create     wrapBoxCreate
.endtable

.h3 Properties (Common Container Fields)

WrapBox uses the common WidgetT container fields for layout control:

.table
  Property     Description
  --------     -----------
  spacing      Gap between children in both the horizontal and vertical directions (tagged size). Default is 4 pixels.
  padding      Internal padding around children (tagged size). Default is 2 pixels.
.endtable

.h3 Properties (BASIC Interface)

.table
  Property     Type                         Access       Description
  --------     ----                         ------       -----------
  Alignment    Enum (Left, Center, Right)   Read/Write   Row alignment for rows that do not fill the full width.
.endtable

.h3 Methods

No widget-specific methods.

.h3 Events

WrapBox is a container widget. It uses the common events only. No widget-specific events are defined.

.h3 Default Event

"Click" (VB basName: WrapBox, namePrefix: WrapBox).
