Repository navigation
tkPanel
Home › All Categories › tkControls › tkPanel
Groups controls on a plain background, with an optional border.
tkPanel is the tkControls container for grouping controls without a caption. It is never a tab stop. Children are parented to the panel (tkPanel_Create returns the widget to pass as their hParent) and are positioned relative to its top-left corner.
The background uses the theme's window colour and the border its border colour. tkPanel_SetTransparent skips the background fill, so what is behind the panel shows through. tkPanel_SetBorderStyle takes PNL_BORDER_NONE or PNL_BORDER_LINE; any other value becomes PNL_BORDER_NONE.
A paint callback draws over the background and border and under the children, for a panel that needs its own artwork.
A panel is also the page of a tkTabControl.
#import "vendor/tkControls/tkPanel"
using tkPanel
using tkHostThe module brings in tkHost (and through it tkPaint, SDL3, SDL_ttf and SDL_image) and tkTheme. The paint callback's TK_PAINT type comes from tkPaint.
host is a TK_HOST ptr from tkHost_Create, set up as in the tkButton example.
sub Card_Paint( byval p as TKPANEL_PAINTINFO ptr )
p->b->SetPenColor( &hFF569CD6ul )
p->b->PaintBorderRect( @p->rcClient )
end sub
dim as TK_WIDGET ptr card = tkPanel_Create( tkHost_Root( host ), 2100 )
tkPanel_SetBorderStyle( card, PNL_BORDER_LINE )
tkPanel_SetPaintCallback( card, @Card_Paint )
tkWidget_SetPos( card, tkHost_Scale( host, 20 ), tkHost_Scale( host, 20 ), _
tkHost_Scale( host, 300 ), tkHost_Scale( host, 160 ) )
' a child panel, placed relative to the card
dim as TK_WIDGET ptr kid = tkPanel_Create( card, 2101 )
tkWidget_SetPos( kid, tkHost_Scale( host, 10 ), tkHost_Scale( host, 10 ), _
tkHost_Scale( host, 100 ), tkHost_Scale( host, 40 ) )The module also provides Panel, a typed value for designed forms (see tkForms and the Form Designer). Panel.Handle is the TK_WIDGET ptr. It has Create( hParent, id ), SetFocus( ), and these properties, each read and write:
Enabled, Visible, BackColor, BorderColor, BorderStyle, Transparent.
-
tkPanel_SetBackColorandtkPanel_SetBorderColorpin the colours: they then survive a theme change untiltkPanel_UnpinColors. - The paint callback receives a
TKPANEL_PAINTINFOwith the panel, theTK_PAINT ptrfor this frame and the client rectangle. It runs on every paint, after the fill and the border.
Every public name the module declares, as the source declares it. Signatures are exact; type bodies keep their field comments and drop the rest.
enum
PNL_BORDER_NONE = 0
PNL_BORDER_LINE
end enumtype TKPANEL_COLORS
BackColor as ulong
BorderColor as ulong
end type
type TKPANEL_PAINTINFO
hPanel as TK_WIDGET ptr
b as TK_PAINT ptr
rcClient as TKRECT
end type
type TKPANEL_STATE ' per-instance state; reach it through the procedures
type PNL_PaintCallbackSub as sub( byval p as TKPANEL_PAINTINFO ptr )function tkPanel_Create( byval hParent as TK_WIDGET ptr, byval ctrlId as long ) as TK_WIDGET ptr
function tkPanel_GetBackColor( byval h as TK_WIDGET ptr ) as ulong
sub tkPanel_SetBackColor( byval h as TK_WIDGET ptr, byval clr as ulong )
function tkPanel_GetBorderColor( byval h as TK_WIDGET ptr ) as ulong
sub tkPanel_SetBorderColor( byval h as TK_WIDGET ptr, byval clr as ulong )
function tkPanel_GetBorderStyle( byval h as TK_WIDGET ptr ) as long
sub tkPanel_SetBorderStyle( byval h as TK_WIDGET ptr, byval nStyle as long )
function tkPanel_GetTransparent( byval h as TK_WIDGET ptr ) as boolean
sub tkPanel_SetTransparent( byval h as TK_WIDGET ptr, byval bTransparent as boolean )
sub tkPanel_SetPaintCallback( byval h as TK_WIDGET ptr, byval usersub as PNL_PaintCallbackSub )
function tkPanel_ThemeColors( byref t as TKTHEME_COLORS ) as TKPANEL_COLORS
sub tkPanel_ApplyTheme( byval h as TK_WIDGET ptr, byref t as TKTHEME_COLORS )
sub tkPanel_UnpinColors( byval h as TK_WIDGET ptr )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