Next Previous Up Top Contents Index

7.2.4 Display controls

7.2.4.1 Tree controls

The <tree-control> class (also known as a tree view control in Microsoft documentation) is a special list control that displays a set of objects in an indented outline based on the logical hierarchical relationship between the objects. A number of slots are available to control the information that is displayed in the control, and the appearance of that information.

Figure 7.12 A tree control

The tree-control-children-generator slot contains a function that is used to generate any children below the root of the tree control. It is called with one argument, which can be any instance of <object>.

The icon-function: init-keyword specifies a function that returns an icon to display with each item in the tree control. The function is called with the item that needs an icon as its argument, and it should return an instance of <image> as its result. Typically, you might want to define an icon function that returns a different icon for each type of item in the control. For example, if the control is used to display the files and directories on a hard disk, you would want to return the appropriate icon for each registered file type.

Typically, icons should be no larger than 32 pixels high and 32 pixels wide: if the icon function returns an image larger than this, then there may be unexpected results.

Note that there is no setter for the icon function, so the function cannot be manipulated after the control has been created. In the example below, $odd-icon and $even-icon are assumed to be icons that have been defined.

make(<tree-control>,
     roots: #[1],
     children-generator: 
       method (x) vector(x * 2, 1 + (x * 2)) end,
     icon-function: method (item :: <integer>)
                      case
                        odd?(item)  => $odd-icon;
                        even?(item) => $even-icon;
                    end);

Like list boxes and list controls, tree controls support the scroll-bars: init-keyword.


Building Applications Using DUIM - 26 May 1999

Next Previous Up Top Contents Index