When you define a segment with the chained attribute switched ON, that segment becomes a part of the segment chain and is called a chained segment. The segment chain is composed of all chained segments defined in a single presentation space. Segments can be chained together so that they can be drawn as a group. By default, each new segment is chained to the previous segment.
There can be only one segment chain at a time in a single presentation space, and all chained segments are chained to each other in the order in which you created them. Zero segments must have the chained attribute.
Usually, a logical relationship exists between the segments in a segment chain, although this is not a requirement. The whole segment chain can be drawn using GpiDrawChain. Each segment in the chain is called a root segment. Root segments are affected by those GPI functions that act on the segment chain, but they also can be manipulated independently of the chain.
Segments that are defined with the chained attribute switched OFF are called unchained segments. Your application can switch off the chain attribute using GpiSetInitialSegmentAttrs (hps, ATTR_CHAIN, ATTR_OFF). Unchained segments always are retained when they are created, regardless of the current drawing-mode parameter. An unchained segment must have a unique name.
There are a number of reasons for defining a segment as unchained. For example, a particular segment might not belong to the picture that is defined by the segment chain. You also are likely to define as unchained any segment that belongs to the picture but that has no single, fixed place in the segment chain. A car wheel, for example, could be defined once but drawn four times in a picture of a car. It would have no single, fixed place in the segment chain, but would be included four times in the picture by being called from one or more root segments.
A segment is called from another segment by including GpiCallSegmentMatrix in the calling segment. A segment and the segments it calls logically are one object. An important point about called segments is that they assume the primitive attribute settings of the calling segment. Of course, you can change the attribute settings within the called segment if the inherited values are inappropriate.
A closed, unchained segment can be called from any other segment. Chained segments, however, cannot be called from other segments.