<> <> 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; <> 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: ROPE _ NIL] RETURNS [v: ViewerClasses.Viewer] = { ph: PromptHandle _ NEW [PromptRec _ [handle: handle]]; t: Buttons.Button _ Buttons.Create[ info: [ name: Rope.Concat[label, ":"], wy: handle.height, <> 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, <> 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, <> 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 <> ph: PromptHandle _ NARROW[clientData]; ViewerTools.SetSelection[ph.viewer]; -- force the selection END; ToggleBool: Buttons.ButtonProc = { switch: REF BOOL _ NARROW [clientData]; switch^ _ ~switch^; Buttons.SetDisplayStyle[ button: NARROW[parent], style: IF switch^ THEN $WhiteOnBlack ELSE $BlackOnWhite]; }; END.