-
Notifications
You must be signed in to change notification settings - Fork 1
/
U1SampleTK.TEXT
executable file
·452 lines (342 loc) · 12.4 KB
/
U1SampleTK.TEXT
1
UNIT U1TK;{ NB - in LisaEm, IF statements currently cause linker errors }{ Comment out IF object = NIL lines below if compiling as-is }INTERFACEUSES {$U UObject} UObject, {$U QuickDraw } QuickDraw, {$U UDraw } UDraw, {$U UABC} UABC;TYPE TBoxProcess = SUBCLASS OF TProcess FUNCTION TBoxProcess.CREATE: TBoxProcess; FUNCTION TBoxProcess.NewDocManager(volumePrefix: TFilePath; openAsTool: BOOLEAN) : TDocManager; OVERRIDE; END; TBoxDocManager = SUBCLASS of TDocManager FUNCTION TBoxDocManager.CREATE(object: TObject; itsHeap: THeap; itsPathPrefix: TFilePath): TBoxDocManager; FUNCTION TBoxDocManager.NewWindow(heap: THeap; wmgrID: TWindowID): TWindow; OVERRIDE; END; TBoxWindow = SUBCLASS OF TWindow FUNCTION TBoxWindow.CREATE(object: TObject; itsHeap: THeap; itsWmgrID: TWindowID): TBoxWindow; PROCEDURE TBoxWindow.BlankStationery; OVERRIDE; END; TBoxView = SUBCLASS OF TView FUNCTION TBoxView.CREATE(object: TObject; itsHeap: THeap; itsPanel: TPanel; itsExtent: LRect): TBoxView; PROCEDURE TBoxView.Draw; OVERRIDE; PROCEDURE InitIcons; PROCEDURE DrawStuff; PROCEDURE DrawIcon(whichIcon:INTEGER; h:INTEGER; v: INTEGER); END; TYPE IconData = ARRAY[0..95] OF INTEGER;VAR icons: ARRAY[0..5] OF IconData;IMPLEMENTATIONMETHODS of TBoxProcess; FUNCTION TBoxProcess.CREATE: TBoxProcess; BEGIN {$IFC fTrace} BP(11); {$ENDC} SELF := TBoxProcess(TProcess.Create(NewObject(mainHeap, THISCLASS), mainHeap)); {$IFC fTrace}EP;{$ENDC} END; FUNCTION TBoxProcess.NewDocManager(volumePrefix: TFilePath; openAsTool: BOOLEAN): TDocManager; BEGIN {$IFC fTrace} BP(11); {$ENDC} NewDocManager := TBoxDocManager.CREATE(nil, mainHeap, volumePrefix); {$IFC fTrace}EP;{$ENDC} END;END;METHODS OF TBoxDocManager; FUNCTION TBoxDocManager.CREATE(object: TObject; itsHeap: THeap; itsPathPrefix: TFilePath) : TBoxDocManager; BEGIN {$IFC fTrace} BP(11); {$ENDC} IF object = NIL THEN object := NewObject(itsHeap, THISCLASS); SELF := TBoxDocManager(TDocManager.CREATE(object, itsHeap, itsPathPrefix)); {$IFC fTrace}EP;{$ENDC} END; FUNCTION TBoxDocManager.NewWindow(heap: THeap; wmgrID: TwindowID): Twindow; BEGIN {$IFC fTrace} BP(11); {$ENDC} NewWindow := TBoxWindow.CREATE(NIL, heap, wmgrID); {$IFC fTrace} EP; {$ENDC} END;END;METHODS OF TBoxWindow; FUNCTION TBoxWindow.CREATE(object: TObject; itsHeap: THeap; itsWmgrID: TWindowID): TBoxWindow; BEGIN {$IFC fTrace} BP(11); {$ENDC} IF object = NIL THEN object := NewObject(itsHeap, THISCLASS); SELF := TBoxWindow(TWindow.CREATE(object, itsHeap, itsWmgrID, TRUE)); {$IFC fTrace} EP; {$ENDC} END; PROCEDURE TBoxWindow.BlankStationery; VAR viewLRect: LRect; panel: TPanel; boxView: TBoxView; BEGIN {$IFC fTrace} BP(11); {$ENDC} SetLRect(viewLRect,0,0,500,300); panel := TPanel.CREATE(NIL, SELF.Heap, SELF, 0, 0, [aBar,aScroll,aSplit], [aBar,aScroll,aSplit]); boxView := TBoxView.CREATE(NIL, SELF.Heap, panel, zeroLRect); {$IFC fTrace} EP; {$ENDC} END;END;METHODS OF TBoxView; FUNCTION TBoxView.Create(object: TObject; itsHeap: THeap; itsPanel: TPanel; itsExtent: LRect): TBoxView; BEGIN {$IFC fTrace} BP(11); {$ENDC} IF object = NIL THEN object := NewObject(itsHeap, THISCLASS); SELF := TBoxView(itsPanel.NewView(object, itsExtent, NIL, stdMargins, FALSE)); {$IFC fTrace} EP; {$ENDC} END; PROCEDURE TBoxView.Draw; BEGIN {$IFC fTrace} BP(11); {$ENDC} FillRect(thePort^.portRect, white); TBoxView.InitIcons; TBoxView.DrawStuff; {$IFC fTrace} EP; {$ENDC} END; PROCEDURE DrawStuff; VAR i: INTEGER; tempRect: Rect; myPoly: PolyHandle; myRgn: RgnHandle; myPattern: Pattern; BEGIN StuffHex(@myPattern,'8040200002040800'); tempRect := thePort^.portRect; ClipRect(tempRect); EraseRoundRect(tempRect,30,20); FrameRoundRect(tempRect,30,20); { draw two horizontal lines across the top } MoveTo(0,18); LineTo(719,18); MoveTo(0,20); LineTo(719,20); { draw divider lines } MoveTo(0,134); LineTo(719,134); MoveTo(0,248); LineTo(719,248); MoveTo(240,21); LineTo(240,363); MoveTo(480,21); LineTo(480,363); { draw title } TextFont(0); MoveTo(210,14); DrawString('Look what you can draw with QuickDraw'); {--------- draw text samples --------- } MoveTo(80,34); Drawstring('Text'); TextFace([bold]); MoveTo(70,55); Drawstring('Bold'); TextFace([italic]); MoveTo(70,70); Drawstring('Italic'); TextFace([underline]); MoveTo(70,85); Drawstring('Underline'); TextFace([outline]); MoveTo(70,100); Drawstring('Outline'); TextFace([shadow]); MoveTo(70,115); Drawstring('Shadow'); TextFace([]); { restore to normal } { --------- draw line samples --------- } MoveTo(330,34); Drawstring('Lines'); MoveTo(280,25); Line(160,40); PenSize(3,2); MoveTo(280,35); Line(160,40); PenSize(6,4); MoveTo(280,46); Line(160,40); PenSize(12,8); PenPat(gray); MoveTo(280,61); Line(160,40); PenSize(15,10); PenPat(myPattern); MoveTo(280,80); Line(160,40); PenNormal; { --------- draw rectangle samples --------- } MoveTo(560,34); Drawstring('Rectangles'); SetRect(tempRect,510,40,570,70); FrameRect(tempRect); OffsetRect(tempRect,25,15); PenSize(3,2); EraseRect(tempRect); FrameRect(tempRect); OffsetRect(tempRect,25,15); PaintRect(tempRect); OffsetRect(tempRect,25,15); PenNormal; FillRect(tempRect,gray); FrameRect(tempRect); OffsetRect(tempRect,25,15); FillRect(tempRect,myPattern); FrameRect(tempRect); { --------- draw roundRect samples --------- } MoveTo(70,148); Drawstring('RoundRects'); SetRect(tempRect,30,150,90,180); FrameRoundRect(tempRect,30,20); OffsetRect(tempRect,25,15); PenSize(3,2); EraseRoundRect(tempRect,30,20); FrameRoundRect(tempRect,30,20); OffsetRect(tempRect,25,15); PaintRoundRect(tempRect,30,20); OffsetRect(tempRect,25,15); PenNormal; FillRoundRect(tempRect,30,20,gray); FrameRoundRect(tempRect,30,20); OffsetRect(tempRect,25,15); FillRoundRect(tempRect,30,20,myPattern); FrameRoundRect(tempRect,30,20); { --------- draw bit image samples --------- } MoveTo(320,148); Drawstring('Bit Images'); TBoxView.DrawIcon(0,266,156); TBoxView.DrawIcon(1,336,156); TBoxView.DrawIcon(2,406,156); TBoxView.DrawIcon(3,266,196); TBoxView.DrawIcon(4,336,196); TBoxView.DrawIcon(5,406,196); { --------- draw Wedge samples --------- } MoveTo(570,148); Drawstring('Wedges'); SetRect(tempRect,520,153,655,243); FillArc(tempRect,135,65,dkGray); FillArc(tempRect,200,130,myPattern); FillArc(tempRect,330,75,gray); FrameArc(tempRect,135,270); OffsetRect(tempRect,20,0); PaintArc(tempRect,45,90); { --------- draw polygon samples --------- } MoveTo(80,262); Drawstring('Polygons'); myPoly:=OpenPoly; MoveTo(30,290); LineTo(30,280); LineTo(50,265); LineTo(90,265); LineTo(80,280); LineTo(95,290); LineTo(30,290); ClosePoly; { end of definition } FramePoly(myPoly); OffsetPoly(myPoly,25,15); PenSize(3,2); ErasePoly(myPoly); FramePoly(myPoly); OffsetPoly(myPoly,25,15); PaintPoly(myPoly); OffsetPoly(myPoly,25,15); PenNormal; FillPoly(myPoly,gray); FramePoly(myPoly); OffsetPoly(myPoly,25,15); FillPoly(myPoly,myPattern); FramePoly(myPoly); KillPoly(myPoly); { --------- demonstrate region clipping --------- } MoveTo(320,262); Drawstring('Regions'); myRgn:=NewRgn; OpenRgn; ShowPen; SetRect(tempRect,260,270,460,350); FrameRoundRect(tempRect,24,16); MoveTo(275,335); { define triangular hole } LineTo(325,285); LineTo(375,335); LineTo(275,335); SetRect(tempRect,365,277,445,325); { oval hole } FrameOval(tempRect); HidePen; CloseRgn(myRgn); { end of definition } SetClip(myRgn); ClipRect(thePort^.portRect); DisposeRgn(myRgn); { --------- draw oval samples --------- } MoveTo(580,262); Drawstring('Ovals'); SetRect(tempRect,510,264,570,294); FrameOval(tempRect); OffsetRect(tempRect,25,15); PenSize(3,2); EraseOval(tempRect); FrameOval(tempRect); OffsetRect(tempRect,25,15); PaintOval(tempRect); OffsetRect(tempRect,25,15); PenNormal; FillOval(tempRect,gray); FrameOval(tempRect); OffsetRect(tempRect,25,15); FillOval(tempRect,myPattern); FrameOval(tempRect); END; { DrawStuff } PROCEDURE DrawIcon(whichIcon,h,v: INTEGER); VAR srcBits: BitMap; srcRect,dstRect: Rect; BEGIN srcBits.baseAddr:=@icons[whichIcon]; srcBits.rowBytes:=6; SetRect(srcBits.bounds,0,0,48,32); srcRect:=srcBits.bounds; dstRect:=srcRect; OffsetRect(dstRect,h,v); CopyBits(srcBits,thePort^.portBits,srcRect,dstRect,srcOr,Nil); END; PROCEDURE InitIcons; { Manually stuff some icons. Normally we would read them from a file } BEGIN { Lisa } StuffHex(@icons[0, 0],'000000000000000000000000000000000000001FFFFFFFFC'); StuffHex(@icons[0,12],'00600000000601800000000B0600000000130FFFFFFFFFA3'); StuffHex(@icons[0,24],'18000000004311FFFFF00023120000080F231200000BF923'); StuffHex(@icons[0,36],'120000080F23120000080023120000080023120000080F23'); StuffHex(@icons[0,48],'1200000BF923120000080F2312000008002311FFFFF00023'); StuffHex(@icons[0,60],'08000000004307FFFFFFFFA30100000000260FFFFFFFFE2C'); StuffHex(@icons[0,72],'18000000013832AAAAA8A9F0655555515380C2AAAA82A580'); StuffHex(@icons[0,84],'800000000980FFFFFFFFF300800000001600FFFFFFFFFC00'); { Printer } StuffHex(@icons[1, 0],'000000000000000000000000000000000000000000000000'); StuffHex(@icons[1,12],'00000000000000007FFFFF00000080000280000111514440'); StuffHex(@icons[1,24],'0002000008400004454510400004000017C00004A5151000'); StuffHex(@icons[1,36],'0004000010000004A54510000004000017FE00F4A5151003'); StuffHex(@icons[1,48],'0184000013870327FFFFF10F06400000021B0CFFFFFFFC37'); StuffHex(@icons[1,60],'18000000006B3000000000D77FFFFFFFFFABC00000000356'); StuffHex(@icons[1,72],'8000000001AC87F000000158841000CCC1B087F000CCC160'); StuffHex(@icons[1,84],'8000000001C0C000000003807FFFFFFFFF0007800001E000'); { Trash Can } StuffHex(@icons[2, 0],'000001FC000000000E0600000000300300000000C0918000'); StuffHex(@icons[2,12],'00013849800000026C4980000004C0930000000861260000'); StuffHex(@icons[2,24],'0010064FE0000031199830000020E6301800002418E00800'); StuffHex(@icons[2,36],'0033E3801C0000180E002C00000FF801CC0000047FFE0C00'); StuffHex(@icons[2,48],'000500004C000005259A4C000005250A4C00000525FA4C00'); StuffHex(@icons[2,60],'000524024C00000524924C00600524924C0090E524924C7C'); StuffHex(@icons[2,72],'932524924C82A44524924D01C88524924CF10C4524924C09'); StuffHex(@icons[2,84],'0784249258E70003049233100000E000E40800001FFFC3F0'); { tray } StuffHex(@icons[3, 0],'000000000000000000000000000000000000000000000000'); StuffHex(@icons[3,12],'0000000000000000000000000000000000000007FFFFFFF0'); StuffHex(@icons[3,24],'000E00000018001A00000038003600000078006A000000D8'); StuffHex(@icons[3,36],'00D7FFFFFFB801AC000003580358000006B807FC000FFD58'); StuffHex(@icons[3,48],'040600180AB80403FFF00D58040000000AB8040000000D58'); StuffHex(@icons[3,60],'040000000AB807FFFFFFFD5806AC00000AB8055800000D58'); StuffHex(@icons[3,72],'06B000000AB807FC000FFD70040600180AE00403FFF00DC0'); StuffHex(@icons[3,84],'040000000B80040000000F00040000000E0007FFFFFFFC00'); { File Cabinet } StuffHex(@icons[4, 0],'0007FFFFFC00000800000C00001000001C00002000003400'); StuffHex(@icons[4,12],'004000006C0000FFFFFFD40000800000AC0000BFFFFED400'); StuffHex(@icons[4,24],'00A00002AC0000A07F02D40000A04102AC0000A07F02D400'); StuffHex(@icons[4,36],'00A00002AC0000A08082D40000A0FF82AC0000A00002D400'); StuffHex(@icons[4,48],'00A00002AC0000BFFFFED40000800000AC0000BFFFFED400'); StuffHex(@icons[4,60],'00A00002AC0000A07F02D40000A04102AC0000A07F02D400'); StuffHex(@icons[4,72],'00A00002AC0000A08082D40000A0FF82AC0000A00002D800'); StuffHex(@icons[4,84],'00A00002B00000BFFFFEE00000800000C00000FFFFFF8000'); { drawer } StuffHex(@icons[5, 0],'000000000000000000000000000000000000000000000000'); StuffHex(@icons[5,12],'000000000000000000000000000000000000000000000000'); StuffHex(@icons[5,24],'000000000000000000000000000000000000000000000000'); StuffHex(@icons[5,36],'00000000000000000000000000000000000000001FFFFFF0'); StuffHex(@icons[5,48],'0000380000300000680000700000D80000D0003FFFFFF1B0'); StuffHex(@icons[5,60],'0020000013500020000016B000201FE01D50002010201AB0'); StuffHex(@icons[5,72],'00201FE01560002000001AC0002000001580002020101B00'); StuffHex(@icons[5,84],'00203FF01600002000001C00002000001800003FFFFFF000'); END;END; { TBoxView }END.