// ---- End Project Data ---- // ---- File SoupShow.t ---- // Before Script for "myBase" // Copyright 1993-1994 Apple Computer, Inc. All rights reserved. myBase := {title: "Application", viewBounds: {left: 0, top: 0, right: 240, bottom: 336}, viewSetupFormScript: func() begin // readjust the size of the application to the screen // make it no bigger than a MessagePad a := GetAppParams(); viewBounds := RelBounds(a.AppAreaLeft, a.AppAreaTop, MIN(a.AppAreaWidth, 240), MIN(a.AppAreaHeight, 336)); // now get the information that the app will display // first get a reference to the right soup // NOTE: this is usually where you would do a // :RegisterCardSoup call cardSoup := GetUnionSoup(ROM_cardfilesoupname); // now get a cursor to that data so it can be // displayed. myCursor := Query(cardSoup, {type: 'index}) ; end, cardSoup: nil // reference to the cardsoup, setup in viewSetupFormScript, myCursor: nil // current data pointer, set in viewSetupFormScript, DisplayFromSoup: // this function will display the data from the // current cursor entry, i.e., whatever myCursor // is pointing to. func() begin // send the message to the currentView. That view // will display the data whichever way it should currentView:DisplayFromSoup(); end, viewScrollUpScript: func() begin // the universal scroll up arrow. Want to move to // the previous entry in the names file // however, may be no next item, in that case // beep and go to the end (or try to). if not myCursor:Prev() then begin :SysBeep(); // THIS IS A BAD WAY TO DO THIS!!! // you should really use a key value that is bigger than // the largest possible key value. myCursor:Move(9999999); myCursor:Prev() end; // now update the display :DisplayFromSoup() ; end, viewScrollDownScript: func() begin // the universal scroll down arrow. Want to move to // the next entry in the names file // however, may be no next item, in that case // beep and reset. if not myCursor:Next() then begin :SysBeep(); myCursor:Reset(); end; // now update the display :DisplayFromSoup() ; end, viewQuitScript: func() begin // cleanup after myself cardSoup := nil ; myCursor := nil ; end, currentView: nil // view currently shown, set in cardView.viewSetupDoneScript // and overview.viewSetupDoneScript, viewSetupDoneScript: func() begin // initialize the cards slot to point to me cards := self ; end, DisplayEntry: // displays an individual entry and sets the current // entry to it func(item) begin // first make sure the individual entry view // (cardView) is open, if not open it if currentView = overview then begin overview:Close(); cardView:Open(); end; // now set the item as the current data item myCursor:Goto(item) ; // finaly, display ie :DisplayFromSoup(); end, cards: nil // slot used by children of this view to access this view // especially useful for message sends, viewOverviewScript: func() begin // toggle between the overview and the individual // data (card) item view // NOTE: the overview will just display // itself correctly ,the card view is not // as smart (so make it that way !) if currentView = overview then begin overview:Close() ; cardView:Open() ; cardView:DisplayFromSoup(); end else begin cardView:Close() ; overView:Open(); end; end, _proto: protoApp, debug: "myBase" }; // linked layout // ---- File cardView.t ---- // Before Script for "cardView" // Copyright 1993-1994 Apple Computer, Inc. All rights reserved. cardView := /* child of myBase */ {viewFlags: 0, viewFormat: 257, viewBounds: {left: 0, top: 20, right: 0, bottom: 100}, viewJustify: 48, DisplayFromSoup: // this function will display the data from the // current cursor entry, i.e., whatever myCursor // is pointing to. func() begin local nameEntry := myCursor:Entry() ; // may not be an entry so be careful if nameEntry then begin local temp ; temp := nameEntry.name.honorific ; if temp then temp := temp && nameEntry.name.first && nameEntry.name.last ; else temp := nameEntry.name.first && nameEntry.name.last ; SetValue(theName, 'text, temp) ; temp := nameEntry.Address ; if nameEntry.Address2 then temp := temp & "\n" & nameEntry.Address2 ; SetValue(theAddress, 'text, temp) ; end else begin SetValue(theName, 'text, "") ; SetValue(theAddress, 'text, "") ; end; end, viewSetupDoneScript: func() begin // set the currentView slot of the base view to me currentView := self ; end, viewclass: 74, debug: "cardView" }; // View cardView is declared to myBase _view000 := /* child of cardView */ {text: "Name", viewBounds: {left: 8, top: 8, right: 56, bottom: 24}, _proto: protoStaticText }; _view001 := /* child of cardView */ {text: "Address", viewBounds: {left: 8, top: 32, right: 56, bottom: 48}, _proto: protoStaticText }; theName := /* child of cardView */ {text: "Static Text", viewBounds: {left: 64, top: 8, right: 216, bottom: 24}, _proto: protoStaticText, debug: "theName" }; // View theName is declared to cardView theAddress := /* child of cardView */ {text: "Static Text", viewBounds: {left: 64, top: 32, right: 216, bottom: 72}, _proto: protoStaticText, debug: "theAddress" }; // View theAddress is declared to cardView // ---- Back in File SoupShow.t ---- // linked layout // ---- File overview.t ---- // Before Script for "overview" // Copyright 1993-1994 Apple Computer, Inc. All rights reserved. overview := /* child of myBase */ {viewFlags: 1, viewFormat: 257, viewBounds: {top: 20, left: 0, right: 0, bottom: -20}, viewJustify: 240, viewSetupChildrenScript: func() begin // get my bounding box and figure out // how many protos will fit in me local bbox := :GlobalBox(); local protoHeight := (pt_overViewItem.viewBounds.bottom - pt_overViewItem.viewBounds.top) + 1 ; // 1 for frame local num := (bbox.bottom - bbox.top) DIV protoHeight ; // get a local cursor to iterate over the items // NOTE: do the clone so that this code does not // effect myCursor, i.e., there is always a // current entry local curs := myCursor:Clone(); // get a local to use for the viewChildren local kids := [] ; // now build enough kids to show the required // data items... // this code also initializes the myCard slot // of the overViewItem proto for i := 0 to (num - 1) do begin if curs:entry() then begin AddArraySlot(kids, {_proto: pt_overViewItem, myCard: curs:Entry()}) ; curs:Next(); end else // break out of the loop break ; end; // if there are kids, show myself... if length(kids) > 1 then self.stepChildren := kids ; end, viewSetupDoneScript: func() begin // set my parents currentView slot to me currentView := self ; end, DisplayFromSoup: func() begin // this is a really bad way to do this // will do something better for the first // full release :RedoChildren() end, viewclass: 74, debug: "overview" }; // View overview is declared to myBase // ---- Back in File SoupShow.t ---- // ---- Beginning of non-used User Protos ---- // non-used User Proto layout // ---- File overviewItem ---- // Before Script for "_userproto000" // Copyright 1993-1994 Apple Computer, Inc. All rights reserved. _userproto000 := {text: "", viewBounds: {left: 0, top: 1, right: 0, bottom: 18}, myCard: nil, viewFlags: 515, viewFormat: 337, viewClickScript: func(unit) begin // if tap starts and ends in this view then // send the DisplayItem message to zoom in // to the individual item (card) view if :TrackHilite(unit) then begin // turn off the hilite :Hilite(nil) ; // tell the app to display the card cards:DisplayEntry(myCard) ; // return true to say I handled the click true ; end; end, viewJustify: 8396852, viewSetupFormScript: func() begin // initialize my text to a reasonable value if myCard then SetValue(self, 'text, myCard.name.first && myCard.name.last && myCard.name.title) ; end, _proto: protoStaticText }; // ---- End of non-used User Protos ---- // ---- Beginning of section for non used Layout files ---- // End of output