TSOutputPressImpl.mesa
Michael Plass, November 16, 1982 2:13 pm
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;
};
This CharProc is not called often, due to an accelerator in TSOutputImpl.
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.