// Text of project SoupShow written on 5/14/95 at 5:21 PM // Beginning of 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: @218 }; constant |layout_overviewItem| := _userproto000; // End of file overviewItem // Beginning of file cardView.t // Before Script for "entryBase" // Copyright 1993-1994 Apple Computer, Inc. All rights reserved. entryBase := {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, debug: "entryBase", viewClass: 74 }; _view000 := {text: "Name", viewBounds: {left: 8, top: 8, right: 56, bottom: 24}, _proto: @218 }; AddStepForm(entryBase, _view000); _view001 := {text: "Address", viewBounds: {left: 8, top: 32, right: 56, bottom: 48}, _proto: @218 }; AddStepForm(entryBase, _view001); theName := {text: "Static Text", viewBounds: {left: 64, top: 8, right: 216, bottom: 24}, debug: "theName", _proto: @218 }; AddStepForm(entryBase, theName); StepDeclare(entryBase, theName, 'theName); theAddress := {text: "Static Text", viewBounds: {left: 64, top: 32, right: 216, bottom: 72}, debug: "theAddress", _proto: @218 }; AddStepForm(entryBase, theAddress); StepDeclare(entryBase, theAddress, 'theAddress); constant |layout_cardView.t| := entryBase; // End of file cardView.t // Beginning of file overview.t // Before Script for "over" // Copyright 1993-1994 Apple Computer, Inc. All rights reserved. over := {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 overviewProto := GetLayout("overViewItem") ; local protoHeight := overviewProto.viewBounds.bottom - overviewProto.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: GetLayout("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, debug: "over", viewClass: 74 }; constant |layout_overview.t| := over; // End of file overview.t // Beginning of 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, debug: "myBase", _proto: @157 }; cardView := LinkedSubview(entryBase, {viewBounds: {left: 10, top: 98, right: 138, bottom: 162}, debug: "cardView" }); AddStepForm(myBase, cardView); StepDeclare(myBase, cardView, 'cardView); overview := LinkedSubview(over, {viewBounds: {left: 10, top: 170, right: 138, bottom: 242}, debug: "overview" }); AddStepForm(myBase, overview); StepDeclare(myBase, overview, 'overview); constant |layout_SoupShow.t| := myBase; // End of file SoupShow.t