DIRECTORY Imager, ImagerFont, IO, Pipal, PipalInt, PipalPaint, PipalReal, PipalWB, Real, Rope; PipalWBImpl: CEDAR PROGRAM IMPORTS Imager, ImagerFont, IO, Pipal, PipalInt, PipalPaint, PipalReal, Real EXPORTS PipalWB = BEGIN OPEN PipalWB; boxedTextClass: PUBLIC Pipal.Class _ Pipal.RegisterClass[name: "BoxedText", type: CODE [BoxedTextRec]]; SizeBoxedText: PipalInt.SizeProc ~ { size _ NARROW [object, BoxedText].size}; fixedFont: Imager.Font _ Imager.FindFontScaled["Xerox/XC1-2-2/Modern", 20.0]; PaintBoxedText: PipalPaint.PaintProc ~ { data: BoxedText _ NARROW [object]; Imager.SetXY[context, [0.0, 0.0]]; PipalPaint.SetColor[context, Imager.black]; Imager.SetFont[context, fixedFont]; Imager.ShowRope[context, data.rope]; }; DescribeBoxedText: Pipal.DescribeProc = { boxedText: BoxedText _ NARROW [object]; Pipal.PutIndent[out, indent, cr]; IO.PutF[out, "BoxedText [%g]", IO.rope[boxedText.rope]]; }; CreateBoxedText: PUBLIC PROC [rope: Rope.ROPE, size: PipalInt.Size] RETURNS [boxedText: BoxedText] ~ { boxedText _ NEW[BoxedTextRec _ [rope: rope, size: size]]; IF size=PipalInt.emptySize THEN { extents: ImagerFont.Extents _ ImagerFont.RopeBoundingBox[font: fixedFont, rope: rope]; boxedText.size _ [Real.Round[extents.leftExtent+extents.rightExtent], Real.Round[extents.descent+extents.ascent]]; }; }; Pipal.PutClassMethod[boxedTextClass, PipalInt.sizeMethod, NEW [PipalInt.SizeProc _ SizeBoxedText]]; Pipal.PutClassMethod[boxedTextClass, PipalReal.sizeMethod, NEW [PipalReal.SizeProc _ PipalReal.UseIntSize]]; Pipal.PutClassMethod[boxedTextClass, PipalInt.abutBoxMethod, NEW [PipalInt.AbutBoxProc _ PipalInt.AbutBoxFromSize]]; Pipal.PutClassMethod[boxedTextClass, PipalPaint.paintMethod, NEW [PipalPaint.PaintProc _ PaintBoxedText]]; Pipal.PutClassMethod[boxedTextClass, Pipal.describeMethod, NEW [Pipal.DescribeProc _ DescribeBoxedText]]; END. PipalWBImpl.mesa Copyright Σ 1988 by Xerox Corporation. All rights reserved. Louis Monier January 15, 1988 9:10:02 pm PST Bertrand Serlet May 19, 1988 6:33:49 pm PDT Boxed Text -- problem: the size of a rope is naturally expressed in real numbers! Initialization Κλ– "cedar" style˜codešœ™Kšœ<™˜^K˜•StartOfExpansion[]šΟn œœ˜Kšœœ.˜LKšœ ˜Kšœœ ˜—head™ Kšœœ<œ˜gšž œ˜$Kšœœ˜(—K˜šœM˜MK˜—šžœ˜(Kšœœ ˜"Kšœ"˜"Kšœ+˜+Kšœ#˜#Kšœ$˜$Kšœ˜K˜—šžœ˜)Jšœœ ˜'Kšœ!˜!Kšœœ˜9K˜K˜—KšΟcF™Fš žœœœ œœ˜fKšœ œ*˜9šœœ˜!KšœV˜VKšœr˜rK˜—K˜K˜——™Kšœ:œ&˜cKšœ;œ.˜lKšœ=œ4˜tKšœ=œ*˜jKšœ;œ+˜i—K˜Kšœ˜K˜—…—F A