home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Sample Code / Newton Sample Code 1.2 / Application Design / True Grid-1 / True Grid.text < prev    next >
Encoding:
Text File  |  1994-07-08  |  45.2 KB  |  1,689 lines  |  [TEXT/MPS ]

  1. // Copyright © 1994 Apple Computer, Inc. All rights reserved.
  2.  
  3. constant kAppSymbol := '|TrueGrid:PIEDTS|;
  4. constant kAppObject := '["Record", "Records"];
  5. constant kSoupName := "TrueGrid:PIEDTS";
  6. DefConst('kSoupIndexes, '[{structure: slot, path: aString, type: string}]);
  7.  
  8. constant kSoupPad := 256;    // bytes of "undisplayed" data in the soup.
  9.  
  10. constant kNumbersList := '["1", "5", "10", "25", "50", "100"];
  11. constant kNumbersArray := '[1, 5, 10, 25, 50, 100];
  12.  
  13. // for tracking hilite in drawn rows
  14. DefConst('kXORstyle, {penPattern: vfNone, transferMode: modeXor, fillPattern: vfBlack});
  15.  
  16. // for drawn row.
  17. DefConst('kLeftTextStyle, {font: ROM_fontSystem9, penSize: 1, penPattern: vfBlack, justification: 'left});
  18. DefConst('kCenterTextStyle, {font: ROM_fontSystem9, penSize: 1, penPattern: vfBlack, justification: 'center});
  19. DefConst('kRightTextStyle, {font: ROM_fontSystem9, penSize: 1, penPattern: vfBlack, justification: 'right});
  20. DefConst('kBorderStyle, {penPattern: vfGray});
  21.  
  22.  
  23. // ---- End Project Data ----
  24.  
  25.  
  26. // ---- File True Grid.t ----
  27.  
  28. // Before Script for "TrueGrid"
  29. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  30.  
  31. TrueGrid :=
  32.    {
  33.     gridList:
  34.       [
  35.       "None",
  36.       "Columns",
  37.       "Cached Columns",
  38.       "Draw Rows",
  39.       "Cached Draw Rows",
  40.       "Simple Rows",
  41.       ],
  42.     viewSetupDoneScript:
  43.       func()
  44.       begin
  45.          theSoup :=  call kRegisterCardSoupFunc with (kSoupName, kSoupIndexes, kAppSymbol, kAppObject);
  46.          theCursor := Query(theSoup, {type: 'index, indexPath: 'aString});
  47.       
  48.          viewsList := [columns, cachedColumns, drawRows, cachedDrawRows, simpleRows];
  49.          gc();
  50.          baseMemory := stats();
  51.          :SoupChanged(kSoupName);
  52.       end,
  53.     viewFormat: nil,
  54.     theSoup: nil,
  55.     viewQuitScript:
  56.       func()
  57.       begin
  58.          call kUnRegisterCardSoupFunc with (kSoupName);
  59.           theCursor := nil;
  60.           theSoup := nil;
  61.           viewsList := nil;
  62.           theGrid := nil;
  63.       end,
  64.     baseMemory: nil,
  65.     viewFlags: 7,
  66.     viewsLIst: nil,
  67.     viewBounds: {left: 0, top: 0, right: 240, bottom: 336},
  68.     FillSoup:
  69.       func(theSoup, items)
  70.       begin
  71.          local i;
  72.          for i := 1 to items do
  73.             theSoup:AddToDefaultStore({
  74.                aString: GetRandomWord(5,20) & $- & GetRandomWord(5,20),
  75.                anInteger: Random(0,10000),
  76.                aDate: Time() + Random(-14400,14400),
  77.                pad: SetLength(SetClass(Clone(""), 'binary), kSoupPad),
  78.             });
  79.       end,
  80.     theCursor: nil,
  81.     DestroySoup:
  82.       func()
  83.       begin
  84.          local store, mySoup;
  85.       
  86.          // remove the soup from each store currently installed
  87.          foreach store in GetStores() do
  88.             if mySoup := store:GetSoup(soupName) then
  89.                mySoup:RemoveFromStore();
  90.       end,
  91.     viewScrollDownScript:
  92.       func()
  93.       begin
  94.          if theGrid then begin
  95.               local t1 := ticks();
  96.               theGrid:viewScrollDownScript();
  97.               local t2 := ticks(); 
  98.               RefreshViews();
  99.               local t3 := ticks();
  100.               SetValue(theTimeDisplay, 'text, "Scrolling took " & t2-t1 & "+" & t3-t2 & "=" & t3-t1 & " ticks.");
  101.               gc();
  102.               SetValue(theMemoryDisplay, 'text, "Using " & baseMemory-stats() & " bytes.");
  103.          end;
  104.           else
  105.               :SysBeep();
  106.       end ,
  107.     title: "True Grid",
  108.     viewScrollUpScript:
  109.       func()
  110.       begin
  111.          if theGrid then begin
  112.               local t1 := ticks();
  113.               theGrid:viewScrollUpScript();
  114.               local t2 := ticks(); 
  115.               RefreshViews();
  116.               local t3 := ticks();
  117.               SetValue(theTimeDisplay, 'text, "Scrolling took " & t2-t1 & "+" & t3-t2 & "=" & t3-t1 & " ticks.");
  118.               gc();
  119.               SetValue(theMemoryDisplay, 'text, "Using " & baseMemory-stats() & " bytes.");
  120.           end
  121.          else
  122.               :SysBeep();
  123.       end,
  124.     EmptySoup:
  125.       func(theSoup, items)
  126.       begin
  127.          local c := Query(theSoup, {type: 'index});
  128.          for i := 1 to items do begin
  129.             if c:Entry() then EntryRemoveFromSoup(c:Entry());
  130.                   c:Next();
  131.             end;
  132.       end,
  133.     declareSelf: 'base,
  134.     theGrid: nil,
  135.     viewclass: 74,
  136.     debug: "TrueGrid",
  137.     soupChanged:
  138.       func(theSoupName)
  139.       begin
  140.           theCursor:Reset();
  141.           local l := Length(MapCursor(theCursor, func(x) true));
  142.           SetValue(theCountDisplay, 'text, l && "soup entries");
  143.           RefreshViews();
  144.           local t1 := ticks();
  145.           theGrid:?soupChanged(theSoupName);
  146.           RefreshViews();
  147.           local t2 := ticks(); 
  148.           RefreshViews();
  149.           local t3 := ticks();
  150.           SetValue(theTimeDisplay, 'text, "Updating took " & t2-t1 & "+" & t3-t2 & "=" & t3-t1 & " ticks.");
  151.           gc();
  152.           SetValue(theMemoryDisplay, 'text, "Using " & baseMemory-stats() & " bytes.");
  153.       end,
  154.     EntrySelected:
  155.       func(entry)
  156.       begin
  157.          SetValue(tappedOn, 'text, "Tapped On: " & if entry then entry.aString else "<none>");
  158.          tappedOn:Open();
  159.          RefreshViews();
  160.          sleep(60);
  161.          tappedOn:Close();
  162.       end
  163.    };
  164.  
  165. theTitle := /* child of TrueGrid */
  166.    {title: "True Grid", _proto: protoTitle, debug: "theTitle"};
  167. // View theTitle is declared to TrueGrid
  168.  
  169.  
  170.  
  171. _view000 := /* child of TrueGrid */ {_proto: protoStatusBar};
  172.  
  173. _view001 := /* child of _view000 */
  174.    {viewBounds: {top: -16, left: -19, right: -6, bottom: -3},
  175.     _proto: protoLargeClosebox
  176.    };
  177.  
  178.  
  179.  
  180. RemoveButton := /* child of _view000 */
  181.    {text: "Remove",
  182.     viewBounds: {top: 2, left: -50, right: -6, bottom: 15},
  183.     pickActionScript:
  184.       func(item)
  185.       begin
  186.           :EmptySoup(theSoup, kNumbersArray[item]);
  187.           :SoupChanged(kSoupName);
  188.           :Hilite(nil) ;
  189.       end,
  190.     viewJustify: 8390662,
  191.     pickCancelledScript:
  192.       func()
  193.       begin
  194.           :Hilite(nil);
  195.       end,
  196.     viewClickScript:
  197.       func(unit)
  198.       begin
  199.       // need to use a viewClickScript to get the correct
  200.       // hiliting behavior for a picker
  201.           if :TrackHilite(unit) then
  202.           begin
  203.               local l := :LocalBox() ;
  204.              DoPopup(kNumbersList, l.right+3, l.top, self);
  205.           end;
  206.       
  207.       end,
  208.     _proto: protoTextButton,
  209.     debug: "RemoveButton"
  210.    };
  211.  
  212.  
  213.  
  214. AddButton := /* child of _view000 */
  215.    {text: "Add",
  216.     viewBounds: {top: 2, left: -38, right: -6, bottom: 15},
  217.     pickActionScript:
  218.       func(item)
  219.       begin
  220.           :FillSoup(theSoup, kNumbersArray[item]);
  221.           :SoupChanged(kSoupName);
  222.           :Hilite(nil) ;
  223.       end,
  224.     viewJustify: 8390662,
  225.     pickCancelledScript:
  226.       func()
  227.       begin
  228.           :Hilite(nil);
  229.       end,
  230.     viewClickScript:
  231.       func(unit)
  232.       begin
  233.       // need to use a viewClickScript to get the correct
  234.       // hiliting behavior for a picker
  235.           if :TrackHilite(unit) then
  236.           begin
  237.               local l := :LocalBox() ;
  238.              DoPopup(kNumbersList, l.right+3, l.top, self);
  239.           end;
  240.       
  241.       end,
  242.     _proto: protoTextButton,
  243.     debug: "AddButton"
  244.    };
  245.  
  246.  
  247.  
  248. ChooseButton := /* child of _view000 */
  249.    {viewBounds: {left: 25, top: 2, right: 85, bottom: 15},
  250.     pickActionScript:
  251.       func(item)
  252.       begin
  253.           // maintain state for the checkmark in the pick list
  254.           selected := item ;
  255.           
  256.          if item = 0 then begin
  257.              theTitle:Close();
  258.              SetValue(theTitle, 'title, "True Grid");
  259.              theTitle:Open();
  260.             theGrid:?Close();
  261.          end;
  262.          else if item <= length(viewsList) then begin
  263.             theGrid:?Close();
  264.              theTitle:Close();
  265.             SetValue(theTitle, 'title, gridList[item]);
  266.              theTitle:Open();
  267.             RefreshViews();
  268.              gc();
  269.              baseMemory := stats();
  270.             theGrid := viewsList[item-1];
  271.             local t1 := ticks();
  272.             theGrid:Open();
  273.             local t2 := ticks();
  274.             RefreshViews();
  275.             local t3 := ticks();
  276.               SetValue(theTimeDisplay, 'text, "Opening took " & t2-t1 & "+" & t3-t2 & "=" & t3-t1 & " ticks.");
  277.               gc();
  278.               SetValue(theMemoryDisplay, 'text, "Using " & baseMemory-stats() & " bytes.");
  279.          end;
  280.          // unhilite the button
  281.          :Hilite(nil) ;
  282.       
  283.       end,
  284.     selected: 0,
  285.     viewClickScript:
  286.       func(unit)
  287.       begin
  288.       // need to use a viewClickScript to get the correct
  289.       // hiliting behavior for a picker
  290.           if :TrackHilite(unit) then
  291.           begin
  292.               local l := :LocalBox() ;
  293.               local popList := Clone(gridList);
  294.               popList[selected] := {item: popList[selected], mark: kCheckMarkChar};
  295.              DoPopup(popList, l.right+3, l.top, self);
  296.           end;
  297.       
  298.       end,
  299.     pickCancelledScript:
  300.       func()
  301.       begin
  302.           :Hilite(nil);
  303.       end,
  304.     _proto: protoTextButton,
  305.     debug: "ChooseButton"
  306.    };
  307.  
  308. // After Script for "ChooseButton"
  309. thisView := ChooseButton;
  310. // set the bounds of the button so that it is to the right
  311. // of the clock and the correct height for the status bar
  312.  
  313. // NOTE: this is the first button, so argument to the
  314. // ButtonBounds function MUST be negative
  315. thisView.viewBounds := ButtonBounds(-(thisView.viewBounds.right - thisView.viewBounds.left));
  316.  
  317. // set the text to have the pop diamond
  318. thisView.text := kPopChar && "Choose" ;
  319.  
  320.  
  321.  
  322.  
  323.  
  324. theTimeDisplay := /* child of TrueGrid */
  325.    {text: "timing",
  326.     viewBounds: {left: 0, top: 18, right: 186, bottom: 30},
  327.     viewJustify: 8388626
  328.     ,
  329.     _proto: protoStaticText,
  330.     debug: "theTimeDisplay"
  331.    };
  332. // View theTimeDisplay is declared to TrueGrid
  333.  
  334.  
  335.  
  336. theMemoryDisplay := /* child of TrueGrid */
  337.    {text: "Tapped On: <none>",
  338.     viewBounds: {left: 0, top: 0, right: 186, bottom: 12},
  339.     viewJustify: 8396818,
  340.     _proto: protoStaticText,
  341.     debug: "theMemoryDisplay"
  342.    };
  343. // View theMemoryDisplay is declared to TrueGrid
  344.  
  345.  
  346.  
  347. theCountDisplay := /* child of TrueGrid */
  348.    {text: "Static Text",
  349.     viewBounds: {left: 0, top: 0, right: 186, bottom: 12},
  350.     viewJustify: 8396818,
  351.     _proto: protoStaticText,
  352.     debug: "theCountDisplay"
  353.    };
  354. // View theCountDisplay is declared to TrueGrid
  355.  
  356.  
  357.  
  358. // ---- File Columns.t ----
  359.  
  360. // Before Script for "columns"
  361. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  362.  
  363. columns := /* child of TrueGrid */
  364.    {myCursor: nil,
  365.     viewSetupDoneScript:
  366.       func()
  367.       begin
  368.           visibleRows := :LocalBox().bottom DIV viewLineSpacing + 1;
  369.           myCursor := theCursor:Clone();
  370.           myCursor:Reset();
  371.           topEntry := myCursor:Entry();
  372.          :FillCache();
  373.       end,
  374.     viewFormat: 337,
  375.     viewlinespacing: 13,
  376.     viewQuitScript:
  377.       func()
  378.       begin
  379.          keyArray := nil;
  380.          stringCache := nil;
  381.          dateCache := nil;
  382.          integerCache := nil;
  383.          myCursor := nil;
  384.       end,
  385.     integerCache: nil,
  386.     stringCache: nil,
  387.     viewFlags: 544,
  388.     viewBounds: {top: 60, left: 0, right: 220, bottom: -22},
  389.     fillCache:
  390.       func()
  391.       begin
  392.           local stringLen := 0;
  393.           local integerLen := 0;
  394.           local dateLen := 0;
  395.          local stringCache := SmartStart(128);
  396.          local integerCache :=  SmartStart(128);
  397.           local dateCache :=  SmartStart(128);
  398.           local entry := topEntry;
  399.       
  400.           keyArray := Array(visibleRows, nil);
  401.          if entry then
  402.              begin
  403.                  myCursor:Goto(topEntry);
  404.                  for i := 0 to visibleRows-1 do
  405.                     begin
  406.                           stringLen := SmartConcat(stringCache, stringLen, entry.aString);
  407.                           stringLen := SmartConcat(stringCache, stringLen, $\n);
  408.                           integerLen := SmartConcat(integerCache, integerLen, SPrintObject(entry.anInteger));
  409.                           integerLen := SmartConcat(integerCache, integerLen, $\n);
  410.                           dateLen := SmartConcat(dateCache, dateLen, ShortDateStr(entry.aDate, kIncludeAllElements));
  411.                           dateLen := SmartConcat(dateCache, dateLen, $\n);
  412.                           keyArray[i] := entry.aString;
  413.                           if not entry := myCursor:Next() then begin
  414.                               SetLength(keyArray, i+1);
  415.                               break;
  416.                           end;
  417.                       end;
  418.               end;
  419.           else
  420.               SetLength(keyArray, 0) ;
  421.               
  422.          SmartStop(stringCache, stringLen);
  423.          SmartStop(integerCache, integerLen);
  424.          SmartStop(dateCache, dateLen);
  425.          SetValue(stringCol, 'text, stringCache);
  426.          SetValue(integerCol, 'text, integerCache);
  427.          SetValue(dateCol, 'text, dateCache);
  428.       end,
  429.     viewOriginY: 0,
  430.     viewScrollDownScript:
  431.       func()
  432.       begin
  433.           myCursor:Goto(topEntry);
  434.           if not topEntry := myCursor:Move(visibleRows - 2) then
  435.               if not topEntry := myCursor:Move(2 - visibleRows) then
  436.                   topEntry := myCursor:Next();
  437.           :fillCache();
  438.       end,
  439.     viewJustify: 208,
  440.     topEntry: nil,
  441.     visibleRows: nil,
  442.     viewScrollUpScript:
  443.       func()
  444.       begin
  445.           myCursor:Goto(topEntry);
  446.           if not topEntry := myCursor:Move(2 - visibleRows) then
  447.               topEntry := myCursor:Next();
  448.           :fillCache();
  449.       end,
  450.     keyArray: nil,
  451.     viewClickScript:
  452.       func(unit)
  453.       begin
  454.          InkOff(unit);
  455.          PlaySound(ROM_click);
  456.          local box := :LocalBox();
  457.          local row := (GetPoint(finalY, unit) - :GlobalBox().top) div viewLineSpacing;
  458.          local theRow := row;
  459.          local inside := true;
  460.          local t := MakeRect(0, row * viewLineSpacing, box.right, (row+1) * viewLineSpacing);
  461.          :DoDrawing('DrawShape, [t, kXORstyle]);
  462.          repeat
  463.             row := (GetPoint(finalY, unit) - :GlobalBox().top) div viewLineSpacing;
  464.             if inside and row <> theRow then begin
  465.                :DoDrawing('DrawShape, [t, kXORstyle]);
  466.                inside := nil;
  467.             end;
  468.               else if not inside and row = theRow then begin
  469.                   :DoDrawing('DrawShape, [t, kXORstyle]);
  470.                   inside := true;
  471.               end;    
  472.             sleep(1);
  473.          until StrokeDone(unit);
  474.        
  475.          row := (GetPoint(finalY, unit) - :GlobalBox().top) div viewLineSpacing;
  476.          if row = theRow and row < length(keyArray) then 
  477.             :EntrySelected(myCursor:GotoKey(keyArray[row]));
  478.          else
  479.             :EntrySelected(nil);
  480.          if inside then
  481.              begin    // simply XOring the rectangle again won't work, :EntrySelected() changes drawing.
  482.                  :Dirty();
  483.                  RefreshViews();
  484.              end
  485.       end;,
  486.     viewclass: 74,
  487.     debug: "columns",
  488.     dateCache: nil,
  489.     soupChanged:
  490.       func(theSoupName)
  491.           if StrEqual(theSoupName, kSoupName) then begin
  492.               topEntry := myCursor:Reset();
  493.              :FillCache();
  494.       end
  495.    };
  496. // View columns is declared to TrueGrid
  497.  
  498. stringCol := /* child of columns */
  499.    {viewFormat: 12593,
  500.     viewFont: ROM_fontSystem9;,
  501.     viewBounds: {left: 0, top: 0, right: 300, bottom: 1000},
  502.     viewFlags: 134217731,
  503.     viewlinespacing: 13,
  504.     viewclass: 81,
  505.     debug: "stringCol"
  506.    };
  507. // View stringCol is declared to columns
  508.  
  509.  
  510.  
  511. dateCol := /* child of columns */
  512.    {viewFlags: 134217731,
  513.     viewFormat: 12593,
  514.     viewBounds: {top: 0, left: -60, right: 0, bottom: 1000},
  515.     viewFont: ROM_fontSystem9;,
  516.     viewlinespacing: 13,
  517.     viewJustify: 34,
  518.     viewclass: 81,
  519.     debug: "dateCol"
  520.    };
  521. // View dateCol is declared to columns
  522.  
  523.  
  524.  
  525. integerCol := /* child of columns */
  526.    {viewFlags: 134217731,
  527.     viewFormat: 12593,
  528.     viewFont: ROM_fontSystem9;,
  529.     viewBounds: {top: 0, left: -40, right: 0, bottom: 1000},
  530.     viewlinespacing: 13
  531.     ,
  532.     viewJustify: 2049,
  533.     viewclass: 81,
  534.     debug: "integerCol"
  535.    };
  536. // View integerCol is declared to columns
  537.  
  538.  
  539.  
  540.  
  541. // ---- Back in File True Grid.t ----
  542.  
  543. // ---- File Cached Columns.t ----
  544.  
  545. // Before Script for "cachedColumns"
  546. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  547.  
  548. cachedColumns := /* child of TrueGrid */
  549.    {viewFlags: 544,
  550.     viewFormat: 337,
  551.     viewBounds: {top: 60, left: 0, right: 220, bottom: -22},
  552.     fillCache:
  553.       func()
  554.       begin
  555.           local stringLen := 0;
  556.           local integerLen := 0;
  557.           local dateLen := 0;
  558.          local stringCache := SmartStart(128);
  559.          local integerCache :=  SmartStart(128);
  560.           local dateCache :=  SmartStart(128);
  561.       
  562.          local f := func(entry)
  563.             begin
  564.                   stringLen := SmartConcat(stringCache, stringLen, entry.aString);
  565.                   stringLen := SmartConcat(stringCache, stringLen, $\n);
  566.                   integerLen := SmartConcat(integerCache, integerLen, SPrintObject(entry.anInteger));
  567.                   integerLen := SmartConcat(integerCache, integerLen, $\n);
  568.                   dateLen := SmartConcat(dateCache, dateLen, ShortDateStr(entry.aDate, kIncludeAllElements));
  569.                   dateLen := SmartConcat(dateCache, dateLen, $\n);
  570.                   entry.aString;
  571.             end;
  572.       
  573.          myCursor:Reset();
  574.          keyArray := MapCursor(myCursor, f);
  575.          SmartStop(stringCache, stringLen);
  576.          SmartStop(integerCache, integerLen);
  577.          SmartStop(dateCache, dateLen);
  578.          SetValue(stringCol, 'text, stringCache);
  579.          SetValue(integerCol, 'text, integerCache);
  580.          SetValue(dateCol, 'text, dateCache);
  581.       end,
  582.     keyArray: nil,
  583.     viewOriginY: 0,
  584.     viewScrollUpScript:
  585.       func()
  586.       begin
  587.          :SetOrigin(0, MAX(viewOriginY - scrollIncrement, 0));
  588.       end,
  589.     viewScrollDownScript:
  590.       func()
  591.       begin
  592.          :SetOrigin(0, viewOriginY + scrollIncrement);
  593.       end,
  594.     viewlinespacing: 13,
  595.     viewSetupDoneScript:
  596.       func()
  597.       begin
  598.           scrollIncrement := (:LocalBox().bottom DIV viewLineSpacing - 1) * viewLineSpacing;
  599.          :SetOrigin(0,0);
  600.          myCursor := theCursor:Clone();
  601.          myCursor:Reset();
  602.          :FillCache();
  603.       end,
  604.     soupChanged:
  605.       func(theSoupName)
  606.       if StrEqual(theSoupName, kSoupName) then begin
  607.          :SetOrigin(0,0);
  608.          :FillCache();
  609.       end,
  610.     viewClickScript:
  611.       func(unit)
  612.       begin
  613.          InkOff(unit);
  614.          PlaySound(ROM_click);
  615.          local box := :LocalBox();
  616.          local row := (GetPoint(finalY, unit) - :GlobalBox().top) div viewLineSpacing;
  617.          local oldRow := row;
  618.          local t := MakeRect(0, row * viewLineSpacing, box.right, (row+1) * viewLineSpacing);
  619.          :DoDrawing('DrawShape, [t, kXORstyle]);
  620.          repeat
  621.             row := (GetPoint(finalY, unit) - :GlobalBox().top) div viewLineSpacing;
  622.             if row <> oldRow then begin
  623.                PlaySound(ROM_click);
  624.                :DoDrawing('DrawShape, [t, kXORstyle]);
  625.                t := MakeRect(0, row * viewLineSpacing, box.right, (row+1) * viewLineSpacing);
  626.                :DoDrawing('DrawShape, [t, kXORstyle]);
  627.                oldRow := row;
  628.             end;
  629.             sleep(1);
  630.          until StrokeDone(unit);
  631.        
  632.          row := (GetPoint(finalY, unit) - :GlobalBox().top + viewOriginY) div viewLineSpacing;
  633.          if row < length(keyArray) then 
  634.             :EntrySelected(myCursor:GotoKey(keyArray[row]));
  635.          else
  636.             :EntrySelected(nil);
  637.          :DoDrawing('DrawShape, [t, kXORstyle]);
  638.       end;,
  639.     viewQuitScript:
  640.       func()
  641.       begin
  642.          keyArray := nil;
  643.          stringCache := nil;
  644.          dateCache := nil;
  645.          integerCache := nil;
  646.          myCursor := nil;
  647.       end,
  648.     myCursor: nil,
  649.     scrollIncrement: nil,
  650.     viewJustify: 208,
  651.     viewclass: 74,
  652.     debug: "cachedColumns"
  653.    };
  654. // View cachedColumns is declared to TrueGrid
  655.  
  656. stringCol := /* child of cachedColumns */
  657.    {viewFormat: 12593,
  658.     viewFont: ROM_fontSystem9;,
  659.     viewBounds: {left: 0, top: 0, right: 300, bottom: 1000},
  660.     viewFlags: 134217731,
  661.     viewlinespacing: 13,
  662.     viewclass: 81,
  663.     debug: "stringCol"
  664.    };
  665. // View stringCol is declared to cachedColumns
  666.  
  667.  
  668.  
  669. dateCol := /* child of cachedColumns */
  670.    {viewFlags: 134217731,
  671.     viewFormat: 12593,
  672.     viewBounds: {top: 0, left: -60, right: 0, bottom: 1000},
  673.     viewFont: ROM_fontSystem9;,
  674.     viewlinespacing: 13,
  675.     viewJustify: 34,
  676.     viewclass: 81,
  677.     debug: "dateCol"
  678.    };
  679. // View dateCol is declared to cachedColumns
  680.  
  681.  
  682.  
  683. integerCol := /* child of cachedColumns */
  684.    {viewFlags: 134217731,
  685.     viewFormat: 12593,
  686.     viewFont: ROM_fontSystem9;,
  687.     viewBounds: {top: 0, left: -40, right: 0, bottom: 1000},
  688.     viewlinespacing: 13
  689.     ,
  690.     viewJustify: 2049,
  691.     viewclass: 81,
  692.     debug: "integerCol"
  693.    };
  694. // View integerCol is declared to cachedColumns
  695.  
  696.  
  697.  
  698.  
  699. // ---- Back in File True Grid.t ----
  700.  
  701. // ---- File Draw Rows.t ----
  702.  
  703. // Before Script for "drawRows"
  704. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  705.  
  706. drawRows := /* child of TrueGrid */
  707.    {viewFlags: 32,
  708.     viewFormat: 337,
  709.     viewBounds: {top: 60, left: 0, right: 220, bottom: -22},
  710.     fillCache:
  711.       func()
  712.       begin
  713.          local fillCursor := myCursor:Clone();
  714.          for i := 0 to numChildren-1 do begin
  715.             :ChildViewFrames()[i]:UpdateFromSoup(fillCursor:Entry());
  716.             fillCursor:Next();
  717.          end;
  718.           :Dirty();
  719.       end,
  720.     viewScrollUpScript:
  721.       func()
  722.       begin
  723.           myCursor:Move(2 - numChildren);
  724.           if not myCursor:Entry() then myCursor:Next();
  725.           :FillCache();
  726.       end,
  727.     viewScrollDownScript:
  728.       func()
  729.       begin
  730.           myCursor:Move(numChildren-2);
  731.           :FillCache();
  732.       end,
  733.     viewSetupDoneScript:
  734.       func()
  735.       begin
  736.          myCursor := theCursor:Clone();
  737.          myCursor:Reset();
  738.          :FillCache();
  739.       end,
  740.     soupChanged:
  741.       func(theSoupName)
  742.       if StrEqual(theSoupName, kSoupName) then begin
  743.          myCursor:Reset();
  744.          :FillCache();
  745.       end,
  746.     viewClickScript:
  747.       
  748.       func(unit)
  749.       begin
  750.       
  751.       end;,
  752.     viewQuitScript:
  753.       func()
  754.       begin
  755.          keyArray := nil;
  756.          stringCache := nil;
  757.          dateCache := nil;
  758.          integerCache := nil;
  759.          myCursor := nil;
  760.       end,
  761.     viewSetupChildrenScript:
  762.       func()
  763.       begin
  764.          numChildren := :LocalBox().bottom DIV 13 + 1;
  765.          self.stepChildren := Array(numChildren, pt_protoDrawnRow);
  766.       end,
  767.     numChildren: nil,
  768.     myCursor: nil,
  769.     viewJustify: 208,
  770.     viewclass: 74,
  771.     debug: "drawRows"
  772.    };
  773. // View drawRows is declared to TrueGrid
  774.  
  775.  
  776. // ---- Back in File True Grid.t ----
  777.  
  778. // ---- File Cached Draw Rows.t ----
  779.  
  780. // Before Script for "cachedDrawRows"
  781. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  782.  
  783. cachedDrawRows := /* child of TrueGrid */
  784.    {viewFlags: 32,
  785.     viewFormat: 337,
  786.     viewBounds: {top: 60, left: 0, right: 220, bottom: -22},
  787.     fillCache:
  788.       func()
  789.       begin
  790.           local childTemplate;
  791.           local visibleChildren := :LocalBox().bottom DIV viewLineSpacing + 1;
  792.           
  793.          local f := func(entry)
  794.             begin
  795.                 childTemplate := {_proto: pt_protoDrawnRow};
  796.                 childTemplate:UpdateFromSoup(entry);
  797.                 AddArraySlot(stepChildren, childTemplate); 
  798.                   entry.aString;
  799.             end;
  800.           
  801.           stepChildren := [];
  802.           myCursor:Reset();
  803.           keyArray := MapCursor(myCursor, f);
  804.           numChildren := length(keyArray);
  805.           maxScrollHeight := MAX(0, numChildren - visibleChildren + 2) * viewLineSpacing;
  806.           for i := 0 to MAX(2, visibleChildren - numChildren + 2) do begin
  807.               childTemplate := {_proto: pt_protoDrawnRow};
  808.               childTemplate:UpdateFromSoup(nil);
  809.               AddArraySlot(stepChildren, childTemplate);
  810.           end;
  811.       end,
  812.     viewScrollUpScript:
  813.       func()
  814.       begin
  815.          :SetOrigin(0, MAX(viewOriginY - scrollIncrement, 0));
  816.       end,
  817.     viewScrollDownScript:
  818.       func()
  819.       begin
  820.          :SetOrigin(0, MIN(viewOriginY + scrollIncrement, maxScrollHeight));
  821.       end,
  822.     soupChanged:
  823.       func(theSoupName)
  824.       if StrEqual(theSoupName, kSoupName) then begin
  825.          myCursor:Reset();
  826.          :FillCache();
  827.          :RedoChildren();
  828.       end,
  829.     viewQuitScript:
  830.       func()
  831.       begin
  832.          keyArray := nil;
  833.          stringCache := nil;
  834.          dateCache := nil;
  835.          integerCache := nil;
  836.          myCursor := nil;
  837.       end,
  838.     viewSetupChildrenScript:
  839.       func()
  840.       begin
  841.           self.stepChildren := nil;
  842.          myCursor := theCursor:Clone();
  843.          :FillCache();
  844.       end,
  845.     numChildren: nil,
  846.     myCursor: nil,
  847.     viewJustify: 208,
  848.     viewSetupDoneScript:
  849.       func()
  850.       begin
  851.           scrollIncrement := (:LocalBox().bottom DIV viewLineSpacing - 1) * viewLineSpacing;
  852.       end,
  853.     scrollIncrement: nil,
  854.     viewOriginX: 0,
  855.     viewOriginY: 0,
  856.     viewlinespacing: 13,
  857.     maxScrollHeight: nil,
  858.     viewclass: 74,
  859.     debug: "cachedDrawRows"
  860.    };
  861. // View cachedDrawRows is declared to TrueGrid
  862.  
  863.  
  864. // ---- Back in File True Grid.t ----
  865.  
  866. // ---- File SimpleRows.t ----
  867.  
  868. // Before Script for "simpleRows"
  869. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  870.  
  871. simpleRows := /* child of TrueGrid */
  872.    {viewFlags: 32,
  873.     viewFormat: 337,
  874.     viewBounds: {top: 60, left: 0, right: 220, bottom: -22},
  875.     fillCache:
  876.       func()
  877.       begin
  878.          local fillCursor := myCursor:Clone();
  879.          for i := 0 to numChildren-1 do begin
  880.             :ChildViewFrames()[i]:UpdateFromSoup(fillCursor:Entry());
  881.             fillCursor:Next();
  882.          end;
  883.           :Dirty();
  884.       end,
  885.     viewScrollUpScript:
  886.       func()
  887.       begin
  888.           myCursor:Move(2 - numChildren);
  889.           if not myCursor:Entry() then myCursor:Next();
  890.           :FillCache();
  891.       end,
  892.     viewScrollDownScript:
  893.       func()
  894.       begin
  895.           myCursor:Move(numChildren-2);
  896.           :FillCache();
  897.       end,
  898.     viewSetupDoneScript:
  899.       func()
  900.       begin
  901.          myCursor := theCursor:Clone();
  902.          myCursor:Reset();
  903.          :FillCache();
  904.       end,
  905.     soupChanged:
  906.       func(theSoupName)
  907.       if StrEqual(theSoupName, kSoupName) then begin
  908.          myCursor:Reset();
  909.          :FillCache();
  910.       end,
  911.     viewClickScript:
  912.       
  913.       func(unit)
  914.       begin
  915.       
  916.       end;,
  917.     viewQuitScript:
  918.       func()
  919.       begin
  920.          keyArray := nil;
  921.          stringCache := nil;
  922.          dateCache := nil;
  923.          integerCache := nil;
  924.          myCursor := nil;
  925.       end,
  926.     viewSetupChildrenScript:
  927.       func()
  928.       begin
  929.          numChildren := :LocalBox().bottom DIV 13 + 1;
  930.          self.stepChildren := Array(numChildren, pt_protoSimpleRow);
  931.       end,
  932.     numChildren: nil,
  933.     myCursor: nil,
  934.     viewJustify: 208,
  935.     viewclass: 74,
  936.     debug: "simpleRows"
  937.    };
  938. // View simpleRows is declared to TrueGrid
  939.  
  940.  
  941. // ---- Back in File True Grid.t ----
  942.  
  943. // ---- File TappedOn.t ----
  944.  
  945. // Before Script for "tappedOn"
  946. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  947.  
  948. tappedOn := /* child of TrueGrid */
  949.    {text: "",
  950.     viewBounds: {left: 0, top: 0, right: 160, bottom: 80},
  951.     viewFormat: 83886673,
  952.     viewJustify: 86,
  953.     viewFlags: 2,
  954.     viewEffect: 236577,
  955.     _proto: protoStaticText,
  956.     debug: "tappedOn"
  957.    };
  958. // View tappedOn is declared to TrueGrid
  959.  
  960.  
  961. // ---- Back in File True Grid.t ----
  962.  
  963.  
  964. // ---- Beginning of non-used User Protos ----
  965.  
  966. // ---- File protoDrawnRow ----
  967.  
  968. // Before Script for "protoDrawnRow"
  969. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  970.  
  971. protoDrawnRow :=
  972.    {viewFlags: 515,
  973.     viewFormat: 305,
  974.     viewBounds: {left: 0, top: 0, right: 220, bottom: 13},
  975.     UpdateFromSoup:
  976.       func(entry)
  977.       begin
  978.          myEntryKey := if entry then entry.aString else nil;
  979.           shapes := if entry then
  980.              [
  981.                 kLeftTextStyle,
  982.                   MakeText(entry.aString, 0,0,160,10),
  983.                 kRightTextStyle,
  984.                 MakeText(SPrintObject(entry.anInteger), 120,0,160,10),
  985.                 kCenterTextStyle,
  986.                 MakeText(ShortDateStr(entry.aDate, kIncludeAllElements), 160,0,220,10),
  987.                 kBorderStyle,
  988.                 MakeLine(120,0,120,13),
  989.                 MakeLine(160,0,160,13),
  990.              ]
  991.           else
  992.               [
  993.                 kBorderStyle,
  994.                 MakeLine(120,0,120,13),
  995.                 MakeLine(160,0,160,13),
  996.               ];
  997.       end,
  998.     viewDrawScript:
  999.       func()
  1000.       begin
  1001.          :DrawShape(shapes, nil);
  1002.       end,
  1003.     shapes: nil,
  1004.     viewJustify: 8192,
  1005.     viewClickScript:
  1006.       func(unit)
  1007.       begin
  1008.           if :TrackHilite(unit) then
  1009.               :EntrySelected(if myEntryKey then myCursor:GotoKey(myEntryKey) else nil);
  1010.           :Hilite(nil);
  1011.       end,
  1012.     myEntryKey: nil,
  1013.     viewclass: 74,
  1014.     debug: "protoDrawnRow"
  1015.    };
  1016.  
  1017.  
  1018. // ---- File protoSimpleRow ----
  1019.  
  1020. // Before Script for "protoSimpleRow"
  1021. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  1022.  
  1023. protoSimpleRow :=
  1024.    {viewFlags: 515,
  1025.     viewFormat: 0,
  1026.     viewBounds: {left: 0, top: 0, right: 220, bottom: 13},
  1027.     UpdateFromSoup:
  1028.       func(entry)
  1029.       begin
  1030.           if entry then begin
  1031.              myEntryKey := entry.aString;
  1032.               SetValue(stringView, 'text, entry.aString);
  1033.               SetValue(integerView, 'text, SPrintObject(entry.anInteger));
  1034.               SetValue(dateView, 'text, ShortDateStr(entry.aDate, kIncludeAllElements));
  1035.           end;
  1036.           else begin
  1037.               myEntryKey := nil;
  1038.               SetValue(stringView, 'text, nil);
  1039.               SetValue(integerView, 'text, nil);
  1040.               SetValue(dateView, 'text, nil);
  1041.           end;
  1042.       end,
  1043.     viewJustify: 8192,
  1044.     viewClickScript:
  1045.       func(unit)
  1046.       begin
  1047.           if :TrackHilite(unit) then
  1048.               :EntrySelected(if myEntryKey then myCursor:GotoKey(myEntryKey) else nil);
  1049.           :Hilite(nil);
  1050.       end,
  1051.     myEntryKey: nil,
  1052.     viewclass: 74,
  1053.     debug: "protoSimpleRow"
  1054.    };
  1055.  
  1056. stringView := /* child of protoSimpleRow */
  1057.    {viewFlags: 134217731,
  1058.     viewFormat: 305,
  1059.     viewFont: ROM_fontSystem9,
  1060.     viewBounds: {left: 0, top: 0, right: 120, bottom: 13},
  1061.     viewJustify: 8388612,
  1062.     viewclass: 81,
  1063.     debug: "stringView"
  1064.    };
  1065. // View stringView is declared to protoSimpleRow
  1066.  
  1067.  
  1068.  
  1069. integerView := /* child of protoSimpleRow */
  1070.    {viewFlags: 134217731,
  1071.     viewFormat: 305,
  1072.     viewFont: ROM_fontSystem9,
  1073.     viewBounds: {left: 120, top: 0, right: 160, bottom: 13},
  1074.     viewJustify: 8388613,
  1075.     viewclass: 81,
  1076.     debug: "integerView"
  1077.    };
  1078. // View integerView is declared to protoSimpleRow
  1079.  
  1080.  
  1081.  
  1082. dateView := /* child of protoSimpleRow */
  1083.    {viewFlags: 134217731,
  1084.     viewFormat: 305,
  1085.     viewFont: ROM_fontSystem9,
  1086.     viewBounds: {left: 160, top: 0, right: 220, bottom: 13},
  1087.     viewJustify: 8388614,
  1088.     viewclass: 81,
  1089.     debug: "dateView"
  1090.    };
  1091. // View dateView is declared to protoSimpleRow
  1092.  
  1093.  
  1094.  
  1095.  
  1096. // ---- End of non-used User Protos ----
  1097.  
  1098.  
  1099.  
  1100. // ---- Beginning of section for non used Layout files ----
  1101.  
  1102. // ---- File Cached Columns.t ----
  1103.  
  1104. // Before Script for "cachedColumns"
  1105. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  1106.  
  1107. cachedColumns :=
  1108.    {viewFlags: 544,
  1109.     viewFormat: 337,
  1110.     viewBounds: {top: 60, left: 0, right: 220, bottom: -22},
  1111.     fillCache:
  1112.       func()
  1113.       begin
  1114.           local stringLen := 0;
  1115.           local integerLen := 0;
  1116.           local dateLen := 0;
  1117.          local stringCache := SmartStart(128);
  1118.          local integerCache :=  SmartStart(128);
  1119.           local dateCache :=  SmartStart(128);
  1120.       
  1121.          local f := func(entry)
  1122.             begin
  1123.                   stringLen := SmartConcat(stringCache, stringLen, entry.aString);
  1124.                   stringLen := SmartConcat(stringCache, stringLen, $\n);
  1125.                   integerLen := SmartConcat(integerCache, integerLen, SPrintObject(entry.anInteger));
  1126.                   integerLen := SmartConcat(integerCache, integerLen, $\n);
  1127.                   dateLen := SmartConcat(dateCache, dateLen, ShortDateStr(entry.aDate, kIncludeAllElements));
  1128.                   dateLen := SmartConcat(dateCache, dateLen, $\n);
  1129.                   entry.aString;
  1130.             end;
  1131.       
  1132.          myCursor:Reset();
  1133.          keyArray := MapCursor(myCursor, f);
  1134.          SmartStop(stringCache, stringLen);
  1135.          SmartStop(integerCache, integerLen);
  1136.          SmartStop(dateCache, dateLen);
  1137.          SetValue(stringCol, 'text, stringCache);
  1138.          SetValue(integerCol, 'text, integerCache);
  1139.          SetValue(dateCol, 'text, dateCache);
  1140.       end,
  1141.     keyArray: nil,
  1142.     viewOriginY: 0,
  1143.     viewScrollUpScript:
  1144.       func()
  1145.       begin
  1146.          :SetOrigin(0, MAX(viewOriginY - scrollIncrement, 0));
  1147.       end,
  1148.     viewScrollDownScript:
  1149.       func()
  1150.       begin
  1151.          :SetOrigin(0, viewOriginY + scrollIncrement);
  1152.       end,
  1153.     viewlinespacing: 13,
  1154.     viewSetupDoneScript:
  1155.       func()
  1156.       begin
  1157.           scrollIncrement := (:LocalBox().bottom DIV viewLineSpacing - 1) * viewLineSpacing;
  1158.          :SetOrigin(0,0);
  1159.          myCursor := theCursor:Clone();
  1160.          myCursor:Reset();
  1161.          :FillCache();
  1162.       end,
  1163.     soupChanged:
  1164.       func(theSoupName)
  1165.       if StrEqual(theSoupName, kSoupName) then begin
  1166.          :SetOrigin(0,0);
  1167.          :FillCache();
  1168.       end,
  1169.     viewClickScript:
  1170.       func(unit)
  1171.       begin
  1172.          InkOff(unit);
  1173.          PlaySound(ROM_click);
  1174.          local box := :LocalBox();
  1175.          local row := (GetPoint(finalY, unit) - :GlobalBox().top) div viewLineSpacing;
  1176.          local oldRow := row;
  1177.          local t := MakeRect(0, row * viewLineSpacing, box.right, (row+1) * viewLineSpacing);
  1178.          :DoDrawing('DrawShape, [t, kXORstyle]);
  1179.          repeat
  1180.             row := (GetPoint(finalY, unit) - :GlobalBox().top) div viewLineSpacing;
  1181.             if row <> oldRow then begin
  1182.                PlaySound(ROM_click);
  1183.                :DoDrawing('DrawShape, [t, kXORstyle]);
  1184.                t := MakeRect(0, row * viewLineSpacing, box.right, (row+1) * viewLineSpacing);
  1185.                :DoDrawing('DrawShape, [t, kXORstyle]);
  1186.                oldRow := row;
  1187.             end;
  1188.             sleep(1);
  1189.          until StrokeDone(unit);
  1190.        
  1191.          row := (GetPoint(finalY, unit) - :GlobalBox().top + viewOriginY) div viewLineSpacing;
  1192.          if row < length(keyArray) then 
  1193.             :EntrySelected(myCursor:GotoKey(keyArray[row]));
  1194.          else
  1195.             :EntrySelected(nil);
  1196.          :DoDrawing('DrawShape, [t, kXORstyle]);
  1197.       end;,
  1198.     viewQuitScript:
  1199.       func()
  1200.       begin
  1201.          keyArray := nil;
  1202.          stringCache := nil;
  1203.          dateCache := nil;
  1204.          integerCache := nil;
  1205.          myCursor := nil;
  1206.       end,
  1207.     myCursor: nil,
  1208.     scrollIncrement: nil,
  1209.     viewJustify: 208,
  1210.     viewclass: 74,
  1211.     debug: "cachedColumns"
  1212.    };
  1213.  
  1214. stringCol := /* child of cachedColumns */
  1215.    {viewFormat: 12593,
  1216.     viewFont: ROM_fontSystem9;,
  1217.     viewBounds: {left: 0, top: 0, right: 300, bottom: 1000},
  1218.     viewFlags: 134217731,
  1219.     viewlinespacing: 13,
  1220.     viewclass: 81,
  1221.     debug: "stringCol"
  1222.    };
  1223. // View stringCol is declared to cachedColumns
  1224.  
  1225.  
  1226.  
  1227. dateCol := /* child of cachedColumns */
  1228.    {viewFlags: 134217731,
  1229.     viewFormat: 12593,
  1230.     viewBounds: {top: 0, left: -60, right: 0, bottom: 1000},
  1231.     viewFont: ROM_fontSystem9;,
  1232.     viewlinespacing: 13,
  1233.     viewJustify: 34,
  1234.     viewclass: 81,
  1235.     debug: "dateCol"
  1236.    };
  1237. // View dateCol is declared to cachedColumns
  1238.  
  1239.  
  1240.  
  1241. integerCol := /* child of cachedColumns */
  1242.    {viewFlags: 134217731,
  1243.     viewFormat: 12593,
  1244.     viewFont: ROM_fontSystem9;,
  1245.     viewBounds: {top: 0, left: -40, right: 0, bottom: 1000},
  1246.     viewlinespacing: 13
  1247.     ,
  1248.     viewJustify: 2049,
  1249.     viewclass: 81,
  1250.     debug: "integerCol"
  1251.    };
  1252. // View integerCol is declared to cachedColumns
  1253.  
  1254.  
  1255.  
  1256.  
  1257. // ---- File Cached Draw Rows.t ----
  1258.  
  1259. // Before Script for "cachedDrawRows"
  1260. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  1261.  
  1262. cachedDrawRows :=
  1263.    {viewFlags: 32,
  1264.     viewFormat: 337,
  1265.     viewBounds: {top: 60, left: 0, right: 220, bottom: -22},
  1266.     fillCache:
  1267.       func()
  1268.       begin
  1269.           local childTemplate;
  1270.           local visibleChildren := :LocalBox().bottom DIV viewLineSpacing + 1;
  1271.           
  1272.          local f := func(entry)
  1273.             begin
  1274.                 childTemplate := {_proto: pt_protoDrawnRow};
  1275.                 childTemplate:UpdateFromSoup(entry);
  1276.                 AddArraySlot(stepChildren, childTemplate); 
  1277.                   entry.aString;
  1278.             end;
  1279.           
  1280.           stepChildren := [];
  1281.           myCursor:Reset();
  1282.           keyArray := MapCursor(myCursor, f);
  1283.           numChildren := length(keyArray);
  1284.           maxScrollHeight := MAX(0, numChildren - visibleChildren + 2) * viewLineSpacing;
  1285.           for i := 0 to MAX(2, visibleChildren - numChildren + 2) do begin
  1286.               childTemplate := {_proto: pt_protoDrawnRow};
  1287.               childTemplate:UpdateFromSoup(nil);
  1288.               AddArraySlot(stepChildren, childTemplate);
  1289.           end;
  1290.       end,
  1291.     viewScrollUpScript:
  1292.       func()
  1293.       begin
  1294.          :SetOrigin(0, MAX(viewOriginY - scrollIncrement, 0));
  1295.       end,
  1296.     viewScrollDownScript:
  1297.       func()
  1298.       begin
  1299.          :SetOrigin(0, MIN(viewOriginY + scrollIncrement, maxScrollHeight));
  1300.       end,
  1301.     soupChanged:
  1302.       func(theSoupName)
  1303.       if StrEqual(theSoupName, kSoupName) then begin
  1304.          myCursor:Reset();
  1305.          :FillCache();
  1306.          :RedoChildren();
  1307.       end,
  1308.     viewQuitScript:
  1309.       func()
  1310.       begin
  1311.          keyArray := nil;
  1312.          stringCache := nil;
  1313.          dateCache := nil;
  1314.          integerCache := nil;
  1315.          myCursor := nil;
  1316.       end,
  1317.     viewSetupChildrenScript:
  1318.       func()
  1319.       begin
  1320.           self.stepChildren := nil;
  1321.          myCursor := theCursor:Clone();
  1322.          :FillCache();
  1323.       end,
  1324.     numChildren: nil,
  1325.     myCursor: nil,
  1326.     viewJustify: 208,
  1327.     viewSetupDoneScript:
  1328.       func()
  1329.       begin
  1330.           scrollIncrement := (:LocalBox().bottom DIV viewLineSpacing - 1) * viewLineSpacing;
  1331.       end,
  1332.     scrollIncrement: nil,
  1333.     viewOriginX: 0,
  1334.     viewOriginY: 0,
  1335.     viewlinespacing: 13,
  1336.     maxScrollHeight: nil,
  1337.     viewclass: 74,
  1338.     debug: "cachedDrawRows"
  1339.    };
  1340.  
  1341.  
  1342. // ---- File Columns.t ----
  1343.  
  1344. // Before Script for "columns"
  1345. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  1346.  
  1347. columns :=
  1348.    {myCursor: nil,
  1349.     viewSetupDoneScript:
  1350.       func()
  1351.       begin
  1352.           visibleRows := :LocalBox().bottom DIV viewLineSpacing + 1;
  1353.           myCursor := theCursor:Clone();
  1354.           myCursor:Reset();
  1355.           topEntry := myCursor:Entry();
  1356.          :FillCache();
  1357.       end,
  1358.     viewFormat: 337,
  1359.     viewlinespacing: 13,
  1360.     viewQuitScript:
  1361.       func()
  1362.       begin
  1363.          keyArray := nil;
  1364.          stringCache := nil;
  1365.          dateCache := nil;
  1366.          integerCache := nil;
  1367.          myCursor := nil;
  1368.       end,
  1369.     integerCache: nil,
  1370.     stringCache: nil,
  1371.     viewFlags: 544,
  1372.     viewBounds: {top: 60, left: 0, right: 220, bottom: -22},
  1373.     fillCache:
  1374.       func()
  1375.       begin
  1376.           local stringLen := 0;
  1377.           local integerLen := 0;
  1378.           local dateLen := 0;
  1379.          local stringCache := SmartStart(128);
  1380.          local integerCache :=  SmartStart(128);
  1381.           local dateCache :=  SmartStart(128);
  1382.           local entry := topEntry;
  1383.       
  1384.           keyArray := Array(visibleRows, nil);
  1385.          if entry then
  1386.              begin
  1387.                  myCursor:Goto(topEntry);
  1388.                  for i := 0 to visibleRows-1 do
  1389.                     begin
  1390.                           stringLen := SmartConcat(stringCache, stringLen, entry.aString);
  1391.                           stringLen := SmartConcat(stringCache, stringLen, $\n);
  1392.                           integerLen := SmartConcat(integerCache, integerLen, SPrintObject(entry.anInteger));
  1393.                           integerLen := SmartConcat(integerCache, integerLen, $\n);
  1394.                           dateLen := SmartConcat(dateCache, dateLen, ShortDateStr(entry.aDate, kIncludeAllElements));
  1395.                           dateLen := SmartConcat(dateCache, dateLen, $\n);
  1396.                           keyArray[i] := entry.aString;
  1397.                           if not entry := myCursor:Next() then begin
  1398.                               SetLength(keyArray, i+1);
  1399.                               break;
  1400.                           end;
  1401.                       end;
  1402.               end;
  1403.           else
  1404.               SetLength(keyArray, 0) ;
  1405.               
  1406.          SmartStop(stringCache, stringLen);
  1407.          SmartStop(integerCache, integerLen);
  1408.          SmartStop(dateCache, dateLen);
  1409.          SetValue(stringCol, 'text, stringCache);
  1410.          SetValue(integerCol, 'text, integerCache);
  1411.          SetValue(dateCol, 'text, dateCache);
  1412.       end,
  1413.     viewOriginY: 0,
  1414.     viewScrollDownScript:
  1415.       func()
  1416.       begin
  1417.           myCursor:Goto(topEntry);
  1418.           if not topEntry := myCursor:Move(visibleRows - 2) then
  1419.               if not topEntry := myCursor:Move(2 - visibleRows) then
  1420.                   topEntry := myCursor:Next();
  1421.           :fillCache();
  1422.       end,
  1423.     viewJustify: 208,
  1424.     topEntry: nil,
  1425.     visibleRows: nil,
  1426.     viewScrollUpScript:
  1427.       func()
  1428.       begin
  1429.           myCursor:Goto(topEntry);
  1430.           if not topEntry := myCursor:Move(2 - visibleRows) then
  1431.               topEntry := myCursor:Next();
  1432.           :fillCache();
  1433.       end,
  1434.     keyArray: nil,
  1435.     viewClickScript:
  1436.       func(unit)
  1437.       begin
  1438.          InkOff(unit);
  1439.          PlaySound(ROM_click);
  1440.          local box := :LocalBox();
  1441.          local row := (GetPoint(finalY, unit) - :GlobalBox().top) div viewLineSpacing;
  1442.          local theRow := row;
  1443.          local inside := true;
  1444.          local t := MakeRect(0, row * viewLineSpacing, box.right, (row+1) * viewLineSpacing);
  1445.          :DoDrawing('DrawShape, [t, kXORstyle]);
  1446.          repeat
  1447.             row := (GetPoint(finalY, unit) - :GlobalBox().top) div viewLineSpacing;
  1448.             if inside and row <> theRow then begin
  1449.                :DoDrawing('DrawShape, [t, kXORstyle]);
  1450.                inside := nil;
  1451.             end;
  1452.               else if not inside and row = theRow then begin
  1453.                   :DoDrawing('DrawShape, [t, kXORstyle]);
  1454.                   inside := true;
  1455.               end;    
  1456.             sleep(1);
  1457.          until StrokeDone(unit);
  1458.        
  1459.          row := (GetPoint(finalY, unit) - :GlobalBox().top) div viewLineSpacing;
  1460.          if row = theRow and row < length(keyArray) then 
  1461.             :EntrySelected(myCursor:GotoKey(keyArray[row]));
  1462.          else
  1463.             :EntrySelected(nil);
  1464.          if inside then
  1465.              begin    // simply XOring the rectangle again won't work, :EntrySelected() changes drawing.
  1466.                  :Dirty();
  1467.                  RefreshViews();
  1468.              end
  1469.       end;,
  1470.     viewclass: 74,
  1471.     debug: "columns",
  1472.     dateCache: nil,
  1473.     soupChanged:
  1474.       func(theSoupName)
  1475.           if StrEqual(theSoupName, kSoupName) then begin
  1476.               topEntry := myCursor:Reset();
  1477.              :FillCache();
  1478.       end
  1479.    };
  1480.  
  1481. stringCol := /* child of columns */
  1482.    {viewFormat: 12593,
  1483.     viewFont: ROM_fontSystem9;,
  1484.     viewBounds: {left: 0, top: 0, right: 300, bottom: 1000},
  1485.     viewFlags: 134217731,
  1486.     viewlinespacing: 13,
  1487.     viewclass: 81,
  1488.     debug: "stringCol"
  1489.    };
  1490. // View stringCol is declared to columns
  1491.  
  1492.  
  1493.  
  1494. dateCol := /* child of columns */
  1495.    {viewFlags: 134217731,
  1496.     viewFormat: 12593,
  1497.     viewBounds: {top: 0, left: -60, right: 0, bottom: 1000},
  1498.     viewFont: ROM_fontSystem9;,
  1499.     viewlinespacing: 13,
  1500.     viewJustify: 34,
  1501.     viewclass: 81,
  1502.     debug: "dateCol"
  1503.    };
  1504. // View dateCol is declared to columns
  1505.  
  1506.  
  1507.  
  1508. integerCol := /* child of columns */
  1509.    {viewFlags: 134217731,
  1510.     viewFormat: 12593,
  1511.     viewFont: ROM_fontSystem9;,
  1512.     viewBounds: {top: 0, left: -40, right: 0, bottom: 1000},
  1513.     viewlinespacing: 13
  1514.     ,
  1515.     viewJustify: 2049,
  1516.     viewclass: 81,
  1517.     debug: "integerCol"
  1518.    };
  1519. // View integerCol is declared to columns
  1520.  
  1521.  
  1522.  
  1523.  
  1524. // ---- File Draw Rows.t ----
  1525.  
  1526. // Before Script for "drawRows"
  1527. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  1528.  
  1529. drawRows :=
  1530.    {viewFlags: 32,
  1531.     viewFormat: 337,
  1532.     viewBounds: {top: 60, left: 0, right: 220, bottom: -22},
  1533.     fillCache:
  1534.       func()
  1535.       begin
  1536.          local fillCursor := myCursor:Clone();
  1537.          for i := 0 to numChildren-1 do begin
  1538.             :ChildViewFrames()[i]:UpdateFromSoup(fillCursor:Entry());
  1539.             fillCursor:Next();
  1540.          end;
  1541.           :Dirty();
  1542.       end,
  1543.     viewScrollUpScript:
  1544.       func()
  1545.       begin
  1546.           myCursor:Move(2 - numChildren);
  1547.           if not myCursor:Entry() then myCursor:Next();
  1548.           :FillCache();
  1549.       end,
  1550.     viewScrollDownScript:
  1551.       func()
  1552.       begin
  1553.           myCursor:Move(numChildren-2);
  1554.           :FillCache();
  1555.       end,
  1556.     viewSetupDoneScript:
  1557.       func()
  1558.       begin
  1559.          myCursor := theCursor:Clone();
  1560.          myCursor:Reset();
  1561.          :FillCache();
  1562.       end,
  1563.     soupChanged:
  1564.       func(theSoupName)
  1565.       if StrEqual(theSoupName, kSoupName) then begin
  1566.          myCursor:Reset();
  1567.          :FillCache();
  1568.       end,
  1569.     viewClickScript:
  1570.       
  1571.       func(unit)
  1572.       begin
  1573.       
  1574.       end;,
  1575.     viewQuitScript:
  1576.       func()
  1577.       begin
  1578.          keyArray := nil;
  1579.          stringCache := nil;
  1580.          dateCache := nil;
  1581.          integerCache := nil;
  1582.          myCursor := nil;
  1583.       end,
  1584.     viewSetupChildrenScript:
  1585.       func()
  1586.       begin
  1587.          numChildren := :LocalBox().bottom DIV 13 + 1;
  1588.          self.stepChildren := Array(numChildren, pt_protoDrawnRow);
  1589.       end,
  1590.     numChildren: nil,
  1591.     myCursor: nil,
  1592.     viewJustify: 208,
  1593.     viewclass: 74,
  1594.     debug: "drawRows"
  1595.    };
  1596.  
  1597.  
  1598. // ---- File SimpleRows.t ----
  1599.  
  1600. // Before Script for "simpleRows"
  1601. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  1602.  
  1603. simpleRows :=
  1604.    {viewFlags: 32,
  1605.     viewFormat: 337,
  1606.     viewBounds: {top: 60, left: 0, right: 220, bottom: -22},
  1607.     fillCache:
  1608.       func()
  1609.       begin
  1610.          local fillCursor := myCursor:Clone();
  1611.          for i := 0 to numChildren-1 do begin
  1612.             :ChildViewFrames()[i]:UpdateFromSoup(fillCursor:Entry());
  1613.             fillCursor:Next();
  1614.          end;
  1615.           :Dirty();
  1616.       end,
  1617.     viewScrollUpScript:
  1618.       func()
  1619.       begin
  1620.           myCursor:Move(2 - numChildren);
  1621.           if not myCursor:Entry() then myCursor:Next();
  1622.           :FillCache();
  1623.       end,
  1624.     viewScrollDownScript:
  1625.       func()
  1626.       begin
  1627.           myCursor:Move(numChildren-2);
  1628.           :FillCache();
  1629.       end,
  1630.     viewSetupDoneScript:
  1631.       func()
  1632.       begin
  1633.          myCursor := theCursor:Clone();
  1634.          myCursor:Reset();
  1635.          :FillCache();
  1636.       end,
  1637.     soupChanged:
  1638.       func(theSoupName)
  1639.       if StrEqual(theSoupName, kSoupName) then begin
  1640.          myCursor:Reset();
  1641.          :FillCache();
  1642.       end,
  1643.     viewClickScript:
  1644.       
  1645.       func(unit)
  1646.       begin
  1647.       
  1648.       end;,
  1649.     viewQuitScript:
  1650.       func()
  1651.       begin
  1652.          keyArray := nil;
  1653.          stringCache := nil;
  1654.          dateCache := nil;
  1655.          integerCache := nil;
  1656.          myCursor := nil;
  1657.       end,
  1658.     viewSetupChildrenScript:
  1659.       func()
  1660.       begin
  1661.          numChildren := :LocalBox().bottom DIV 13 + 1;
  1662.          self.stepChildren := Array(numChildren, pt_protoSimpleRow);
  1663.       end,
  1664.     numChildren: nil,
  1665.     myCursor: nil,
  1666.     viewJustify: 208,
  1667.     viewclass: 74,
  1668.     debug: "simpleRows"
  1669.    };
  1670.  
  1671.  
  1672. // ---- File TappedOn.t ----
  1673.  
  1674. // Before Script for "tappedOn"
  1675. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  1676.  
  1677. tappedOn :=
  1678.    {text: "",
  1679.     viewBounds: {left: 0, top: 0, right: 160, bottom: 80},
  1680.     viewFormat: 83886673,
  1681.     viewJustify: 86,
  1682.     viewFlags: 2,
  1683.     viewEffect: 236577,
  1684.     _proto: protoStaticText,
  1685.     debug: "tappedOn"
  1686.    };
  1687.  
  1688.  
  1689. // End of output