home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / Newton Platform Info / Newton 2.0 Sample Code / NewtApp / Checkbook-6 / Constants.f < prev    next >
Encoding:
Text File  |  1996-01-31  |  2.8 KB  |  86 lines  |  [TEXT/NTP1]

  1. /*
  2. **      Newton Developer Technical Support Sample Code
  3. **
  4. **      Checkbook, a complete NewtApp sample
  5. **
  6. **      by Neil Rhodes, Calliope &
  7. **          Newton Developer Technical Support
  8. **
  9. **      Copyright © 1994-6 by Apple Computer, Inc.  All rights reserved.
  10. **
  11. **      You may incorporate this sample code into your applications without
  12. **      restriction.  This sample code has been provided "AS IS" and the
  13. **      responsibility for its operation is 100% yours.  You are not
  14. **      permitted to modify and redistribute the source as "DTS Sample Code."
  15. **      If you are going to re-distribute the source, we require that you
  16. **      make it clear in the source that the code was descended from
  17. **      Apple-provided sample code, but that you've made changes.
  18. */
  19.  
  20.  
  21. OpenResFile(HOME & "Icons.rsrc");
  22. DefConst('kReconciledIcon, GetPictAsBits("Reconcile", nil));
  23. DefConst('kSmallCheckIcon, GetPictAsBits("SmallCheck", nil));
  24. CloseResFile();
  25.  
  26. DefConst( 'kPrefsTemplate, {autoDate: nil,
  27.                             autoCheckNum: nil});
  28.  
  29. // Modify these numbers to do testing
  30. constant kMaxWidth := 320;
  31. constant kMaxHeight := 320;
  32.  
  33. constant kMinWidth := 200;
  34. constant kMinHeight := 200;
  35.  
  36. // Define data symbols (used for routing)
  37. constant kCheckClassSym             := '|Check:Checkbook:PIETraining|;
  38. constant kCheckFrameFormatSym         := '|FrameFormat:Checkbook:PIETraining|;
  39. constant kCheckPrintFormatSym         := '|ViewFormat:Checkbook:PIETraining|;
  40.  
  41. // Define a 'routing format' to handle frames (beam, mail, etc)
  42. // By default, protoFrameFormat handles text also; override 'dataTypes to change that.
  43. // Register a separate protoPrintFormat (see the allViewDefs slot in the base view)
  44. // if you want to support print and fax.
  45. DefConst('kCheckFrameFormat, {
  46.     _proto: protoFrameFormat,
  47.     name: "Check frame Format",
  48.     symbol: kCheckFrameFormatSym,
  49.     TextScript: func(item, target)
  50.         begin
  51.             // ... export text if possible.
  52.             // if format.textScript isn't present but a dataDef is, the datadef's
  53.             // textscript will be used to export the text
  54.             
  55.             local string := "Check" & target.number;
  56.             if target.date then
  57.                 string := string && "\nDate" && datentime(target.date);
  58.             if target.payee then
  59.                 string := string && "\nto" && target.payee;
  60.             if target.amount then
  61.                 string := string && "\n$" & formattednumberstr(target.amount, "%.2f");
  62.  
  63.             if target.reconciled then
  64.                 string := string & "\nReconciled";
  65.             else
  66.                 string := string & "\nUnreconciled";
  67.  
  68.             if target.memo then
  69.                 string := string && "\nMemo: " && target.memo;
  70.  
  71.             string;
  72.         end,
  73.         
  74.     SetupItem: func(item, targetInfo)
  75.         begin
  76.             // set up the routing item if necessary
  77.             inherited:?SetupItem(item, targetInfo);
  78.  
  79.             local string := "Check" && targetInfo.target.number;
  80.             if targetInfo.target.payee then
  81.                 string := string && "to" && targetInfo.target.payee;
  82.             
  83.             item.title := string
  84.         end;
  85.         
  86.     });