// Text of project Drawing written on 5/9/95 at 2:34 PM // Beginning of file Draw.t // Before Script for "_view000" /* ** Newton Developer Technical Support Sample Code ** ** Drawing, Shows how to use shapes ** ** by Bob Ebert, Newton Developer Technical Support ** ** Copyright © 1993-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. */ nil; // result of beforeScript _view000 := {title: "Drawing Examples", viewBounds: {left: -1, top: 0, right: 236, bottom: 325}, viewDrawScript: func() begin :DrawMe(); // just draw all the shapes end, myLine: nil, myRect: nil, myRoundRect: nil, myOval: nil, myWedge: nil, myPolygon: nil, myShape: nil, myRegion: nil, myPict: nil, myText: nil, myScaledPict: nil, myStyle: nil, DrawMe: func() begin /* There are two ways to pass shapes to DrawShape, either individual shape objects, or all of them inside an Array. We show both techniques in this sample. :DrawShape(myLine, myStyle); :DrawShape(myRect, myStyle); :DrawShape(myRoundRect, myStyle); :DrawShape(myOval, myStyle); :DrawShape(myWedge, myStyle); :DrawShape(myPolygon, myStyle); :DrawShape(myRegion, myStyle); :DrawShape(myPict, myStyle); :DrawShape(myText, myStyle); :DrawShape(myScaledPict, myStyle); */ :DrawShape([myLine, myRect, myRoundRect, myOval, myWedge, myPolygon, myRegion, myPict, myText, myScaledPict], myStyle); end, viewSetupDoneScript: func() begin // Create all the example shape objects. myLine := MakeLine(0,0, 20, 20); myRect := MakeRect(0,30,20,50); myRoundRect := MakeRoundRect(0, 60, 20, 80, 10); myOval := MakeOval(0, 90, 20, 110); myWedge := MakeWedge(0, 120, 20, 140, 0, 90); myPolygon := MakePolygon([0, 150, 20, 170, 20, 150]); local rectangle := MakeRect(0, 210, 30, 230); local oval := MakeOval(0, 220, 30, 240); myRegion := MakeRegion([rectangle, oval,]); myText := MakeText("Bob", 0, 250, 55, 270); myPict := MakePict([myLine, myRect, myRoundRect, myOval, myWedge, myPolygon, myRegion, myText], myStyle); // Do the PICT thing, adjust the PICT resource to the pict shape object. OffsetShape(myPict, 40, 5); myScaledPict := DeepClone(myPict); local startRect := ShapeBounds(myScaledPict); local endRect := {left: 80, top: 10, right: 150, bottom: 150,}; ScaleShape(myScaledPict, startRect, endRect); end, viewSetupFormScript: func() begin local a := GetAppParams(); self.viewBounds := RelBounds(a.appAreaLeft, a.appAreaTop, a.appAreaWidth, a.appAreaHeight); end, viewQuitScript: func() begin // NIL out all the shapes to reclaim some space. myLine := nil; myRect := nil; myRoundRect := nil; myOval := nil; myWedge := nil; myPolygon := nil; myRegion := nil; myText := nil; myPict := nil; myScaledPict := nil; myStyle := nil; end, _proto: @157 }; _view001 := {viewFlags: 545, viewFormat: 336, viewBounds: {left: 122, top: 18, right: 234, bottom: 138}, viewClickScript: func(unit) begin // We will lock the screen, do the drawing, and unlock // the screen. :LockScreen(true); :DoDrawing('DrawMe, nil); // :DrawMe(); // Don't do it this way, won't set up clipping etc. :LockScreen(nil); end, viewClass: 74 }; AddStepForm(_view000, _view001); constant |layout_Draw.t| := _view000; // End of file Draw.t