Index Parent

Listtree class


The Listtree class is used to manipulate trees of lists.

A Listtree object can only be added to a Listview object at Listview creation time.

Despite Listtree class is declared to be subclass of List class, no List attribute and method may be used with a Listtree object.

Listtree is a subclass of Listtree.mcc so you must have Listtree.mcc in MUI:Libs/MUI to use it. Listtree.mcc is copyright of Klaus Melchior.

 

Attributes
Name Type Class Note
ActiveID N ISGN

This attribute indicates the active entry in a Listtree. The possible values are non negative integer, where 0 means no active entry, >0 means there is an active entry.
Note that any reference to an entry is made by ActiveID !!!.

ActiveName S ISGN The name of the active entry
DoubleClick B GN G2N  
DragDropSort B IS  
DropMark N G  
DropType S G One of:
  • Above
  • Below
  • Onto
  • Sorted
  • None
EmptyNodes B IS  
Format S I  
Quiet B IS  
Title S I  
TreeColumn N ISGN  

 

 

Methods
Name Parameters Note
Clear   Clear the whole Listtree.
Close   Closes the whole Listtree
FindName <var>,<name>,[list],[flags] Gets an entry by name.

Arguments:

  • var - where to store results
  • name - the name of the entry to find
  • list - where to search; a positive integral number or one of:
    • Active
    • Root (Default)
  • flags - one or more of:
    • Activate
    • SameLevel
    • Selected
    • StartNode
    • Visible
GetEntry <var>,[id] Gets an entry by id.

Arguments:

  • var - where to store results
  • id - a positive integral number or Active (Default)

The method writes in var the entry and in the fields:

  • .Frozen
  • .List
  • .NoSign
  • .Open
  • .Selected

an ARexx boolean

GetEntry2 <var>,[id],[pos],[flags] Relative-gets an entry by id.

Arguments:

  • var - where to store results
  • id - a positive integral number or one of:
    • Active
    • Root (Default)
  • pos - id-relative position of the node to get; one of:
    • Head (Default)
    • Tail
    • Active
    • Next
    • Previous
    • Parent
  • flags - one or more of:
    • SameLevel
    • Visible

The method writes in var the entry and in the fields:

  • .Frozen
  • .List
  • .NoSign
  • .Open
  • .Selected

an ARexx boolean

Insert <entry>,[list],[prev],[flags],[name] Arguments:
  • entry - the entry to insert
  • list - the node which list is used to insert the entry; a positive integral number or one of:
    • Root
    • Active (Default)
  • list - the node which is the predecessor of the node to insert; a positive integral number or one of:
    • Head
    • Tail
    • Active (Default)
    • Sorted
  • flags - one or more of:
    • Open
    • List
    • Frozen
    • NoSign
    • NextNode
    • Active
    • Visible
  • name - the name of the entry
Open   Opens the whole Listtree
Remove [id],[what] Removes and entry.

Arguments:

  • id - the entry to remove; a positive integral number or one of:
    • Active
    • Root (default)
  • what - what to remove with id; one of:
    • Head
    • Tail
    • Active
    • All

Note that if what is not supplied, all id is removed.

Sort [id],[flags] Sorts entries.

Arguments:

  • id - what to sort; a positive integral number or one of:
    • Active
    • Root (Default)
  • flags - one of:
    • Open

 

Example

 

Static creation

 list.Frame="InputList"
 list.Format="BAR,"
 list.Title="Name|Phone"
  list.0="Friends"; list.0.flags="close"; list.0.list="am"
   am.0="Frank|0864845111"; am.0.name="Frank"
   am.2="University"; am.2.name="uni"; am.2.type="tree"; am.2.flags="close"
   am.2.list="uni"
    uni.0="Mary"; uni.0.name="Mary"
    uni.1="Jhon"
    uni.2="Profs"; uni.2.flags="list"
   am.1="Robert"
  list.1="Computer Shop"

Dynamic insertion

 list.Frame="InputList"
 list.Format="BAR,"
 list.Title="Name|Phone"

 ...

 call set("list","Quiet",1)
 call DoMethod("list","Insert","Friends","root",,"List"); friends=rc
  call DoMethod("list","Insert","Franck|0864845111",friends,,,"A")
  call DoMethod("list","Insert","University",friends,,"List","uni"); uni=rc
   call DoMethod("list","Insert","Mary",uni,,,"Mary")
   call DoMethod("list","Insert","Jhon",uni)
   call DoMethod("list","Insert","Profs",uni,,"list")
  call DoMethod("list","Insert","Robert",friends)
 call DoMethod("list","Insert","Computer Shop","root")
 call set("list","Quiet",0)

How to get all the entries of a Listtree (with its structure)

 call printList("root",0)

 ...

 printList: procedure
 parse arg l,s
     call DoMethod("Listtree","GetEntry2","e",l,"head")
     do while rc
         say copies(" ",s) || "Name:"e.name "Value:"e "ID:"e.id "IsList:"e.list
         if e.list then call printList(e.id,s+1)
         call DoMethod("Listtree","GetEntry2","e",e.id,"next")
     end
     return