[ Previous | Next | Contents | Glossary | Home | Search ]
Motif 2.1 Programmer's Guide



Default Colors and Pixmaps

The following resources determine the colors or pixmaps generally used in Motif:

Borders
Core resources XmNborderColor and XmNborderPixmap

Backgrounds
Core resources XmNbackground and XmNbackgroundPixmap

Foregrounds
Gadget, Primitive, and Manager resource XmNforeground; Label and LabelGadget resources XmNlabelPixmap and XmNlabelInsensitivePixmap

Shadows
Gadget, Primitive, and Manager resources XmNbottomShadowColor, XmNbottomShadowPixmap, XmNtopShadowColor, and XmNtopShadowPixmap

Focus highlights
Gadget, Primitive, and Manager resources XmNhighlightColor and XmNhighlightPixmap

Arming and selection
PushButton and PushButtonGadget resources XmNarmColor and XmNarmPixmap; ToggleButton and ToggleButtonGadget resources XmNarmColor, XmNindeterminateInsensitivePixmap, XmNindeterminatePixmap, XmNselectInsensitivePixmap, XmNselectPixmap, and XmNunselectColor; ScrollBar resource XmNtroughColor; Display resource XmNenableToggleColor

The following sections describe these groups of resources and their defaults.

Borders

The border color or border pixmap is used to fill the border of a widget if XmNborderWidth is greater than 0. Note that the border is outside the widget; that is, it is not within the area determined by the widget's XmNheight and XmNwidth. If the user or application supplies a value for XmNborderPixmap, that pixmap is used to fill the border; otherwise, XmNborderColor is used.

If the application resource reverseVideo is False or unspecified, the default for XmNborderColor is the black pixel of the widget's screen. If reverseVideo is True, the default for XmNborderColor is the white pixel of the widget's screen.

Backgrounds

The background color or background pixmap is used to fill a widget before anything else is displayed in it. If the user or application supplies a value for XmNbackgroundPixmap, that pixmap is used to fill the background; otherwise, the XmNbackground color is used. A gadget inherits the background color and background pixmap of its parent, if those resources are not set.

The default for XmNbackground is implementation dependent.

Foregrounds

The foreground color is used to display text and most graphics in a widget. Most widgets use the XmNforeground color for this purpose. Label, LabelGadget, and their subclasses (except for ToggleButton and ToggleButtonGadget which are special cases described later in this chapter) have pixmap resources that are used for the face of the label or button when XmNlabelType is set to XmPIXMAP. In this case, XmNlabelPixmap is used for the face when the widget is sensitive, and XmNlabelInsensitivePixmap is used when the widget is insensitive. A gadget inherits the foreground color of its parent (if none is set).

The default for XmNforeground is a color that contrasts with the background color, based on the XmScreen resource XmNforegroundThreshold. The value of this resource is an integer between 0 and 100, inclusive, that specifies a level of perceived brightness for a color. If the perceived brightness of the background color is equal to or below this level, Motif treats the background as "dark" when computing the default foreground color. If the perceived brightness of the background color is above this level, Motif treats the background as "light" when computing the default foreground color. When the background is "dark," the default foreground is white; when the background is "light," the default foreground is black.

Shadows

The top shadow color or top shadow pixmap is used to draw the top and left sides of the three-dimensional shadow at the edge of some widgets. If the user or application supplies a value for XmNtopShadowPixmap, that pixmap is used for the top and left sides; otherwise, XmNtopShadowColor is used.

The bottom shadow color or bottom shadow pixmap is used to draw the bottom and right sides of the three-dimensional shadow. If the user or application supplies a value for XmNbottomShadowPixmap, that pixmap is used for the bottom and right sides; otherwise, XmNbottomShadowColor is used.

A gadget inherits the top and bottom shadow colors and pixmaps of its parent, if those resources are not set.

In computing the defaults for XmNtopShadowColor and XmNbottomShadowColor, Motif uses the XmScreen resources XmNdarkThreshold and XmNlightThreshold. The value of each resource is an integer between 0 and 100, inclusive, that specifies a level of perceived brightness for a color. If the perceived brightness of the background color is equal to or below the XmNdarkThreshold, Motif treats the background as "dark" when computing the default shadow colors. If the perceived brightness of the background color is above the XmNlightThreshold, Motif treats the background as "light" when computing the default shadow colors. Otherwise, Motif treats the background as "medium" when computing the defaults.

Motif computes the defaults in the following way, depending on the perceived brightness of the background:

Dark background
The top and bottom shadow colors are interpolated toward white from the background, with the top shadow color shifted more toward white than the bottom shadow color.

Light background
The top and bottom shadow colors are interpolated toward black from the background, with the bottom shadow color shifted more toward black than the top shadow color.

Medium background
The top shadow color is interpolated toward white from the background, and the bottom shadow color is interpolated toward black from the background.

Focus Highlights

The highlight color or highlight pixmap is used to draw the highlighting rectangle around widgets that have keyboard focus. If the user or application supplies a value for XmNhighlightPixmap, that pixmap is used for the highlight; otherwise, XmNhighlightColor is used. The highlight color is also used to draw the location cursor around List items that have keyboard focus. A gadget inherits the highlight color and highlight pixmap of its parent if those resources are not set.

The default highlight color is the same as the default foreground color.

Arming and Selection

In PushButtons and PushButtonGadgets outside menus, XmNarmColor is used as the button background when the XmNfillOnArm resource is True and the user arms the button. In PushButtons and PushButtonGadgets outside menus, XmNarmPixmap is used as the button face (the label area) when XmNlabelType is XmPIXMAP and the user arms the button. These also work inside menus if the XmNenableEtchedInMenu resource of XmDisplay is True.

Selection rules in ToggleButton and ToggleButtonGadget are rather complicated. Many different resources control the colors and pixmaps displayed by ToggleButtons. Before getting into the selection rules, we should define a few terms. ToggleButton and ToggleButtonGadgets display the following visual areas:

  1. A label, which consists of either text or a pixmap.

  2. An optional indicator, which consists of an optional glyph, an enclosing border, and the background area between the enclosing border and the glyph. XmNindicatorOn specifies whether or not the ToggleButton or ToggleButtonGadget contains an indicator area. If it does, XmNindicatorOn also specifies the kind of indicator. The optional glyph is either a checkmark or a cross. If XmNindicatorType is XmN_OF_MANY, then the glyph is included as part of the indicator area. If XmNindicatorType is something other than XmN_OF_MANY, then the indicator area does not contain a glyph.

    Figure 13 illustrates a ToggleButton displaying these two visual areas:

    Figure 13. Visual Areas of a ToggleButton.

    View figure.

    XmNset specifies whether a user or application has set or unset a ToggleButton or ToggleButtonGadget. A third possibility is that the ToggleButton or ToggleButtonGadget is neither set nor unset, but is in an indeterminate state. ToggleButton and ToggleButtonGadget must visually convey the value of XmNset through colors and pixmaps.

    Table 10 summarizes the color used to paint various "background areas" in ToggleButtons or ToggleButtonGadgets. For example, the background area of an indicator is the area surrounding the glyph. Table 10 assumes that the ToggleButton or ToggleButtonGadget is outside of a menu and that XmNindicatorOn is something other than XmINDICATOR_NONE.

    Table 10. Color of Various Background Areas in ToggleButton

    XmNfillOnSelect XmNset Resulting Color of "Background Area"
    =

    True XmSET XmNselectColor
    True XmUNSET XmNunselectColor
    True XmINDETERMINATE Stipple of XmNselectColor and XmNunselectColor
    False any value XmNbackground

    If XmNindicatorOn is XmINDICATOR_NONE, then the ToggleButton or ToggleButtonGadget displays no indicator area. In this case, the colors in Table 10 apply to the background area of the label.

    If the XmNindicatorType is XmN_OF_MANY, then the indicator area contains a glyph. Table 11 summarizes the color of the glyph.

    Table 11. Color of Glyph in ToggleButton

    XmNset Resulting Glyph Color
    =
    XmSET XmNforeground
    XmUNSET No glyph is drawn
    XmINDETERMINATE Stipple of XmNforeground and XmNbackground

    If a user or application does not specify a value for XmNselectColor, then the XmNenableToggleColor resource of XmDisplay determines the background color.

    If the label area is a pixmap, then the ToggleButton's sensitivity and the value of its XmNset resource determines which pixmap is rendered. Table 12 summarizes these combinations.

    Table 12. Pixmap Used in Label Area of ToggleButton

    XmNset Sensitive? Resulting Pixmap
    =

    XmSET Yes XmNselectPixmap
    XmUNSET Yes XmNlabelPixmap
    XmINDETERMINATE Yes XmNindeterminatePixmap
    XmSET No XmNselectInsensitivePixmap
    XmUNSET No XmNlabelInsensitivePixmap
    XmINDETERMINATE No XmNindeterminateInsensitivePixmap

    In ScrollBars, XmNtroughColor is used to fill the part of the slider area that is not taken up by the slider.

    Motif computes a single default, known as the select color, for XmNarmColor, XmNselectColor, and XmNtroughColor. Motif uses the XmScreen resources XmNdarkThreshold and XmNlightThreshold to determine whether the background is "dark," "light," or "medium" in the same way as for shadow colors. Motif then computes the default in the following way:

    Dark background
    The select color is interpolated toward white from the background.

    Light background
    The select color is interpolated toward black from the background.

    Medium background
    The select color is interpolated toward black from the background.


  3. [ Previous | Next | Contents | Glossary | Home | Search ]