Next Previous Up Top Contents Index

8.11 DUIM-Gadgets Module

<tree-control>

Open abstract instantiable class

Summary

The class of tree controls.

Superclasses

<collection-gadget>

Init-keywords

children-generator:

An instance of type <function>.

children-predicate:

An instance of type <function>.

icon-function:
An instance of type <function>.

show-edges?:
An instance of type <boolean>. Default value: #t.

show-root-edges?:
An instance of type <boolean>. Default value: #t.

show-buttons?:
An instance of type <boolean>. Default value: #t.

initial-depth:
An instance of type <integer>. Default value: 0.

scroll-bars:
An instance of type one-of(#f, #"none", #"horizontal", #"vertical", #"both", #"dynamic"). Default value: #"both".

popup-menu-callback:

An instance of type <function>.

key-press-callback:

An instance of type false-or(<command>, <function>).

roots:
An instance of type <sequence>. Default value: #[].

Library

duim-gadgets

Module

duim-gadgets

Description

The class of tree controls.

Figure 8.44 A tree contorl

The children-generator: is the function that is used to generate the children below the root of the tree control. It is called with one argument, an object.

The icon-function: init-keyword lets you specify a function to supply icons for display in the 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 kind 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.

The show-edges?:, show-root-edges?:, and show-buttons?: init-keywords define whether lines are displayed for the edges of items in the tree control, the roots in the tree control, and whether the icons of items in the tree control are displayed, respectively. By default, all three are visible.

The number of levels of outline that are shown when the tree control is first displayed is controlled by the initial-depth: init-keyword. The default value of this is 0, meaning that only the top level of the outline is shown, with no nodes expanded.

The scroll-bars: init-keyword specifies whether the tree control has scroll bars or not.

You can use the popup-menu-callback: init-keyword to specify a context-sensitive menu to display for one or more selected items in the tree control. In Windows 95, for instance, such a context-sensitive menu can be displayed by right-clicking on any item or group of selected items in the list control.

The key-press-callback: init-keyword lets you specify a key-press callback. This type of callback is invoked whenever a key on the keyboard is pressed while the gadget has focus. For tree controls, a typical key-press callback might select an item in the control. See gadget-key-press-callback, page 567, for a fuller description of key-press callbacks.

The roots: init-keyword is used to specify any roots for the tree control. It is a sequence.

Internally, this class maps into the Windows tree view control.

Operations

contract-node expand-node tree-control-children-predicate tree-control-children-predicate-setter tree-control-children-generator tree-control-children-generator-setter tree-control-roots tree-control-roots-setter

Example

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);

See also

add-node, page 529

find-node, page 548

make-node, page 612

remove-node, page 637


Functional Developer Library Reference: DUIM - 3 Dec 1998

Next Previous Up Top Contents Index