# 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.tabcontrol
.title TabControl
.toc 0 TabControl
.index TabControl
.index TabPage
.index wgtTabControl
.index wgtTabPage
.index wgtTabControlSetActive
.index wgtTabControlGetActive

.h2 TabControl

A tabbed container that displays one page at a time with clickable tabs along the top. Each tab page is a container that holds its own child widgets.

Header: widgets/tabCtrl.h

.h3 Creation

.code
WidgetT *tabs = wgtTabControl(parent);
WidgetT *page1 = wgtTabPage(tabs, "General");
WidgetT *page2 = wgtTabPage(tabs, "Advanced");
// add children to page1, page2...
.endcode

.h3 API Functions

.table
  Function                                       Description
  --------                                       -----------
  WidgetT *wgtTabControl(parent)                 Create a tab control.
  WidgetT *wgtTabPage(parent, title)             Add a tab page with the given title. Returns the page container widget.
  void wgtTabControlSetActive(w, idx)            Set the active tab by index (0-based).
  int32_t wgtTabControlGetActive(w)              Get the index of the active tab.
.endtable

.h3 API Struct (wgtRegisterApi "tabcontrol")

.table
  Slot         Function
  ----         --------
  create       wgtTabControl
  page         wgtTabPage
  setActive    wgtTabControlSetActive
  getActive    wgtTabControlGetActive
.endtable

.h3 Properties (BASIC Interface)

.table
  Property     Type       Access       Description
  --------     ----       ------       -----------
  TabIndex     Integer    Read/Write   Index of the currently active tab (0-based).
.endtable

.h3 Methods (BASIC Interface)

.table
  Method                Description
  ------                -----------
  AddPage title$        Add a new tab page with the given title.
  GetActive()           Returns the index of the active tab.
  SetActive idx%        Set the active tab by index (0-based).
.endtable

.h3 Events

.table
  Callback     Description
  --------     -----------
  onChange     Fires when the active tab changes.
.endtable

.h3 Default Event

"Click" (VB basName: TabStrip).
