Index Parent

NListtree class


The NListtree class is used to manipulate trees of lists.

A NListtree object can only be added to a NListview object at NListview creation time.

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

NListtree is a subclass of NListtree.mcc so you must have NListtree.mcc in MUI:libs/mui to use it. NListtree.mcc is copyright of Carsten Scholling.

 

Attributes
Name Type Class Note
ActiveID N ISGN

This attribute indicates the active entry in a NListtree. 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 !!!.

ActiveList N G  
ActiveName S ISGN  
AutoVisible M ISGN G2N A number or one of:
  • Off
  • Normal
  • FirstOpen
  • Expand
DoubleClick M ISGN G2N A number or one of:
  • Off
  • All
  • Tree
  • NoTrigger
DragDropSort B IS  
DragSortable B ISG  
DropTarget S GN  
DropType S GN One of:
  • Above
  • Below
  • Onto
  • Sorted
  • None
EmptyNodes B IS  
Format S I  
Image S I See Images in lists
MultiSelect M I A number or one of:
  • None
  • Default
  • Shifted
  • Always
Quiet B IS  
ShowTree N ISGN Show tree structures flag.If 0, the tree is not shown, if 1 the tree is shown, if set to -1, toggle tree.
Title S I  
TreeColumn N ISGN  
Visible N N  

 

 

Methods
Name Parameters Note
Clear   Clear the whole NListtree.
Close [list],[what] Closes an entry.

Arguments

  • list - the list to close; a positive integral number or one of:
    • Active (default)
    • Parent
    • Root
  • what - what to close; one of:
    • Active (Default)
    • All
    • Head
    • Tail
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],[flags] Gets an entry by id.

Arguments:

  • var - where to store results
  • id - a positive integral number or Active (Default)
  • flags - one or more of:
    • SameLevel
    • Visible

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

  • .Frozen
  • .ID
  • .List
  • .Name
  • .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
  • .ID
  • .List
  • .Name
  • .NoSign
  • .Open
  • .Selected

an ARexx boolean

GetSelected <var> Gets the list of the selected entries.

Arguments:

  • var - where to store results

The method writes in var.num the number of the selected entries and in var.0,... var.i (i=var.num-1) the entries:

    do i=0 to sel.num-1
        say sel.i
    end
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
    • ActiveFallBack (Default)
    • LastInserted
  • prev - 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
    • Active
    • NextNode
  • name - the name of the entry
Open [list],[what] Opens an entry.

Arguments

  • list - the list to open; a positive integral number or one of:
    • Active (default)
    • Parent
    • Root
  • what - what to open; one of:
    • Active
    • All (Default)
    • Head
    • Tail
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:
    • Active
    • All
    • Head
    • Tail

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

Select [id],[selType] Selects entries.

Arguments:

  • id - the entry to select; a positive integral number or one of:
    • Active (default)
    • All
    • Visible
  • selType - one of:
    • Off
    • On (Default)
    • Toggle
Sort [id],[flags] Sorts entries.

Arguments:

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

 

Example

 

Static creation

 list.Frame="InputList"
 list.Format="BAR,"
 list.Title="Name|Phone"
  list.0="Friends"; 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.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 NListtree (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