Displaying text

The program Main.m3 illustrates some of the many possible variations concerning the display of text on the screen. The text to appear is just one of many options for TextVBT; some of the others are margins, fonts, color and alignment.

The default horizontal alignment and vertical alignment is 0.5. This means that the text is centered inside the rectangular window. To get left justification the setting of halign is 0.0. The default font is Font.Builtin. Other fonts can be chosen using Font.FromName, assuming that they are available from the X Window System. By default, the foreground and background colors of the text are white and black, but different colors are possible. A TextVBT requires that the colors be specified by a collection of four painting operations called a ColorQuad. The most common collection requires specifying the foreground and background colors that should be used in the ``painting'' of the text VBT. This collection is constructed using the MakeColorQuad function. The colors themselves are specified by their red/green/blue components.

The program Main.m3 uses characters from the ISO Latin-1 character set. Character names, for instance, the upside down question mark and the ``e'' with the acute accent, can be obtained from the module Latin1Key. This module is part of the standard Modula-3 distribution and plays no particular role in Trestle. The constants in Latin1Key can be used to select the correct character from the 8-bit, discrete type CHAR.

The following images

contain three views of the window created by the Trestle program. The background color is blue and the letters are written in white. The first view shows approximately what the window looks like when it is first mapped by the X Window system. The other two show what happens when the window is resized by the window manager. The position of the text is governed by the horizonal and vertical alignment parameters. Since ha is 0.0, the text is left justified. Since va is 0.4, the text is slightly above the center of window.