// Text of project Extend Notes Project written on 5/9/97 at 2:49 PM // Beginning of text file Extend Notes Definitions.f // Copyright ©1995 Apple Computer, Inc. All rights reserved. // App stuff constant kSuperSymbol := 'notes; // paperRoll's SuperSymbol constant kDataSymbol := '|IOU:PIEDTS|; // our dataDef Symbol // constant kData2Symbol := '|UOMe:PIEDTS|; // example of a 2nd data def symbol DefConst('kFrameFormat, { _proto: protoFrameFormat, symbol: 'IOUFrameFormat, title: "IOU Frame Format"}); // End of text file Extend Notes Definitions.f // Beginning of file myNewtLabelInputLine // Before Script for myNewtLabelInputLine /* ** Newton Developer Technical Support Sample Code ** ** WhoOwesWhom, a Stationery Example ** ** by Bob Ebert & Greg Christie, Newton Developer Technical Support ** ** Copyright © 1995 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. ** ** newtFooView -- Do It Yourself simple labeled slotView sample. Gregory N. Christie ** This is intended to illustrate how to create a proto which works with the ** newtApp set of protos, but which is built entirely from standard (that is, ** non-newtApp) parts. */ myNewtLabelInputLine := {viewBounds: {left: 0, top: 8, right: 0, bottom: 32}, viewJustify: 9728, path: nil // pathExpr defining where this view should get it's data // from and where it should update to. , TargetData: // Does the actual work of updating this view. func() begin if target AND path then Clone(target.(path)) else defaultValue; end, Retarget: // when called, updates this view from the entry. func() begin inReTarget := true; SetValue(self.entryLine, 'text, :TargetData()); inReTarget := nil; end, viewLineSpacing: 25, jamSlot: nil // Should this view be Jammed? nil for no, otherwise this slot contains // a pathExpr defining where the jammed info should be gotten from. // akin to path but for the foreign entry. , JamFromEntry: // Used when this entry is "Jammed" by a foreign entry. // Execution controlled by JamSlot func( otherEntry ) begin if jamSlot then begin target.(path) := nil; if otherEntry then target.(path) := otherEntry.(jamSlot); end; end;, defaultValue: "" // if target.(path) = nil, then use this value See :TargetData(). , textChanged: func() begin if NOT inReTarget then begin target.(path) := Clone(self.text); :StartFlush(); end; end, inReTarget: nil // used to block a viewChangedScript/SetValue loop , viewSetupDoneScript: func() begin SetValue(self.entryLine,'text, :TargetData()); end, debug: "myNewtLabelInputLine", _proto: @189 /* protoLabelInputLine */ }; constant |layout_myNewtLabelInputLine| := myNewtLabelInputLine; // End of file myNewtLabelInputLine // Beginning of file iouDataDef // Before Script for iouDataDef // Copyright © 1995 by Apple Computer, Inc. All Rights Reserved. iouDataDef := {symbol: kDataSymbol, name: "IOU" // Shows up in "New" button. , description: "An IOU Entry" // shows up in "info" slip when you tap in the newtEntryHeader bar , icon: GetPictAsBits("overviewIcon", true), superSymbol: kSuperSymbol, StringExtract: // Called by overview to get a text description of the data. func(item, numLines) begin if numLines = 1 then return item.title else return item.title && item.(kDataSymbol).who; end, TextScript: // used by text transports (for example, email) to get a text version of the entire entry // differs from StringExtract in that this returns the whole thing as text. func(item, target) begin item.text := "IOU\n" & target.(kDataSymbol).who && "owes me" && NumberStr(target.(kDataSymbol).howMuch); end, version: 1, height: 176, FillNewEntry: // takes a new entry "shell" and fills it with class-specific data // We recommend that the data-def specific data be kept in a sub-frame in the // entry. (This provides a nice abstraction layer which may come in handy when // using the dataDef with other applications, or updating generic data.) func(theNewEntry) begin constant kOneWeekInSeconds := 7*1440; // number of seconds in one week constant kDataTemplate := '{ who: nil, phone: nil, howMuch: 0, dueDate: nil, risk: "Dunno", notes: nil, }; theNewEntry.(kDataSymbol) := Clone(kDataTemplate); theNewEntry.(kDataSymbol).dueDate := time()+(kOneWeekInSeconds); // Give 'em a week to pay theNewEntry.class := theNewEntry.viewStationery := kDataSymbol; theNewEntry.title := ShortDate(time()); theNewEntry; end, MakeNewEntry: // If the newtApp opening this has no CreateBlankEntry method for the newtSoup, // then this method will be called. So create a "minimal" soup entry for the // otherwise-generic application. (Just use FillNewEntry on an empty frame...) func() begin :FillNewEntry({}); // † end; // †to the first time reader: // * MakeNewEntry is sent as a message to the datadef, so :FillNewEntry calls // the right function. // * We pass the empty frame because FillNewEntry needs a frame to fill, and the // dataDef can provide no other information. // * FillNewEntry evaluates to the newly filled entry, which will be the return value // from this method. , debug: "iouDataDef", _proto: @451 /* newtStationery */ }; constant |layout_iouDataDef| := iouDataDef; // End of file iouDataDef // Beginning of file iouDefaultViewDef // Before Script for iouDefaultViewDef // Copyright © 1995 by Apple Computer, Inc. All Rights Reserved. iouDefaultViewDef := {viewBounds: {left: 0, top: 0, right: 0, bottom: 0}, viewFlags: 1, viewFormat: 1, viewJustify: 240, name: "IOU Info" // Appears in the "Show" button , symbol: 'default // one viewDef *must* be the 'default , type: 'editor // 'viewer, 'editor, 'printFormat are standards, but you can extend the types , viewDefHeight: 176 // each slotView is 8+34 high, add 8 border at bottom // this slot is not used for card flavor of newtApplications , protection: 'private // show this only in this app. For instance, DONT show it in IOBox , debug: "iouDefaultViewDef", viewClass: 74 /* clView */ }; who := {viewBounds: {left: 8, top: 0, right: -8, bottom: 32}, path: [pathExpr: kDataSymbol, 'who] // where to look in a soup entry for this data , label: "Who:", usePopup: "nil", viewJustify: 8240, debug: "who", _proto: @427 /* newtSmartNameView */ }; AddStepForm(iouDefaultViewDef, who); iouDefaultViewDef_v425_0 := {path: [pathExpr: kDataSymbol, 'phone], label: "Phone:", viewJustify: 8240, viewBounds: {left: 8, top: 0, right: -8, bottom: 32}, _proto: @425 /* newtLabelPhoneInputLine */ }; AddStepForm(iouDefaultViewDef, iouDefaultViewDef_v425_0); how much := {viewBounds: {left: 8, top: 0, right: -8, bottom: 32}, path: [pathExpr: kDataSymbol, 'howMuch], label: "How Much:", viewJustify: 8240, JamFromEntry: // Used when this entry is "Jammed" by a foreign entry. // This "do-nothing" script will prevent a foreign entry from overwriting this slot. func(otherEntry) begin nil; end, debug: "how much", _proto: @423 /* newtLabelNumInputLine */ }; AddStepForm(iouDefaultViewDef, how much); date due := {viewBounds: {left: 8, top: 0, right: -8, bottom: 32}, path: [pathExpr: kDataSymbol, 'dueDate], label: "Date Due:", viewJustify: 8240, JamFromEntry: // Used when this entry is "Jammed" by a foreign entry. // This "do-nothing" script will prevent a foreign entry from overwriting this slot. func(otherEntry) begin nil; end, debug: "date due", _proto: @424 /* newtLabelDateInputLine */ }; AddStepForm(iouDefaultViewDef, date due); iouDefaultViewDef_v0_4 := {viewBounds: {left: 8, top: 0, right: -8, bottom: 32}, viewJustify: 8240, path: [pathExpr: kDataSymbol, 'risk] // pathExpr defining where this view should get it's data // from and where it should update to. , labelCommands: ["Dunno", "Trustworthy","DeadBeat"], label: "Risk:", _proto: myNewtLabelInputLine }; AddStepForm(iouDefaultViewDef, iouDefaultViewDef_v0_4); constant |layout_iouDefaultViewDef| := iouDefaultViewDef; // End of file iouDefaultViewDef // Beginning of file iouPrintFormat // Before Script for _v200_0 // Copyright ©1995 Apple Computer, Inc. All rights reserved. _v200_0 := { printNextPageScript: func() begin nil; // Retrun nil to indicate 'only print one page' end, title: "IOU", symbol: 'iouPrintFormat, _proto: @200 /* protoPrintFormat */ }; _v200_0_v81_0 := {viewBounds: {top: 30, left: 30, right: -30, bottom: -30}, viewFlags: 1, viewFont: tsFancy + tsSize(18) + tsBold, text: "\"\"", fluff: "^0 owes me ^1, payable at exactly ^2.", viewJustify: 8434, viewSetupFormScript: func() begin local theName := "Nobody"; if target.(kDataSymbol).who then theName := target.(kDataSymbol).who; local theAmount := "nothing"; if target.(kDataSymbol).howMuch then theAmount := "$"&& FormattedNumberStr(target.(kDataSymbol).howMuch,"%.2f"); local theDue := "never"; if target.(kDataSymbol).dueDate then theDue := DateNTime(target.(kDataSymbol).dueDate); text := ParamStr(fluff,[theName,theAmount,theDue]); end, viewClass: 81 /* clParagraphView */ }; AddStepForm(_v200_0, _v200_0_v81_0); constant |layout_iouPrintFormat| := _v200_0; // End of file iouPrintFormat // Beginning of text file Extend Notes Inst&Remove.f // Copyright ©1995 Apple Computer, Inc. All rights reserved. InstallScript := func(partFrame,removeFrame) begin local dataSym := EnsureInternal(kDataSymbol); RegDataDef(dataSym, GetLayout("iouDataDef")); RegisterViewDef(GetLayout("iouDefaultViewDef"), dataSym); RegisterViewDef(GetLayout("iouPrintFormat"), dataSym); RegisterViewDef(kFrameFormat, dataSym); end; RemoveScript := func(removeFrame) begin UnRegisterViewDef('default, kDataSymbol); UnRegisterViewDef('iouPrintFormat, kDataSymbol); UnRegisterViewDef('IOUFrameFormat, kDataSymbol); UnRegDataDef(kDataSymbol); end // End of text file Extend Notes Inst&Remove.f