Repository navigation
tkIconPanel
Home › All Categories › tkControls › tkIconPanel
Draws a row or column of icon-only buttons, toggles and separators.
tkIconPanel is a compact strip of icon buttons with no captions: the small tool row above a panel, or the activity bar down the side of an editor window. Each item is an IP_KIND_COMMAND (a button), an IP_KIND_TOGGLE (latches on and off) or an IP_KIND_SEPARATOR. An icon is a glyph from the font you set, or an image file; captions belong in the tooltips.
Each cell is its declared icon size plus padding, whatever the glyph, and tkIconPanel_SetJustify places the run left, centred or right. The item set is static once built. Selection is a set of latched toggles; a radio-style group is one call, tkIconPanel_SelectExclusive, from the SelChange callback.
tkIconPanel_SetVertical turns the row into a column, and tkIconPanel_SetMarker draws a selection marker: a slab down a column's left edge, or a rule under a row's cell. Both are off by default. A click never takes the keyboard focus. Setters are silent; Click and SelChange fire only for what the user does.
#import "vendor/tkControls/tkIconPanel"
using tkIconPanel
using tkHostThe module brings in tkHost, tkTheme, tkTooltip and tkImage. Add using tkPaint to write a paint callback.
An activity bar. gHost is the window (tkHost); gGlyph12 is the bundled icon font, opened with tkHost_OpenFont( gHost, tkHost_FontDir() & TK_FONT_ICONS, 12 ).
sub OnSelChange( byval p as TK_WIDGET ptr, byval idx as long, byval isSelected as boolean )
tkIconPanel_SelectExclusive( p, idx ) ' one view at a time
end sub
sub OnClick( byval p as TK_WIDGET ptr, byval idx as long, byval id as long )
print "command "; id
end sub
dim as TK_WIDGET ptr bar = tkIconPanel_Create( tkHost_Root( gHost ), 1100 )
tkIconPanel_SetVertical( bar, true )
tkIconPanel_SetFont( bar, gGlyph12 )
tkIconPanel_SetIconSize( bar, tkHost_Scale( gHost, 24 ), tkHost_Scale( gHost, 24 ) )
tkIconPanel_SetPadding( bar, tkHost_Scale( gHost, 6 ), tkHost_Scale( gHost, 6 ) )
tkIconPanel_SetMarker( bar, tkHost_Scale( gHost, 3 ), true )
tkIconPanel_SetSelChangeCallback( bar, @OnSelChange )
tkIconPanel_SetClickCallback( bar, @OnClick )
dim as long idx
idx = tkIconPanel_AddItem( bar, IP_KIND_TOGGLE, wchr( TK_ICON_DOCUMENT ), 1 ) : tkIconPanel_SetTooltipText( bar, idx, "Explorer" )
idx = tkIconPanel_AddItem( bar, IP_KIND_TOGGLE, wchr( TK_ICON_SEARCH ), 2 ) : tkIconPanel_SetTooltipText( bar, idx, "Search" )
tkIconPanel_AddSeparator( bar )
idx = tkIconPanel_AddItem( bar, IP_KIND_COMMAND, wchr( TK_ICON_SETTINGS ), 4 ) : tkIconPanel_SetTooltipText( bar, idx, "Settings" )
tkIconPanel_SetSelected( bar, 0, true )
tkWidget_SetPos( bar, 0, 0, tkIconPanel_GetIdealWidth( bar ), tkIconPanel_GetIdealHeight( bar ) )The toolchain's examples/tkControls/tkIconPanel/ shows three rows (left, centred and right, one with a custom painter) and this column.
The PsIconPanel page remains the behaviour reference for everything not listed here: the cell layout, the three kinds, selection, the press / slide-off / release gesture, the colours and the tooltips are the same.
-
PsIconPanel_*→tkIconPanel_*;PSICONPANEL_*→TKICONPANEL_*(_COLORS,_ITEM,_PAINTINFO,_MESSAGEINFO,_DEFAULT_*).IP_JUSTIFY_*,IP_KIND_*and theIP_*callback types keep their names. -
tkIconPanel_Create( parent, id )takes aTK_WIDGET ptrparent and returns the panel as aTK_WIDGET ptr. The font is aTTF_Font ptrthe panel borrows; with none set, the host's default font draws. -
tkIconPanel_SetImageloads any image file tkImage can read. InTKICONPANEL_PAINTINFO,bis aTK_PAINT ptrandpImageatkImageFile ptr(draw it withtkImage_Paint);isVerticalis new. -
TKICONPANEL_MESSAGEINFOcarriesmsg(aTKM_*value),xandyinstead ofuMsg/wParam/lParam. A double click is two ordinary presses. -
tkIconPanel_SetHoverTimeis the tooltip delay only;tkIconPanel_GetTooltipHandlereturns theTK_TIP ptr. - Added:
tkIconPanel_SetVertical/tkIconPanel_GetVertical. In a column,IP_JUSTIFY_LEFT/CENTER/RIGHTmean top / centre / bottom,tkIconPanel_GetIdealWidthis the widest icon andtkIconPanel_GetIdealHeightthe whole run. - Added:
tkIconPanel_SetMarker( h, nSize, bFillSelected ),tkIconPanel_GetMarker,tkIconPanel_GetMarkerRect, coloured byTKICONPANEL_COLORS.MarkerColor(theme roleAccent).bFillSelected = falseleaves a latched toggle on the idle fill, for a tab-row look. - Added:
tkIconPanel_SelectExclusive(silent),tkIconPanel_GetHotItem,tkIconPanel_GetPressedItem. - No equivalent:
WM_MOUSEHOVERreporting,SetTooltipMode/GetTooltipMode, PsRegistry.
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 TKICONPANEL_DEFAULT_ICONWIDTH = 20
const TKICONPANEL_DEFAULT_ICONHEIGHT = 20
const TKICONPANEL_DEFAULT_PADBEFORE = 4
const TKICONPANEL_DEFAULT_PADAFTER = 4
const TKICONPANEL_DEFAULT_SEPWIDTH = 1
enum
IP_JUSTIFY_LEFT = 0 ' TOP in vertical mode
IP_JUSTIFY_CENTER
IP_JUSTIFY_RIGHT ' BOTTOM in vertical mode
end enum
enum
IP_KIND_TOGGLE = 0
IP_KIND_COMMAND
IP_KIND_SEPARATOR
end enumtype TKICONPANEL_COLORS
BackColor as ulong = &hFF21252Bul ' ( 33, 37, 43) panel + idle cell
ForeColor as ulong = &hFFD7DAE0ul ' (215,218,224) idle glyph
BackColorHot as ulong = &hFF2C313Aul ' ( 44, 49, 58)
ForeColorHot as ulong = &hFFFFFFFFul
BackColorSelect as ulong = &hFF264F78ul ' ( 38, 79,120) latched toggle + press flash
ForeColorSelect as ulong = &hFFFFFFFFul
ForeColorDisabled as ulong = &hFF6E737Dul ' (110,115,125)
SeparatorColor as ulong = &hFF464C58ul ' ( 70, 76, 88)
MarkerColor as ulong = &hFF569CD6ul ' the selection marker (tk addition)
end type
type TKICONPANEL_ITEM
itemKind as long = IP_KIND_TOGGLE
wszGlyph as ustring
pImage as tkImageFile ptr ' OWNED; a cell is a glyph or an image, never both
wszTooltip as ustring
id as long
itemData as integer
isSelected as boolean
isEnabled as boolean = true
nPadBefore as long = -1 ' -1 = inherit
nPadAfter as long = -1
nIconWidth as long = 0 ' 0 = inherit
nIconHeight as long = 0
ForeColorItem as ulong
bHasForeColor as boolean
nCellWidth as long ' the cell's extent ALONG the run (a height when vertical)
rc as TKRECT
rcIcon as TKRECT
end type
type TKICONPANEL_PAINTINFO
hIconPanel as TK_WIDGET ptr
itemID as long
b as TK_PAINT ptr
itemKind as long
rc as TKRECT
rcIcon as TKRECT
isHot as boolean
isSelected as boolean
isPressed as boolean
isEnabled as boolean
wszGlyph as ustring
pImage as tkImageFile ptr ' draw with tkImage_Paint INSTEAD OF the glyph
isVertical as boolean
end type
type TKICONPANEL_MESSAGEINFO
hIconPanel as TK_WIDGET ptr
msg as long ' TKM_*
x as single
y as single
idx as long ' item under the mouse, -1 for none
end type
type TKICONPANEL_STATE ' per-instance state; reach it through the procedures
type IP_PaintItemCallbackSub as sub( byval p as TKICONPANEL_PAINTINFO ptr )
type IP_MessageCallbackFunc as function( byval m as TKICONPANEL_MESSAGEINFO ptr ) as boolean
type IP_TooltipCallbackFunc as function( byval hIconPanel as TK_WIDGET ptr, byval idx as long ) as ustring
type IP_ClickCallbackSub as sub( byval hIconPanel as TK_WIDGET ptr, byval idx as long, byval id as long )
type IP_SelChangeCallbackSub as sub( byval hIconPanel as TK_WIDGET ptr, byval idx as long, byval isSelected as boolean )function tkIconPanel_Create( byval hParent as TK_WIDGET ptr, byval CtrlID as long ) as TK_WIDGET ptr
function tkIconPanel_AddItem( byval hIconPanel as TK_WIDGET ptr, byval itemKind as long, byval Glyph as ustring, byval id as long = 0, byval itemData as integer = 0 ) as long
function tkIconPanel_AddSeparator( byval hIconPanel as TK_WIDGET ptr ) as long
sub tkIconPanel_Refresh( byval hIconPanel as TK_WIDGET ptr )
function tkIconPanel_GetCount( byval hIconPanel as TK_WIDGET ptr ) as long
function tkIconPanel_IsValidItem( byval hIconPanel as TK_WIDGET ptr, byval idx as long ) as boolean
function tkIconPanel_FindItemByID( byval hIconPanel as TK_WIDGET ptr, byval id as long ) as long
function tkIconPanel_HitTest( byval hIconPanel as TK_WIDGET ptr, byval x as long, byval y as long ) as long
function tkIconPanel_GetItemKind( byval hIconPanel as TK_WIDGET ptr, byval idx as long ) as long
function tkIconPanel_GetGlyph( byval hIconPanel as TK_WIDGET ptr, byval idx as long ) as ustring
function tkIconPanel_SetGlyph( byval hIconPanel as TK_WIDGET ptr, byval idx as long, byval Glyph as ustring ) as boolean
function tkIconPanel_SetImage( byval hIconPanel as TK_WIDGET ptr, byval idx as long, byval Path as ustring ) as boolean
function tkIconPanel_GetItemID( byval hIconPanel as TK_WIDGET ptr, byval idx as long ) as long
function tkIconPanel_SetItemID( byval hIconPanel as TK_WIDGET ptr, byval idx as long, byval id as long ) as boolean
function tkIconPanel_GetItemData( byval hIconPanel as TK_WIDGET ptr, byval idx as long ) as integer
function tkIconPanel_SetItemData( byval hIconPanel as TK_WIDGET ptr, byval idx as long, byval itemData as integer ) as boolean
function tkIconPanel_GetSelected( byval hIconPanel as TK_WIDGET ptr, byval idx as long ) as boolean
function tkIconPanel_SetSelected( byval hIconPanel as TK_WIDGET ptr, byval idx as long, byval isSelected as boolean ) as boolean
sub tkIconPanel_SelectExclusive( byval hIconPanel as TK_WIDGET ptr, byval idx as long )
function tkIconPanel_GetEnabled( byval hIconPanel as TK_WIDGET ptr, byval idx as long ) as boolean
function tkIconPanel_SetEnabled( byval hIconPanel as TK_WIDGET ptr, byval idx as long, byval isEnabled as boolean ) as boolean
function tkIconPanel_GetJustify( byval hIconPanel as TK_WIDGET ptr ) as long
sub tkIconPanel_SetJustify( byval hIconPanel as TK_WIDGET ptr, byval nJustify as long )
sub tkIconPanel_SetVertical( byval hIconPanel as TK_WIDGET ptr, byval bVertical as boolean )
function tkIconPanel_GetVertical( byval hIconPanel as TK_WIDGET ptr ) as boolean
sub tkIconPanel_SetMarker( byval hIconPanel as TK_WIDGET ptr, byval nSize as long, byval bFillSelected as boolean = true )
sub tkIconPanel_GetMarker( byval hIconPanel as TK_WIDGET ptr, byref nSize as long, byref bFillSelected as boolean )
function tkIconPanel_GetMarkerRect( byval hIconPanel as TK_WIDGET ptr, byval idx as long, byref rc as TKRECT ) as boolean
sub tkIconPanel_GetIconSize( byval hIconPanel as TK_WIDGET ptr, byref nIconWidth as long, byref nIconHeight as long )
sub tkIconPanel_SetIconSize( byval hIconPanel as TK_WIDGET ptr, byval nIconWidth as long, byval nIconHeight as long )
sub tkIconPanel_GetPadding( byval hIconPanel as TK_WIDGET ptr, byref nPadBefore as long, byref nPadAfter as long )
sub tkIconPanel_SetPadding( byval hIconPanel as TK_WIDGET ptr, byval nPadBefore as long, byval nPadAfter as long )
function tkIconPanel_GetSeparatorWidth( byval hIconPanel as TK_WIDGET ptr ) as long
sub tkIconPanel_SetSeparatorWidth( byval hIconPanel as TK_WIDGET ptr, byval nSepWidth as long )
function tkIconPanel_SetItemPadding( byval hIconPanel as TK_WIDGET ptr, byval idx as long, byval nPadBefore as long, byval nPadAfter as long ) as boolean
function tkIconPanel_SetItemIconSize( byval hIconPanel as TK_WIDGET ptr, byval idx as long, byval nIconWidth as long, byval nIconHeight as long ) as boolean
function tkIconPanel_GetItemRect( byval hIconPanel as TK_WIDGET ptr, byval idx as long, byref rc as TKRECT ) as boolean
function tkIconPanel_GetItemIconRect( byval hIconPanel as TK_WIDGET ptr, byval idx as long, byref rc as TKRECT ) as boolean
function tkIconPanel_GetIdealWidth( byval hIconPanel as TK_WIDGET ptr ) as long
function tkIconPanel_GetIdealHeight( byval hIconPanel as TK_WIDGET ptr ) as long
sub tkIconPanel_GetColors( byval hIconPanel as TK_WIDGET ptr, byval pColors as TKICONPANEL_COLORS ptr )
sub tkIconPanel_SetColors( byval hIconPanel as TK_WIDGET ptr, byval pColors as TKICONPANEL_COLORS ptr )
function tkIconPanel_ThemeColors( byref t as TKTHEME_COLORS ) as TKICONPANEL_COLORS
sub tkIconPanel_ApplyTheme( byval hIconPanel as TK_WIDGET ptr, byref t as TKTHEME_COLORS )
sub tkIconPanel_UnpinColors( byval hIconPanel as TK_WIDGET ptr )
sub tkIconPanel_ApplyFonts( byval hIconPanel as TK_WIDGET ptr, byval fText as TTF_Font ptr, byval fGlyph as TTF_Font ptr )
function tkIconPanel_SetItemForeColor( byval hIconPanel as TK_WIDGET ptr, byval idx as long, byval clr as ulong ) as boolean
function tkIconPanel_ClearItemForeColor( byval hIconPanel as TK_WIDGET ptr, byval idx as long ) as boolean
function tkIconPanel_GetFont( byval hIconPanel as TK_WIDGET ptr ) as TTF_Font ptr
function tkIconPanel_SetFont( byval hIconPanel as TK_WIDGET ptr, byval f as TTF_Font ptr ) as boolean
function tkIconPanel_GetTooltipHandle( byval hIconPanel as TK_WIDGET ptr ) as TK_TIP ptr
sub tkIconPanel_SetHoverTime( byval hIconPanel as TK_WIDGET ptr, byval milliseconds as long )
sub tkIconPanel_SetAutoPopTime( byval hIconPanel as TK_WIDGET ptr, byval milliseconds as long )
sub tkIconPanel_SetReshowTime( byval hIconPanel as TK_WIDGET ptr, byval milliseconds as long )
function tkIconPanel_GetTooltipText( byval hIconPanel as TK_WIDGET ptr, byval idx as long ) as ustring
function tkIconPanel_SetTooltipText( byval hIconPanel as TK_WIDGET ptr, byval idx as long, byval Text as ustring ) as boolean
function tkIconPanel_GetHotItem( byval hIconPanel as TK_WIDGET ptr ) as long
function tkIconPanel_GetPressedItem( byval hIconPanel as TK_WIDGET ptr ) as long
sub tkIconPanel_SetPaintItemCallback( byval hIconPanel as TK_WIDGET ptr, byval usersub as IP_PaintItemCallbackSub )
sub tkIconPanel_SetMessageCallback( byval hIconPanel as TK_WIDGET ptr, byval userfunc as IP_MessageCallbackFunc )
sub tkIconPanel_SetTooltipCallback( byval hIconPanel as TK_WIDGET ptr, byval userfunc as IP_TooltipCallbackFunc )
sub tkIconPanel_SetClickCallback( byval hIconPanel as TK_WIDGET ptr, byval usersub as IP_ClickCallbackSub )
sub tkIconPanel_SetSelChangeCallback( byval hIconPanel as TK_WIDGET ptr, byval usersub as IP_SelChangeCallbackSub )- tkControls
- tkApp, tkHost
- PsIconPanel, the PsControls control
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Home
- What Is tiko-lang
- Quick Start
- Installing on macOS
- Debugging
- Feature Index
- Compatibility
- FAQ
- AI Cheatsheet
- 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)
- Time Zones
- 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