NAME
Tree widget − a constraint widget that arranges its children in a tree.
SYNOPSIS
Public Headers:<X11/StringDefs.h> <X11/Xaw/Tree.h>
Private Header:<X11/Xaw/TreeP.h>
Class Name:Tree
Class Pointer:treeWidgetClass
Instantiation:widget = XtCreateWidget(name, treeWidgetClass, ...)
CLASS HIERARCHY
Core → Composite → Constraint → Tree
AVAILABILITY
Release 5 and later.
DESCRIPTION
The Tree widget provides geometry management of arbitrary widgets arranged in a directed, acyclic graph (i.e., a tree). The hierarchy is constructed by attaching a constraint resource called XtNtreeParent to each child indicating which other node in the tree should be treated as the child’s superior. The structure of the tree is shown by laying out the nodes in the standard format for tree diagrams with lines drawn to connect each node with its children.
The Tree sizes itself according to the needs of its children and is not intended to be resized by its parent. Instead, it should be placed inside another composite widget (such as the Porthole or Viewport) that can be used to scroll around in the tree.
RESOURCES
When creating a Tree widget instance, the following resources are retrieved from the argument list or from the resource database:
| Name | Type | Default | Description | |||
| XtNaccelerators | Accelerator- Table |
NULL | Accelerators for this widget. | |||
| XtNancestor− Sensitive |
Boolean | True | Sensitivity state of the ancestors of this widget. | |||
| XtNautoReconfigure | Boolean | False | Whether to re-layout the tree when each new child is added. | |||
| XtNbackground | Pixel | XtDefault− Background |
Window background color. | |||
| XtNbackground− Pixmap |
Pixmap | XtUnspecified− Pixmap |
Window background pixmap. | |||
| XtNborderColor | Pixel | XtDefault− Foreground |
Window border color. | |||
| XtNborderPixmap | Pixmap | XtUnspecified− Pixmap |
Window border pixmap. | |||
| XtNborderWidth | Dimension | 1 | Width of border in pixels. | |||
| XtNchildren | WidgetList | NULL | List of all this composite widget’s current children. | |||
| XtNcolormap | Colormap | Parent’s colormap. | Colormap that this widget will use. | |||
| XtNdepth | int | Parent’s depth. | Depth of this widget’s window. | |||
| XtNdestroy− Callback |
XtCallback- List |
NULL | Callbacks for XtDestroyWidget(). | |||
| XtNforeground | Pixel | XtDefault- Foreground |
Widget foreground color. | |||
| XtNgravity | XtGravity | West | Window gravity of widget. | |||
| XtNheight | Dimension | Computed at realize. | Height of tree. | |||
| XtNhSpace | Dimension | 20 | Horizontal space between children. | |||
| XtNlineWidth | Dimension | 0 | Width of tree lines. | |||
| XtNmappedWhen− Managed |
Boolean | TRUE | Whether XtMapWidget() is automatic. | |||
| XtNnumChildren | Cardinal | 0 | Number of children in this composite widget. | |||
| XtNscreen | Screen | Parent’s screen. | Screen on which this widget is displayed. | |||
| XtNsensitive | Boolean | TRUE | Whether widget receives input. | |||
| XtNtranslations | Translation- Table |
NULL | Event-to-action translations. | |||
| XtNvSpace | Dimension | 6 | Vertical space between children. | |||
| XtNwidth | Dimension | Computed at realize. | Width of tree. | |||
| XtNx | Position | 0 | x-coordinate in pixels. | |||
| XtNy | Position | 0 | y-coordinate in pixels. | |||
XtNautoReconfigure
Whether or not to lay out the tree every time a node is added or removed.
XtNforeground
Foreground color for the widget.
XtNgravity
Specifies the side of the widget from which the tree should grow. Valid values include WestGravity, NorthGravity, EastGravity, and SouthGravity.
XtNhSpace
Amount of horizontal space, in pixels, to leave between the children. This resource also specifies the amount of space between the outermost children and the edge of the box.
XtNlineWidth
The width of the lines drawn between nodes that do not have a XtNtreeGC constraint resource and their inferiors in the tree.
XtNvSpace
The amount of vertical space, in pixels, to leave between the children. This resource also specifies the amount of space left between the outermost children and the edge of the box.
CONSTRAINTS
When creating children to be added to a Tree, the following additional resources are retrieved from the argument list or from the resource database. Note that these resources are maintained by the Tree widget even though they are stored in the child.
| Name | Type | Default | Description | |||
| XtNtreeGC | GC | NULL | GC used to draw lines between the child and its inferiors in the tree. | |||
| XtNtreeParent | Widget | NULL | The child’s superior node in the tree. | |||
XtNtreeGC
This specifies the GC to use when drawing lines between this widget and its inferiors in the tree. If this resource is not specified, the Tree’s XtNforeground and XtNlineWidth will be used.
XtNtreeParent
This specifies the superior node in the tree for this widget. The default is for the node to have no superior (and to therefore be at the top of the tree).
The position of each child in the tree hierarchy (as opposed to the widget hierarchy) is determined by the value of the XtNtreeParent constraint resource. Each time a child is managed or unmanaged, the Tree widget will attempt to reposition the remaining children to fix the shape of the tree if the XtNautoReconfigure resource is set. Children at the root of the tree are drawn at the side specified by the XtNgravity resource. After positioning all children, the Tree widget attempts to shrink its own size to the minimum dimensions required for the layout.
PUBLIC FUNCTIONS
•XawTreeForceLayout() forces a Tree widget to re-layout its children. When adding several children to a Tree widget, it is most efficient to set XtNautoReconfigure to False and use this function once all the widgets have been added.
void XawTreeForceLayout(w) Widget w;
wspecifies the Tree widget.
SEE ALSO
Constraint.