Next | Prev | Up | Top | Contents | Index

Resource Types

Some resources are just string values (such as -labelString), but others have more complicated types. Since moat is a string language, all values should be manipulated in string representations; moat uses either Motif internal routines or specific converters to make the necessary conversions.

This section briefly describes the main types used by Tm and moat.


Basic Types: Integer, Boolean, and String

In Tcl, every variable's value is a character string. Nevertheless, some strings can be interpreted as an integer or as a Boolean. In Tm, a string could be any Tcl string or list, correctly surrounded by braces or double quotes. An integer is a string containing only decimal digits. A Boolean is one of the words true, false, on, off, yes, or no (in upper, lower, or mixed case), or an integer 1 or 0 where 0 indicates false.


Dimensions

Dimensions are particular integers measuring distance in screen space. Their actual value depends on the -units resource. This can involve different horizontal and vertical units of measurement (when based on current font metrics, for instance). For example, the following code sets a window size to 80 x 24 characters:

$window setValues \
   -units 100th_font_units \
   -width 8000 -height 2400 

Color Resources

In the X Window System, colors may be specified using portable symbolic names (such as NavyBlue) defined in the /usr/lib/X11/rgb.txt file, or using hexadecimal triplets of the form #RGB, with R, G, and B being two hex digits, such as #081080 (a dark blue).

Depending on the visual type, X11 may always produce the exact color you specified, or give you a close approximation. RGB values are not portable, because they depend on the screen hardware gamma, the software contrast correction, and the graphic board linearity. The /usr/lib/X11/rgb.txt file should be tuned for each hardware and software configuration (by the vendor), but this is rarely done well.


Font Resources

Font names used by X11 can be fully qualified dash-separated strings, or aliased nicknames. The general form of the full font name is as follows:

-foundry-name-weight-slant-width-style-14-80-100-100-m-60-encoding

The * character can be used as a wildcard to match any specifier available for the field. Table 4-7 shows what the fields represent.

Fields in a Font Name
FieldWhat it Represents
foundrythe font maker, such as Adobe(TM), Bitstream(TM), or Silicon Graphics
namefont family name as defined by its vendor, for example, Palatino or Helvetica
weightbold, book, demi, light, medium, regular
slanti for italic, o for oblique, r for regular (roman)
widthnarrow, normal, semicondensed
stylesans, serif, elfin, nil
sizesfont size (in various units) followed by resolutions
encodingusually iso8859-1

The xlsfonts command lists all fonts known to the X server; see xlsfonts(1) for details.


Font List

A font list is a comma-separated set of fonts. The first font in the list is the default one, while other ones are used for alternate codesets. This is quite useful in Japan, Korea, and China, where one font is not enough to contain all characters in common use. A widget's default font list usually derives from its ancestor. The top-level defaults are set from the VendorShell abstract class, or from the X defaults mechanism.


Pixmap Resources

Pixmaps are small rectangular arrays of pixels, often used to draw a button or pointer, or to be tiled to fill a graphic area.

On color displays, pixmaps can be either two color, using the -background and -foreground resources, or full color. Pixmaps may also be partially transparent, when they are accompanied by a transparency mask.

Simple two color pixmaps are created from a bitmap, using the current foreground and background colors at the time they are first loaded. Once created, the colored pixmap is retained in the server's memory by a caching mechanism. On most X servers, this coloring is retained until the X server is restarted. Use the bitmap command to create or modify bitmaps; see bitmap(1) for details. The following code establishes a bitmap:

#! /usr/sgitcl/bin/moat 
xtAppInitialize
xmPushButton .face managed \
    -labelType pixmap -labelPixmap /usr/share/src/sgitcl/face \
    -armPixmap face_no
.face activateCallback {exit 0}
. realizeWidget
. mainLoop

Enumerated Resources

For some resources, the value is given by a symbolic name, which can be chosen only from a small set of legal values. Tm uses the Motif standard name, without the leading XmN prefix, in a mixed case combination for setValues. Tm always returns lower-case strings from getValues.


Next | Prev | Up | Top | Contents | Index