// ---- End Project Data ---- // ---- File Different Strokes.t ---- // Before Script for "strokeApp" // Copyright 1993-1994 Apple Computer, Inc.. All rights reserved. strokeApp := {title: "Different Strokes", viewBounds: {top: 0, left: 0, right: 240, bottom: 336}, 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) ); end, _proto: protoApp, debug: "strokeApp" }; canvas := /* child of strokeApp */ {viewFlags: 513, viewFormat: 336, viewBounds: {left: 11, top: 19, right: 233, bottom: 281}, viewClickScript: // Sample code Copyright(c) 1993 by Apple Computer Inc. // Written by Bob Ebert. func(unit) begin local a, p, temp; // pause here until the user is done making the stroke. // Yes! You can do this... surprised me too. while not StrokeDone(unit) do Sleep(10); // Turn the stroke into an array of points // and put them in X,Y order (they come in Y,X order from GetPointsArray) // and offset them so they are relative to the current view. a := GetPointsArray(unit); for i := 0 to Length(a)-1 by 2 do begin temp := a[i]; a[i] := a[i+1] - viewBounds.left; a[i+1] := temp - viewBounds.top; end; // make a drawing object from the resulting array, add it to the // stroke accumulator slot for this view, and draw it. p := MakePolygon(a); AddArraySlot(strokes, p); // strokes is set up in viewSetupDoneScript :DoDrawing('DrawShape, [p, nil]); // return TRUE so no one else handles the "click" TRUE; end, viewDrawScript: // This script draws all the strokes in the accumulator in the default // style. It's very boring. func() begin foreach stroke in strokes do :DrawShape(stroke, nil); end, viewSetupDoneScript: func() begin // initialize the strokes accumulator. I didn't just add a slot // to the template because then we'd have to make sure it was // in RAM and that's a pain. Easier to just assign it here. self.strokes := []; end, viewclass: 74, debug: "canvas" }; // View canvas is declared to strokeApp _view000 := /* child of strokeApp */ {text: "Erase", buttonClickScript: func() begin // erase the canvas by setting its accumulator array // back to empty and dirtying the view. canvas.strokes := []; canvas:Dirty(); end, viewBounds: {top: 298, left: 0, right: 75, bottom: 314}, viewJustify: 8388630, _proto: protoTextButton }; // ---- Beginning of section for non used Layout files ---- // End of output