Repository navigation
tkStatusBar
Home › All Categories › tkControls › tkStatusBar
Draws a status bar of text panels, one of which stretches to fill the leftover width.
tkStatusBar is the strip along the bottom of a window: "Ready", the caret position, the line ending, the encoding. Each panel holds text and item data, and is as wide as its text plus padding, or its minimum width if that is larger. One panel, set with tkStatusBar_SetExpandPanel, is the spring that takes the leftover width. When the bar is too narrow nothing shrinks; panels run past the right edge.
Without a paint callback the bar draws its panels itself: the text inset by the padding and a divider between panels. Set a click callback and a panel under the mouse gets a hover fill, since it can now be clicked. A paint callback replaces the built-in painter and draws every panel pixel itself.
The bar takes no focus and no keyboard, and has no size grip; your program places it, usually from the window's size handler. Each panel can show a tooltip, from the tooltip callback or else its own text. Setters are silent.
#import "vendor/tkControls/tkStatusBar"
using tkStatusBar
using tkHostThe module brings in tkHost, tkTheme and tkTooltip. Add using tkPaint to write a paint callback.
gHost is the window (tkHost); gFont10 is a font opened with tkHost_OpenFont.
sub OnClick( byval hBar as TK_WIDGET ptr, byval idx as long, byval clicks as long )
print "clicked "; tkStatusBar_GetText( hBar, idx ); " (clicks="; clicks; ")"
end sub
dim as TK_WIDGET ptr sb = tkStatusBar_Create( tkHost_Root( gHost ), 1 )
tkStatusBar_SetFont( sb, gFont10 )
tkStatusBar_SetClickCallback( sb, @OnClick )
tkStatusBar_AddPanel( sb, "Ready", 1001 )
tkStatusBar_AddPanel( sb, "", 1002 ) ' the spring
tkStatusBar_AddPanel( sb, "Ln 1, Col 1", 1003 )
tkStatusBar_AddPanel( sb, "UTF-8", 1004 )
tkStatusBar_SetExpandPanel( sb, 1 )
tkStatusBar_SetPanelMinWidth( sb, 2, tkHost_Scale( gHost, 110 ) )
' in the window's size handler, with pw x ph the window's pixel size:
tkWidget_SetPos( sb, 0, ph - tkHost_Scale( gHost, 24 ), pw, tkHost_Scale( gHost, 24 ) )
' later, silently:
tkStatusBar_SetText( sb, 2, "Ln 12, Col 5" )tkStatusBar_SetPanelVisible( sb, idx, false ) hides a panel without renumbering the others: it keeps its index and takes no width. The toolchain's examples/tkControls/tkStatusBar/ shows two bars with custom painters and one with the built-in painter and a click callback.
The PsStatusBar page remains the behaviour reference for everything not listed here: the panel model, the width law, the spring, the index fix-ups, hover and the tooltips are the same.
-
PsStatusBar_*→tkStatusBar_*;PSSTATUSBAR_*→TKSTATUSBAR_*(_PANELINFO,_PAINTINFO,_MESSAGEINFO,_DEFAULT_PADDING). TheSB_*callback types keep their names. Indices arelong. -
tkStatusBar_Create( parent, id )takes aTK_WIDGET ptrparent; for a window's top level passtkHost_Root( h ). It is created zero-sized, so it shows nothing until you size it. The font is aTTF_Font ptrthe bar borrows; with none set, the host's default font is used. -
TKSTATUSBAR_MESSAGEINFOcarriesmsg,x,y,clicksandidxinstead ofuMsg/wParam/lParam. A double click isTKM_LBUTTONDOWNwithclicks = 2; the hover message isTKSB_MOUSEHOVER, sent once per rest while the mouse stays on the bar. -
tkStatusBar_GetTooltipHandlereturns theTK_TIP ptr.tkStatusBar_SetHoverTimestill sets both the tooltip delay and the hover message's. - The background colour lives in
TKSTATUSBAR_COLORSwith the built-in painter's colours;tkStatusBar_SetBackColorstill works. The bar follows theme changes on its own. - Added: the built-in painter;
tkStatusBar_SetClickCallback, fired on the left-button release over a panel withclicks = 2on the second click of a double click (a message callback that returns true for that release suppresses it). - Added:
tkStatusBar_GetColors/tkStatusBar_SetColors/tkStatusBar_ThemeColors,tkStatusBar_HitTest,tkStatusBar_GetHot,tkStatusBar_SetPanelVisible/tkStatusBar_GetPanelVisible. - A scale change rescales the padding and every panel's minimum width on its own; there is no
Rescale. - No equivalent:
SetTooltipMode/GetTooltipMode, PsRegistry. There are still no per-panel icons, per-panel alignment or fixed-width panels.
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 TKSTATUSBAR_DEFAULT_PADDING = 8
const as long TKSTATUSBAR_DEFAULT_HOVERTIME = 250
const as long TKSTATUSBAR_DEFAULT_DIVIDERINSET = 4
const as long TKSB_MOUSEHOVER = 1001type TKSTATUSBAR_PANELINFO
Text as ustring
itemData as integer
nMinWidth as long ' floor for this panel's width; 0 = auto-size to the text
bHidden as boolean ' laid out at width 0: not painted, no divider, never hit (tk addition)
rc as TKRECT ' derived by LayoutPanels, read-only to the host
end type
type TKSTATUSBAR_COLORS
BackColor as ulong = &hFF21252Bul ' ( 33, 37, 43) theme Window
BackColorHot as ulong = &hFF373D48ul ' ( 55, 61, 72) theme SurfaceHot
ForeColor as ulong = &hFF969CA6ul ' (150,156,166) theme TextDim
ForeColorHot as ulong = &hFFE2E6EEul ' (226,230,238) theme TextHot
DividerColor as ulong = &hFF373C45ul ' ( 55, 60, 69) theme Divider
end type
type TKSTATUSBAR_PAINTINFO
hStatusBar as TK_WIDGET ptr ' the control, so the callback can ask for GetPadding
itemID as long ' the panel's model index
b as TK_PAINT ptr ' this repaint's painter (borrowed)
rc as TKRECT ' this panel's rect, widget-local -- the only rect to fill
isHot as boolean ' the mouse is over this panel
wszCaption as ustring ' the panel's Text
end type
type TKSTATUSBAR_MESSAGEINFO
hStatusBar as TK_WIDGET ptr
msg as long ' TKM_MOUSEMOVE / TKM_MOUSELEAVE / TKM_LBUTTONDOWN (clicks = 2:
x as single ' widget-local pixels
y as single
clicks as long
idx as long ' panel under the mouse, -1 for none
end type
type TKSTATUSBAR_STATE ' per-instance state; reach it through the procedures
type SB_PaintCallbackSub as sub( byval p as TKSTATUSBAR_PAINTINFO ptr )
type SB_MessageCallbackFunc as function( byval m as TKSTATUSBAR_MESSAGEINFO ptr ) as boolean
type SB_TooltipCallbackFunc as function( byval hStatusBar as TK_WIDGET ptr, byval idx as long ) as ustring
type SB_ClickCallbackSub as sub( byval hStatusBar as TK_WIDGET ptr, byval idx as long, byval clicks as long )function tkStatusBar_Create( byval hParent as TK_WIDGET ptr, byval CtrlID as long ) as TK_WIDGET ptr
function tkStatusBar_AddPanel( byval hStatusBar as TK_WIDGET ptr, byval Text as ustring, byval itemData as integer = 0 ) as long
function tkStatusBar_InsertPanel( byval hStatusBar as TK_WIDGET ptr, byval idx as long, byval Text as ustring, byval itemData as integer = 0 ) as long
function tkStatusBar_DeletePanel( byval hStatusBar as TK_WIDGET ptr, byval idx as long ) as boolean
sub tkStatusBar_Clear( byval hStatusBar as TK_WIDGET ptr )
function tkStatusBar_GetCount( byval hStatusBar as TK_WIDGET ptr ) as long
sub tkStatusBar_Refresh( byval hStatusBar as TK_WIDGET ptr )
function tkStatusBar_GetText( byval hStatusBar as TK_WIDGET ptr, byval idx as long ) as ustring
function tkStatusBar_SetText( byval hStatusBar as TK_WIDGET ptr, byval idx as long, byval Text as ustring ) as boolean
function tkStatusBar_GetItemData( byval hStatusBar as TK_WIDGET ptr, byval idx as long ) as integer
function tkStatusBar_SetItemData( byval hStatusBar as TK_WIDGET ptr, byval idx as long, byval itemData as integer ) as boolean
function tkStatusBar_GetPanelMinWidth( byval hStatusBar as TK_WIDGET ptr, byval idx as long ) as long
function tkStatusBar_SetPanelVisible( byval hStatusBar as TK_WIDGET ptr, byval idx as long, byval bVisible as boolean ) as boolean
function tkStatusBar_GetPanelVisible( byval hStatusBar as TK_WIDGET ptr, byval idx as long ) as boolean
function tkStatusBar_SetPanelMinWidth( byval hStatusBar as TK_WIDGET ptr, byval idx as long, byval nMinWidth as long ) as boolean
function tkStatusBar_GetExpandPanel( byval hStatusBar as TK_WIDGET ptr ) as long
function tkStatusBar_SetExpandPanel( byval hStatusBar as TK_WIDGET ptr, byval idx as long ) as boolean
function tkStatusBar_GetPadding( byval hStatusBar as TK_WIDGET ptr ) as long
sub tkStatusBar_SetPadding( byval hStatusBar as TK_WIDGET ptr, byval nPadding as long )
function tkStatusBar_GetPanelRect( byval hStatusBar as TK_WIDGET ptr, byval idx as long, byref rc as TKRECT ) as boolean
function tkStatusBar_GetItemRect( byval hStatusBar as TK_WIDGET ptr, byval idx as long ) as TKRECT
function tkStatusBar_HitTest( byval hStatusBar as TK_WIDGET ptr, byval x as long, byval y as long ) as long
function tkStatusBar_GetHot( byval hStatusBar as TK_WIDGET ptr ) as long
function tkStatusBar_GetBackColor( byval hStatusBar as TK_WIDGET ptr ) as ulong
function tkStatusBar_SetBackColor( byval hStatusBar as TK_WIDGET ptr, byval clr as ulong ) as ulong
sub tkStatusBar_GetColors( byval hStatusBar as TK_WIDGET ptr, byval pColors as TKSTATUSBAR_COLORS ptr )
sub tkStatusBar_SetColors( byval hStatusBar as TK_WIDGET ptr, byval pColors as TKSTATUSBAR_COLORS ptr )
function tkStatusBar_ThemeColors( byref t as TKTHEME_COLORS ) as TKSTATUSBAR_COLORS
sub tkStatusBar_ApplyTheme( byval hStatusBar as TK_WIDGET ptr, byref t as TKTHEME_COLORS )
sub tkStatusBar_UnpinColors( byval hStatusBar as TK_WIDGET ptr )
function tkStatusBar_GetFont( byval hStatusBar as TK_WIDGET ptr ) as TTF_Font ptr
function tkStatusBar_SetFont( byval hStatusBar as TK_WIDGET ptr, byval f as TTF_Font ptr ) as boolean
sub tkStatusBar_ApplyFonts( byval hStatusBar as TK_WIDGET ptr, byval fText as TTF_Font ptr, byval fGlyph as TTF_Font ptr )
function tkStatusBar_GetTooltipHandle( byval hStatusBar as TK_WIDGET ptr ) as TK_TIP ptr
sub tkStatusBar_SetHoverTime( byval hStatusBar as TK_WIDGET ptr, byval milliseconds as long )
sub tkStatusBar_SetAutoPopTime( byval hStatusBar as TK_WIDGET ptr, byval milliseconds as long )
sub tkStatusBar_SetReshowTime( byval hStatusBar as TK_WIDGET ptr, byval milliseconds as long )
sub tkStatusBar_SetPaintCallback( byval hStatusBar as TK_WIDGET ptr, byval usersub as SB_PaintCallbackSub )
sub tkStatusBar_SetMessageCallback( byval hStatusBar as TK_WIDGET ptr, byval userfunc as SB_MessageCallbackFunc )
sub tkStatusBar_SetTooltipCallback( byval hStatusBar as TK_WIDGET ptr, byval userfunc as SB_TooltipCallbackFunc )
sub tkStatusBar_SetClickCallback( byval hStatusBar as TK_WIDGET ptr, byval usersub as SB_ClickCallbackSub )- tkControls
- tkApp, tkHost
- PsStatusBar, the PsControls control
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