LandPrintDirA.mesa;
Last Edited by: Sweet, September 14, 1985 0:50:02 am PDT
DIRECTORY
Ascii,
Buttons,
Containers USING [ChildXBound, ChildYBound, Container],
LandPrintDefs,
Rope,
SirPress,
TSFont,
TSTypes,
TypeScript,
VFonts,
ViewerClasses USING [Viewer, ViewerClassRec],
ViewerIO USING [CreateViewerStreams],
ViewerTools USING [MakeNewTextViewer, SetSelection];
LandPrintDirA: CEDAR PROGRAM    
IMPORTS Buttons, Containers, LandPrintDefs, Rope, SirPress, TSFont, TSTypes, TypeScript, VFonts, ViewerIO, ViewerTools
EXPORTS LandPrintDefs =
BEGIN OPEN LandPrintDefs;
The Containers interface is used to create an outer envelope or "container" for the different sections below. For uniformity, we define some standard distances between entries in the tool.
entryHeight: CARDINAL = 15; -- how tall to make each line of items
entryVSpace: CARDINAL = 8;  -- vertical leading space between lines
entryHSpace: CARDINAL = 10;  -- horizontal space between items in a line
dash: CHAR = Ascii.ControlV;
PromptRec: TYPE = RECORD [
handle: Handle, viewer: ViewerClasses.Viewer ← NIL];
PromptHandle: TYPE = REF PromptRec;
faceNormal: CARDINAL = 0;
faceItalic: CARDINAL = 1;
faceBold: CARDINAL = 2;
faceBoldItalic: CARDINAL = 3;
LookupFonts: PUBLIC PROC [handle: Handle] = {
DoFont: PROC [class: FontClass, family: ROPE, size: INT, face: CARDINAL ← faceNormal] = {
handle.fontCode[R90][class] ← handle.press.GetFontCode[
family: family,
rotation: 90 * 60,
size: size,
face: face];
IF ~handle.oneRot^ THEN handle.fontCode[R270][class] ← handle.press.GetFontCode[
family: family,
rotation: 270 * 60,
size: size,
face: face];
handle.fontInfo[class] ← TSFont.Lookup[
(SELECT face FROM
faceItalic => Rope.Concat[family, "I"],
faceBold => Rope.Concat[family, "B"],
faceBoldItalic => Rope.Concat[family, "BI"],
ENDCASE => family),
TSTypes.IntDimn[size, TSTypes.bp]];
};
DoFont[body, "TimesRoman", handle.dim.fontSize];
DoFont[smallItalic, "TimesRoman", handle.dim.fontSize, faceItalic];
DoFont[title, "TimesRoman", handle.dim.fontSize + 1];
DoFont[bodyBold, "TimesRoman", handle.dim.fontSize + 1, faceBold];
DoFont[bodyItalic, "TimesRoman", handle.dim.fontSize + 1, faceItalic];
DoFont[tiny, "TimesRoman", handle.dim.fontSize - 2];
DoFont[headingLarge, "TimesRoman", 10];
DoFont[headingSmall, "TimesRoman", 8];
DoFont[pageNum, "TimesRoman", 10];
DoFont[date, "Helvetica", 10];
DoFont[tabs, "Helvetica", handle.dim.tabHeight];
DoFont[display, "TimesRoman", handle.dim.displayHeight, faceBold];
DoFont[symbols, "Math", 10];
};
MakeTypescript: PUBLIC PROC [handle: Handle] = BEGIN
handle.height ← handle.height + entryVSpace; -- space down from the top of the viewer
handle.ts ← TypeScript.Create[
info: [name: "PrintDir.ts", wy: handle.height, parent: handle.outer, border: FALSE ]];
[handle.tsIn, handle.tsOut] ← ViewerIO.CreateViewerStreams [
name: "PrintDir.ts", viewer: handle.ts, backingFile: "PrintDir.ts", editedStream: FALSE];
Containers.ChildXBound[handle.outer, handle.ts];
Containers.ChildYBound[handle.outer, handle.ts];
END;
MakeCommands: PUBLIC PROC [handle: Handle] = BEGIN
initialData: Rope.ROPE = NIL;
wx: INT ← 0;
NewLine: PROC = {handle.height ← handle.height + entryHeight + entryVSpace; wx ← 0};
LabeledItem: PROC [label: ROPE, width: INT, data: ROPENIL]
RETURNS [v: ViewerClasses.Viewer] = {
ph: PromptHandle ← NEW [PromptRec ← [handle: handle]];
t: Buttons.Button ← Buttons.Create[
info: [
name: Rope.Concat[label, ":"],
wy: handle.height,
default the width so that it will be computed for us --
wh: entryHeight, -- specify rather than defaulting so line is uniform
wx: wx,
parent: handle.outer,
border: FALSE ],
proc: Prompt,
clientData: ph]; -- this will be passed to our button proc
wx ← wx + t.ww + entryHSpace;
v ← ViewerTools.MakeNewTextViewer[ [
parent: handle.outer,
wx: wx,
wy: handle.height,
ww: width*VFonts.CharWidth['0],
wh: entryHeight,
data: data,
scrollable: FALSE,
border: FALSE]];
ph.viewer ← v;
wx ← wx + v.ww + entryHSpace};
Cmd: PROC [label: ROPE, proc: Buttons.ButtonProc] = {
t: Buttons.Button ← Buttons.Create[
info: [
name: label,
wx: wx,
wy: handle.height,
default the width so that it will be computed for us --
wh: entryHeight, -- specify rather than defaulting so line is uniform
parent: handle.outer,
border: TRUE ],
proc: proc,
clientData: handle]; -- this will be passed to our button proc
wx ← wx + t.ww + entryHSpace};
Bool: PROC [label: ROPE, initial: BOOL] RETURNS [flag: REF BOOL] = {
t: Buttons.Button;
flag ← NEW[BOOL ← initial];
t ← Buttons.Create[
info: [
name: label,
wx: wx,
wy: handle.height,
default the width so that it will be computed for us --
wh: entryHeight, -- specify rather than defaulting so line is uniform
parent: handle.outer,
border: TRUE ],
proc: ToggleBool,
clientData: flag]; -- this will be passed to our button proc
Buttons.SetDisplayStyle[
button: t, style: IF initial THEN $WhiteOnBlack ELSE $BlackOnWhite, paint: FALSE];
wx ← wx + t.ww + entryHSpace};
NewLine[];
Cmd["Print", DoIt];
NewLine[];
handle.cmd.inputFile ← LabeledItem["input", 50];
NewLine[];
handle.cmd.pressFile ← LabeledItem["press", 50];
NewLine[];
handle.duplex ← Bool["duplex", TRUE];
handle.oneRot ← Bool["oneRotation", TRUE];
handle.cmd.yLead ← LabeledItem["paraLead", 5, "8"];
handle.cmd.fontSize ← LabeledItem["fontSize", 5, "10"];
handle.cmd.lineHeight ← LabeledItem["lineHeight", 5, "12"];
NewLine[];
handle.perfectBind ← Bool["perfect", FALSE];
handle.alphaSort ← Bool["alphaSort", TRUE];
handle.cmd.pageWidth ← LabeledItem["pageWidth", 6, "396"];
handle.cmd.pageHeight ← LabeledItem["pageHeight", 6, "612"];
NewLine[];
handle.cmd.topMargin ← LabeledItem["topMargin", 5, "54"];
handle.cmd.bottomMargin ← LabeledItem["bottomMargin", 5, "54"];
handle.cmd.leftMargin ← LabeledItem["leftMargin", 5, "36"];
handle.cmd.rightMargin ← LabeledItem["rightMargin", 5, "36"];
NewLine[];
handle.cmd.fudgePoints ← LabeledItem["fudge", 5, "0"];
handle.cmd.displayHeight ← LabeledItem["displayFontSize", 5, "18"];
handle.cmd.tabHeight ← LabeledItem["indexFontSize", 5, "8"];
handle.cmd.nameIndent ← LabeledItem["nameIndent", 5, "18"];
NewLine[];
END;
Prompt: Buttons.ButtonProc -- [parent: REF ANY, clientData: REF ANY ← NIL, mouseButton: Menus.MouseButton ← red, shift: BOOL ← FALSE, control: BOOL ← FALSE] -- = BEGIN
force the selection into the user input field
ph: PromptHandle ← NARROW[clientData];
ViewerTools.SetSelection[ph.viewer];  -- force the selection
END;
ToggleBool: Buttons.ButtonProc = {
switch: REF BOOLNARROW [clientData];
switch^ ← ~switch^;
Buttons.SetDisplayStyle[
button: NARROW[parent],
style: IF switch^ THEN $WhiteOnBlack ELSE $BlackOnWhite];
};
END.