TIconGroup / TIconGet
Sources: source/classes/igroup.prg, source/classes/iget.prg
TIconGroup FROM TControl | TIconGet FROM TMultiGet
TIconGroup displays a grid of icons with text prompts. Users can navigate with keyboard arrows, click to select, and double-click to execute actions. TIconGet is an edit control used internally by TIconGroup for inline prompt editing.
Key DATA Members (TIconGroup)
| DATA | Type | Description |
|---|---|---|
aIcons | Array | Array of icon handles (hIcon) |
aPrompts | Array | Array of text labels below each icon |
aActions | Array | Array of code blocks executed on double-click |
aCoors | Array | Array of coordinate arrays (icon + text bounding boxes) |
aOrder | Array | Visual order of icons (indices into aIcons) |
nFocused | Numeric | Index of the currently focused icon |
lEdit | Logical | .T. when editing a prompt inline |
lAutoEdit | Logical | .T. enables inline editing on click; F2 always triggers edit |
Methods (TIconGroup)
| Method | Description |
|---|---|
New( nTop, nLeft, nW, nH, aIcons, aPrompts, aActions, oWnd ) | Create an icon group control |
ReDefine( nId, aIcons, aPrompts, aActions, oWnd ) | Redefine from a dialog resource |
Add( hIcon, cPrompt, bAction ) | Add an icon with label and action to the group |
Modify( hIcon, cPrompt, bAction, nAt ) | Modify icon, prompt or action at position |
Del( nAt ) | Delete icon, prompt and action at position |
Adjust() | Recalculate icon positions in grid layout |
Arrange() | Reset scroll positions and re-layout all icons |
Commands
@ nRow, nCol ICONGROUP ITEMS aIcons, aPrompts, aActions ;
SIZE nW, nH OF oWnd
Example: Icon Grid with Click Actions
#include "FiveWin.ch"
function Main()
local oWnd, oIconGrp
local aIcons := {}
local aPrompts := {}
local aActions := {}
DEFINE WINDOW oWnd TITLE "Icon Group Demo" SIZE 400, 300
AAdd( aIcons, "folder.ico" )
AAdd( aPrompts, "Open" )
AAdd( aActions, {|| MsgInfo( "Open clicked" ) } )
AAdd( aIcons, "help.ico" )
AAdd( aPrompts, "Help" )
AAdd( aActions, {|| MsgInfo( "Help clicked" ) } )
@ 10, 10 ICONGROUP ITEMS aIcons, aPrompts, aActions ;
SIZE 300, 200 OF oWnd
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- Icons can be loaded from .ico files by passing the file path as a string to
Add()or the aIcons array. - Navigate with arrow keys; press Enter to activate the focused icon's action.
- Press F2 to edit the text prompt when
lAutoEditis .T. - TIconGet is an internal control based on TMultiGet, styled for centered single-line editing within the icon area.