You can change primitive-attribute settings at any time. The new values you specify replace the existing values. For example, if the current foreground color is green and you change it to red, red replaces green as the foreground color attribute.

When you set primitive attributes within a retained or nonretained segment, you can save the existing attribute values on a last-in-first-out (LIFO) stack, from where they can later be retrieved and made current again. You do this by selecting either of the two attribute modes:

In AM_NOPRESERVE mode, which is the default setting, existing attribute values are replaced by any new attribute values that you supply. In AM_PRESERVE mode, the existing attribute values are stored on a LIFO stack, and then the new values that you specify take effect. AM_PRESERVE mode also causes the current position to be saved if the position was specified using GpiSetCurrentPosition. If you use GpiMove to set the current position, the position is not saved, regardless of the attribute mode.

To select a current attribute mode, use GpiSetAttrMode. The current attribute mode affects subsequent attribute-setting requests in the presentation space. Attribute modes are not applicable to micro presentation spaces, because graphics segments can be created only in normal presentation spaces.

To retrieve an attribute value from the LIFO stack, use GpiPop, which pulls back the attribute that was stored most recently on the stack. You can retrieve more than one attribute value by supplying a number as an input parameter of this function. For example, if you specify 4, GpiPop retrieves the four attributes that were most recently stored on the stack. If each of the values retrieved applies the same type of attribute to the same primitive (for example, if all four are line-type settings), the last one to be retrieved (and, therefore, the first one on the stack) becomes the current setting.

If you save attribute values from any segment called from another segment, and do not retrieve the values using GpiPop, the values are restored automatically when the end of the segment is reached. If you save attribute values from any segment that is not called from another segment and do not explicitly restore those values using GpiPop, they are lost at the end of the segment.

The AM_PRESERVE mode is useful when you do not want attributes in calling segments to be overwritten by attributes specified in the called segments. This overwriting happens because a calling segment and the segments it calls are logically one object. Attribute changes within a called segment remain current upon return to the calling segment. If you set some attribute values at the start of a called segment, and the current attribute mode is AM_PRESERVE, the attribute values of the calling segment are stored on the LIFO stack. At the end of the called segment, the values on the stack are retrieved automatically so that the calling segment continues with its own attribute values.


[Back] [Next]