Defining Window Attributes

One advantage to secondary windows is that you can define the window's title, dimensions, and colors before you display it. As for nonscrolling regions, you provide this information in the [WINDOWS] section of the .MVP file for your title.

The entries in the [WINDOWS] section define the attributes for different types of secondary windows. A secondary window type defines the caption, size, and colors used for a window of that type. You can define up to five types in a single .MVP file.

After you define a secondary window type, you can give the type name in any jump. After the jump, the jump destination topic will appear in a secondary window of that type.

The general form of a type definition for a secondary window is as follows:

typename="caption", (placement), (windowstate), (textcolors), (nonscrollingcolors)

The definition using the [WINDOWS] section from the USA.MVP file is as follows:

[WINDOWS]
main=, (0,0,1023,1023), , , (192,192,192)
inform="Information", (0,0,511,511), 0, ,(192,192,192)
bird="State Bird", (0,0,600,1023), 0, ,(192,192,192)
;
; Secondary window type used with ChangeButtonBinding
; example in [CONFIG] section
; contents="USA Contents", (0, 0, 894, 787), 0, ,

The following sections describe each component of a type definition.

Name

The name before the equal sign (=) identifies a secondary window type. The name is required.

When a jump includes this name, the jumped-to topic appears in a window of this type. (See “Jumping to Secondary Windows,” later in this chapter, for an example of a jump to a secondary window in the USA Tour.)

The name “main” defines attributes for the main Viewer window. Even if you don't define main-window attributes in this section, you cannot name a secondary window type “main.”

Caption

For secondary window types, the name in quotes immediately following the equal sign is the window's caption. Secondary windows of this type display the caption on their caption bar. For example, “State Bird” topics in the USA Tour sample title are displayed in windows with “State Bird” in the caption bar.

The caption should be blank (,) for type “main.”

Window Placement

The first set of four numbers in parentheses defines where the secondary window appears in the main Viewer window. This entry is required.

The first two numbers define the horizontal and vertical position of the upper-left corner of the window. Positions are defined in terms of Viewer coordinates. Viewer uses a 1,024-by-1,024 coordinate system, mapped onto the horizontal and vertical resolutions of the video card, so you'll have to do some calculations to determine the exact pixel location. For example, the resolution of your video card is horiz by vert pixels, and the horizontal and vertical locations you specify are at Viewer coordinates x and y, then the x coordinate of the upper-left corner is at the pixel given by the following formula:

x * (horiz/1,024)

The y coordinate of the upper-left corner is at the pixel given by the following formula:

y * (vert/1,024)

For example, the upper-left corner coordinates for secondary windows of type “inform” are (0,0), the upper-left corner of the screen.

The second two numbers define the normal width and height of the window, again in terms of the Viewer coordinate system. “Inform” windows are specified with a width of 511 and a height of 511. A standard VGA card has a resolution of 640-by-480 pixels, so the width is actually the following number of pixels:

511 * (640/1,024) = 319

The height is actually the following number:

511 * (480/1,024) = 240

In other words, “inform” windows take up approximately one quarter of the area of the Viewer screen (half the width multiplied by half the height).

To convert from pixels to Viewer coordinates, you invert the ratio between Viewer's resolution and the video resolution. Again, assuming the resolution of your video card is horiz by vert pixels, and the horizontal and vertical locations (or dimensions) you want are x and y pixels, the x coordinate (or width), in Viewer coordinates, is as follows:

x * (1,024/horiz)

The y coordinate (or height), in Viewer coordinates, is:

y * (1,024/vert)

Because Viewer coordinate system ranges from 0 through 1,023 in both directions, the horizontal position plus the width must be less than 1,023. Similarly, the vertical position plus the height must be less than 1,023.

Display Size

The number after the numbers in parentheses indicates whether or not the window takes up the entire screen when it is first displayed. If this number is 0, or if no number appears between the commas, the window is displayed at normal size. If it is 1, the window is maximized when it is first displayed.

In the previous example, “inform” windows are first displayed in their normal size.

Text and Nonscrolling Colors

Next, you'll notice two sequences of three numbers in parentheses. The first sequence specifies the background color for the window. The second sequence specifies the background color for the nonscrolling region of the window (if any). These sequences have the following form:

(red;green;blue)

The numbers in each sequence represent the red, green, and blue (RGB) components of the color. If these colors are not given, the scrolling and nonscrolling areas use the normal system colors in the background.

Hint:

Use the Colors application from the Windows Control Panel to see the colors resulting from different RGB values. Choose the Colors button in the application, then choose the Define Custom Colors button at the bottom of the palette.

In the example, the main window type and the two secondary window types use the system default value for the background color, since no numbers appear. They use light gray (given by the RGB values “(192,192,192)”) as the background color for nonscrolling regions.