DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Integrating applications into the Desktop

Defining display-dependent colors

If your application makes extensive or special use of color, you may want to define your color resources directly rather than through the color API's color name variables.


NOTE: The following applies only to those color resources that are not defined with the color API color name variables.

When defining color resources directly, consider the wide variety of displays on which the Desktop is viewed. Resources defined for a color display may not work for a monochrome or grayscale display, and some servers support more colors or shades of gray than do others.

If your colors work well on all supported displays (color, monochrome, grayscale) and servers (16-color and above), define your color resources in your app-defaults file. If you want to use different colors for different displays or servers, conditionally define your color resources in your ODR file. For more about preparing an ODR file, see ``Adapting to display resolution at run time''.

Define color resources in your ODR file only if your application makes special use of color that cannot be achieved with the color name variables. You may explicitly define colors for certain objects and use the color API for the rest. This approach is useful when you want to prevent users from changing the color of an object (the red, green, and blue slider bars of an RGB color mixer, for example).

Define display-dependent resources as you would resolution-dependent ones: use standard #if, #elif, and #else preprocessor directives and xrdb display attribute symbols to conditionally specify resources.

Use the xrdb COLOR symbol to differentiate color and monochrome displays.

   #if COLOR
   	. . .
   	[definitions for color displays]
   	. . .
   #else
   	. . .
   	[definitions for monochrome displays]
   	. . .
   #endif
For most applications, defining separate resources for color and monochrome displays should be adequate. Check how your color resources look on a grayscale display. If the result is unacceptable, use the CLASS symbol to define grayscale resources separately.
   #if CLASS = GrayScale
   	. . .
   	[definitions for grayscale displays]
   	. . .
   #elif COLOR
   	. . .
   	[definitions for color displays]
   	. . .
   #else
   	. . .
   	[definitions for monochrome displays]
   	. . .
   #endif


NOTE: Your SCO OpenServer system or X terminal may be running on a server that only supports 16 colors (or shades of gray). The 16 color cells are taken by the palette manager (eight color cells), the server (two color cells, for black and white), and the Desktop icons (six color cells). If you need to define more colors, you must install your own colormap using the facilities provided by the Xlib library.

Use the PLANES symbol to specify resources for 16-color (or grayscale) servers.

   #if CLASS = GrayScale
   	#if PLANES < 8
   		. . .
   		[definitions for 16-grayscale displays]
   		. . .
   	#else
   		. . .
   		[definitions for 256(or more)-grayscale displays]
   		. . .
   	#endif
   #elif COLOR
   	#if PLANES < 8
   		. . .
   		[definitions for 16-color displays]
   		. . .
   	#else
   		. . .
   		[definitions for 256(or more)-color displays]
   		. . .
   	#endif
   #else
   	. . .
   	[definitions for monochrome displays]
   	. . .
   #endif
In your app-defaults file, define default values for resources defined in your ODR file. These default definitions will ensure that your application will always display, even if it is run without the session manager (and, therefore, without your ODR file loaded).
Next topic: Communicating with the session manager
Previous topic: Color name variables

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003