Repository navigation
tkTabControl
Home › All Categories › tkControls › tkTabControl
Shows one page of controls at a time under a strip of tabs.
tkTabControl is the tkControls tab container. It is a tkTabBar across the top and one tkPanel page for each tab. Only the page of the selected tab is visible. To put controls on a tab, make them children of tkTabControl_GetPage( tab, index ).
The control itself is never a tab stop; its bar is. The bar takes a fixed height (tkTabControl_SetTabHeight, in design units) and the pages fill the rest of the control. Pages are laid out again when the control is resized or the scale changes.
tkTabControl_AddPage appends a tab and its empty page. The first page added is selected; adding later ones leaves the selection where it is. tkTabControl_SetCurSel is silent: the selection callback runs only when the user changes the tab.
For the strip's own styling (fonts, colours, glyphs, closable tabs) use the bar that tkTabControl_GetTabBar returns, with the tkTabBar functions.
#import "vendor/tkControls/tkTabControl"
using tkTabControl
using tkHostThe module brings in tkHost (and through it tkPaint, SDL3, SDL_ttf and SDL_image), tkTheme, tkTabBar and tkPanel.
host is a TK_HOST ptr from tkHost_Create, set up as in the tkButton example.
#import "vendor/tkControls/tkLabel"
using tkLabel
sub Tabs_Changed( byval hTab as TK_WIDGET ptr, byval idxOld as long, byval idxNew as long )
print "tab " & idxOld & " to " & idxNew
end sub
dim as TK_WIDGET ptr tabs = tkTabControl_Create( tkHost_Root( host ), 2400 )
tkTabControl_AddPage( tabs, "General" )
tkTabControl_AddPage( tabs, "Advanced" )
tkTabControl_SetSelChangeCallback( tabs, @Tabs_Changed )
dim as TK_WIDGET ptr page1 = tkTabControl_GetPage( tabs, 1 )
dim as TK_WIDGET ptr note = tkLabel_Create( page1, 2401 )
tkLabel_SetText( note, "Settings for experts." )
tkWidget_SetPos( note, tkHost_Scale( host, 12 ), tkHost_Scale( host, 12 ), _
tkHost_Scale( host, 200 ), tkHost_Scale( host, 24 ) )
tkTabControl_SetCurSel( tabs, 1 ) ' silent: no callback
tkWidget_SetPos( tabs, tkHost_Scale( host, 20 ), tkHost_Scale( host, 20 ), _
tkHost_Scale( host, 400 ), tkHost_Scale( host, 240 ) )The module also provides TabControl, a typed value for designed forms (see tkForms and the Form Designer). TabControl.Handle is the TK_WIDGET ptr. It has Create( hParent, id ), SetFocus( ), and these properties, each read and write:
Enabled, Visible, TabHeight.
Pages are added through the procedures, with TabControl.Handle.
-
tkTabControl_InsertPage( h, idx, text )inserts atidx;-1, or an index past the end, appends. It returns the new index, or -1 on failure. Inserting before the selected tab keeps the same page selected. -
tkTabControl_DeletePagedestroys the tab, its page and everything on the page. Do not call it from inside an event callback of a control on that page. It returns false for a bad index. -
tkTabControl_SetCurSelreturns false for an index outside the pages, and changes nothing. -
tkTabControl_GetCurSelis -1 while there are no pages. -
tkTabControl_GetPagereturns 0 for an index outside the pages. -
tkTabControl_SetTabHeightis in design units and ignores a negative value. The default isTKTABCONTROL_DEFAULT_TABHEIGHT. - The control's bar has control id 1, and the pages take ids from 100 up. Give your own controls ids that do not clash within the same parent.
Every public name the module declares, as the source declares it. Signatures are exact; type bodies keep their field comments and drop the rest.
const as long TKTABCONTROL_DEFAULT_TABHEIGHT = 30type TKTABCONTROL_STATE ' per-instance state; reach it through the procedures
type TC_SelChangeCallbackSub as sub( byval hTabControl as TK_WIDGET ptr, byval idxOld as long, byval idxNew as long )function tkTabControl_Create( byval hParent as TK_WIDGET ptr, byval ctrlId as long ) as TK_WIDGET ptr
function tkTabControl_GetTabBar( byval h as TK_WIDGET ptr ) as TK_WIDGET ptr
function tkTabControl_InsertPage( byval h as TK_WIDGET ptr, byval idx as long, byref text as const ustring ) as long
function tkTabControl_AddPage( byval h as TK_WIDGET ptr, byref text as const ustring ) as long
function tkTabControl_DeletePage( byval h as TK_WIDGET ptr, byval idx as long ) as boolean
function tkTabControl_GetPageCount( byval h as TK_WIDGET ptr ) as long
function tkTabControl_GetPage( byval h as TK_WIDGET ptr, byval idx as long ) as TK_WIDGET ptr
function tkTabControl_GetPageText( byval h as TK_WIDGET ptr, byval idx as long ) as ustring
function tkTabControl_SetPageText( byval h as TK_WIDGET ptr, byval idx as long, byref text as const ustring ) as boolean
function tkTabControl_GetCurSel( byval h as TK_WIDGET ptr ) as long
function tkTabControl_SetCurSel( byval h as TK_WIDGET ptr, byval idx as long ) as boolean
function tkTabControl_GetTabHeight( byval h as TK_WIDGET ptr ) as long
sub tkTabControl_SetTabHeight( byval h as TK_WIDGET ptr, byval nHeight as long )
sub tkTabControl_SetSelChangeCallback( byval h as TK_WIDGET ptr, byval usersub as TC_SelChangeCallbackSub )tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing