# 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.radio
.title Radio Button
.toc 0 Radio Button
.index Radio
.index RadioGroup
.index wgtRadio
.index wgtRadioGroup
.index wgtRadioGroupSetSelected
.index wgtRadioGetIndex

.h2 Radio Button

A mutually exclusive selection control. Radio buttons must be placed inside a radio group container. Only one radio button within a group can be selected at a time.

Header: widgets/radio.h

.h3 Creation

.code
WidgetT *grp = wgtRadioGroup(parent);
WidgetT *r1  = wgtRadio(grp, "Option A");
WidgetT *r2  = wgtRadio(grp, "Option B");
.endcode

.h3 API Functions

.table
  Function                                       Description
  --------                                       -----------
  WidgetT *wgtRadioGroup(parent)                 Create a radio group container.
  WidgetT *wgtRadio(parent, text)                Create a radio button inside a group.
  void wgtRadioGroupSetSelected(group, idx)      Set the selected radio button by index within the group.
  int32_t wgtRadioGetIndex(w)                    Get the index of this radio button within its group.
.endtable

.h3 API Struct (wgtRegisterApi "radio")

.table
  Slot                Function
  ----                --------
  group               wgtRadioGroup
  create              wgtRadio
  groupSetSelected    wgtRadioGroupSetSelected
  getIndex            wgtRadioGetIndex
.endtable

.h3 Properties (BASIC Interface)

.table
  Property     Type       Access       Description
  --------     ----       ------       -----------
  Value        Integer    Read-only    Index of this radio button within its group.
.endtable

Caption is managed via the standard wgtSetText() / wgtGetText() interface (WCLASS_HAS_TEXT).

.h3 Methods (BASIC Interface)

.table
  Method                  Description
  ------                  -----------
  SetSelected idx%        Set the selected radio button by index within the group.
.endtable

.h3 Events

.table
  Callback     Description
  --------     -----------
  onClick      Fires on the radio button when clicked.
  onChange     Fires when the selection changes.
.endtable

.h3 Default Event

"Click" (VB basName: OptionButton, namePrefix: Option).
