beautypg.com

Creating a frame format 21 – Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 769

background image

C H A P T E R 2 1

Routing Interface

Using Routing

21-21

The

PrintNextPageScript

method should construct the view for the next page

of data so that the message

self:Dirty()

shows the view. Typically, you do this

by keeping track of what data has been routed so far. When the format receives this
message, you select a new set of child views representing the next page of data to
send. Then you call the view method

RedoChildren

, which closes and then

reopens the child views. This method also causes the transport to send your print
format view the

ViewSetupChildrenScript

message again.

Note that in the

PrintNextPageScript

method, you can also change the

content of child views on the current page. For example, you might want to change
the content of a text field. To do this, use the

SetValue

function to pass in a new

value for the view content, like this:

SetValue(myParagraphView, 'text, newRichString);

When faxing, it’s best not to perform lengthy operations in the

PrintNextPageScript

method, since the connection stays open between

pages. However, this is less time critical than the

ViewDrawScript

method. If

possible, execute lengthy operations in the

FormatInitScript

method, which

is called just once before the connection is opened.

If you need to create any custom shapes to be drawn on the page by the

ViewDrawScript

method, create the shapes in the

FormatInitScript

method. Alternatively, you can create shapes at compile time, if they are static.
Because of fax connection time-out issues, minimize shape creation in the

ViewDrawScript

method, as shape creation takes too much time and the

connection might time out as a result.

Creating a Frame Format

21

You create a frame format by using

protoFrameFormat

. This is the standard

format for routing objects with

'frame

or

'text

data types, such as for beaming

and e-mail. To enable these types of transports for your data, you must register at least
one format based on this proto. Here is an example of a format based on this proto:

MyFrameFormat := {

_proto: protoFrameFormat,

symbol: '|myFrameFormat:SIG|,

title: "No comments",

SetupItem: func(item, targetInfoFrame) begin

local myData := clone(myTargetInfo.target);

RemoveSlot(myData, 'comments); // remove some stuff

item.body := myData;

// this item.body is not a soup entry.

// if it MIGHT be a soup entry, call

// inherited:SetupItem(item, targetInfoFrame)