Print/Fax Style
1. Define a constant for the symbol of the new viewDef in "Constants":
constant kBookDataDefSym := '|Book:Bookstore:Calliope|; constant kBookEditorViewDefSym := 'default; constant kBookPrintViewDefSym := 'print; constant kSuperSymbol := kAppSymbol;2. Create a new layout and draw within it a protoPrintFormat. Edit the protoPrintFormat's
symbol
slot to refer to the new symbol:
kBookPrintViewDefSymThe protoPrintFormat's
printNextPageScript
doesn't need to change, since it already signifies that only one page will be printed:
func() begin nil; // no more pages endWithin the protoPrintFormat, we'll have a header which displays the application name and print time, and then we'll display each of the slots.
3. To create the header, draw a protoStaticText at the top left of the protoPrintFormat. Add a viewSetupFormScript
to set the header text:
func() begin inherited:?viewSetupFormScript(); self.text := kAppName && DateNTime(Time()); end;Do you remember the slot layer protos we used in the editor viewDef? They are just what we need here in the print format.
4. Copy the five slot layer protos that are children of the clView in "BookEditorViewDef.t" and paste them as children of the protoPrintFormat.
5. Save the layout as "BookPrintViewDef.t" and add it to the project. Rearrange the order so it is processed before "Main.t".
6. Edit the allViewDefs
slot of the newtApplication template so that the new viewDef will be registered:
f := {}; f.(kBookDataDefSym).(kBookEditorViewDefSym) := GetLayout("BookEditorViewDef.t"); f.(kBookDataDefSym).protoFrameFormat := protoFrameFormat; f.(kBookDataDefSym).(kBookPrintViewDefSym) := GetLayout("BookPrintViewDef.t"); f;FIGURE 12.11 shows the result of doing a Print Preview.
An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.
Last modified: 1 DEC 1996