PlatemakerInterfaceImpl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Tim Diebert: April 21, 1987 9:42:15 am PDT
DIRECTORY
BasicTime USING [Now],
Buttons USING [Button, ButtonProc, Create],
Commander USING [CommandProc, Register],
Containers USING [ChildXBound, ChildYBound, Container, Create],
Convert USING [CardFromRope, Error],
FS USING [Error],
Imager USING [Context, metersPerInch, TranslateT],
ImagerSample USING [Clear, RasterSampleMap],
Interpress USING [DoPage, LogProc, Master, Open],
IO USING [PutF, PutF1, PutRope, rope, STREAM, time],
Loader USING [BCDBuildTime],
PlatemakerControl USING [ContextFromSampleMap, MakePrinterSampleMap, PrintMap],
Rope USING [ROPE],
Rules USING [Create, Rule],
TypeScript USING [Create],
VFonts USING [EstablishFont, Font, FontHeight],
ViewerClasses USING [Viewer],
ViewerIO USING [CreateViewerStreams],
ViewerOps USING [PaintViewer, SetOpenHeight],
ViewerTools USING [GetContents, InhibitUserEdits, MakeNewTextViewer, SetSelection];
PlatemakerInterfaceImpl: CEDAR PROGRAM
IMPORTS BasicTime, Buttons, Commander, Containers, Convert, FS, Imager, ImagerSample, IO, Interpress, Loader, PlatemakerControl, Rules, TypeScript, VFonts, ViewerIO, ViewerOps, ViewerTools
EXPORTS
~ BEGIN
ROPE: TYPE ~ Rope.ROPE;
STREAM: TYPE ~ IO.STREAM;
---- ---- ---- ---- ---- ---- ---- ----
Tool
---- ---- ---- ---- ---- ---- ---- ----
Tool: TYPE ~ REF ToolRep;
ToolRep: TYPE ~ RECORD [
outer: Containers.Container ← NIL,
height: INT ← 0,
busy: BOOLFALSE,
fileNameViewer: ViewerClasses.Viewer,
fileName: ROPE,
pageNumberViewer: ViewerClasses.Viewer,
pageNumber: ROPE,
negButton: Buttons.Button,
reverseScan: Buttons.Button,
typeScript: STREAM];
---- ---- ---- ---- ---- ---- ---- ----
Configuration Parameters (private)
---- ---- ---- ---- ---- ---- ---- ----
minFeedbackLines: NAT = 4;
interactionQuestionLines: NAT = 1;
idleMessage: ROPE ← " ";
offScreen: INT = -9999;
font: VFonts.Font ← VFonts.EstablishFont["Tioga", 10];
entryHSpace: INT ← 10;
entryHeight: INT ← VFonts.FontHeight[font] + 2;
entryVSpace: INT ← VFonts.FontHeight[font]/6;
---- ---- ---- ---- ---- ---- ---- ----
Tool Construction
---- ---- ---- ---- ---- ---- ---- ----
NewTool: PROC [] RETURNS [tool: Tool] = BEGIN
AddSeparatingRule: PROC = BEGIN
rule: Rules.Rule = Rules.Create[info: [
wx: 0,
wy: tool.height,
ww: 9999, -- arbitrary; Containers.ChildXBound overrides
wh: 1,
parent: tool.outer
]];
Containers.ChildXBound[tool.outer, rule]; -- constrain rule to be width of parent
tool.height ← tool.height + entryVSpace; -- spacing after rule
END;
BuildCommandButtons: PROC = BEGIN
prev: ViewerClasses.Viewer;
prev ← Buttons.Create[
info: [name: "Decompose",
wx: entryHSpace,
wy: tool.height,
wh: entryHeight,
parent: tool.outer, 
border: FALSE
],
proc: Decompose,
fork: TRUE,
clientData: tool,
font: font
];
prev ← Buttons.Create[
info: [name: "Print",
wx: prev.wx + prev.ww + entryHSpace,
wy: tool.height,
wh: entryHeight,
parent: tool.outer, 
border: FALSE
],
proc: Print,
fork: TRUE,
clientData: tool,
font: font
];
tool.height ← tool.height + entryHeight + entryVSpace;
AddSeparatingRule[];
END;
BuildFileInfo: PROC = BEGIN
prev: ViewerClasses.Viewer;
prev ← Buttons.Create[
info: [name: "File:",
wx: entryHSpace,
wy: tool.height,
wh: entryHeight,
parent: tool.outer, 
border: FALSE
],
proc: SelectFileName,
fork: FALSE,
clientData: tool,
font: font
];
tool.fileNameViewer ← ViewerTools.MakeNewTextViewer[info: [
wx: prev.wx + prev.ww + entryHSpace/2,
wy: tool.height,
ww: 9999,
wh: entryHeight,
data: NIL,
parent: tool.outer,
scrollable: FALSE,
border: FALSE
]];
Containers.ChildXBound[container: tool.outer, child: tool.fileNameViewer];
tool.height ← tool.height + entryHeight + entryVSpace;
AddSeparatingRule[];
END; -- BuildFileInfo
BuildPageNumber: PROC = BEGIN
prev: ViewerClasses.Viewer;
prev ← Buttons.Create[
info: [name: "Page #:",
wx: entryHSpace,
wy: tool.height,
wh: entryHeight,
parent: tool.outer, 
border: FALSE
],
proc: SelectPageNumber,
fork: FALSE,
clientData: tool,
font: font
];
tool.pageNumberViewer ← ViewerTools.MakeNewTextViewer[info: [
wx: prev.wx + prev.ww + entryHSpace/2,
wy: tool.height,
ww: 9999,
wh: entryHeight,
data: NIL,
parent: tool.outer,
scrollable: FALSE,
border: FALSE
]];
Containers.ChildXBound[container: tool.outer, child: tool.pageNumberViewer];
tool.height ← tool.height + entryHeight + entryVSpace;
AddSeparatingRule[];
END; -- BuildPageNumber
***Main Body of NewTool***
v: ViewerClasses.Viewer;
tool ← NEW [ToolRep];
tool.outer ← Containers.Create[
info: [
name: "Platemaker Tool", iconic: FALSE, column: right, scrollable: FALSE
],
paint: TRUE
];
tool.height ← entryVSpace;
BuildCommandButtons[];
BuildFileInfo[];
BuildPageNumber[];
v ← TypeScript.Create[
info: [
wx: 0,
wy: tool.height + 5,
ww: 9999,
wh: 9999,
parent: tool.outer,
border: FALSE]
];
tool.typeScript ← ViewerIO.CreateViewerStreams[name: "PlatemakerTool.log", viewer: v, backingFile: "PlatemakerTool.log"].out;
Containers.ChildXBound[container: tool.outer, child: v];
Containers.ChildYBound[container: tool.outer, child: v];
ViewerTools.InhibitUserEdits[v];
ViewerOps.SetOpenHeight[tool.outer, tool.height];
ViewerOps.PaintViewer[tool.outer, all];
IO.PutF[tool.typeScript, "PlatemakerTool of %t\nSession began at %t\n", IO.time[Loader.BCDBuildTime[]], IO.time[BasicTime.Now[]]];
END;
-- Internal Procs
Decompose: Buttons.ButtonProc = BEGIN
[parent: Viewer, clientData: REF ANYNIL, mouseButton: MouseButton ← red, shift, control: BOOLFALSE];
ENABLE UNWIND => NULL;
Log: Interpress.LogProc = BEGIN -- [class: INT, code: ATOM, explanation: ROPE];
IO.PutF1[tool.typeScript, "\nIntepress Error: %g", IO.rope[explanation]];
END;
tool: Tool ← NARROW[clientData];
contents: ROPE ← ViewerTools.GetContents[tool.fileNameViewer];
pageNumberRope: ROPE ← ViewerTools.GetContents[tool.pageNumberViewer];
pageNumber: INT ← 1;
ip: Interpress.Master; context: Imager.Context;
IF tool.busy THEN RETURN;
IF contents = NIL THEN RETURN;
IF pageNumberRope = NIL THEN RETURN;
pageNumber ← Convert.CardFromRope[pageNumberRope
! Convert.Error => {IO.PutRope[tool.typeScript, "\nConvert Error on pagenumber"];
GOTO Out}];
ip ← Interpress.Open[contents, Log
! FS.Error => {IO.PutF1[tool.typeScript, "\nFS Error: %g", IO.rope[error.explanation]];
GOTO Out}];
ImagerSample.Clear[sampleMap];
context ← PlatemakerControl.ContextFromSampleMap[sampleMap];
Imager.TranslateT[context, [x: 0.75 * Imager.metersPerInch, y: 0.125 * Imager.metersPerInch]];
Interpress.DoPage[ip, pageNumber, context, Log];
EXITS Out => RETURN;
END;
Print: Buttons.ButtonProc = BEGIN
[parent: Viewer, clientData: REF ANYNIL, mouseButton: MouseButton ← red, shift, control: BOOLFALSE];
ENABLE UNWIND => NULL;
tool: Tool ← NARROW[clientData];
IO.PutRope[tool.typeScript, "\nInsert paper"];
[] ← PlatemakerControl.PrintMap[sampleMap];
IO.PutRope[tool.typeScript, "\nGet papern"];
END;
SelectFileName: Buttons.ButtonProc = BEGIN
[parent: Viewer, clientData: REF ANYNIL, mouseButton: MouseButton ← red, shift, control: BOOLFALSE];
ENABLE UNWIND => NULL;
tool: Tool ← NARROW[clientData];
ViewerTools.SetSelection[tool.fileNameViewer];
END;
SelectPageNumber: Buttons.ButtonProc = BEGIN
[parent: Viewer, clientData: REF ANYNIL, mouseButton: MouseButton ← red, shift, control: BOOLFALSE];
ENABLE UNWIND => NULL;
tool: Tool ← NARROW[clientData];
ViewerTools.SetSelection[tool.pageNumberViewer];
END;
CommanderNewTool: Commander.CommandProc = BEGIN
[cmd: Handle] RETURNS [result: REFNIL, msg: ROPENIL];
[] ← NewTool[];
END;
sampleMap: ImagerSample.RasterSampleMap ← PlatemakerControl.MakePrinterSampleMap[];
Commander.Register["PlatemakerTool", CommanderNewTool];
END...