The color attribute defines the color used to draw a primitive or an object. The mix attribute determines how the color of a primitive or an object is combined with the color of the drawing surface or any other objects on the surface.

The character-string color defines the color used to draw the output from any of the draw-character-string functions. When a presentation space is created, the character-string color default is black. Character strings are one of the primitives that have both a foreground and a background color, as shown in the following figure.

For image characters, colors are determined by setting pels. For outline characters, the foreground consists of arcs and lines that define the character; the background color appears between the foreground lines. The character can be solid or filled, in which cases the background color does not appear between the foreground lines.

Character string primitives have a color attribute for both the actual character and its character cell, which surrounds the character. The character-cell color is the background color.

The foreground mix attribute controls the combination of character-string color and drawing-surface color, while the background mix attribute controls the combination of the character-cell color and the drawing-surface color, as illustrated in the following figure.

Character String Primitives

When a presentation space is created, the character string mix attribute default is FM_OVERPAINT. The overpaint mix attribute specifies that the character-string color is not to be modified by the color of the drawing surface. If the character string mix attribute is changed, the character-string color is mixed with colors that are already on the drawing surface.

The character string background color default is CLR_BACKGROUND, usually defined by the application as the same color as the drawing surface. The character string background mix attribute default is BM_LEAVEALONE. The leave-alone background mix attribute specifies that the character string background color not be drawn. The cell that surrounds the character string appears only if the background character-string color and mix attributes are changed.

Use GpiSetAttrs to specify a new color or mix attribute. As input, this function accepts the following:

GpiSetAttrs also is useful to specify color and mix attributes for a specific data structure -for example, CHARBUNDLE. GpiSetAttrs provides some protection against invalid colors.

To determine the current character-string color and mix attributes, call GpiQueryAttrs, which accepts as input the primitive type and the attributes in question. GpiQueryAttrs returns an array of values for the queried attributes.

To reset the default character-string color and mix attributes, as with all attributes specified in CHARBUNDLE, call GpiSetDefAttrs, which accepts as input the type of primitive, attributes to be changed, and values that will become the new default values. Changing default values is especially important when working with segments. Changing the default values during a series of drawing functions is not recommended.

The character color and mix attributes also can be specified using the following functions: