2.2 color

All colors you want to use have to be declared as a resource. The number of available colors depends on your graphics system.

The declaration of a color starts with the keyword color, followed by the color identifier and the color definition. The declaration ends with a ; (semicolon).

Definition

{ export | reexport } color <Identifier> <colorSpec> | <variantDef>
colorSpec ::=
  { rgb(<R>, <G>, <B>) | hls(<H>, <L>, <S>) | gradient("<kind> [ , <arg> ]") |
    "<predefined color>" }
  { , grey(<N>) } { , black | white } ;
variantDef ::=
{
           0 : <colorSpec>
  [ <number> : <colorSpec> ]
}

Examples

Non-variant

color RED         rgb(255, 0, 0), grey(50), white;
color AQUA        hls(90, 127, 255), grey(127), white;
color YELLOW      rgb(255, 255, 0);
color BLUE        "blue", black;
color ClMagenta   "magenta";
color BEAUTYCOLOR "orchid", grey(10), white;

Variant

color BEAUTYCOLOR
{
  0: rgb(100,200,200);
  1: "orchid", grey(10), white;
  2: rgb(150,100,190);
  3: "pink";
}

Different kinds of displays use the color specifications in a different way. Color displays use exclusively the color specification, greyscale displays use greyscales, and monochrome displays use black-and-white values.

rgb(<R>, <G>, <B>)

R, G, B are the color intensities of the portions of the colors red, Ggreen and bllue. The value range for all three values is 0 to 255. Brackets and commas are components of the color declaration.

Depending on your choice of RGB values, Microsoft Windows uses grid mixed colors. This can mostly be avoided by choosing suitable values, e.g. 0, 63, 127, 191, 255.

color  MyGrey  rgb(127,127,127);

color  Azure  rgb(63,127,191);

hls(<H>, <L>, <S>)

In the HLS color model, colors are defined by hue H, lightness or luminance L, and saturation S. The range for all three values is 0 to 255.

The colors are arranged within a cylinder whose top plane is white and whose bottom plane is black. Lightness L increases from 0 (dark) at the bottom to 255 (bright) at the top. For colors within the circle intersecting the center point of the cylinder, L is 127. These colors are neither brightened (by mixture with white) nor darkened (by mixture with black).

Hue H is determined by the angle on the circular area. The range for H from 0 to 255 and the angle A in the color circle (actually ranging from 0 to 359 degrees) relate as given below:

  • H = A / 2.
  • A = (H modulo 180) * 2; that is the values from 180 to 255 match the color shades from 0 to 75.

Red has a value of H = 0 (or 180), H = 60 (or 240) yields green and H = 120 yields blue.

The shades of gray lie on the vertical line through the center of the cylinder, all having a saturation of S = 0. The colors on the lateral area of the cylinder have the highest saturation S = 255. The colors on the perimeter of the middle circle with L = 127 and S = 255 sometimes are referred as pure colors.

grey(<N>)

This is the grayscale value which is to be used on a grayscale screen for the color. N is a number from 0 to 255.

black | white

These are the color values for monochrome monitors.

gradient("<kind> [ , <arg> ]")

Availability

IDM for Qt only

color resources support gradients on Qt.

The parameter <kind> defines the gradient type. Only one gradient type may be specified.

The other parameters may include:

  • Supplementary parameters for the gradient type
  • Stop point definitions
  • Color definitions

These gradient types are available:

Table 20-1: Types of gradients

Gradient

Definition

Explanation

linear

gradient("Linear, ...")

gradient("LinearV, ...")

vertical gradient

gradient("LinearH, ...")

horizontal gradient

radial

gradient("Radial, ...")

gradient("Radial, <R>, ...")

radial gradient with default radius 50%

radial gradient with supplementary parameter radius R%

radius is given as a percentage of the available space

conical

gradient("Conical, ...")

gradient("Conical, <S>, ...")

conical gradient with start at 90°

conical gradient with supplementary parameter S°, which indicates the starting angle

The color definitions are always appended after the gradient type and any supplementary parameters. You can use color names, HTML notation, and the rgb(…), hls(…), and grey(…)notations known for color resources.

