beautypg.com

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

Page 766

background image

C H A P T E R 2 1

Routing Interface

21-18

Using Routing

Creating a Print Format

21

You create a print format by using

protoPrintFormat

. This proto is required

for routing formats with a

'view

data type, such as views that you would print or

fax. This proto format is actually a view template, which displays the target object
visually. The data to be displayed is laid out as child views of the

protoPrintFormat

view.

Here is an example of a format based on this proto:

// in NTK you create a new layout for view formats

MyPrintFormat := {

_proto: protoPrintFormat,

symbol: '|myPrintFormat:SIG|,

title: "PrintIt",

ViewSetupChildrenScript: func() begin

// construct child views for first page here

end,

PrintNextPageScript: func() begin

nil;

// construct child views for next page here

end,

};

For more information about the slots and methods provided by this proto, see
“Routing Format Protos” (page 18-9) in Newton Programmer’s Reference.

Topics unique to

protoPrintFormat

are discussed in the following subsections.

Page Layout

21

The view based on the

protoPrintFormat

proto is automatically sized (in the

ViewSetupFormScript

method) to fit the dimensions of a page on the output

device to which it is being routed. Do not change the values of the

viewBounds

or

viewJustify

slots in the print format view.

You can increase the margins used on the page by setting the

margins

slot. Set

this slot to a bounds rectangle frame, like this:

{left: 25, top: 20, right: 25, bottom: 30}

Each slot in this frame is interpreted as an inset from each edge of the printable
area of the paper in pixels. You must specify only non-negative values, to make
sure that you don’t print off the page. The default value of the

margins

slot is

{left:0, top:0, right:0, bottom:0}

.

Also, you can control the orientation of the data on the paper by setting the

orientation

slot. Specify a symbol indicating whether to use the paper vertically