TSOutputDisplayImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Implements TSOutput interface for the Tioga typesetter to display in a Viewer/Imager context
Created by: Beach, December 7, 1983 5:33 pm
Michael Plass, May 12, 1985 5:03:25 pm PDT
DIRECTORY
Imager,
ImagerColor,
ImagerColorDefs,
ImagerFont,
Real,
Rope,
TSFont,
TSTypes,
TSOutput,
TSOutputDisplay,
ViewerClasses,
ViewerOps;
TSOutputDisplayImpl:
CEDAR
PROGRAM
IMPORTS Imager, ImagerColor, ImagerFont, TSFont, TSTypes, ViewerOps, Rope
EXPORTS TSOutput =
BEGIN
OPEN TSOutputDisplay;
CreateViewer:
PUBLIC PROCEDURE [viewerName: Rope.
ROPE ← NIL]
RETURNS [handle: TSOutput.Handle] = {
v: ViewerClasses.Viewer ← ViewerOps.FindViewer[viewerName];
IF v # NIL THEN ViewerOps.DestroyViewer[v];
v ← ViewerOps.CreateViewer[
flavor: $TSDisplay,
info: [
name: viewerName,
iconic: FALSE,
column: left,
scrollable: TRUE,
data: handle],
paint: TRUE];
handle ←NARROW [ViewerOps.FetchProp[v, $TSDisplayHandle]];
};
Char: TSOutput.CharProc = {
-- [self: Handle, x, y: TSTypes.Dimn, char: CHAR, font: TSFont.Ref]
displayState: DisplayState ← NARROW[self.outputState];
CharPaint: DisplayProc = {
ShowOne: Imager.XStringProc ~ {
charAction[[0, ORD[char]]];
};
Imager.SetColor[dc, displayState.color];
Imager.SetXY[dc, [x.DimnInt[TSTypes.pt], y.DimnInt[TSTypes.pt]]];
Imager.SetFont[dc, displayState.imagerFont];
Imager.Show[dc, ShowOne];
};
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;
imagerFont: Imager.Font;
fontName: ROPE;
[family, micaSize, face, rotation] ← TSFont.ParcFontSpecification[font];
fontName ← Rope.Cat[
"xerox/pressfonts/",
family,
SELECT face
FROM
0 => "-MRR",
1 => "-MIR",
2 => "-BRR",
3 => "-BIR",
ENDCASE => NIL
];
imagerFont ← ImagerFont.Find[fontName];
displayState.imagerFont ← ImagerFont.Scale[imagerFont, micaSize * pointsPerMica];
};
displayState.currentFont ← font;
};
Rule: TSOutput.RuleProc = { --
[self: Handle, leftX, bottomY, width, height: TSTypes.Dimn]
displayState: DisplayState ← NARROW[self.outputState];
RulePaint: DisplayProc = {
Imager.SetColor[dc, displayState.color];
Imager.MaskBox[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];
color: ImagerColorDefs.ConstantColor ← ImagerColor.ColorFromGray[1.0-brightness];
displayState.color ← color;
};
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]
displayState: DisplayState ← NARROW[self.outputState];
};
TSDisplayInitViewer: ViewerClasses.InitProc = {
displayState: DisplayState ← NEW[DisplayStateRec];
handle: TSOutput.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 ← self;
ViewerOps.AddProp[self, $TSDisplayHandle, 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];
Imager.TranslateT[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]^];
containerInit: ViewerClasses.InitProc ~ tsDisplayClass.init;
containerPaint: ViewerClasses.PaintProc ~ tsDisplayClass.paint;
tsDisplayClass.init ← TSDisplayInitViewer;
tsDisplayClass.paint ← TSDisplayPaint;
ViewerOps.RegisterViewerClass[$TSDisplay, tsDisplayClass];
END.
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)