In addition, a stop point can be specified for each color definition, which determines the weighting of the color. A stop point is a percentage with an optional percentage sign that always precedes each color and affects how much space that color occupies in the gradient. A gradient starts at 0% and ends at 100%, based on the area it fills. The specification … , 20%, green, ... means, for example, that after 20% of the area to be filled, the color green is set. If no other color is set for the 0–20% range, the first 20% of the range is colored green. If another color is already set before 20%, then a transition between this color and green is displayed.

Stop points should always be set in ascending order. If several colors are defined with the same stop point, the color that is furthest at the end of the parameter list applies. For example, the definition ... , 20%, green, 40%, blue, 20%, red, ... produces a gradient with a shade of red at 20%, which changes to a blue tone that is shown as saturated at 40%.

Examples

gradient("Linear, green, yellow, red");  named colors, evenly distributed
gradient("Linear, #00FFFF, #00FF00, #FF0000");  HTML notation,
                                                colors evenly distributed
gradient("Linear,red, #00FF00, rgb(0,0,255)");  mixed notations,
                                                colors evenly distributed
gradient("Linear, 20%, green, 60%, yellow, 80%, red");  named colors with
                                                        percentage stop points
gradient("Linear, 20, green, 60, yellow, 80 ,red");  the % sign at the
                                                     stop points is optional

Notes

Qt allows the setting of gradients in most places, but does not necessarily apply them. Whether a gradient is displayed depends very much on the object and the UI style. In this case, areas (e.g. backgrounds) are usually unproblematic, with delicate structures (e.g. texts) the gradient is often replaced by a single color. For grouping objects, gradients as a background are usually displayed.

<predefined color>

A color identifier defined by the window system that can be used in the ISA Dialog Manager.

2.2.1 Predefined Colors

A list of the predefined cursors available on the respective system can be requested via the attribute .colorname[integer] on the setup object.

2.2.1.1 Independent UI-colors

The UI color resources are WSI-independent predefined colors that are available on all systems with similar characteristics or meaning. The default colors used by the current desktop/window manager or theme are used for this purpose. The uniform COLOR resources are defined as follows:

Note for Windows

The UI_*_COLOR colors access the Windows system colors. It should be noted that with the introduction of Visual Styles, the individual objects no longer use the system colors, but rather bitmaps defined by the theme. Depending on the selected theme there can be strong discrepancies. Therefore no colors (or UI_NULL_COLOR) should be set under Windows mach Möglichkeit. On the other hand, it should be noted that with Windows 10 the color variety has been reduced. For example, the colors UI_HEADERBG_COLOR, UI_HEADERFG_COLOR, UI_MENUBG_COLOR, UI_MENUFG_COLOR, UI_TITLEBG_COLOR and UI_TITLEFG_COLOR are no longer supported. This means that these colors can still be used, but they are not used by any object.

2.2.1.2 Motif (X-Windows)

When using system names for color resources, it is possible to address Motif's default colors. The following system names are available:

On Motif (X Windows) systems all colors from the color definition file rgb.dat can be used.

2.2.1.3 Microsoft Windows

These system colors are available in the IDM für Windows:

2.2.1.4 Qt

As color identifiers all SVG color names can be used (http://www.w3.org/TR/SVG/types.html#ColorKeywords), where upper and lower case is ignored. When using these color names (for example, green), the colors are realized according to the SVG color names of the W3C. Therefore, some colors differ in tone and intensity from the X11 colors.

In addition, the following Qt default colors depending on the current settings are available:

Normal and active states are identical.

The identifier DEFAULT serves as null color. If this color is assigned, the respective color is reset to the corresponding default color (depending on the current system settings).

2.2.2 Dynamically changeable attributes

The table below shows those atrributes of color resources, that can be changed dynamically at runtime. Please note, that .rgb[enum], .hls[enum] and .name are mutually exclusive so that get returns can’t get value.

Table 20-2: Modifiable attributes of the color resource

Attribute

Data Type

Index Range

Description

.rgb[enum]

integer

0 … 255

color_red,
color_green,
color_blue

red, green, blue

.hls[enum]

integer

0 … 255

color_hue,
color_light,
color_sat

hue, lightness, saturation

.gradient

string

kind and parameters of a gradient

.name

string

system name of the color

.grey

integer

0 … 255

grey scale value

.bw

enum

color_black,
color_white

black and white value

With the attributes .rgb[enum] and .hls[enum] the color is not updated before the last value (color_blue respectively color_sat) is set, thus giving the opportunity to define the color as a whole.