TreeGadget()
Syntax
Result = TreeGadget(#Gadget, x, y, Width, Height [, Flags])Description
Creates a Tree gadget in the current GadgetList. If #PB_Any is used as '#Gadget' parameter, the new gadget identifier will be returned as 'Result'. #Gadget will be the numeric identifier returned by EventGadgetID() command. Once a Tree is created, its list of items is empty.
You can add a 'mini help' to this gadget by using GadgetToolTip().
The following commands can be used to act on the list content:
- AddGadgetItem(): Add an item (with an optional picture in the standard 16x16 icon size).
- RemoveGadgetItem(): Remove an item (and all its child items).
- ClearGadgetItemList(): Remove all the items.
- CountGadgetItems(): Return the number of items currently in the #Gadget.
- GetGadgetItemState(): Return the current state of the specified item.
- SetGadgetItemState(): Change the current state of the specified item.
- GetGadgetItemText(): Return the current text of the specified item.
- SetGadgetItemText(): Change the current text of the specified item.
- GetGadgetState(): Return the current selected item.
- SetGadgetState(): Change the currently selected item.
- GetGadgetText(): Return the text of the currently selected item.
- SetGadgetText(): Change the text of the currently selected item.
- OpenTreeGadgetNode(): Open a new node for subitems in the #Gadget.
- CloseTreeGadgetNode(): Close an open node in the #Gadget.
- CountTreeGadgetNodeItems(): Return the number of subitems the specified item has.
- GadgetItemID(): Return the OS handle of the specified item. (Useful for API functions)
- TreeGadgetItemNumber(): Returns the item number for a given OS item handle. (Useful for API functions)
'Flags' are optionals and can be composed of one of the following constants:#PB_Tree_AlwaysShowSelection : Even if the gadget isn't activated, the selection is still visible. #PB_Tree_NoLines : Hide the little lines between each nodes. #PB_Tree_NoButtons : Hide the '+' node buttons. #PB_Tree_CheckBoxes : Add a checkbox before each item.Example:If OpenWindow(0,0,0,355,180,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"TreeGadget") And CreateGadgetList(WindowID(0)) TreeGadget(0, 10,10,160,160) ; TreeGadget standard TreeGadget(1,180,10,160,160,#PB_Tree_CheckBoxes|#PB_Tree_NoLines) ; TreeGadget with Checkboxes + NoLines For ID=0 To 1 For a=0 To 10 AddGadgetItem (ID, -1, "Normal Item "+Str(a)) ; if you want to add an image, use AddGadgetItem (ID, -1, "Node "+Str(a)) ; UseImage(x) as 4th parameter OpenTreeGadgetNode(ID) AddGadgetItem(ID, -1, "Sub-Item 1") AddGadgetItem(ID, -1, "Sub-Item 2") AddGadgetItem(ID, -1, "Sub-Item 3") AddGadgetItem(ID, -1, "Sub-Item 4") CloseTreeGadgetNode(ID) AddGadgetItem (ID, -1, "File "+Str(a)) Next Next Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow EndIf
Supported OS
Windows, Linux, MacOS X