Each entry in an HList widget has a unique name, called its entry-path, which determines each entry's position in the HList widget. The entry-paths of the HList entries are very similar to the pathnames of Unix files. Each entry-path is a list of string names separated by a separator character. By default, the separator character is the period character (.), but it can be configured using the -separator option of the HList widget.
In program 4-3, we add several new entries foo, foo.bar, foo.bor, foo.bar.bao, .. etc, into the HList widget using the add method. The relationship between the entries is signified by their names, in a way similar to how Unix denotes directories and subdirectories. For example, foo is the parent of foo.bar and foo.bor; foo.bar is the parent of foo.bar.bao, and so on. As far as the terminology goes, we also say that foo.bar a child of foo; foo is an ancestor of foo.bar.bao and foo.bar.bao is a descendant of foo.
The output of program 4-2 is shown in figure 4-3. As we can see, the entries are displayed under their parents with the amount of indentation control by the -indent option of the HList widget: foo.bar.bao and foo.bar.kao are display under foo.bar, which is in turn displayed under foo.
Entries with no parents, for example, foo and dor in program 4-2, are called top-level entries. Top-level entries are usually entries with no immediate superiors in a hierarchical. For example, the owner of a company, the principle of a school or the root directory of a Unix file system. Toplevel entries are displayed with no indentation.
As evident from program 4-2, all entries who entry-path does not contain a separator character are top-level entries. The only exception is the separator character itself is also a toplevel entry. This makes it easy to display Unix file and directory names inside the HList widget, as shown in program 4-4.
set folder [tix getimage folder]
tixScrolledHList .sh -options {
hlist.separator /
hlist.itemType imagetext
hlist.drawBranch true
hlist.indent 14
hlist.wideSelection false
}
pack .sh -expand yes -fill both
set hlist [.sh subwidget hlist]
foreach directory {/ /usr /usr/bin /usr/local /etc /etc/rc.d} {
$hlist add $directory -image $folder -text $directory
}
Each entry is associated with a display item (see section 3.2 about display items). We can use the -itemtype option of the HList widget to specify the default type of display item to be created by the the add method, as shown in program 4-2 and 4-4. Alternatively, we can also specify the type of display item using the -itemtype option for the add method.