DEFINE TREE
Creates a Tree
Control
Standard Syntax (xBase Style):
DEFINE TREE <ControlName>
[ OF | PARENT <ParentWindowName> ]
AT <nRow> ,<nCol>
WIDTH <nWidth>
HEIGHT <nHeight>
[ VALUE <nValue> ]
[ FONT <cFontname> SIZE <nFonSize> ]
[ TOOLTIP <cToolTipText> ]
[ ON GOTFOCUS <OnGotFocusProcedur> | <bBlock> ]
[ ON CHANGE <OnChangeProcedure> | <bBlock> ]
[ ON LOSTFOCUS <OnLostFocusProcedure> | <bBlock> ]
[ ON DBLCLICK <OnDblClickProcedure> | <bBlock> ]
[ ON EXPAND <OnExpandProcedure> | <bBlock> ]
[ ON COLLAPSE <OnCollapseProcedure> | <bBlock> ]
[ BREAK ]
[ NODEIMAGES <aImgNode> [ ITEMIMAGES <aImgItem> ]
[ NOROOTBUTTON ]
[ ITEMIDS ]
[ HELPID <nHelpId> ]
[ NOTRANSPARENT ]
[ NODE <cNodeCaption> ]
[ IMAGES <aImage> ]
[ ID <nItemID> ]
...
[ TREEITEM <cTreeItemCaption>
[ IMAGES <aImage> ]
[ ID <nItemID> ] ]
...
[ END NODE ]
...
...
END TREE
Alternate Syntax:
DEFINE TREE <ControlName>
[ PARENT <ParentWindowName> ]
ROW <nRow>
COL <nCol>
WIDTH <nWidth>
HEIGHT <nHeight>
[ VALUE <nValue> ]
[ FONTNAME <cFontname> ]
[ FONTSIZE <nFonSize> ]
[ TOOLTIP <cToolTipText> ]
[ ONGOTFOCUS <OnGotFocusProcedure> | <bBlock> ]
[ ONCHANGE <OnChangeProcedure> | <bBlock> ]
[ ONLOSTFOCUS <OnLostFocusProcedure> | <bBlock> ]
[ ONDBLCLICK <OnDblClickProcedure> | <bBlock> ]
[ ONEXPAND <OnExpandProcedure> | <bBlock> ]
[ ONCOLLAPSE <OnCollapseProcedure> | <bBlock> ]
[ BREAK <lValue> ]
[ NODEIMAGES <aImgNode> ]
[ ITEMIMAGES <aImgItem> ]
[ ROOTBUTTON <lValue> ]
[ ITEMIDS <lValue> ]
[ HELPID <nHelpId> ]
[ TRANSPARENT <lValue> ]
[ NODE <cNodeCaption> ]
[ IMAGES <aImage> ]
[ ID <nItemID> ]
...
[ TREEITEM <cTreeItemCaption>
[ IMAGES <aImage> ]
[ ID <nItemID> ] ]
...
[ END NODE ]
...
...
END TREE
Properties:
- Value
- Enabled
- Visible
- Row
- Col
- Width
- Height
- Item ( nItemIndex | nItemID )
- FontName
- FontSize
- FontBold
- ToolTip
- Name (R)
- Break (D)
- NodeImages (D)
- ItemImages (D)
- HelpId (D)
- Parent (D)
- RootButton (D)
D: Available at control definition only
R: Read-Only
Events:
- OnChange
- OnExpand (*)
- OnCollapse (*)
(*)Note: Property available for OnExpand and OnCollapse events and DynamicForeColor, DynamicBackColor and DynamicFont properties:
- This.TreeItemValue
Methods:
- Show
- Hide
- AddItem ( cItemText , nParentItemIndex | nParentItemID )
- DeleteItem ( nItemIndex | nItemID )
- Expand ( nItemIndex | nItemID )
- Collapse ( nItemIndex | nItemID )
- SetFocus
- Release
When ITEMIDS clause is specified, you can assign a numeric ID (ID clause) to tree items and nodes. That way, all tree properties and methods will work using these ID's instead item position.
# TREE Control improvement
Note: nValue = nItemIndex | nItemID
- New
Get Properties:
<ParentWindowName>.<TreeControlName>.AllValue --> anAllItemsValues | NIL
<ParentWindowName>.<TreeControlName>.RootValue --> nValue | NIL
<ParentWindowName>.<TreeControlName>.FirstItemValue --> nValue | NIL
<ParentWindowName>.<TreeControlName>.ParentValue ( nValue ) --> nValue | NIL
<ParentWindowName>.<TreeControlName>.ChildValue ( nValue ) --> anChildItemsValues | NIL
<ParentWindowName>.<TreeControlName>.SiblingValue ( nValue ) --> anSiblingItemsValues | NIL
<ParentWindowName>.<TreeControlName>.ItemText ( anItemsValues ) --> acItemsText | NIL
<ParentWindowName>.<TreeControlName>.IsTrueNode ( nValue ) --> lBoolean
<ParentWindowName>.<TreeControlName>.NodeFlag ( nValue ) --> lBoolean
<ParentWindowName>.<TreeControlName>.ImageCount --> nImageCount
<ParentWindowName>.<TreeControlName>.ImageIndex ( nValue ) --> { iUnSelectItem , iSelectItem }
<ParentWindowName>.<TreeControlName>.IsExpand ( nValue ) --> lBoolean
<ParentWindowName>.<TreeControlName>.ImageList --> hImageList
<ParentWindowName>.<TreeControlName>.HasLines --> lBoolean
<ParentWindowName>.<TreeControlName>.FullRowSelect --> lBoolean
<ParentWindowName>.<TreeControlName>.HasButton ( nValue ) --> lBoolean
<ParentWindowName>.<TreeControlName>.Cargo ( nValue ) --> xData
<ParentWindowName>.<TreeControlName>.CargoScan ( xData ) --> nValue | NIL
<ParentWindowName>.<TreeControlName>.GetPathValue ( nValue ) --> anPathValue | NIL
<ParentWindowName>.<TreeControlName>.GetPathName ( nValue ) --> acPathName | NIL
<ParentWindowName>.<TreeControlName>.GetDisplayLevel ( nValue ) --> nDisplayColumn | NIL
- New
Set Properties:
<ParentWindowName>.<TreeControlName>.NodeFlag ( nValue ) := lBoolean
<ParentWindowName>.<TreeControlName>.ImageIndex ( nValue ) := { iUnSelectItem , iSelectItem }
<ParentWindowName>.<TreeControlName>.AddImage := cImageName
<ParentWindowName>.<TreeControlName>.TextColor := anRGBcolor
<ParentWindowName>.<TreeControlName>.BackColor := anRGBcolor
<ParentWindowName>.<TreeControlName>.LineColor := anRGBcolor
<ParentWindowName>.<TreeControlName>.DynamicForeColor := {|| anRGBcolor }
<ParentWindowName>.<TreeControlName>.DynamicBackColor := {|| anRGBcolor }
<ParentWindowName>.<TreeControlName>.DynamicFont := {|| {cFontName, nFontSize, [ lBold, lItalic, lUnderline, lStrikeOut ]} }
<ParentWindowName>.<TreeControlName>.ChangeFontSize := nSize | NIL // Useful for use Dynamic Font with more (less) Height than the size of font the Tree control
<ParentWindowName>.<TreeControlName>.ImageList := hImageList
<ParentWindowName>.<TreeControlName>.HasLines := lBoolean
<ParentWindowName>.<TreeControlName>.FullRowSelect := lBoolean
<ParentWindowName>.<TreeControlName>.HasButton ( nValue ) := lBoolean
<ParentWindowName>.<TreeControlName>.Cargo ( nValue ) := xData
- New
Methods:
<ParentWindowName>.<TreeControlName>.Expand ( nValue , lRecursive )
<ParentWindowName>.<TreeControlName>.Collapse ( nValue , lRecursive )
<ParentWindowName>.<TreeControlName>.DisableUpdate
<ParentWindowName>.<TreeControlName>.EnableUpdate
<ParentWindowName>.<TreeControlName>.SetDefaultAllNodeFlag
<ParentWindowName>.<TreeControlName>.SetDefaultNodeFlag ( nValue )
<ParentWindowName>.<TreeControlName>.Sort ( nValue , lRecursive, lCaseSensitive, lAscendingOrder, nNodePosition )
TREESORT ControlName OF ParentName
[ ITEM nValue ]
[ RECURSIVE lRecursive ]
[ CASESENSITIVE lCaseSensitive ]
[ ASCENDINGORDER lAscendingOrder ]
[ NODEPOSITION nNodePosition ]
nNodePosition = TREESORTNODE_FIRST | TREESORTNODE_LAST | TREESORTNODE_MIX
Note:
<ParentWindowName>.<TreeControlName>.IsTrueNode ( nValue ) --> Only returns .T. if the item contain sub-items (child items).
<ParentWindowName>.<TreeControlName>.NodeFlag ( nValue ) := lBoolean --> This flag allows you to force an Item to be Node (.T.) or not (.F.). This flag only affect the Nodes positions when run the Sort method.
For more information about of the new features see demo SortTreeDir in SAMPLES folder.
Dynamic Font:
- ARRAY FONT <cFontName> SIZE <nFontSize> [ BOLD ] [ ITALIC ] [ UNDERLINE ] [ STRIKEOUT ] --> { cFontName, nFontSize, lBold, lItalic, lUnderline, lStrikeout }
- CREATE ARRAY FONT <cFontName> SIZE <nFontSize> [ BOLD <lBold> ] [ ITALIC <lIitalic> ] [ UNDERLINE <lUnderline> ] [ STRIKEOUT <lStrikeout> ] --> { cFontName, nFontSize, lBold, lItalic, lUnderline, lStrikeout }