// Text of project BigPrints written on 5/12/95 at 5:33 PM // Beginning of text file Project Data /* ** Newton Developer Technical Support Sample Code ** ** Big Prints, a 'large text' printing example ** ** by J. Christopher Bell, Newton Developer Technical Support ** ** Copyright © 1994-5 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. */ // declare some useful constants constant kBorderFormat := '|borderFormat:bigPrints:PIEDTS| ; // run at application install time // setup stuff the app may need before it is ever opened // or opened for this restart :-) InstallScript := func(partFrame) begin local myApp := partFrame.theForm ; // put my routing frame in the global routing frame routing.(kAppSymbol) := myApp.myRoutingFrame ; // put my format in the root so it can be found GetRoot().(kBorderFormat) := BuildContext(myApp.myPrintFormat); end; // run when application and/or card with app removed // cleanup routing stuff RemoveScript := func(packageFrame) begin // get rid of entry in global routing frame RemoveSlot(routing, kAppSymbol); // remove my print format RemoveSlot(GetRoot(), kBorderFormat); // End of text file Project Data // Beginning of file LongText // Before Script for "_userproto000" // Created by J. Christopher Bell // ©1993-94 Apple Computer, Inc. All rights reserved. // // NOTE: For this proto to work for your print format, // your base view print format must CONTAIN the following slots: // numPages -- will be set to the number of pages in the document // needed to fit all the text // // textPageHeight -- used to move the actual text view upward // textPrintHeight -- used to set the clipping height properly. _userproto000 := {viewFlags: 33, text: "Text", viewSetupFormScript: func() begin self.viewBounds := :Parent():LocalBox() ; viewLineSpacing := FontHeight(viewFont); print("Font height:"&& viewLineSpacing); local weHaveCoverPage; if fields.hasCoverPage then weHaveCoverPage := 1; else weHaveCoverPage := 0; // if we have a coverpage, the "first" page of text is really the second page. // We only need to check the total print height on the first page. if fields.pageNumber = 1 + weHaveCoverPage then begin print("Height of printable area (height):"&& viewbounds.bottom - viewbounds.top); textTotalHeight := call kSimpleTextHeightFunc with (text, viewbounds.right - viewbounds.left, viewfont); print("Total Text Height = " & textTotalHeight); lines := ceiling(textTotalHeight / viewLineSpacing); print("Number of lines in document:" && lines); // THIS MUST BE DEFINED (YOU CAN SET IT TO NIL) IN THE BASE PRINTFORMAT! TextPageHeight := floor((viewbounds.bottom - viewbounds.top)/ viewLineSpacing) * viewLineSpacing; print("Number of pixels per page:" && textPageHeight); print("Number of lines per page:" && floor(textPageHeight/ viewLineSpacing)); // THIS MUST BE DEFINED (YOU CAN SET IT TO NIL) IN THE BASE PRINTFORMAT! TextPrintHeight := textPageHeight + FontDescent(viewFont); // THIS MUST BE DEFINED (YOU CAN SET IT TO NIL) IN THE BASE PRINTFORMAT! numPages := ceiling(textTotalHeight / textPageHeight); print("Number of pages need to print text:" && numPages); viewbounds.top := 0; viewbounds.bottom := TextPrintHeight; // this is what actually 'clips' the view end; else // for pages 2...numPages begin viewbounds.top := 0; viewbounds.bottom := TextPrintHeight; // this is what actually 'clips' the view end; end, viewFont: {family: 'newYork, size: 12, face: 0};, viewJustify: 0, viewFormat: nil, realFormat: nil, viewClass: 74 }; _view000 := {viewFlags: 1, viewFont: // Set font in the parent view! , viewSetupFormScript: func() begin local weHaveCoverPage; // if we have a coverpage, the "first" page of text is really the second page. if fields.hasCoverPage then weHaveCoverPage := 1; else weHaveCoverPage := 0; viewbounds := :Parent():LocalBox(); viewbounds.top := viewbounds.top - TextPageHeight * (fields.pageNumber - 1 + weHaveCoverPage); viewbounds.bottom := 30000; // make sure we fit! print("Page number:" && fields.pageNumber && " top is:" && viewbounds.top); self.viewFont := :Parent().viewFont; // font is set from parent! self.text := :Parent().text; // text is set from parent! end, viewFormat: 256, viewClass: 81 }; AddStepForm(_userproto000, _view000); constant |layout_LongText| := _userproto000; // End of file LongText // Beginning of file myBorderFormat // Before Script for "main" // Created by J. Christopher Bell // ©1993-94 Apple Computer, Inc. All rights reserved. // nil // this code will be executed before the template is processed main := { printNextPageScript: func() begin // numPages is set in the 'para' paragraph view if fields.pageNumber <= numPages then begin :RedoChildren() ; true ; end else nil ; end, numPages: // required for protoLongText , textPageHeight: // required for protoLongText , TextPrintHeight: // required for protoLongText , debug: "main", _proto: @200 }; _view001 := {text: "Static Text", viewBounds: {top: 0, left: 0, right: 0, bottom: -20}, viewSetupFormScript: func() begin text := fields.myData.data ; end, viewFont: fancyFont18+tsBold, viewJustify: 242, _proto: @218 }; AddStepForm(main, _view001); pageNumber := {text: "Static Text", viewBounds: {top: -20, left: 0, right: 0, bottom: 0}, viewJustify: 8388790, viewSetupFormScript: func() begin text := "Page" && NumberStr(fields.pageNumber) ; end, viewFont: simpleFont18+tsBold, debug: "pageNumber", _proto: @218 }; AddStepForm(main, pageNumber); _view002 := {viewBounds: {left: 20, top: 136, right: 100, bottom: 216}, viewFlags: 1, viewFormat: 288, viewSetupFormScript: func() begin viewbounds := :Parent():Localbox(); viewbounds.top := viewbounds.top + 40; viewbounds.bottom := viewbounds.bottom - 25; end, viewClass: 74 }; AddStepForm(main, _view002); _view003 := { text: "Contents \n \nTips\n - Restoring Type 1 Fonts to Their Original State\n - Tekton Plus RegularSC Prints as Courier From Some Applications\n\nTroubleshooting\n - QuickDraw GX and Memory\n - Printing Problems\n - QuickDraw GX and Application Programs\n - If Your Macintosh Fails to Restart\n - Installing QuickDraw GX with the Power Macintosh Upgrade Card\n - The Tray Mismatch Scaling Option\n - QuickDraw GX with the Vector Imaging System on the Power Macintosh\n\n\nTips\n\nRestoring Type 1 Fonts to Their Original State\n\nIf you remove QuickDraw GX from your system, you need to restore your Type 1 Fonts.To restore Type 1 fonts, follow these steps:\n\n1. Open the System Folder.\n2. Open the Fonts folder.\n3. Drag any suitcases that have been enabled to the Trash.\n4. Open the \u2022\uArchived Type 1 Fonts\u2022\u folder.\n5. Move the contents of the \u2022\uArchived Type 1 Fonts\u2022\u folder to the Fonts folder.\n6. Drag the \u2022\uArchived Type 1 Fonts\u2022\u folder to the Trash.\n\nTekton Plus RegularSC Prints as Courier From Some Applications\n\nIn application programs which do not take advantage of QuickDraw GX, Tekton Plus appears as two fonts: Tekton Plus Regular and Tekton Plus RegularSC. Applications such as Adobe Illustrator, QuarkXPress, and Aldus PageMaker print characters from Tekton Plus RegularSC as Courier on PostScript printers.\n\n\nTroubleshooting\n\nQuickDraw GX and Memory\n\n\u2022\u On a Macintosh with 8 MB of available memory with Macintosh system software version 7.5, QuickDraw GX, and PowerTalk, you can enable only a limited number of printing extensions and desktop printers. More than 7 of each at the same time may cause a low-memory alert to appear. If you want to have more than 7 desktop printers, removing a printing extension will help alleviate memory difficulties and vice-versa. If a low-memory alert does appear, try deactivating printing extensions or removing desktop printers. For more information about desktop printers and printing extensions, see the Macintosh System 7.5 Upgrade Guide.\n\n\u2022\u The presence of several inactive desktop printers (with Xs through the icon) on the desktop or on disks other than the startup disk can cause low-memory alerts to appear. They may also cause your computer to be unable to start up. To solve the problem, hold down the Shift key as you start up your computer. When the computer is ready, drag the inactive desktop printers to the Trash.\n\nPrinting Problems\n\n\u2022\u Occasionally, jobs waiting in a desktop printer queue may not be printed. Be sure to check the status of the document in the desktop printer to ensure it is not on hold. If the status of the document is normal and your document is not printing, restart your Macintosh.\n\n\u2022\u If you set up \u201C\uclient\u201D\u desktop printers (created in Chooser with the Servers pop-up menu), keep these client desktop printer windows closed. Leaving these windows open causes extra network traffic and may cause your system to crash.\n\n\u2022\u Once QuickDraw GX is installed, do not lock the System file. Locking the System file may cause your system to crash, especially if you drag the default desktop printer icon to the Trash.The reason is that QuickDraw GX software stores the name of the default desktop printer (and the name of its Chooser extension) in the System file. To unlock the System file, select the System file's icon, choose Get Info from the File menu, then click the Locked checkbox to remove the X. \n\n\u2022\u Occasionally, your system may not respond when you choose Shut Down while printing. If you choose Shut Down repeatedly, the correct message will appear (asking whether you want to shut down after printing or shut down immediately). If you try to cancel the shutdown at this point, the computer may still shut down. If this happens, no print jobs are lost. The document currently being printed will finish and any other print jobs will show up in the print queue when you start up your computer again. If a print job is on Hold after you start up again, select it and click Resume.\n\nQuickDraw GX\u00A0\uand Application Programs\n\n\u2022\u If possible, do not use the QuickDraw GX Helper (to turn off desktop printing) with WordPerfect. In WordPerfect, when you turn desktop printing off, the third item on the Apple Menu (which corresponds to the first alphabetic item in the Apple Items folder) opens.\n\n\u2022\u In PageMaker version 5.0, documents containing PICTs will print without the PICTs and an extra blank page may be printed at the end of some documents. To print correctly, hold down the Option key when you choose Print from the File menu.\n\n\u2022\u Adobe Illustrator version 5.5 incorrectly installs ATM 3.6.1 alongside ATM 3.7 (ATM GX) when ATM 3.7 is already installed. ATM will not run when two versions of ATM are installed at the same time. To remove ATM 3.6.1 after installing Adobe Illustrator 5.5, follow these steps:\n\n1. Open the System Folder.\n2. Drag the the ~ATM 68020/030/040 file onto your desktop.\n3. Open the Control Panels folder in the System Folder.\n4. Drag the ATM 3.6.1 control panel (named ~ATM\u2122\u) onto your desktop.\n5. Restart your Macintosh.\n6. Drag the ~ATM\u2122\u and ~ATM 68020/030/040 files to the Trash.\n\n\u2022\u To print on a PostScript printer using Insignia Solutions' SoftPC and SoftWindows products, you must turn off desktop printing or use the Epson LQ-2500 output option. To turn off desktop printing, use the QuickDraw GX Helper (one of the QuickDraw GX Utilities). To install the QuickDraw GX Utilities, see the instructions in Chapter 3 (\"Installing QuickDraw GX\") of the Macintosh System 7.5 Upgrade Guide.\n\n\u2022\u You should print documents that use the Al-Nashir Al-Sahafi font (Arabic Design Studio) on raster (non-PostScript) printers. If you try to print an Al-Nashir Al-Sahafi document on a PostScript printers, no document will print. \n\n\u2022\u When you open Adobe Acrobat Reader or Adobe Acrobat Exchange with QuickDraw GX or ATM 3.7 installed, the following message appears: \u201C\uThe ATM Font Database must be installed to use Acrobat. The program will now quit.\u201D\u This error message is displayed (even if the ATM Font Database is present) because ATM 3.7 does not have font substitution capability, which is a requirement for Acrobat products.\n\nIf your Macintosh Fails to Restart\n\nOccasionally, your Macintosh may fail to restart when you choose Restart from the Special menu.\nIf this occurs, follow these steps:\n1. Open the Special menu and choose Restart.\n2. Hold down the Shift key as the computer starts up.\n3. When the computer is ready, open the System Folder.\n4. Open the Preferences folder (inside the System Folder).\n5. Drag the Finder Preferences file from the Preferences folder into the Trash.\n6. Open the Special menu and choose Restart again.\n\nInstalling QuickDraw GX with the Power Macintosh Upgrade Card \n\nWhen you install QuickDraw GX on a Macintosh with the Power Macintosh Upgrade Card, make sure that the upgrade card is enabled before installing QuickDraw GX.\n\nThe Tray Mismatch Alert Scaling Option\n\nThe Tray Mismatch Alert scaling option is not completely implemented for QuickDraw GX 1.0.1. Under certain circumstances, the pages will not be properly scaled even if you select the Scale option. To avoid this problem, format the pages from within the application program to match the output device tray.\n\nQuickDraw GX with the Vector Imaging System on the Power Macintosh\n\nThere is a problem with the Vector Imaging System and Power Macintosh. If you have problems plotting, turn off Modern Memory in the Memory control panel.\n\n\n(8/1/94)\n\n\n\u00A9\u1994 Apple Computer. Inc.\nApple, the Apple logo, AppleShare, LaserWriter, Macintosh, PowerBook, and Macintosh Quadra are trademarks of Apple Computer, Inc., registered in the U.S.A. and other countries. AudioVision, Balloon Help, Macintosh PC Exchange, Power Macintosh,QuickDraw, TrueType, and World Script are trademarks of Apple Computer, Inc. Acrobat, ATM, PostScript, and Adobe Illustrator are trademarkes of Adobe Systems Inc., which may be registered in certain jurisdiction. Optima is a trademark of Linitype-Hell AG and/or its subsidiaries. ITC Eras is a registered trademark of International Typeface Corporation. QuarkXPress is a registered trademark of Quark, Inc. PageMaker is a registered trademark of Aldus Corporation. All other product names are trademarks or registered trademarks of their respective holders. Mention of non-Apple products is for informational purposes and constitutes neither an endorsement nor a recommendation. Apple assumes no responsibility with regard to the selection, performance, or use of these products. \n\n" , viewFont: {family: 'newYork, size: 12, face: 0};, _proto: _userproto000 }; AddStepForm(_view002, _view003); constant |layout_myBorderFormat| := main; // End of file myBorderFormat // Beginning of file main.t // Before Script for "myBase" /* ** Newton Developer Technical Support Sample Code ** ** Big Prints, a 'large text' printing example ** ** by J. Christopher Bell, Newton Developer Technical Support ** ** Copyright © 1994 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. */ myBase := {viewBounds: {left: -4, top: 38, right: 200, bottom: 186}, appSymbol: kAppSymbol, myRoutingFrame: { // very simple routing frame, just doing printing // and faxing // here is the printing stuff, simple yes? print: { title: "Print Text", routeForm: 'printSlip, formats: [kBorderFormat]}, }, SetupRoutingSlip: func(fields) begin // message sent after the user says print or fax // put some information in fields for print, fax // and mail to use. Since fields is available from // print/fax/mail formats, you can add a slot with // relevant info. // NOTE: make the info as small as you can, also // make the info invariant (i.e., do not // just pass a reference to target, since the // the target can change by the time the // print occurs fields.myData := Clone(target) ; // ALSO NOTE: beaming will use the target // slot in your app for the thing beamed. // setup the title that will show in the // outbox item. NOTE: the outbox does not wrap // it will let you overwrite the line below fields.title := title && DateNTime(Time()); end, title: "Big Prints", viewSetupDoneScript: func() begin // setup the routing information // the target data for the route, this would normally be // a cursor Entry. If you want to do mailing, beaming // or 'card moving', ... this MUST be a cursor entry. self.target := {data: ""}; // view that gets the routing messages self.targetView := self ; end, PutAway: func(item) begin // This is the place where you could get wild and move the information // into soups, other apps, and otherwise extract the information. print(item); end, myTextScript: func(fields, target) begin target.data ; // returns the text that will be put into a mail message end, myPrintFormat: { // format for this application. An application can // have more than one format if it wants. // title that shows up in the Format picker // in the print or fax slip title: "Using protoLongText", // this could be a symbol for an auxilliary // information slip. See the auxForm sample code auxForm: nil, // symbol for a script that is called by // mail for a text only message to send textScript: 'myTextScript, // true if the user can attach a real // frame to the mail attachment: true, // a proto to get a coverPage for free! _proto: ROM_coverPageFormat, // the main format used for each page of // a print or fax output. mainFormat: GetLayout("myBorderFormat"), }, debug: "myBase", _proto: @157 }; theLine := {viewBounds: {left: 8, top: 32, right: 200, bottom: 120}, viewChangedScript: func(slot, view) begin if (slot = 'text) then target.data := text ; end, debug: "theLine", _proto: @185 }; AddStepForm(myBase, theLine); StepDeclare(myBase, theLine, 'theLine); _view004 := {viewJustify: 166, viewBounds: {top: -16, left: -42, right: -25, bottom: -3}, _proto: @209 }; AddStepForm(myBase, _view004); constant |layout_main.t| := myBase; // End of file main.t