Courteous Colors
Courteous Colors
Courteous colors may seem so polite as to be useless, but they can serve as
convenient placeholders. If your application uses a small number of colors,
you can place them in a palette, ordered according to your preference and
designated as courteous.
Suppose you have an open window named myColorWindow that has a palette
resource consisting of a set of eight colors: white, black, red, orange, yellow,
green, blue, and violet, in that order, each with a usage category specified as
courteous, as shown in the Figure below.
A courteous palette
The following example paints the rectangle myRect in yellow (palette entry
4, where white is 0).
SetPort (myColorWindow);
PaintRect (&myRect);
This is exactly analogous to the following sequence of Color QuickDraw
routines, where yellowRGB is of type ColorSpec:
yellowRGB.red = 0xFFFF;
yellowRGB.green = 0xFFFF;
yellowRGB.blue = 0x0000;
SetPort (myColorWindow);
RGBForeColor (&yellowRGB);
PaintRect (&myRect);
Colors with specified usage categories that cannot be satisfied by the
Palette Manager default to courteous colors. This occurs, for example,
when drawing to a direct device or one with a fixed CLUT.