This page uses CSS, and renders properly in the latest versions of Microsoft Internet Explorer and Mozilla.
This is Frontier: The Definitive Guide by Matt Neuburg, unabridged and unaltered from the January 1998 printing.
It deals with the freeware Frontier 4.2.3; for commercial Frontier 8, look here, and for the inexpensive Radio UserLand, look here. See my Web site for information.
Those wishing an offline or printed copy may purchase the book, which is still in print.
Copyright 1998 O'Reilly & Associates, Inc. ALL RIGHTS RESERVED. Reprinted with permission.
TOP UP: Interface NEXT: Import/Export

28

Pictures

A Frontier picture is a non-scalar object type, like a wptext or an outline, except that it has no internal editing facilities: opening a picture's edit window simply displays the picture as a graphic in a window, without giving the user any ability to edit that graphic. On the whole, a Frontier picture is like a PICT (a standard Mac OS format for graphics), and verbs are provided to convert between the two; but a Frontier picture has the additional feature that its text can be calculated by evaluating a UserTalk expression in real time.

This chapter describes UserTalk verbs and techniques for manipulating Frontier pictures.

PICTs and Frontier Pictures

Since a Frontier picture cannot be edited as a graphic within Frontier, a common strategy is to create or edit it as a PICT in some other application, and then import the PICT into the database. It will be imported as a binary (of type 'PICT'); UserTalk provides verbs that convert between a PICT binary and a Frontier picture object.

To convert a PICT binary object to a Frontier picture object:

pict.PICTtoPicture (addrBinaryPICT, addrPicture)

To convert a Frontier picture object to a PICT binary object:

pict.pictureToPICT (addPicture, addrBinaryPICT)

One way to import the PICT is through the clipboard. As we shall see in Chapter 31, Driving the System, Frontier has verbs that move data between the clipboard and an object. So, in another application that works with PICT graphics, we can select and copy a PICT onto the clipboard. Then, in Frontier, the following script will store the clipboard contents into the database as a Frontier picture and display the picture.

Example 28-1 Displaying a copied PICT as a Frontier picture (continued)
local (tempPICT)
clipboard.get('PICT', @tempPICT)
pict.PICTtoPicture (@tempPICT, @workspace.myPicture)
edit (@workspace.myPicture); window.zoom(@workspace.myPicture)

If a file contains a PICT resource, it can be imported using a rez verb; see Chapter 20, Resources. For instance, one might change the second line of Example 28-1 to:

rez.getResource("desire:docs:myFile",'PICT', 1000, @tempPICT)

If an application saves its documents as a PICT in the document file's data fork, the data can be read into Frontier and converted to a Frontier picture; see suites.samples.basicStuff.readPictureFile(). For example, Aldus SuperPaint can save a file in this format.

The verbs pict.PICTtoPicture() and pict.pictureToPICT() are actually utility scripts. They do their work through two other verbs which also convert between a PICT and a Frontier picture, but do not take any parameter saying what Frontier picture to work on - the picture's edit window must already be the "target." (For the target, see Chapter 18, Non-Scalars.)

To convert a PICT binary object to the target Frontier picture object:

pict.setPicture (binaryPICTvalue)

To convert the target Frontier picture object to a PICT binary object:

pict.getPicture (addrBinaryPICT)

Since the target can be a visible window, pict.setPicture() can cause the graphic in a visible Frontier picture edit window to change. There is a flicker, so this would not be a good way to implement animation, but one could conceivably make a crude "slide show" presentation.

Text in Pictures

A PICT can contain text objects. If the text of such a text object begins with an equal sign (=), it can be replaced in the Frontier picture version by evaluating as a UserTalk expression whatever text follows the equal sign and coercing the result to a string. For example, if a PICT contains a text object whose text is =clock.now(), the Frontier picture made from this PICT can display an actual date-time value. Whether this evaluation is performed for any given picture is governed by a boolean associated with the picture.

Moreover, a Frontier picture has associated with it an update interval, which dictates how often its expressions should be automatically re-evaluated. So, if a Frontier picture were made from a PICT which contained a text object whose text is =clock.now(), and the update interval for that picture was one second, then while that picture's edit window was open, the window would contain a counting clock.

To set whether the target Frontier picture object should have its expressions evaluated:

pict.expressions (boolean)

To set the interval at which the target Frontier picture object should have its expressions evaluated:

pict.scheduleUpdate (seconds)

The default value for the update interval, if not explicitly set, is infinity (I believe).

Other Graphic Formats

Frontier itself cannot convert between Frontier picture objects and graphic formats other than PICTs; but there are applications which can convert between PICTs and other graphic formats, and some of these applications are scriptable, so Frontier can drive them (see Chapter 32, Driving Other Applications).

Suppose, for example, we have read a GIF image file into the database, where it becomes a binary. Then it is possible to write a utility script which drives Clip2GIF to convert such a binary to a PICT; the PICT may then be converted to a Frontier picture. I use such a utility in conjunction with Frontier's Web site management facilities; I can store a GIF in the database, and use the utility to display it within Frontier.


TOP UP: Interface NEXT: Import/Export

This is Frontier: The Definitive Guide by Matt Neuburg, unabridged and unaltered from the January 1998 printing.
It deals with the freeware Frontier 4.2.3; for commercial Frontier 8, look here, and for the inexpensive Radio UserLand, look here. See my Web site for information.
Those wishing an offline or printed copy may purchase the book, which is still in print.
Copyright 1998 O'Reilly & Associates, Inc. ALL RIGHTS RESERVED. Reprinted with permission.