Chapter 7


[XXX A blurb on why bother with "resource objects": shared resources, commonly used objects such as dialog boxes, etc.]

7.1 Fonts Mapper

The object that lives in "viola/res/objs/res.font.v" is an object that maps simple font specification names to the system font name. It allows viola objects specify a font by, say, "normal_large", and map it to a system (X Windows) dependent notation such as "-adobe-helvetica-medium-r-*-*-17-*-*-*-p-*-*-*".

This is where you can customize the fonts that work the That is, if fonts are coming out funny on your system, you can replace the given fonts to ones you know look good on your system. A useful Unix/X tool for aiding in selecting a set of replacement fonts is 'xfontsel'.

Another job done in this object is to specify fall back fonts. For example, for each font, one can specify the alternative fonts for viola to try to get. Like this, for the "normal_large" type font:

normal_large[0] = "-adobe-helvetica-medium-r-*-*-17-*-*-*-p-*-*-*"; normal_large[1] = "-*-helvetica-medium-r-*-*-17-*-*-*-p-*-*-*"; normal_large[2] = "-*-*-medium-r-*-*-17-*-*-*-p-*-*-*"; normal_large[3] = "-misc-fixed-*";

The 0'th specification is tried first, then the 1'st, etc. There's no limit to the size of the list, but more than 3 is probably overkill. Notice that the order of the array goes from from the most specific font to the most general.

Please refer to the object file (viola/res/objs/res.font.v) for the specifics.

7.2 Dialog Boxes

Line Entry Dialog Box

A quick way to get a line of text from the user. Here's the calling syntax:

send("res.getLineEntry", "show", <display message>, <default entry>, <caller, the obj to call back to>, <call back message token>, <optional x position>, <optional y position>);

The ideas is to keep commonly used, and sharable object, in a commonly accessilbe place -- a library. Weel, OK, so not much exists now. But it's a beginning.

Here are some ways to call and use the pre defined dialog boxes.

\class {txtButton} \name {getLineEntryTest} \script { switch (arg[0]) { case "buttonRelease": /* this statement calls up a dialog box */ send("res.getLineEntry",/* the templage dialog object */ "show", /* operational command */ "Your Name?", /* the message to display */ "Bart", /* default value */ self(), /* call back objec */ "gotALine", /* call back token */ get("x"), get("y"));/* location of the dialog */ break; case "gotALine": /* Okay, the dialog box has called back with * a line text for me to label myself */ set("label", arg[1]); render(); return; break; } usual(); } \label {I have no label. Click on me to give one.} \width {400} \height {50} \

Execute the above application gets you this GUI:

Clicking on the button invokes the following dialog box:

Replace with default string "Bart" with "Homer", and the label of our ``getLineEntryTest'' application changes:

7.3 X Resources

See the README files which came with the software for more specific information. But generally...

ViolaWWW gets many of its color settings from the ~/.Xdefault file. Here's an example of what you might insert into your X resource defaults file:

Viola.x: 550 Viola.y: 10 Viola.width: 620 Viola.height: 700 #ifdef COLOR Viola*foreground: black Viola*background: grey80 Viola.foreground_doc: black Viola.background_doc: grey90 #else Viola*foreground: white Viola*background: black Viola*borderColor: white #endif

Then do this to update the X resources, to let it take effect:

% xrdb -load ~/.Xresources
GOTO Preface, Previous Chapter (6), Next Chapter (8)