------------------------------------------------------------------------------- Client-side colorname map. The Environment variable XCMSDB contains the path to a personal client side colorname to RGB mapping file. Default ProjectRoot/lib/X11/Xcmstxt If you lookup a color name using ANY Xlib routine and that color is listed in this file then this file is used to resolve the color name before any contact is made to the X server to look it up in the servers rgb database. EG: file of the format, anything outside the START and END tags is ignored. Color name must be delimited by one or more tab characters. =======8<-------- XCMS_COLORDB_START 0.1 menucolor #959595 red entry CIEXYZ:0.371298/0.201443/0.059418 ... XCMS_COLORDB_END =======8<-------- Thanks to Randall Hopper for the above information. ------------------------------------------------------------------------------- XAllocNamedColor -- "nearest match" This is a typical misreading of the manual (which is not very clear though). XAllocNamedColor returns An exact color if possible Closest color available on a HARDWARE (static) colormap. EG: on dynamic visuals colormap the call will fail if color table is full but on a static visual it can never fail. D. Richard Hipp wrote.. With the standard PseudoColor visual, there is no way to tell the X server to give you the "closest" available color. This is one of the things people hate most about the X protocol. But there are ways to work around the problem. Basically, you have to load the entire colormap into the client, then look for close colors yourself. This is a lot of work, but it will get the job done. For examples of how to load close colors in X, check out the source code to XPM (in the file alloc.c, if I recall) or Tk4.0 (in the file tkColor.c.) Both of these systems will allocates the closest available color if no free color cells are available. The Tk4.0 code, in particular, is very clearly written and might be extractable and usable in a project that doesn't otherwise use Tk. ------------------------------------------------------------------------------- Color Allocation Overflow Allocate colors as you have, when you run out THEN call XCopyColormapAndFree() to allocate a separate color map from the default and continue where you left off. This way you will use the default color map if you can but will switch to a private colormap if necessary... From the Orielly's Xlib book ( X Windows R4/R5, Vol 1, page 243 ) XCopyColormapAndFree() Moves all of the client's existing colormap entries to a new colormap and frees those entries of the old colormap. This is used when colorcell allocation fails and some cells have already been allocated. It saves needing to create a colormap and start from the beginning allocating colors. For applications with special color needs that can't make do, they can call XCopyColormapAndFree(), set their colormap window attribute, and continue allocating colors in the new colormap where they left off. ------------------------------------------------------------------------------- From: Scot Art Newsgroups: comp.windows.x Subject: Best colours to reduce eye strain From William K Horton, "Designing and writing online documentation", p166 "No color combination has the contrast and hence legibility of black and white. Reading colored text is often slower and more error-prone than reading black and white text (Bouma, 1980)." "... Characters formed of a combination of primary colors may appear fuzzy because of misregistration, especially near the edges and corners of the screen (Williges and Williges, 1984). Generally for a black background, green proves the best choice on a red-green-blue color display because red is too intense and blue is too dark." "... Legible text stands out from its background. For legibility make foreground and background colors differnt in lightness and hue. Especially avoid combinations that are the same lightness level, for example, yellow on white or navy blue on black." " ... For other legible color combinations, use opponent colors, such as yellow and blue (Dumas 1988). If you use a pure blue, use it as a background. Many people cannot clearly focus on blue objects. If you must use blue as a foreground color, mix green with the blue..." [reasons given but left out here for space considerations] "... Limit the number of colors ..." [section heading] "... Apply the user's color conventions" [section heading] "Every domain has its own color conventions ..." [examples given] "Color associations" [section heading] "Colors take on strong cultural and political associations. You are going to have a hard time sellign your system to the government of Swamalamaland if your screens display the colors of the outlawed revolutionary opposition party..." (personal examples of note include the fact that in many Islamic and Asian nations WHITE is the colour of mourning; in China, RED is used at weddings and festivals, being the colour of good luck; in Japan, BLUE has scatological associations, while BLACK has no particular meaning; and in a Western Hospital, BLUE is associated with DEATH). Scot Art ------------------------------------------------------------------------------- ! My suggested Coloring Scheme using the Libraries Standard Color Table ! ! Athena Widget Set... ! *foreground: black *borderColor: black ! *Command.background: sky blue *Toggle.background: sky blue *MenuButton.background: sky blue *Label.background: lemon chiffon *Box.background: lemon chiffon *Form.background: lemon chiffon *SimpleMenu*background: wheat *List.background: wheat *Dialog.background: wheat *Dialog.Label.background: wheat *Text*background: white ! ! ! Motif Widget Set... (incomplete) ! *Foreground: black *XmScrollBar*Foreground: wheat *XmLabel*Foreground: navy blue *XmToggleButton*Foreground: black *XmPushButton*Foreground: navy blue # background colors *Background: wheat *XmList*Background: wheat *XmText*Background: wheat *XmSelectionBox*Background: wheat *XmMessageBox*Background: wheat *XmTextField*Background: tan # hightlighted edge of widgets *TopShadowColor: lemon chiffon *XmList*TopShadowColor: lemon chiffon *XmText*TopShadowColor: lemon chiffon *XmSelectionBox*TopShadowColor: lemon chiffon *XmMessageBox*TopShadowColor: lemon chiffon # trough of scrollbar (dark color) *TroughColor: sienna # selection color (dark color) *SelectColor: sea green ! ! And then to adjust the colors of the important widgets which are specific ! to that application. ! --- Anthony Thyssen ! -------------------------------------------------------------------------------