home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-01-31 | 2.8 KB | 86 lines | [TEXT/NTP1] |
- /*
- ** Newton Developer Technical Support Sample Code
- **
- ** Checkbook, a complete NewtApp sample
- **
- ** by Neil Rhodes, Calliope &
- ** Newton Developer Technical Support
- **
- ** Copyright © 1994-6 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.
- */
-
-
- OpenResFile(HOME & "Icons.rsrc");
- DefConst('kReconciledIcon, GetPictAsBits("Reconcile", nil));
- DefConst('kSmallCheckIcon, GetPictAsBits("SmallCheck", nil));
- CloseResFile();
-
- DefConst( 'kPrefsTemplate, {autoDate: nil,
- autoCheckNum: nil});
-
- // Modify these numbers to do testing
- constant kMaxWidth := 320;
- constant kMaxHeight := 320;
-
- constant kMinWidth := 200;
- constant kMinHeight := 200;
-
- // Define data symbols (used for routing)
- constant kCheckClassSym := '|Check:Checkbook:PIETraining|;
- constant kCheckFrameFormatSym := '|FrameFormat:Checkbook:PIETraining|;
- constant kCheckPrintFormatSym := '|ViewFormat:Checkbook:PIETraining|;
-
- // Define a 'routing format' to handle frames (beam, mail, etc)
- // By default, protoFrameFormat handles text also; override 'dataTypes to change that.
- // Register a separate protoPrintFormat (see the allViewDefs slot in the base view)
- // if you want to support print and fax.
- DefConst('kCheckFrameFormat, {
- _proto: protoFrameFormat,
- name: "Check frame Format",
- symbol: kCheckFrameFormatSym,
- TextScript: func(item, target)
- begin
- // ... export text if possible.
- // if format.textScript isn't present but a dataDef is, the datadef's
- // textscript will be used to export the text
-
- local string := "Check" & target.number;
- if target.date then
- string := string && "\nDate" && datentime(target.date);
- if target.payee then
- string := string && "\nto" && target.payee;
- if target.amount then
- string := string && "\n$" & formattednumberstr(target.amount, "%.2f");
-
- if target.reconciled then
- string := string & "\nReconciled";
- else
- string := string & "\nUnreconciled";
-
- if target.memo then
- string := string && "\nMemo: " && target.memo;
-
- string;
- end,
-
- SetupItem: func(item, targetInfo)
- begin
- // set up the routing item if necessary
- inherited:?SetupItem(item, targetInfo);
-
- local string := "Check" && targetInfo.target.number;
- if targetInfo.target.payee then
- string := string && "to" && targetInfo.target.payee;
-
- item.title := string
- end;
-
- });