
June 1996 Newton Technology Journal
16
The Default Layout
For the default layout in the application, use
newtLayout
,
newtPageLayout
or
newtRollLayout
. For card-flavor applications,
use
newtLayout
. Page and roll applications should use
newtPageLayout
and
newtRollLayout
respectively. This layout
level is where the user will view and edit soup entries. Therefore, the views
which will contain your soup entries will be added to the default layout. For
a
newtLayout
proto, use NTK to draw a
newtEntryView
(see Entry
Views, below) as a child view of this template. For
newtPageLayout
or
newtRollLayout
use a
GetLayout(filename)-style
reference to
an entry view in the layout-level
protoChild
slot, and the system will create
the entry views as needed. If you want some fancy graphics as backdrop for
your entries, or some controls which operate on a soup-wide basis, the
layout layer is an appropriate place for them.
The Overview Layout
There are two different layouts which can be used as overviews:
newtOverLayout
is meant for card-flavor applications, and
newtRollOverLayout
is used for page- or roll-flavor applications. These
overview protos give you a lot for your money. They provide the standard
Newton 2.0 OS overview for the application, complete with scrolling, check
boxes, icons based on
dataDefs
, and the one- or two-line summary of
each entry. In addition, tapping on an item displays the corresponding entry
in the default layout. You can suppress the check boxes, change the
summary, or modify the behavior when an item is tapped. The details of the
newtOverLayout
and
newtRollOverLayout
protos are in the
Newton Programmer’s Guide. But to get standard overview behavior, just
set the
masterSoupSlot
and go.
THE ENTRY LAYER
The entry layer is where an actual soup entry will be represented and
displayed in your application. This is where you can work with individual
soup entries, and display controls which correspond to slots found in all
soup entries for your application. This level and below is where you do most
of the programming needed to customize a NewtApp for different
applications. There are three different entryview protos. For a card-flavor
application use
newtEntryView
, and for page or roll applications, use
newtRollEntryView
. The third type is the
newtFalseEntryView
,
which is used for stationery or slot views in a non-NewtApp-based
application. Although not discussed further here, use of the
newtFalseEntryView
is an important topic, and is detailed in the
Newton Programmer’s Guide.
Since the
entryView
has a one-to-one correspondence with the soup
entry, it is responsible for updating the view from changed soup data and
updating the soup entry. Every entry view has a slot called target which
contains the current soup entry. Anytime you need to write data or get data
from the entry, you can use target to do this. Like the layout level, an entry
view also has a
DoRetarget()
method. You can use this method to
update the entry view if you’ve changed the target.
In addition to updating the view from the target, the entry layer is
responsible for writing view changes back to the target soup entry. Actually,
the changes themselves are made by the individual slot views (see below),
but the changed entry is not written back to the store immediately. Instead,
a call is made to the entry level method
StartFlush()
, which starts an idle
timer. After a few seconds, or whenever you scroll entries, change layouts or
close the application, the changed entry is written back to the store. If you
ever modify an entry directly, and outside of your slot views, be sure to call
StartFlush()
.
There are other entry-level slots besides target which give you a handle
on your current context at runtime. They include
currentDataDef
and
currentViewDef
, which contain the current stationery components
being used in conjunction with the target. The
viewDef
and
dataDef
in
these slots are the templates supplied in your package. At runtime, the
current
viewDef
is instantiated into a “live” view. To get at the actual
runtime views in your
viewDef
, there is a slot called
currentStatView
which contains your instantiated
viewDef
.
You may wish to have a header in your entry view, like the one in the
built-in Notes application. There are two versions of this proto. To include
action and filing buttons on the header, use
newtEntryRollHeader
. For
a simple title and icon header, use
newtEntryPageHeader
. For page-
and roll-style applications, you can control the header by drag-resizing of
entries through the resizable slot in these header protos. In addition to the
headers and any general entry level controls you add to this level, an entry
view can hold individual slot views and the stationery container.
THE STATIONERY LEVEL
Although “stationery” is a term used to collectively describe
viewDefs
and
dataDefs
, in the layers of NewtApp we are concerned with only
viewDefs
. The use of
viewDefs
in NewtApp is very straightforward.
You merely place a
newtStationeryView
inside your entry-level proto.
You do not directly lay out
viewDefs
in your
entryView
. The system
will match up the currently chosen
viewDef
for the
dataDef
which
corresponds to the current soup entry, or target. Designing the
viewDef
itself is much more work than actually using it. If your
entryView
corresponds to a single soup entry with controls that pertain to your soup
entries in general, then a
viewDef
is like a subentry view, displaying the
data from that soup entry which pertains to its
dataDef
class.
If you want to provide multiple views of your data, for example an info
view and a notes view, then all you have to do is create two
viewDefs
which
show the different slots of your entry. So long as you have included a
newtShowStationeryButton
in your application, your users can
easily switch back and forth between the different views. Any
viewDefs
you add to this application via supplemental packages will also be displayed
in the Show picker. Although you can display the contents of any slot in an
entry in any
viewDef
, it is better design to allow
viewDefs
to display
only slots which are created by the
viewDef
’s corresponding
dataDef
.
To display and edit the individual slots in a soup entry,
viewDefs
contain
slot views. For more detailed information on
viewDefs
, see the Newton
Programmer’s Guide.
THE SLOT LEVEL
There are many protos in the NewtApp framework which are used to display
and edit single slots of a soup entry. These are collectively known as slot views,
and share many similarities. There are three basic classes of slot views: plain,
labeled, and miscellaneous. The plain slot views are ones like
newtTextView
or
newtRONumberView
which simply display and
update the value in a soup entry slot. Examples of the labeled slot views include
newtLabelInputLine
,
newtSmartNameView
and
newtLabelPhoneInputLine
. These slots are related to the
protoLabelInputLine
. In addition to the capabilities of the plain slot views,
Kommentare zu diesen Handbüchern