beautypg.com

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

Page 191

background image

C H A P T E R 5

Stationery

Using Stationery

5-9

The following example uses the constant

kSuperSymbol

as the value of the

superSymbol

slot. It is defined as follows in the

Extend Notes

Definition.f

file:

constant kSuperSymbol := 'notes;// Note's SuperSymbol

Once you have created an NTK layout, named the template

iouDataDef

, and

saved the file under the name

iouDataDef

, you may set the slots of the

iouDataDef

as follows:

Set

name

to

"IOU"

. This shows up in the New button’s picker.

Set

superSymbol

to the constant

kSuperSymbol

. This stationery can

only be used by an application that has a matching value in the

newtApplication

base view’s

superSymbol

slot.

Set

description

to

"An IOU entry"

. This string shows up in the

information box that appears when the user taps the icon on the left side of
the header, as shown in Figure 4-5 (page 4-9).

Set

symbol

to

kDataSymbol

.

Set

version

to

1

. This is an arbitrary stationery version number set at your

discretion.

Remove the

viewBounds

slot; it’s not needed since this object is not a view.

There are a number of methods defined within the

newtStationery

proto that

you should override for your data type.

Defining DataDef Methods

5

The three methods

MakeNewEntry

,

StringExtract

, and

TextScript

are

illustrated in this section. You use the method

MakeNewEntry

to define the soup

entries for your dataDef; the method

StringExtract

is required by NewtApp

overview scripts to return text for display in the overview; and

TextScript

is

called by the routing interface to return a text description of your data.

The

MakeNewEntry

method returns a complete entry frame which will be added

to some (possibly unknown) application soup. You should use

MakeNewEntry

,

instead of the

FillNewEntry

method (which works in conjunction with the

NewtApp framework’s

newtSoup.CreateBlankEntry

), when your stationery

is being defined as an auto part.

The example of

MakeNewEntry

used here defines the constant

kEntryTemplate

as a frame in which to define all the generic parts of the entry.

All the specific parts of the data definition are kept in a nested frame that has the
name of the data class symbol,

kDataSymbol

. By keeping the specific definitions

of your data grouped in a single nested frame and accessible by the class of the
data, you are assuring that your code will be reusable in other applications.