Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 768

Advertising
background image

C H A P T E R 2 1

Routing Interface

21-20

Using Routing

Then the print format view is closed. Note that the

ViewShowScript

and

ViewDrawScript

messages are not sent to the view. This takes a lot of time

for the transport to determine the number of pages, so if you can, override the

CountPages

method with one of your own.

3. The transport instantiates the print format view and sends it the

ViewSetupFormScript

message. Depending on certain factors, the transport

connection might be made at the beginning of this step or in step 4. You can rely
only on the connection being made sometime after step 2.

4. The transport sends the

ViewSetupChildrenScript

message to the print

format view, then the child views are instantiated (and sent the standard view
messages), and finally the transport sends the

ViewSetupDoneScript

and

ViewShowScript

messages to the view.

5. The transport draws the print format view and sends the

ViewDrawScript

message to the view. Note that each child view on the page is also drawn and sent
the

ViewDrawScript

message, in hierarchical order. The page might be printed

or faxed in “bands” (sections), so this step may repeat several times for the page.

If you need to draw something in your

ViewDrawScript

method, you can call

the view method

GetDrawBox

to determine the band that is currently being

drawn. Then you can draw just those shapes that are necessary for the current
band. The transport does not draw any views or shapes outside the current band.
Any shapes extending outside the current band are automatically clipped.

IMPORTANT

The

ViewDrawScript

message is sent at a time-critical point

in a fax operation. It is imperative that you do as little work as
possible in the

ViewDrawScript

method.

6. The transport sends the

PrintNextPageScript

message to the print format

view. If your print format handles more than a single page of data, you must
define the

PrintNextPageScript

method in your print format. The transport

sends this message each time it reaches the end of a page, to allow you to
construct the next page of data. While there is more data to route, this method
should return a non-

nil

value; in that case, the printing process continues

with the next page at step 4. When there is no more data to route, the

PrintNextPageScript

method should return

nil

; in that case the printing

process ends and the connection is closed.

You set up the child views containing the data for the first page in the

ViewSetupChildrenScript

method of your print format. Typically, you do

this by setting the value of the

stepChildren

array. Don’t forget to call the

inherited method (

inherited:?ViewSetupChildrenScript

) so that the

proto behavior is preserved.

Advertising