TNavigator
Source: source/classes/navpanels.prg
Inherits from: TControl
TNavigator is a collapsible navigation panel with a gradient title bar, toggle button, and automatic sibling panel repositioning. When collapsed, the panel shrinks to a narrow vertical bar with a rotated title; when expanded, it reveals child controls. Multiple TNavigator instances can be linked via aRelatedNavigators so that toggling one panel repositions its siblings -- ideal for side-docking navigation bars.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
lExpanded | Logical | Current expanded/collapsed state (default .T.) |
nOriginalWidth | Numeric | Width when fully expanded, used on restore |
nWidthClosed | Numeric | Width when collapsed (default 50) |
cTitle | Character | Title text displayed in the header bar |
nTitleHeight | Numeric | Height of the gradient title bar (default 40) |
aRelatedNavigators | Array | Linked sibling panels for auto-repositioning |
bToggled | Block | Code block fired after toggle completes |
nRound | Numeric | Corner rounding radius (default 6) |
nTopColor | Numeric | Gradient top/start color |
nBottomColor | Numeric | Gradient bottom/end color |
nClrHover | Numeric | Title text color on mouse hover |
nBetWeenSpace | Numeric | Gap between sibling navigator panels (default 2) |
cImage | Character | Optional background image file path |
cBtnImage1 | Character | Toggle button image when collapsed (arrow right) |
cBtnImage2 | Character | Toggle button image when expanded (arrow left) |
Methods
| Method | Description |
|---|---|
New( nTop, nLeft, nBottom, nRight, oWnd, lBorder, nClrBorder, nBackColor, nWidthClosed, cTitle, cImage, cBtnImg1, cBtnImg2, nClrText, nClrHover, nTitleH, nSpace, lDesign, lPixel ) | Create a new TNavigator panel |
ReDefine( nId, oWnd, lBorder, nClrBorder, nBackColor, nWidthClosed, cTitle, cImage, cBtnImg1, cBtnImg2, nClrText, nClrHover, nTitleH, nSpace, lDesign ) | Redefine from dialog resource |
ToggleSize() | Toggle between expanded and collapsed states, reposition siblings |
CloseAll() | Collapse all linked navigator panels |
OpenAll() | Expand all linked navigator panels |
ChangeWidth( nWidth, nHeight ) | Resize the navigator panel |
Example: Linked Navigator Panels
#include "FiveWin.ch"
function Main()
local oWnd, oNav1, oNav2
DEFINE WINDOW oWnd TITLE "Navigator" SIZE 600, 400
oNav1 := TNavigator():New( 0, 0, 400, 200, oWnd,,,;
RGB( 157, 188, 219 ), 50, "Files" )
oNav2 := TNavigator():New( 0, 202, 400, 402, oWnd,,,;
RGB( 157, 188, 219 ), 50, "Search" )
oNav1:aRelatedNavigators := { oNav2 }
oNav2:aRelatedNavigators := { oNav1 }
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- Sibling panels are repositioned automatically via
aRelatedNavigators. The array is sorted bynOriginalLeftto maintain left-to-right ordering during toggle. - When collapsed, the title text is drawn vertically using the
oBoldVerticalfont. When expanded, it is drawn horizontally in the gradient header. - The toggle button image defaults to built-in arrow bitmaps (
CreaArrowLeft/CreaArrowRight). Custom button images can be supplied viacBtnImage1andcBtnImage2. - Child controls are automatically shown/hidden as the panel expands and collapses.