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 )
ParameterTypeDescription
nTop, nLeftNumericPosition in pixels
nWidth, nHeightNumericSize in pixels
oWndTWindowParent window
bActionCodeblockDefault action for items
nClrTextNumericText color (default: white)
nClrPaneNumericBackground color (default: light gray)
oFontTFontFont for item text
lBorderLogicalShow border (default: .f.)
nHItemNumericMinimum item height in pixels
cTextAlignCharacter"LEFT", "CENTER", "RIGHT", "MULTILINE"
underCharacterSelection style: "SOLID", "INSET", "XBOX", "BUMP", "ETCHED", "RAISED", "UNDERLINE", "SOLIDUNDERLINE"
nMargenNumericLeft margin in pixels
nClrPSelNumericSelection pane color
selmodeCharacterFill mode: "FILLED", "LFILLED", "RFILLED", "NONE", "LFOLDER", "RFOLDER", "DOTS"
bChangeCodeblockCalled when selection changes
nClrTSelNumericSelected text color
cWaterMarkCharacterBitmap filename for watermark

Methods

MethodReturnsDescription
SetTitle(cCaption, nHTitle, oFont, nClrText, nClrPane, ...)nilSet the collapsible title header
CollapseToggle()nilToggle collapsed/expanded state
NextItem()nilMove selection to next item
PrevItem()nilMove selection to previous item
EvalAction(nItem)nilExecute item's action
ResizeItems()nilRecalculate item positions
RefreshSel(nItem)nilRefresh selection highlight

Key DATA Members

DATATypeDescription
aItemsArrayArray of TVItem objects
nOptionNumericCurrently selected item index
cTitleCharacterTitle text
lBorderLogicalShow border
lOpenCloseLogicalEnable open/close animation
lOpenedLogicalPanel is expanded
nHItemNumericMinimum item height
oImageListTC5ImgListImage 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 ]

See Also