home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Sample Code / Newton Sample Code 1.1 / Routing / auxForm-3 / README.AuxForm < prev   
Encoding:
Text File  |  1994-02-28  |  5.1 KB  |  153 lines  |  [TEXT/R*ch]

  1. AuxForm
  2. Copyright © 1993, 1994 by Apple Computer, Inc.  All rights reserved.
  3. by Maurice Sharp
  4.  
  5.  
  6. This sample shows how to add an auxilliary slip to a print or fax slip.
  7. You should use the enclosed proto (myAuxFormat) as a basis for any of
  8. your auxilliary slips.
  9.  
  10. Thanks to John Miller whose question and code formed the start of this
  11.  
  12. A. What is an auxilliary slip?
  13. ------------------------------
  14.  
  15. If you try and print a note item from your Newton and select the Letter
  16. format, you get an auxilliary slip asking for the address of the
  17. person to send things to.
  18.  
  19. In your format specification, there is a slot called auxForm. If you want
  20. an auxilliary slip, you give this a value that is a quoted symbol. That
  21. symbol should correspond to a slot in the rootView that is a frame
  22. for your auxilliary form (see below about how to make these).
  23.  
  24. If you need extra information you can use an auxilliary slip. There are 
  25. also 2 built in auxilliary information slips you can use...
  26.  
  27.  
  28. B. Built in AuxForm slips
  29. -------------------------
  30.  
  31. You have access to 2 build in auxilliary information slips.
  32. You can use them by giving the appropriate value for your auxForm slot:
  33.  
  34. 'addresseeSlip    - get the name and address of a person
  35. 'toSubjectSlip  - get a person and subject (used for a Memo)
  36.  
  37. The slips add extra information to the fields variable that you can
  38. use when you print or fax your information.
  39.  
  40. The addresseeSlip adds these slots:
  41.  
  42.     fields.toName - string of the name of the person
  43.     fields.toFullAddress - full address of the person
  44.     
  45. The toSubjectSlip adds these slots:
  46.  
  47.     fields.toName - string of the name of the person
  48.     fields.title  - title of the Memo
  49.     
  50. NOTE: fields.title is also the title that will show up in the outbox, so
  51.       your code may modify it later. Better check if it still exists!
  52.  
  53.  
  54. C. Building your own auxForm slip
  55. ---------------------------------
  56.  
  57. If none of the system provided auxilliary slips will do, you can always
  58. build your own. It is relatively simple, but there are a few gotchas.
  59.  
  60. 1. Start by building your own user proto template with a protoFloater
  61.    (NOT floatNGo) as your base level form. Give your base level form
  62.    a name using the Template Info command
  63.    
  64. 2. Add a protoStaticText to your auxForm and give the name "explanation"
  65.    using the Template Info command. You MUST call it explanation.
  66.  
  67.    This static text should contain a very brief description of what
  68.    the auxilliary slip is for. No more than about 50 characters.
  69.    
  70.    The proto should be fully justified horizontally, parent top vertical,
  71.    and the text should be centered.
  72.  
  73. 3. Add prototypes etc you will need to get the information you want
  74.    (i.e., layout your form).
  75.  
  76. 4. Add code to jam the information you want in the fields variable.
  77.  
  78.    *MAKE SURE* that you initialize those slots you jam in fields to
  79.    some reasonable default.
  80.  
  81. 5. Add code to *resize* the auxilliary form to the correct place and size
  82.    on the Newton (i.e., just below the print/fax slip)
  83.    
  84.    (see below)
  85.    
  86. 6. Put a symbol in your auxForm slot in your format. The symbol is really
  87.    arbitrary.
  88.    
  89.    something like:
  90.    {
  91.            ...
  92.            auxForm: 'myAuxSlip,
  93.            ...
  94.        }
  95.  
  96. 7. Add code to your application to add the new auxilliary slip to
  97.    the rootView. Make sure the symbol for the slip is the same as the
  98.    symbol you used in step 5.
  99.    
  100.    Since you used a user proto template to create the slip, your code
  101.    to put it in the root view will look something like:
  102.    
  103.    GetRoot().myAuxSlip := BuildContext(pt_myAuxSlipProto) ;
  104.  
  105. 8. Use the new information in your print templates (see other docs on
  106.    building and using print templates)
  107.    
  108.  
  109. D. Resizing Those AuxForm slips
  110. -------------------------------
  111.  
  112. You must make sure that your slip shows up just below the print/fax slip.
  113. You can not rely on the coordinates used in the current product, so you
  114. should base yourself on the slip.
  115.  
  116. See the viewSetupFormScript in the proto included in the sample code
  117. (here it is below...)
  118.  
  119.     viewSetupFormScript:
  120.       func()
  121.       begin
  122.          // adjust viewbounds to be right under the printslip
  123.          // (or faxslip, they both have the same bottom)
  124.          local printBounds := GetRoot().printslip.viewBounds ;
  125.          local myHeight := viewBounds.bottom - viewBounds.top ;
  126.          local newViewbounds := {} ;
  127.       
  128.          newViewBounds.left := printBounds.left ;
  129.          // add 10 to account for frame of this floater and
  130.          // the other floater (i.e., frame size is in addition
  131.          // to viewBounds.
  132.          newViewBounds.top := printBounds.bottom + 10 ;
  133.          newViewBounds.right := printBounds.right ;
  134.          newViewBounds.bottom := newViewBounds.top + myHeight + 10 ;
  135.       
  136.          self.viewBounds := newViewBounds ;
  137.       
  138.       end,
  139.  
  140. E. Accessing Data in AuxForm Slips
  141. ----------------------------------
  142.  
  143. Your auxForm slip will add information to the fields variable that
  144. your own format can use when printing/faxing. In other words,
  145. there will be some script in your auxForm that adds a slot (or slots) to
  146. the fields frame and keeps that slot up to date.
  147.  
  148. To help you do that, the auxForm will get 2 slots added to it:
  149.  
  150.     fields: the fields variable that you can change and look at
  151.     target: the target of the route as set by your application
  152.     
  153.