Creating a Simple NewtApp

One of the Newton 2.x OS Q&As
Copyright © 1997 Newton, Inc. All Rights Reserved. Newton, Newton Technology, Newton Works, the Newton, Inc. logo, the Newton Technology logo, the Light Bulb logo and MessagePad are trademarks of Newton, Inc. and may be registered in the U.S.A. and other countries. Windows is a registered trademark of Microsoft Corp. All other trademarks and company names are the intellectual property of their respective owners.


For the most recent version of the Q&As on the World Wide Web, check the URL: http://www.newton-inc.com/dev/techinfo/qa/qa.htm
If you've copied this file locally, click here to go to the main Newton Q&A page.
This document was exported on 7/23/97.


Creating a Simple NewtApp (4/7/97)

Q: What are the basic steps to create a simple NewtApp-based application?

A: The following steps will create a basic NewtApp-based application:

Basic Setup
1) Create a project.
2) In NTK's Project Settings dialog, set Platform to "Newton 2.0" or "Newton 2.1".

Create the NewtApp base view
1) Create a layout file.
2) Drag out a newtApplication.
3) Set the following slots to the following values:
        allLayouts:    {

default: GetLayout("default.t"),
// see step 9 in the next section
overview: GetLayout("Overview.t"),
// set step 4, overview section
}

    allSoups:       {
        mySoup: {
            _proto: newtSoup,
            soupName: "SoupName:SIG",
            soupIndices: [],
            soupQuery: {}  } }
    title: kAppName

4) Draw a newtClockFolderTab or newtFolderTab as a child of the newtApp.
5) Draw a newtStatusBar as a child of the newtApp.
6) For the newtStatusBar set the following slots:
    menuLeftButtons:  [newtInfoButton]
    menuRightButtons: [newtActionButton, newtFilingButton]

7) Save the layout file as "main.t" and add it to the project.

Create the default view:
1) Create another layout file.
2) Draw a newtLayout in the new layout file.
3) Add a viewJustify slot to the newtLayout and set it to parentRelativeFull horizontal and vertical.
4) Set the viewBounds of the newtLayout to:
        {top: 20, // leave room for the folder tab
    bottom: -25,  // leave room for the status bar
    left: 0, 
    right: 0}

5) Draw a newtEntryView as a child of the newtLayout.
6) Add a viewJustify slot and set it to parentRelativeFull horizontal and vertical (necessary only until platform file is updated).
7) Set the viewBounds of the newtEntryView to:
        {top: 0, bottom: 0, right: 0, left: 0};

8) Draw slot views as children of the entry view to display slots from the soup entry.
For example:
a) Draw a newtLabelInputLine as a child of the newtEntryView.
b) Set the following slots:
        label:  "My Label"
        path:   'myTextSlot

c) Draw a newtLabelNumInputLine as a child of the newtEntryView.
d) Set the following slots:
        label:  "Number"
        path:   'myNumberSlot

9) Save the layout file as "default.t" and add it to the project. Move it so that it is compiled before the main layout (use the Process Earlier menu item).

Add Overview support
1) Create another layout file.
2) Draw a newtOverLayout in the new layout file.
3) Add the Abstract slot to the newtOverLayout, for example:
            Abstract := func(item, bbox )
        begin
            local t := item.myTextSlot & ",";
            if item.myNumberSlot then
                t := t && NumberStr(item.myNumberSlot);
            MakeText(t, bbox.left+18, bbox.top,
                bbox.right, bbox.bottom - 18);
        end;

4) Save the layout file as "overview.t" and add it to the project. Move it so that it is compiled before the main layout (use the Process Earlier menu item).

Add InstallScript and RemoveScript
1) Create a text file and add the following to it:
    InstallScript := func(partFrame) begin
    partFrame.removeFrame :=
        (partFrame.theForm):NewtInstallScript(partFrame.theForm);
    end;

    RemoveScript := func(partFrame) begin
         (partFrame.removeFrame):
      NewtRemoveScript(partFrame.removeFrame);
    end;

2) Save the text file and add it to the project.