# 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.label
.title Label
.toc 0 Label
.index Label
.index wgtLabel
.index wgtLabelSetAlign
.index wgtLabelGetAlign

.h2 Label

A static text label. Does not accept keyboard focus directly, but supports accelerator keys that forward focus to the next focusable sibling (WCLASS_FOCUS_FORWARD). Useful for describing other widgets. Supports left, center, and right text alignment.

Header: widgets/label.h

.h3 Creation

.code
WidgetT *lbl = wgtLabel(parent, "&Name:");
.endcode

.h3 API Functions

.table
  Function                                            Description
  --------                                            -----------
  WidgetT *wgtLabel(parent, text)                     Create a text label.
  void wgtLabelSetAlign(w, align)                     Set the text alignment (AlignStartE = left, AlignCenterE = center, AlignEndE = right).
  WidgetAlignE wgtLabelGetAlign(w)                    Get the current text alignment.
.endtable

.h3 API Struct (wgtRegisterApi "label")

.table
  Slot       Function
  ----       --------
  create     wgtLabel
  setAlign   wgtLabelSetAlign
.endtable

.h3 Properties (BASIC Interface)

.table
  Property     Type                         Access       Description
  --------     ----                         ------       -----------
  Alignment    Enum (Left, Center, Right)   Read/Write   Text alignment within the label.
.endtable

Label text is managed via the standard wgtSetText() / wgtGetText() interface. BASIC code uses the generic "Caption" or "Text" property. Place an '&' before a character in the caption to mark an accelerator key.

.h3 Methods

No widget-specific methods.

.h3 Events

Labels are not focusable, so they typically have no event callbacks. The common onClick callback will fire if the label is clicked.

.h3 Default Event

"Click" (VB basName: Label).
