EditColor Widget Class
Overview
The EditColor widget displays a panel that lets the end-user change a color.
The end-user can edit the color using sliders to select values for the RGB, CMY
or HLS components of the color. Alternatively, the end-user can select a new
color from a list of named colors. The programmer uses the EditColor widget's
resources and children's widget IDs to control the layout and contents of the
Editcolor panel. For instance, the programmer can specify that the end-user can
use only the RGB color model or can select only from a list of named colors
that are defined by the application.
The EditColor widget supports StaticColor, TrueColor, and Pseudo Color visual
types.
Specifying a Color to Edit
The application determines the color to be edited and specifies the pixel ID of
the color at EditColor widget creation time using the resource, XmNeditPixel.
If the pixel specified is associated with a read-write color cell, then the
EditColor widget will change the color using that color cell. However, if the
color cell is read-only, then the EditColor widget will allocate a read-write
color cell in the application's colormap to be used during the editing process.
Creating an EditColor Widget
An application creates an EditColor widget as a child of a container widget or
creates an EditColor dialog box using a provided function. During the creation
process, the application uses resources to specify the color to be edited and
the components to be included on the EditColor panel.
Getting the Edited Color
The application can determine the edited color in several ways. For instance,
the function XintEditColorGetColor returns both the original color and the
new color. Another method can be used if the color to be edited is in a
read-write cell. In that case, the read-write cell will be used during editing
and the cell can be referenced directly to determine the new color.
Specifying the editing Methods Available
The programmer specifies the allowable editing methods via the resource,
XintNcolorSelectionMode, during or after widget creation time. The programmer
can specify that only the color sliders are to be used, that only the named
color list is to be used, or that both methods are available to the end-user.
Editing a Color with the Sliders
By default, the sliders will appear on the EditColor panel. The end-user
selects the color model to be used (RGB, CMY or HLS) and then changes the value
of each component with the sliders. When the end-user decides that the color is
as desired, the OK or Apply pushbuttons can be used to let the application know
that the color has been edited.
Editing a Color by Choosing a Named Color
If the appropriate resource value is specified at EditColor widget creation
time, then a list of named colors will appear on the EditColor panel. The
default list of colors used is the list contained in the file rgb.txt, but a
different list can be specified via a resource. When the end-user selects a
named color from the list, the sliders are updated to show the components of
the selected color. The end-user can further edit the color by changing the
sliders (if they are present).
EditColor Panel with Sliders
Below is an example of the EditColor widget's panel showing the color sliders.
The programmer can change the appearance of the panel by specifying resource
values or by getting a child widget's ID and unmanaging the child.

Figure 6: EditColor widget with sliders.
EditColor Panel with Named Colors
When the programmer or end-user selects the color list mode of the EditColor
widget then its panel looks like the picture below. The programmer can change
the appearance of the panel by specifying resource values or by getting a child
widget's ID and unmanaging the child.

Figure 7: EditColor widget with color list.