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.
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] . . . #endifFor 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
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] . . . #endifIn 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).