Newton Developer Technical Support Sample Code Checkbook, NewtApp Sample by Bob Ebert, Neil Rhodes, and J. Christopher Bell for Newton Developer Technical Support Copyright © 1995 by Apple Computer, Inc. All rights reserved. You may incorporate this sample code into your applications without restriction. This sample code has been provided "AS IS" and the responsibility for its operation is 100% yours. You are not permitted to modify and redistribute the source as "DTS Sample Code." If you are going to re-distribute the source, we require that you make it clear in the source that the code was descended from Apple-provided sample code, but that you've made changes. This sample illustrates a basic newtApp based application. CheckBase.t is the newtApplication layer. It holds all the slots that tie the application together. In particular, the 'allSoups slot holds the definition of the soup used by this application, along with methods for creating new entries in the soup. Default View.t is the main "check view" layout. It contains the views needed to edit an individual check. It is registered in the 'allLayouts slot of CheckBase.t Overview.t is the overview layout. Most of its work is done in the 'Abstract method, which creates a shape from a given check soup entry. Constants.f defines a few constants used by the application, it is compiled first. PrefsView.t is the preferences view. It contains two checkboxes that add preferences to the applications preference frame. See the accompanying document on adding preferences to a newtApplication base application. Install&Remove Scripts.f defines the install and remove scripts. It is compiled last. Note that all it does is call the install and remove scripts provided by the newtApplication layer. New Button.t implements the "New" button in the status bar. It is very simple, consisting of layout information and a script that calls a method in the base view. protoCheckAllButton implements the "Check All" feature for the overview layout. It toggles the checked state of all items. Use this proto as-is in your own applications. Find is supported almost entirely through the newtApp protos. We provide only two extra bits of information. A 'dateFindSlot in the newtApplication layer tells find where to look in the soup entry for date information, and a 'FindSoupExcerpt method provides a string that summarizes a given entry for the find overview. (Note the similarity between this method and the 'Abstract method of the Overview.t layout.) Beaming, Emailing are supported by referencing a protoFrameFormat- based viewDef in the allViewDefs slot. The newtApp install script will automatically register viewDefs referenced there. Note that for the overview to allow routing, we had to add an overviewTargetClass slot to our newtOverLayout-based layout. Printing is supported with a protoPrintFormat also referenced in the allViewDefs slot. An extra feature in the action menu, "Reconcile", is provided via the 'extraRouteScripts slot in the newtApplication layer. The definition in this frame provides the label, icon, and method. When the items is chosen, the routeScript method simply calls the 'ReconcileChecks method in the newtApplication layer. Both the "New" and "Reconcile" features could be implemented in the scripts in the buttons themselves. Instead, messages are sent to the newtApplication base view so that all the soup/entry-handling code can be kept together. New in version 8 protoCheckAllButton has been updated to match the UI in the Newton OS 2.1, in checkbook-7 it only checked the visible items. In Checkbook-8 it checks all items that can show up in overview, or unchecks them if they are checked. the ViewSetupFormScript has been updated to do "the right thing" on various screen sizes. It uses kMaxWidth, kMaxHeight, kMinWidth, and kMinHeight to produce a view with the correct borders and placement on any screen in any rotation. (If you use this code for your own apps, keep in mind that the placement pretty much relies on using center/center justification, a draggable border, and vClickable set appropriately.)