DIRECTORY Graphics, GraphicsColor, Inline, Real, Rope, TSFont, TSTypes, TSOutput, VFonts, ViewerClasses, ViewerOps; TSOutputDisplayImpl: CEDAR PROGRAM IMPORTS Graphics, GraphicsColor, Inline, Real, TSFont, TSTypes, VFonts, ViewerOps EXPORTS TSOutput = BEGIN DisplayState: TYPE = REF DisplayStateRec; DisplayStateRec: TYPE = RECORD [ viewer: ViewerClasses.Viewer _ NIL, color: Graphics.Color _ Graphics.black, callBackProc: DisplayProc _ NIL, currentFont: TSFont.Ref _ NIL, graphicsFont: Graphics.FontRef _ NIL, pageHeight: REAL ]; DisplayProc: TYPE = PROCEDURE [dc: Graphics.Context]; CreateViewer: PUBLIC PROCEDURE [viewerName: Rope.ROPE _ NIL] RETURNS [handle: TSOutput.Handle] = { displayState: DisplayState _ NEW[DisplayStateRec]; v: ViewerClasses.Viewer _ ViewerOps.FindViewer[viewerName]; IF v # NIL THEN ViewerOps.DestroyViewer[v]; handle _ NEW[TSOutput.OutputRec]; handle.charProc _ Char; handle.ruleProc _ Rule; handle.colorProc _ Color; handle.newPageProc _ NewPage; handle.pageSizeProc _ PageSize; handle.finishProc _ Finish; handle.outputState _ displayState; displayState.viewer _ ViewerOps.CreateViewer[ flavor: $TSDisplay, info: [ name: viewerName, iconic: FALSE, column: left, scrollable: TRUE, data: handle], paint: TRUE]; }; Char: TSOutput.CharProc = { -- [self: Handle, x, y: TSTypes.Dimn, char: CHAR, font: TSFont.Ref] displayState: DisplayState _ NARROW[self.outputState]; CharPaint: DisplayProc = { Graphics.SetColor[dc, displayState.color]; Graphics.SetCP[dc, x.DimnInt[TSTypes.pt], y.DimnInt[TSTypes.pt]]; Graphics.DrawChar[dc, char, displayState.graphicsFont]; }; SetFont[displayState, font]; Painter[CharPaint, displayState]; }; SetFont: PROCEDURE [displayState: DisplayState, font: TSFont.Ref] = { IF displayState.currentFont # font AND font # NIL THEN { family: Rope.ROPE; micaSize: INTEGER; pointsPerMica: REAL = 72.0/2540.0; face: [0..255]; rotation: INTEGER; [family, micaSize, face, rotation] _ TSFont.ParcFontSpecification[font]; displayState.graphicsFont _ VFonts.GraphicsFont[ VFonts.EstablishFont[ family: family, size: Real.RoundI[micaSize * pointsPerMica], bold: Inline.BITAND[face, 2], italic: Inline.BITAND[face, 1], defaultOnFailure: TRUE ] ]; }; displayState.currentFont _ font; }; Rule: TSOutput.RuleProc = { -- [self: Handle, leftX, bottomY, width, height: TSTypes.Dimn] displayState: DisplayState _ NARROW[self.outputState]; RulePaint: DisplayProc = { Graphics.SetColor[dc, displayState.color]; Graphics.DrawBox[dc, [leftX.DimnInt[TSTypes.pt], bottomY.DimnInt[TSTypes.pt], leftX.AddDimn[width].DimnInt[TSTypes.pt], bottomY.AddDimn[height].DimnInt[TSTypes.pt]]]; }; Painter[RulePaint, displayState]; }; Color: TSOutput.ColorProc = { -- [self: Handle, hue, saturation, brightness: REAL] displayState: DisplayState _ NARROW[self.outputState]; displayState.color _ GraphicsColor.HSVToColor[hue, saturation, brightness]; }; NewPage: TSOutput.NewPageProc = { -- [self: Handle] displayState: DisplayState _ NARROW[self.outputState]; ViewerOps.PaintViewer[viewer: displayState.viewer, hint: all, whatChanged: NIL, clearClient: TRUE]; }; PageSize: TSOutput.PageSizeProc = { -- [self: Handle, height, width: TSTypes.Dimn] displayState: DisplayState _ NARROW[self.outputState]; displayState.pageHeight _ height.texPts; }; Finish: TSOutput.FinishProc = { -- [self: Handle] }; TSDisplayPaint: ViewerClasses.PaintProc = { -- [self: ViewerClasses.Viewer, context: Graphics.Context, whatChanged: REF ANY, clear: BOOL] displayState: DisplayState; IF whatChanged # NIL AND ISTYPE[whatChanged, DisplayState] THEN { displayState _ NARROW[whatChanged, DisplayState]; Graphics.Translate[context, 0.0, self.ch - displayState.pageHeight]; displayState.callBackProc[context]; }; }; Painter: PROCEDURE [proc: DisplayProc, displayState: DisplayState] = { CallBack: DisplayProc = { proc[dc]; }; TRUSTED { displayState.callBackProc _ CallBack; ViewerOps.PaintViewer[viewer: displayState.viewer, hint: client, whatChanged: displayState, clearClient: FALSE]; }; }; tsDisplayClass: ViewerClasses.ViewerClass = NEW[ViewerClasses.ViewerClassRec _ ViewerOps.FetchViewerClass[$Container]^]; containerPaint: ViewerClasses.PaintProc = tsDisplayClass.paint; tsDisplayClass.coordSys _ bottom; tsDisplayClass.paint _ TSDisplayPaint; ViewerOps.RegisterViewerClass[$TSDisplay, tsDisplayClass]; END. >TSOutputDisplayImpl.mesa Implements TSOutput interface for the Tioga typesetter to display in a Viewer/Imager context Created by: Beach, October 18, 1983 10:39 am displayState: DisplayState _ NARROW[self.outputState]; Edited on October 6, 1983 2:39 pm, by Beach Modified TSOutputPressImpl.Mesa to get this interface, DIRECTORY, DisplayProc, Char, paint (local of Char), TSDiplayPaint, tSDisplayClass, containerPaint, tSDisplayClass, ViewerOps, Rule, RulePaint (local of Rule), Color, NewPage, PageSize, Finish, TSDiplayPaint, Painter, CallBack (local of Painter) ΚŠ– "cedar" style˜JšΟc™Jš\™\J™,šΟk ˜ J˜ J˜J˜J˜J˜J˜J˜J˜ J˜J˜J˜ J˜—šœžœž˜"JšžœJ˜QJšžœ ˜—Jšž˜J˜Jšœžœžœ˜)šœžœžœ˜ Jšœž˜#J˜'Jšœžœ˜ Jšœžœ˜Jšœ!ž˜%Jšœ žœ˜J˜J˜—šΟn œžœž œ˜5J˜—šŸ œžœž œžœ˜bJšœžœ˜2Jšœ;˜;Jšžœžœžœ˜+Jšœ žœ˜!J˜J˜J˜J˜J˜J˜J˜"˜-˜˜J˜Jšœžœ˜J˜ Jšœ ž˜Jšœ˜—Jšœžœ˜ ——Jšœ˜J˜—šŸœC˜_Jšœžœ˜6šŸ œ˜J•StartOfExpansionR[self: Graphics.Context, char: CHARACTER, font: GraphicsBasic.FontRef _ NIL]˜*J˜AJ˜7J˜—Jšœ˜Jšœ!˜!J˜J˜—šŸœž œ3˜Ešžœ!žœžœ˜8Jšœ žœ˜Jšœ žœ˜Jšœžœ˜"Jšœ˜Jšœ žœ˜J˜Hšœ0˜0šœ˜Jšœ˜Jšœ,˜,Jšœ žœ ˜Jšœžœ ˜Jšœžœ˜—Jšœ˜—Jšœ˜—Jšœ ˜ J˜J˜—šŸœ<˜ZJšœžœ˜6šŸ œ˜J˜*J˜¦J˜—Jšœ!˜!J˜—J˜šŸœ4˜RJšœžœ˜6J˜KJ˜J˜—šŸœ˜3Jšœžœ˜6JšœKžœžœ˜cJ˜J˜—šŸœ.˜RJšœžœ˜6J˜(J˜J˜—šŸœ˜1Jšœžœ™6J˜J˜—šŸœ_˜‹Jšœ˜š žœžœžœžœžœ˜AJšœžœ˜1J˜EJ˜#Jšœ˜—J˜J˜—šŸœž œ3žœ˜GJšŸœ˜&šœ ˜ Jšœ%˜%Jšœižœ˜pJ˜—J˜J˜—˜+JšžœI˜L—J˜?J˜!J˜&J˜:J˜Jšžœ˜™+Jšœ5Οr%œ [œ Dœ™¬—J™J™Jš™—…—βͺ