Color Usage Categories
Color Usage Categories
When the user activates a window, the Palette Manager examines the
window's palette, if it has one, to determine whether colors need to be loaded
into the current device's color look-up tables. If your window requires 180
shades of green, for example, chances are the current CLUTs lack the
necessary colors. Whether the Palette Manager must change a color table
depends on what colors are in it already, what colors you ask for, and the
categories into which your colors fall.
The Palette Manager tracks colors in six usage categories, which you
specify to control the way the Palette Manager allocates colors. You assign
usage categories to colors when you create your palette, and you can change the
categories using Palette Manager routines.
A courteous color accepts whatever value the Color Manager
determines to be the closest match currently available in the color
table. On indexed devices, the Palette Manager lets the
Color Manager select appropriate pixel values from those
already in the CLUT. On direct devices, courteous colors always
display as specified. Courteous colors have no special properties,
but their use offers you a convenient holding place for collecting
colors.
A tolerant color also accepts the Color Manager choices on an
indexed device, but, unlike a courteous color, a tolerant color
specifies an acceptable range for color matching. If no color in the
device's color table falls within that range, the Palette Manager
loads the color required. On direct devices, the Palette Manager
matches tolerant colors as closely as the hardware allows.
An animated color is used for special color animation effects, as
described in Animated Colors. Animated colors are reserved by a
palette until its window is closed, and until then their spaces are
unavailable to (and cannot be used to match) any other request for
color. The effects of color animation depend on the existence of a
device color table, and, since a direct device does not have one, color
animation has no effect on a direct device's display. If your window
spans two devices, one indexed and one direct, the
Palette Manager is dexterous enough to animate the portion on
the indexed device's screen.
An explicit color specifies an index value, and always generates
the corresponding entry from the device's color table. Explicit
colors are useful if you wish to display the contents of a color
table-for example, to display to a user some or all of the colors
actually available.
An inhibited color is pr evented from appearing on color and
gray-scale devices of specified pixel depths. Inhibited colors are
always combined with other usage categories. You can create a large
palette-for example, with two different sets of color ranges, one
optimized for a 4-bit device, the other optimized for an 8-bit
device-and then inhibit colors on the devices for which they are not
intended.
PmWhite and pmBlack colors are assigned to white or black on
1-bit devices. If your application is working with red and dark blue,
for example, both might get mapped to black on a 1-bit device. By
assigning pmWhite to one and pmBlack to the other, you assure that
they will be distinct. These categories may be combined with other
usage categories, but combining them with each other is un defined.
Several color usage categories can be combined. You can specify that a color is
both tolerant and explicit, for example, which means that your RGB color, or a
tolerably close match, is placed in the color table at the index corresponding to
that palette entry (as opposed to merely being available somewhere in the
table), on all devices that touch the window.
When you specify colors for a palette within a 'pltt' resource, you usually
assign the same usage value to each color in the palette. However, if you must
use a particular color differently than the others, you can assign it a different
usage value, either when creating the resource file, or within the application
by means of the SetEntryUsage procedure.