<> <> <> DIRECTORY IO, SirPress, TSTypes, TSFont, TSOutput, TSOutputPress, Real, Rope; TSOutputPressImpl: CEDAR PROGRAM IMPORTS SirPress, TSTypes, TSFont, Real, Rope EXPORTS TSOutputPress = BEGIN OPEN TSTypes; CreateWithCursor: PUBLIC PROCEDURE [stream: IO.STREAM, documentName: Rope.ROPE, cursorObject: SirPress.CursorObject] RETURNS [handle: TSOutput.Handle] = { pressState: TSOutputPress.PressState _ NEW[TSOutputPress.PressStateRec]; pressState.pressHandle _ SirPress.Create[ outputStream: stream, fileNameForHeaderPage: documentName, cursorObject: cursorObject ]; pressState.pipe _ SirPress.NewPipe[500]; pressState.graphicsContext _ NIL; handle _ NEW[TSOutput.OutputRec]; handle.charProc _ Char; handle.ruleProc _ Rule; handle.colorProc _ Color; handle.newPageProc _ NewPage; handle.pageSizeProc _ PageSize; handle.finishProc _ Finish; handle.outputState _ pressState; }; <> Char: TSOutput.CharProc = { pressState: TSOutputPress.PressState _ NARROW[self.outputState]; SetFont[pressState, font]; pressState.pressHandle.PutText[ textString: Rope.FromChar[char], xCoordinateOfLeftEdge: x.DimnInt[mica], yCoordinateOfBaseline: y.DimnInt[mica] ]; }; SetFont: PUBLIC PROCEDURE [pressState: TSOutputPress.PressState, font: TSFont.Ref] = { IF pressState.curFont # font AND font # NIL THEN { family: Rope.ROPE; micaSize: INTEGER; face: [0..255]; rotation: INTEGER; [family,micaSize,face,rotation] _ TSFont.ParcFontSpecification[font]; pressState.pressHandle.SetFont[ family:family, size:micaSize, face:face, rotation:rotation, unit:SirPress.mica ]; }; pressState.curFont _ font; }; Rule: TSOutput.RuleProc = { pressState: TSOutputPress.PressState _ NARROW[self.outputState]; pressState.pressHandle.PutRectangle[ xstart: leftX.DimnInt[mica], ystart: bottomY.DimnInt[mica], xlen: width.DimnInt[mica], ylen: height.DimnInt[mica] ]; SetFont[pressState, NIL]; }; Color: TSOutput.ColorProc = { pressState: TSOutputPress.PressState _ NARROW[self.outputState]; pressState.pressHandle.SetColor[ hue: Real.RoundLI[hue*240], saturation: Real.RoundLI[saturation*255], brightness: Real.RoundLI[brightness*255] ]; SetFont[pressState, NIL]; }; NewPage: TSOutput.NewPageProc = { pressState: TSOutputPress.PressState _ NARROW[self.outputState]; pressState.pressHandle.WritePage[]; SetFont[pressState, NIL]; }; PageSize: TSOutput.PageSizeProc = { pressState: TSOutputPress.PressState _ NARROW[self.outputState]; pressState.pressHandle.SetPageSize[height: DimnInt[height, mica], width: DimnInt[width, mica], unit: SirPress.mica]; }; Finish: TSOutput.FinishProc = { pressState: TSOutputPress.PressState _ NARROW[self.outputState]; pressState.pressHandle.ClosePress[]; }; END. Michael Plass, September 16, 1982 12:22 pm: Changed fileName parameter to IO.STREAM. Michael Plass, November 2, 1982 9:59 am: Made into CEDAR program. Michael Plass, November 3, 1982 10:53 am: CursorObject. Michael Plass, November 16, 1982 2:11 pm: PageSize. Michael Plass, December 8, 1982 2:33 pm: Made color parameters scale between 0 and 1.