TVMenu
Source: source/classes/VMenu.prg
Inherits from: TControl
TVMenu is an ExplorerBar-style panel control that displays a list of TVItem objects.
It supports a collapsible title header, open/close animation, multiple selection styles
(SOLID, INSET, XBOX, BUMP, ETCHED, RAISED, UNDERLINE), gradient backgrounds, and
theme-aware rendering. TVMenu is the parent container for TVItem objects, which are
automatically added to the menu's aItems array when created.
TC5ImgList (used by oImageList) lives in
source/classes/tc5imglst.prg and is linked from
FiveH.lib (32-bit) and, since 26.08, from
Five64.a / Fivexh64.a (FWH64). Sample:
samples/test/vmenu_test.prg
(build_new.bat vmenu_test hb64).
New() Constructor
TVMenu():New( nTop, nLeft, nWidth, nHeight, oWnd, bAction, nClrText, nClrPane,;
oFont, lBorder, nClrBorder, nHItem, cTextAlign, under, nMargen,;
nClrPSel, nSpeed, selmode, bChange, nClrTSel, oAttach,;
nClrTOver, nClrPOver, nClrPOver2, nClrPSel2,;
lVGradSel, lMGradSel, nClrPane2, cWaterMark )
| Parameter | Type | Description |
|---|---|---|
| nTop, nLeft | Numeric | Position in pixels |
| nWidth, nHeight | Numeric | Size in pixels |
| oWnd | TWindow | Parent window |
| bAction | Codeblock | Default action for items |
| nClrText | Numeric | Text color (default: white) |
| nClrPane | Numeric | Background color (default: light gray) |
| oFont | TFont | Font for item text |
| lBorder | Logical | Show border (default: .f.) |
| nHItem | Numeric | Minimum item height in pixels |
| cTextAlign | Character | "LEFT", "CENTER", "RIGHT", "MULTILINE" |
| under | Character | Selection style: "SOLID", "INSET", "XBOX", "BUMP", "ETCHED", "RAISED", "UNDERLINE", "SOLIDUNDERLINE" |
| nMargen | Numeric | Left margin in pixels |
| nClrPSel | Numeric | Selection pane color |
| selmode | Character | Fill mode: "FILLED", "LFILLED", "RFILLED", "NONE", "LFOLDER", "RFOLDER", "DOTS" |
| bChange | Codeblock | Called when selection changes |
| nClrTSel | Numeric | Selected text color |
| cWaterMark | Character | Bitmap filename for watermark |
Methods
| Method | Returns | Description |
|---|---|---|
SetTitle(cCaption, nHTitle, oFont, nClrText, nClrPane, ...) | nil | Set the collapsible title header |
CollapseToggle() | nil | Toggle collapsed/expanded state |
NextItem() | nil | Move selection to next item |
PrevItem() | nil | Move selection to previous item |
EvalAction(nItem) | nil | Execute item's action |
ResizeItems() | nil | Recalculate item positions |
RefreshSel(nItem) | nil | Refresh selection highlight |
Key DATA Members
| DATA | Type | Description |
|---|---|---|
aItems | Array | Array of TVItem objects |
nOption | Numeric | Currently selected item index |
cTitle | Character | Title text |
lBorder | Logical | Show border |
lOpenClose | Logical | Enable open/close animation |
lOpened | Logical | Panel is expanded |
nHItem | Numeric | Minimum item height |
oImageList | TC5ImgList | Image list for item bitmaps |
Example
local oMenu, oItem DEFINE VMENU oMenu OF oWnd ; SIZE 220, 380 ; COLORS RGB(55,65,80), RGB(245,246,248) ; BORDER ; ITEMHEIGHT 40 ; STYLE "SOLID" ; SELMODE "FILLED" oMenu:SetTitle( "Explorer", 28, oFont, ; RGB(255,255,255), RGB(70,130,180) ) VMENUITEM PROMPT "Home" OF oMenu VMENUITEM PROMPT "Documents" OF oMenu VMENUITEM SEPARATOR OF oMenu VMENUITEM PROMPT "Settings" OF oMenu VMENUITEM PROMPT "Help" OF oMenu
Preprocessor Commands
DEFINE VMENU
Creates a TVMenu panel (ExplorerBar style) inside a window.
DEFINE VMENU [ oMenu ] ; [ AT nTop, nLeft ] ; [ SIZE nWidth, nHeight ] ; [ OF oWnd ] ; [ ACTION bAction ] ; [ COLORS nClrText [, nClrPane] ] ; [ FONT oFont ] ; [ BORDER ] ; [ BORDERCOLOR nClrBorder ] ; [ ITEMHEIGHT nHItem ] ; [ TEXTCENTER | TEXTRIGHT | TEXTMULTILINE ] ; [ STYLE "SOLID" | "INSET" | "XBOX" | "BUMP" ] ; [ MARGEN nMargen ] ; [ SELECTCOLOR nClrPSel ] ; [ SELMODE "FILLED" | "NONE" | "DOTS" ] ; [ ON CHANGE bChange ] ; [ SELECTTEXTCOLOR nClrTSel ] ; [ VGRADSEL ] ; [ PANE2COLOR nClrPane2 ] ; [ WATERMARK cWaterMark ]
REDEFINE VMENU
Redefines a TVMenu from a dialog resource.
REDEFINE VMENU [ oMenu ] ; [ ID nId ] ; [ OF oWnd ] ; [ ACTION bAction ] ; [ COLORS nClrText [, nClrPane] ] ; [ FONT oFont ] ; [ BORDER ] ; [ BORDERCOLOR nClrBorder ] ; [ ITEMHEIGHT nHItem ] ; [ TEXTCENTER | TEXTRIGHT | TEXTMULTILINE ] ; [ STYLE "SOLID" | "INSET" | "XBOX" ] ; [ SELMODE "FILLED" | "NONE" | "DOTS" ] ; [ ON CHANGE bChange ] ; [ SELECTTEXTCOLOR nClrTSel ]
VMENUITEM
Creates a TVItem and adds it to a TVMenu automatically.
VMENUITEM [ oItem ] ; [ OF oMenu ] ; [ PROMPT cText ] ; [ BITMAP cBmp ] ; [ GROUP | HEADER ] ; [ COLORS nClrText [, nClrPane] ] ; [ TEXTCENTER | TEXTRIGHT | TEXTMULTILINE ] ; [ IMAGECENTER | IMAGERIGHT ] ; [ HEIGHT nHeight ] ; [ SEPARATOR | LINE | INSET | DOTDOT ] ; [ ACTION bAction ] ; [ POPUP oPopup ] ; [ WHEN bWhen ] ; [ TOOLTIP cToolTip ]