ColorsMenuInit
[ XITE Reference Manual | XITE home ]
Contents
Name
ColorsMenuInit, OverlaysMenuInit, Color_set, Color_ovl_set,
Color_add, Color_ovl_add, Color_read, Color_ovl_read,
Color_exit, Color_max, Color_ovl_max, Color_map, Color_map2,
ColortabName, OvltabName, Xcolor_deftab, AddColormapCopy,
Has_changeable_map - XITE color routines
#include <xite/Xcolor.h>
void Color_read( char* file_name );
void Color_ovl_read( char* file_name );
void Color_add( XColor coltab[], char* name,
int len );
void Color_ovl_add( XColor coltab[],
char* name, int len );
void ColorsMenuInit( Display* display,
int screenno, Widget parent,
char* colorfile );
void OverlaysMenuInit( Display *display,
int screenno, Widget parent, char *colorfile );
void Color_exit( void );
int Color_set( ImageWidget wid, int color );
int Color_ovl_set( ImageWidget wid, int color );
int Color_max( void );
int Color_ovl_max( void );
char *ColortabName( int coltab );
char *OvltabName( int coltab );
int *Xcolor_deftab( int n );
Colormap Color_map( int map, int xcolors );
Colormap Color_map2( int map, int xcolors,
Visual* visual );
void AddColormapCopy( Widget w, Visual* visual,
char* entryName );
Boolean Has_changeable_map( Display* dpy,
int screen, Visual* visual );
ColorsMenuInit sets the global variables dpy_s and
screen_s to display and screenno respectively. The
global variable visual_s (representing the globally
preferred visual) is set by calling
GetImageVisualAndColormap.
ColorsMenuInit initializes a popup menu for changing colors
in an Image or ImageOverlay widget. The instance name of the
menu (for resource specifications) is "colorsmenu".
ColorsMenuInit adds an entry labeled "Background" (widget
instance name "backgroundcol") as the first entry in the popup
menu. This entry will activate the default colormap. If the
image is displayed with a visual different from the default
visual of the display, then the "Background" entry is
insensitive (can not be chosen).
If a visual with changeable colormap exists for the display
(i.e. PseudoColor or DirectColor) and is registered by the
application, then a second entry called "Work-map" (widget
instance name " Work-map") is added to the colortable popup
menu. This entry will activate a grayscale colortable which is
made by the routine Color_add.
Finally, if the application has registered changeable
colormaps, ColorsMenuInit reads colorfile which contains a
list of colortables, and adds them, using Color_read.
Leading "~" and environment variables in colorfile will be
expanded. If colorfile is not found, try to find it in one
of the directories listed in the environment variable
XSHOWPATH.
If colorfile is NULL, use the default filename
xshow_colortabs and search for this in the directories
listed in the environment variable XSHOWPATH.
OverlaysMenuInit works like ColorsMenuInit except that the
instance name of the popup menu is "overlaysmenu", the first
entry's instance name is "backgroundovl", and the second
entry's label and instance name is " Std-overlay". The popup
menu is used to change the colors of the overlay image in an
ImageOverlay widget. The " Std-overlay" menu entry refers
to a predefined (hard-coded) overlay colortable with 32
entries.
Color_add adds the colortable coltabIn to the list of
colortables in the Image and ImageOverlay widget Colors popup
menu. The menu entry label and widget instance name are both
set to name. Actually, two new colortables are produced
(PseudoColor and DirectColor). One is based on a full-color
version (256 colors for 8-bit visuals and 16 million colors
for 24-bit visuals), the other is based on a reduced-color
version (128 colors + background and overlay colors for 8-bit
visuals, 2 million colors + background and overlay colors for
24-bit visuals). Which one of these two are actually chosen by
selecting a menu entry in the Colors menu, depends on whether
the resource XtNdisplayMethod indicates full-color or
reduced-color display.
The full-color version basis is grayscale. It is fully
modified by the colortable coltabIn supplied as an argument.
The reduced-color version basis is the XITE-initial colormap
described in GetImageColormap(3). It is modified in the
pixel value range [64..191] by the colortable supplied as an
argument. The rgb values corresponding to pixel values
[0..255] in the full-color version are squeezed into the pixel
range [64..191] in the reduced-color version by using only
every second value.
With NULL coltabIn, call the menu entry "Work-map", and make
the corresponding colortable grayscale.
Color_ovl_add works with colors for the overlay of an
ImageOverlay widget. One new colortable is produced and added
as the last entry of the OverlayColors popup menu. With NULL
coltabIn, a predefined 32-element overlay colortable called
"Std-overlay" is put into entries [0..31]. With coltabIn not
NULL, it will be used. It is assumed that the pixel elements
of the color-cells in coltabIn are consecutive in the range
[0..31].
Color_set stores the color argument in the image widget
XtNcolortab resource and sets the corresponding colormap for
the image window. The colormap is chosen depending on the
value of the image widget's displaymethod (reduced-color map
of 128 colors for PSEUDO_COLOR_8A (PseudoColor 8-bit visual),
full-color map of 256 colors for PSEUDO_COLOR_8B (PseudoColor
8-bit visual), reduced-color map of approximately 2 million
colors for DIRECT_COLOR_24_A (DirectColor 24-bit visual),
full-color map of approximately 16 million colors for
DIRECT_COLOR_24_B (DirectColor 24-bit visual)).
Color_ovl_set sets XtNoverlayColorCells (Image widget
resource) colors, taken from the 8-bit PseudoColor or 24-bit
DirectColor colormap corresponding to overlay colortable
ovlcolor, starting with pixel value 0, into the widget's
active colormap identified by XtNcolortab, starting with pixel
value 192. The XtNoverlaytab resource is set equal to
ovlcolor and the previous value of XtNoverlaytab is
returned.
Color_read expands file_name (interpreting csh ~) and
reads a BIFF colortable from file, adds it to the Colors popup
menu for the Image and ImageOverlay widget. It uses the routine
Color_add. If the filename starts with the character '+',
the routine simply calls Color_ovl_read. file_name is
first searched for in the directory given by the environment
variable XSHOWPATH.
Color_ovl_read behaves like Color_add, but the colortable
is added as the last entry of the OverlayColors popup menu for
ImageOverlay widgets. It uses the routine Color_ovl_add.
Color_exit is an empty function.
Color_max returns (one less than) the number of colors in
the list of colortables available from the Image and
ImageOverlay widget Colors popup menu. It is the index to the
last colortable added.
Color_ovl_max returns (one less than) the number of colors
in the list of overlay colortables available from the
ImageOverlay widget OverlayColors popup menu. It is the index
to the last colortable added.
Color_map2 checks whether the visual has changeable
colormaps and if so, uses map as an index into the Image and
ImageOverlay Colors popup menu to return the 128- or
256-element colormap, depending on the value of xcolors
(which should be 2, 128 or 256). If xcolors is zero, use the
number of colormap entries of visual. If this is 256, use
128 (i.e. use "reduced-colors" display as default). If
visual does not have changeable colormaps or if xcolors
(or the number of colormap entries) equals 2, return NULL.
Color_map behaves like Color_map2 except that the globally
preferred visual is used instead of visual.
Xcolor_deftab is obsolete since XITE version 3.3, but is
retained for backwards compatibility. Since version 3.3,
setting default values for the resources XtNcolorPtr and
XtNoverlayColorPtr is taken care of by the Image widget and
ImageOverlayWidget respectively.
Xcolor_deftab returns a pointer to an integer array with 32,
128 or 256 consecutive integer elements, depending on the
argument n. n equal to 32 returns the table 192,...,223.
n equal to 12 returns the table 64,...,191. n equal to
256 returns the table 0,...,255. Illegal n returns NULL.
The 32-element table is used as XtNoverlayColorPtr resource
for ImageOverlay widgets. The 128- and 256-element tables
are used as XtNcolorPtr resources for Image or ImageOverlay
widgets (128 for reduced-color display, 256 for full-color
display).
AddColormapCopy adds the full- and reduced-color versions of
the current colortable (as given by the XtNcolortab Image
widget resource) to the Colors popup menu, with name given by
entryName.
Has_changeable_map checks whether visual has changeable
colormaps. dpy and screen are not used.
ColortabName returns the name of entry number coltab in
the "Colors" menu in the image widget.
OvltabName returns the name of entry number coltab in
the "OverlayColors" menu in the image widget.
Otto Milvang and Svein Bøe
Svein Bøe
$Id: Xcolor.c,v 1.117 1997/08/04 11:14:00 svein Exp $