
June 1996 Newton Technology Journal
14
styles for your application.
Another step before you begin is to sketch out your data structure and
how you want that data to be represented visually. If using stationery, plan it
carefully, and try to encapsulate the data-specific code into your stationery.
Avoid presuming what data your application is displaying, and when
designing stationery, remember that the stationery may be used outside of
your container application. Don’t hard-code references between your
application and your stationery. Instead, use framework-supplied slots and
inheritance to reference one layer from another.
The final thing to remember before building your NewtApp is that most of the
work consists of assembling the protos and setting values in slots. The
framework does the rest. This frees you to create a solid data design which is
represented visually in an easy-to-use manner. To get this functionality, be sure to
call inherited methods in the system-supplied protos when you write your own.
As a final note, be sure to include the required statements in your install
and remove scripts. These magic incantations ensure that your application
will register its stationery and itself for all needed system services.
LAYERS
The NewtApp framework is a collection of layers. From the top down, they
are Application, Layout, Entry, and Slot. If using stationery, it is an additional
layer between Entry and Slot. The Application layer is topmost and is where
the various pieces are plugged together. The Layout layer provides the
overview and default view of your data. The Entry layer is where your
individual soup entries are displayed. The slot views allow the user to view
and edit individual slots in your soup entry. When using stationery, the
stationery layer contains the
viewDefs
for your data, and these
viewDefs
will contain your slot views.
THE APPLICATION LAYER
The NewtApplication proto serves as the base view of your NewtApp. If you
want filing in your application, add a folder tab proto – either
newtFolderTab
or
newtClockFolderTab
. You can also put the
status bar for your application in this base view. The
newtStatusBar
proto contains two slots –
menuLeftButtons
and
menuRightButtons
– where you put the buttons for your status bar.
The buttons will automatically be laid out for you at runtime. If you want
different buttons to be displayed for your overview versus your default view,
NewtApp can handle this too. Create a slot called
statusBarSlot
in your
base view, and in that slot put the declared name of your
newtStatusBar
. In each of your layouts (see Layouts, below) put
menuLeftButtons
and
menuRightButtons
slots. As your
application switches layouts, the appropriate buttons will appear on the
status bar.
Many of the buttons you see in NewtApps are supplied by the system.
With stationery there is a New button which is a
newtNewStationeryButton
, and a Show button which is a
newtShowStationeryButton
. For any NewtApp application, routing
and filing are provided by the
newtActionButton
and the
newtFilingButton
. All of the required behavior is built into these
buttons; you only have to include them in the
menuLeftButtons
and
menuRightButtons
slots where appropriate.
In the
newtApplication
proto, you set a few slots which determine
the application’s behavior for scrolling, finding, and filing. In addition, the
application layer also contains a few key slots to make your application
function. These are
allSoups
,
allLayouts
,
allDataDefs
and
allViewDefs
. Use these slots to customize your NewtApp for the
presentation of your application-specific data.
The allSoups Slot
The
allSoups
slot in the application layer is a frame of frames which
defines the application soup. Each subframe of
allSoups
protos off of the
system’s
newtSoup
proto, and specifies a soup you want to work with in
your application. A simple
allSoups
slot would look like this:
{ appSoup:{_proto: newtSoup,
...}}
When your application is opened, these subframes contain the actual
soups for your application. The required slots of a
newtSoup
are listed in
the Newton Programmer’s Guide, but a few advanced ideas are worth
discussing here.
If you want to provide different soups for your application to work with,
they can be specified here. At runtime (see Layout Level, below) you can
determine which soup you are viewing. You can also use this same
technique to provide different query specifications or sort orders for your
application’s soup. Just put each different one in its own subframe of
allSoups. You should also place any methods which work on your soup in
these frames. If your application requires other soups, for the values in
pickers, or other related information, specify each soup here. These
secondary soups will be created, registered and maintained whenever the
application is open.
Finally, be aware that at runtime these frames are soups and you can add
or remove entries, as well as perform any other soup-related task directly
from these frames. Don’t forget that the application base view cannot be
inherited by methods defined in the
allSoups
frame. Though these slots
are located in the base view, they proto to
newtSoup
, and they are not
children of the base view. If you need to reference the base view from a
method in a
newtSoup
, use
GetRoot().(kAppSymbol)
to get back to
the application base view.
The allLayouts Slot
The two layouts for the application are set up in the
allLayouts
frame.
They are built and instantiated as child views of the base view at runtime.
This is a little different than building an application for Newton 1.x. In some
applications, the basic view of the data and the overview were two different
child views of the application base view, and you would show and hide each
one as needed. Since overview management is a service handled entirely by
NewtApp, you don’t actually declare these layouts to the base view. Just
create a frame with two slots – default and overview – and use
GetLayout
(filename) to specify the NTK layout file to use for each.
Everything else is done for you.
The allDataDefs Slot
If your application uses stationery, this slot is where you specify the
dataDefs
for your application, as well as any other
dataDefs
you may be
registering with the system. These
dataDefs
are installed and registered at
package install time, and are unregistered and removed at package removal
time. This is accomplished through the required call to
NewtInstallScript
in your package’s
InstallScript
. As with allLayouts,
this is a frame of frames. The slot name for each
dataDef
should match the
Kommentare zu diesen Handbüchern