// Copyright 1994 Apple Computer, Inc. All rights reserved. // by J. Christopher Bell, Newton DTS DefConst ('kAppSymbol, '|AutoRoute:PIEDTS|); DefConst ('kPrintFormat, '|borderFormat:AutoRoute:PIEDTS|); DefConst ('kOtherPrintFormat, '|otherPrintFormat:AutoRoute:PIEDTS|); // run at application install time // setup stuff the app may need before it is ever opened 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().(kPrintFormat) := BuildContext(myApp.myPrintFormat); // put my other format in the root so it can be found GetRoot().(kOtherPrintFormat) := BuildContext(myApp.otherPrintFormat); 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(), kPrintFormat); // remove my print format RemoveSlot(GetRoot(), kOtherPrintFormat); end; // ---- End Project Data ---- // ---- Beginning of Print templates ---- // ---- File myPrintFormat ---- // Before Script for "printFormat_myPrintFormat" // Copyright 1994 Apple Computer, Inc. All rights reserved. printFormat_myPrintFormat := { printNextPageScript: func() begin // only print one page // returning nil means there are no other pages nil; end, _proto: protoPrintFormat, debug: "printFormat_myPrintFormat" }; _view000 := /* child of printFormat_myPrintFormat */ {viewFlags: 33, viewFormat: 593, viewBounds: {left: 0, top: 0, right: 0, bottom: 0}, viewSetupFormScript: func() begin self.viewBounds := :Parent():LocalBox() ; self.viewBounds.left := self.viewBounds.left + 2 ; self.viewBounds.right := self.viewBounds.right - 2 ; self.viewBounds.top := self.viewBounds.top + 2 ; self.viewBounds.bottom := self.viewBounds.bottom - 2 ; end, viewclass: 74 }; _view001 := /* child of _view000 */ {text: "AutoRoute!......Custom text sent from a Newton far far away...", viewBounds: {top: 30, left: 2, right: -2, bottom: 50}, viewJustify: 50, _proto: protoStaticText }; _view002 := /* child of _view000 */ {text: "Static Text", viewBounds: {top: 300, left: 2, right: -2, bottom: 350}, viewSetupFormScript: func() begin // Change our appearance based on the routing data SetValue(self, 'text, fields.body.text); end, viewJustify: 50, viewFormat: 336, _proto: protoStaticText }; // ---- File otherPrintFormat ---- // Before Script for "printFormat_otherPrintFormat" // Copyright 1994 Apple Computer, Inc. All rights reserved. printFormat_otherPrintFormat := { printNextPageScript: func() begin // only print one page nil; end, _proto: protoPrintFormat, debug: "printFormat_otherPrintFormat" }; _view003 := /* child of printFormat_otherPrintFormat */ {viewFlags: 33, viewFormat: 593, viewBounds: {left: 0, top: 0, right: 0, bottom: 0}, viewSetupFormScript: func() begin self.viewBounds := :Parent():LocalBox() ; self.viewBounds.left := self.viewBounds.left + 2 ; self.viewBounds.right := self.viewBounds.right - 2 ; self.viewBounds.top := self.viewBounds.top + 2 ; self.viewBounds.bottom := self.viewBounds.bottom - 2 ; end, viewclass: 74 }; _view004 := /* child of _view003 */ { text: "This was done using the other printformat!\nAutoRoute!......Custom text sent from a Newton far far away..." , viewBounds: {top: 30, left: 2, right: -2, bottom: 50}, viewJustify: 50, _proto: protoStaticText }; _view005 := /* child of _view003 */ {text: "Static Text", viewBounds: {top: 300, left: 2, right: -2, bottom: 350}, viewSetupFormScript: func() begin // Change our appearance based on the routing data SetValue(self, 'text, fields.body.text); end, viewJustify: 50, viewFormat: 336, _proto: protoStaticText }; // ---- End of Print templates ---- // ---- File AutoRoute.t ---- // Before Script for "myapp" // Copyright 1994 Apple Computer, Inc. All rights reserved. myapp := { 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. // Note that when you use the auto-email function to send mail, you // must have "self" have a slot called appSymbol so that the mail function // can insert your appsymbol in the outbox item. When the Newton receives // an item which it wants to 'put away', it uses that symbol to actually // know which application to send the item. print("Received the following item:"); print(item); if not GetView(self) then self:Open(); SetValue(para, 'text, item.body.text); end, myCustomText: nil, myRoutingFrame: { // very simple routing frame, just doing printing // and faxing // here is the printing stuff, simple yes? print: { title: "Print Thing", routeForm: 'printSlip, formats: [kPrintFormat, kOtherPrintFormat]}, // and here is the fax stuff fax: { title: "Fax", routeForm: 'faxSlip, formats: [kPrintFormat, kOtherPrintFormat]}, mail: { title: "Mail", routeForm: 'mailSlip, formats: [kPrintFormat, kOtherPrintFormat]}, zap: { title: "Beam", routeForm: 'zapSlip}, }, viewFormat: 83951953, target: "UNUSED TARGET!", hideIOBox: nil, AutoFax: func(sendNow, hideIOBox) begin local myItem, subject; // Do our private setup of 'fields' information. This includes // the phone number to use and the data to send. :SetupMyData(); subject := EnsureInternal("AutoRoute AutoFax: ") && DateNTime(time()); myItem := {connect: sendNow, hidden: hideIOBox, appSymbol: appSymbol, phonenumber: myCustomFrame.toPhone, tophone: "Number to display", title: subject, body: myCustomFrame.myData, name: myCustomFrame.name, printerformat: currentPrintFormat}; call kSendFunc with ('fax, myItem); end, myTextScript: func(fields, target) begin // fields.data ; // returns the text that will be put into a mail message EnsureInternal("This is my text returned by the TextScript!"); end, viewBounds: {left: -1, top: 3, right: 233, bottom: 326}, otherPrintFormat: { // The print 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: "Other Format", // 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, // The proto must be set to this for all printing and faxing behavior // Note that the actual "cover page" for faxes is controlled by a slot // within the routing 'fields' frame. _proto: ROM_coverPageFormat, // the main format used for each page of a print or fax output. // Note that printFormat_myPrintFormat is what NTK will call our // printFormat which has the name myPrintFormat. mainFormat: printFormat_otherPrintFormat, }, SetTemporaryPrinterChoice: func(theChoice) begin currentPrinterSetting := theChoice; end, myPrintFormat: { // The print format for this application. // An application can ave more than one format if it wants. // title that shows up in the Format picker // in the print or fax slip title: "AutoRoute Format", // 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, // The proto must be set to this for all printing and faxing behavior // Note that the actual "cover page" for faxes is controlled by a slot // within the routing 'fields' frame. _proto: ROM_coverPageFormat, // the main format used for each page of a print or fax output. // Note that printFormat_myPrintFormat is what NTK will call our // printFormat which has the name myPrintFormat. mainFormat: printFormat_myPrintFormat, }, _proto: protoApp, myCustomFrame: nil, appSymbol: kAppSymbol, title: "AutoRoute", AutoBeam: func(sendNow, hideIOBox) begin local myItem, subject; subject := EnsureInternal("AutoRoute AutoBeam: ") && DateNTime(time()); // Do our private setup of 'fields' information. This includes // the phone number to use and the data to send. :SetupMyData(); myItem := {connect: sendNow, hidden: hideIOBox, body: myCustomFrame.myData, appSymbol: appSymbol, title: subject }; call kSendFunc with ('beam, myItem); end, SetupMyData: func() begin constant kMyVersionNum := 1; myCustomText := para.text; // since a paragraphView could have 'nil' as its text slot... if not myCustomText then myCustomText := ""; local faxNum := getroot():MungePhone(userconfiguration.faxPhone, userconfiguration.country); // usually, most of these slots will represent the OTHER person's information but we fill // these slots with your own information so that you probably do not have to change any code // to fax or email using this sample. myCustomFrame := TotalClone({toPhone: faxNum, email: userconfiguration.mailAccount, name: "Destination Name/Company", myData: {text: myCustomText, timeStamp: time(), myAppVersion: kMyVersionNum} }); end, currentPrinterSetting: nil, viewSetupFormScript: func() begin local b := GetAppParams(); constant kMaxWidth := 240; constant kMaxHeight := 336; viewBounds := RelBounds(b.appAreaLeft, b.appAreaTop, Min(b.appAreaWidth, kMaxWidth), Min(b.appAreaHeight, kMaxHeight) ); currentPrinterSetting := call kGetUserConfigFunc with ('currentPrinter); currentPrintFormat := kPrintFormat ; end, AutoPrint: func(sendNow, hideIOBox) begin local myItem, subject; :SetupMyData(); subject := EnsureInternal("AutoRoute AutoPrint: ") && DateNTime(time()); myItem := {connect: sendNow, hidden: hideIOBox, appSymbol: appSymbol, body: myCustomFrame.myData, title: subject, printerformat: currentPrintFormat, printer: currentPrinterSetting}; call kSendFunc with ('print, myItem); end, currentPrintFormat: nil, debug: "myapp", AutoEmail: func(sendNow, hideIOBox) begin local subject, myItem; // Do our setup of our custom data for our application :SetupMyData(); subject := EnsureInternal("AutoEmail: " & DateNTime(time())); myItem := {connect: sendNow, hidden: hideIOBox, email: myCustomFrame.email, title: subject, text: myCustomFrame.myData.text, appSymbol: appSymbol, body: myCustomFrame.myData}; call kSendFunc with ('mail, myItem); end, GetTemporaryPrinterChoice: func() begin currentPrinterSetting; end, sendNow: nil }; fax := /* child of myapp */ {text: "Auto-Fax", buttonClickScript: func() begin :AutoFax(sendNow, hideIOBox); end, viewBounds: {left: 0, top: 78, right: 150, bottom: 98}, viewJustify: 8388630, _proto: protoTextButton, debug: "fax" }; print := /* child of myapp */ {text: "Auto-Print", buttonClickScript: func() begin :AutoPrint(sendNow, hideIOBox); end, viewBounds: {left: 0, top: 108, right: 150, bottom: 128}, viewJustify: 8388630, _proto: protoTextButton, debug: "print" }; email := /* child of myapp */ {text: "Auto-Email", buttonClickScript: func() begin :AutoEmail(sendNow, hideIOBox); end, viewBounds: {left: 0, top: 138, right: 150, bottom: 158}, viewJustify: 8388630, _proto: protoTextButton, debug: "email" }; beam := /* child of myapp */ {text: "Auto-Beam", buttonClickScript: func() begin :AutoBeam(sendNow, hideIOBox); end, viewBounds: {left: 0, top: 168, right: 150, bottom: 188}, viewJustify: 8388630, _proto: protoTextButton, debug: "beam" }; para := /* child of myapp */ {viewFlags: 7681, viewFormat: 12625, viewlinespacing: 20, viewFont: 18434, viewBounds: {left: 14, top: 15, right: -6, bottom: 70}, viewJustify: 48, viewclass: 81, debug: "para" }; // View para is declared to myapp send now? := /* child of myapp */ {text: "Send/connect now", viewBounds: {left: -32, top: 195, right: 69, bottom: 214}, valueChanged: func() begin sendNow := viewValue; end, buttonValue: true, viewJustify: 8388628, viewValue: true, viewSetupDoneScript: func() begin :valueChanged(); inherited:?viewSetupDoneScript(); end, _proto: protoCheckbox, debug: "send now?" }; hide iobox? := /* child of myapp */ {text: "Hide outbox", viewBounds: {left: -32, top: 214, right: 69, bottom: 232}, valueChanged: func() begin hideIOBox := viewValue; end, buttonValue: true, viewJustify: 8388628, viewValue: nil, viewSetupDoneScript: func() begin :valueChanged(); inherited:?viewSetupDoneScript(); end, _proto: protoCheckbox, debug: "hide iobox?" }; _view006 := /* child of myapp */ {text: " ", viewBounds: {left: 139, top: 197, right: 207, bottom: 213}, viewJustify: 8388610, possibleStrings: ["(i/o is busy)", "(idle)"], viewIdleScript: func() begin local index := (if iobusy then 0 else 1); // check the global iobusy variable SetValue(self, 'text, possibleStrings[index]); // This should return the number of milliseconds to delay. NIL if no more idling. 1000; // Check only once a second. // If you check too often, you will run down the battery end, viewSetupDoneScript: func() begin :SetupIdle(1); // after only 1 millisecond, start display end, _proto: protoStaticText }; toPrinter := /* child of myapp */ {text: " ", viewBounds: {left: 87, top: 250, right: 234, bottom: 270}, viewSetupDoneScript: func() begin :SetupIdle(1); // after only 1 millisecond, start display end, viewJustify: 8388610, viewIdleScript: func() begin local name := call kGetPrinterNameFunc with (currentPrinterSetting); SetValue(self, 'text, name); // This should return the number of milliseconds to delay. NIL if no more idling. 1000; // Check only once a second. // If you check too often, you will run down the battery end, _proto: protoStaticText, debug: "toPrinter" }; // View toPrinter is declared to myapp currentPrinter := /* child of myapp */ {text: " ", viewBounds: {left: 19, top: 291, right: 225, bottom: 307}, viewSetupDoneScript: func() begin :SetupIdle(1); // after only 1 millisecond, start display end, viewJustify: 8388610, viewIdleScript: func() begin local printerFrame := call kGetUserConfigFunc with ('currentPrinter); local name := call kGetPrinterNameFunc with (printerFrame); SetValue(self, 'text, "(default:" & name & ")"); // This should return the number of milliseconds to delay. NIL if no more idling. 1000; // Check only once a second. // If you check too often, you will run down the battery end, _proto: protoStaticText, debug: "currentPrinter" }; // View currentPrinter is declared to myapp _view007 := /* child of myapp */ {text: "ChangePrinter", buttonClickScript: func() begin printchooser:Open(); end, viewBounds: {top: 252, left: 2, right: 82, bottom: 269}, _proto: protoTextButton }; // ---- File myChooser ---- // Before Script for "printchooser" // Copyright 1994 Apple Computer, Inc. All rights reserved. printchooser := /* child of myapp */ {viewFlags: 512, viewBounds: {left: 10, top: -27, right: -10, bottom: 39}, viewJustify: 112, declareSelf: 'base, viewFormat: 50398705, viewclass: 74, debug: "printchooser" }; // View printchooser is declared to myapp _view008 := /* child of printchooser */ {_proto: protoClosebox}; _view009 := /* child of printchooser */ {viewBounds: {left: 8, top: 14, right: 208, bottom: 46}, viewSetupFormScript: func() begin local toDisplay; //breakloop(); if GetTemporaryPrinterChoice exists then begin // if usedCustomChoice is true, this chooser will // not permanently change userconfiguration.currentPrinter usedCustomChoice := true; originalPrinter := call kGetUserConfigFunc with ('currentPrinter); toDisplay := :GetTemporaryPrinterChoice(); call kSetUserConfigFunc with ('currentPrinter, toDisplay); end; else usedCustomChoice := nil; inherited:?viewSetupFormScript(); end, usedCustomChoice: nil, viewQuitScript: func() begin local theChoice; if usedCustomChoice then begin // assume we need to let someone know what choice was made theChoice := call kGetUserConfigFunc with ('currentPrinter); :SetTemporaryPrinterChoice(theChoice); // restore the current printer to the original choice call kSetUserConfigFunc with ('currentPrinter, originalPrinter); end; // make sure any changes to the user configuration are saved! call kFlushUserConfigFunc with (); inherited:?viewQuitScript(); end, originalPrinter: nil, _proto: protoLabelPicker }; // After Script for "_view009" thisView := _view009; // Turn this into a real printer chooser button from the ROM thisView._proto := ROM_printerchooserbutton ; // ---- Back in File AutoRoute.t ---- alternate format := /* child of myapp */ {text: "Use Other Print Format", viewBounds: {left: -20, top: 232, right: 106, bottom: 250}, valueChanged: func() begin if viewValue then currentPrintFormat := kOtherPrintFormat ; else currentPrintFormat := kPrintFormat ; end, buttonValue: true, viewJustify: 8388628, viewValue: nil, viewSetupDoneScript: func() begin :valueChanged(); inherited:?viewSetupDoneScript(); end, _proto: protoCheckbox, debug: "alternate format" }; // ---- Beginning of section for non used Layout files ---- // End of output