PressScreenImpl.mesa
Program to make AIS/press file of display
Last edited by: Rick Cattell on June 18, 1982 1:58 pm
Last edited by: Warren Teitelman on 6-Apr-82 12:02:06
Last edited by: Michael Plass on November 16, 1982 10:58 am
Last Edited by: Beach, August 22, 1983 10:40 am
DIRECTORY
Buttons,
ChoiceButtons,
CGAIS,
Commander,
Containers,
Convert,
FileIO,
Graphics,
GraphicsOps,
IO,
Labels,
LFUtil,
Menus,
PressScreen,
Process,
Real,
Rope,
Rules,
SirPress,
TSViewerImpl,
UserTerminal,
ViewerClasses,
ViewerLocks,
ViewerOps,
ViewerSpecs,
ViewerTools;
PressScreenImpl: CEDAR MONITOR
IMPORTS Buttons, ChoiceButtons, Commander, Containers, Convert, FileIO, Graphics, GraphicsOps, IO, Labels, LFUtil, Menus, Process, Real, Rope, Rules, SirPress, UserTerminal, ViewerSpecs, ViewerLocks, ViewerOps, ViewerTools
EXPORTS PressScreen
SHARES TSViewerImpl, ViewerLocks = {
OPEN PressScreen;
ROPE: TYPE = Rope.ROPE;
extraWords: NAT ← 6; -- Half-screen prints are widened by this much.
PressScreen: PUBLIC PROC[pressFileName: Rope.ROPE, which: Side] = TRUSTED {
Old interface to convert part or all of the bit mapped screen into a press file.
screen: SirPress.PressHandle← SirPress.Create[
fileNameForHeaderPage: pressFileName,
outputStream: FileIO.Open[pressFileName, overwrite]
];
screenBitMap: GraphicsOps.BitmapRef← GraphicsOps.ScreenBitmap[];
widthInWords: INT ← screenBitMap.width/16;
halfWidthInWords: NAT ← widthInWords/2;
screenPtr: LONG POINTER ← UserTerminal.GetBitBltTable[].dst.word;
define the screen rectangle
IF which=bothSides THEN {
screen.SetPageSize[height: 85, width: 110, unit: SirPress.in/10];
screen.BeginScannedRectangle[
x: 1, y: 1,
numberOfLines: screenBitMap.height,
dotsPerLine: widthInWords*16,
height: 8*4,
unit: SirPress.in/4]
}
ELSE
screen.BeginScannedRectangle[
x: 1, y: 1,
numberOfLines: screenBitMap.height,
dotsPerLine: (halfWidthInWords+extraWords)*16,
unit: SirPress.in/4];
call ShowLine for each line of screen (or half-line, if left side)
FOR i: INT IN [0..screenBitMap.height) DO
offset: LONG CARDINAL ← i*widthInWords;
IF which=rightSide THEN offset ← offset + halfWidthInWords - extraWords;
screen.UnsafeShowLine[screenPtr + offset];
ENDLOOP;
finish the rectangle and close the file
screen.EndScannedRectangle[];
screen.ClosePress[];
};
fileNameTemplate: ROPE ← "Screen#.press";
count is incremented by one and substituted for # in the template
count: INT ← 0;
NewPressName: PUBLIC ENTRY PROCEDURE RETURNS [pressFileName: Rope.ROPE] = {
Returns a file name like "Screen1.press", "Screen2.press", etc.
ENABLE UNWIND => NULL;
i: INT = Rope.Find[s1: fileNameTemplate, s2: "#"];
pressFileName ← IF i = -1 THEN fileNameTemplate
ELSE fileNameTemplate.Replace[start: i, len: 1, with: Convert.ValueToRope[[signed[(count ← count + 1)]]]];
};
PressScreenTool: PUBLIC TYPE = REF PressScreenToolRec;
PressScreenToolRec: PUBLIC TYPE = RECORD[
magnificationChoice: ChoiceButtons.EnumTypeRef,
magnificationViewer: ViewerClasses.Viewer, -- magnification factor
ulx, uly, lrx, lry: ViewerClasses.Viewer, -- upper left, lower right coordinates
formatViewer: ChoiceButtons.EnumTypeRef,
borderViewer: ViewerClasses.Viewer, -- border width
pageMarginViewer: ViewerClasses.Viewer,
logViewer: ViewerClasses.Viewer,
logMessage: ROPE
];
indent: INTEGER ~ TSViewerImpl.indent;
baseline: INTEGER ~ TSViewerImpl.baseline;
NewPressScreenTool: PUBLIC PROCEDURE [serverName: ROPE] RETURNS[psTool: PressScreenTool ← NEW[PressScreenToolRec]] = {
Creates a PressScreen tool viewer.
ENABLE UNWIND => NULL;
curY: INTEGER ← indent/2;
NextY: PROCEDURE RETURNS [y:NAT] = {y ← curY ← curY+baseline};
container: ViewerClasses.Viewer ←
Containers.Create[
info: [
name: IF serverName.Length = 0 THEN "PressScreen" ELSE Rope.Concat["PressScreen to ", serverName],
column: right, scrollable: FALSE
],
paint: FALSE
];
button: ViewerClasses.Viewer;
menu: Menus.Menu ← Menus.CreateMenu[];
InsertMenu: PROCEDURE [name: ROPE, proc: Menus.ClickProc, doc: ROPE] = {
Menus.InsertMenuEntry[menu, Menus.CreateEntry[
name: name,
proc: proc,
clientData: psTool,
documentation: doc
]];
};
LabelledTextViewer: PROCEDURE [name: ROPE] RETURNS [v: ViewerClasses.Viewer] = {
v ← ViewerTools.MakeNewTextViewer[
info:[wx: button.wx+button.ww, wy: curY, ww: 50, wh: button.wh,
parent: container, scrollable: FALSE, border: TRUE],
paint: FALSE
];
button ← Labels.Create[
info: [name: name, wx: v.wx + v.ww, wy: curY+1, wh: button.wh, parent: container, scrollable: FALSE, border: FALSE],
paint: FALSE
];
};
MyButton: PROCEDURE [name: ROPE, proc: Buttons.ButtonProc, doc: ROPE] RETURNS [Buttons.Button] = {
RETURN [Buttons.Create[
info: [name: name, wx: indent, wy: NextY[], parent: container, border: FALSE],
clientData: psTool,
proc: proc,
fork: TRUE,
paint: FALSE,
documentation: doc
]]};
InsertMenu["FlashImage", FlashImageButton,
"Flashes the selected area of the screen for the AIS/Press file"];
InsertMenu["SelectedImage", SelectedImageButton,
"Converts the selected area of the screen into an AIS/Press file"];
InsertMenu["WholeScreen", WholeScreenButton,
"Converts the whole screen into an AIS/Press file"];
InsertMenu["RightColumn", RightColumnButton,
"Converts the right column of the screen into an AIS/Press file"];
InsertMenu["LeftColumn", LeftColumnButton,
"Converts the left column of the screen into an AIS/Press file"];
ViewerOps.SetMenu[container, menu];
Magnification: UseFactor HalfPage FullPage
psTool.magnificationChoice ← ChoiceButtons.BuildEnumTypeSelection[
viewer: container,
x: indent,
y: curY,
title: "Magnification: ",
buttonNames: CONS["UseFactor", CONS["HalfPage", CONS["FullPage", NIL]]],
default: "FullPage",
style: menuSelection];
MagnificationFactor: xxxx %
button ← MyButton["MagnificationFactor: ", MagnificationFactorButton, "Set the magnification factor"];
psTool.magnificationViewer ← LabelledTextViewer["%"];
SetCorners: xxxx x xxxx y xxxx x xxxx y
button ← MyButton["SetCorners: ", SetCornersButton, "Set the corners of the selection image area of the screen"];
psTool.ulx ← LabelledTextViewer["x "];
psTool.uly ← LabelledTextViewer["y "];
psTool.lrx ← LabelledTextViewer["x "];
psTool.lry ← LabelledTextViewer["y"];
Format: Landscape Portrait
psTool.formatViewer ← ChoiceButtons.BuildEnumTypeSelection[
viewer: container,
x: indent,
y: NextY[],
title: "Format: ",
buttonNames: CONS["Landscape", CONS["Portrait", NIL]],
default: "Landscape",
style: menuSelection];
BlackBorder: xxxx pixels
button ← MyButton["BlackBorder: ", SetCornersButton, "Set the corners of the selection image area of the screen"];
psTool.borderViewer ← LabelledTextViewer["pixels"];
PageMargin: xxxx inches
button ← MyButton["PageMargin: ", PageMarginButton, "Set the white space provided around the page"];
psTool.pageMarginViewer ← LabelledTextViewer["inches"];
Rule between buttons and log viewer
Containers.ChildXBound[container, Rules.Create[info: [wx: 0, wy: NextY[], wh: 1, parent: container]]];
Create log viewer for file completion messages
psTool.logViewer ← ViewerTools.MakeNewTextViewer[
info: [wx: 0, wy: curY+2, parent: container, scrollable: TRUE, border: FALSE]
];
Containers.ChildXBound[container, psTool.logViewer];
Containers.ChildYBound[container, psTool.logViewer];
Display default settings
ChoiceButtons.UpdateChoiceButtons[container, psTool.magnificationChoice, "FullPage"];
ViewerTools.SetContents[psTool.magnificationViewer, IO.PutFR["%g", IO.real[100.0]]];
ViewerTools.SetContents[psTool.ulx, IO.PutFR["%g", IO.int[0]]];
ViewerTools.SetContents[psTool.uly, IO.PutFR["%g", IO.int[807]]];
ViewerTools.SetContents[psTool.lrx, IO.PutFR["%g", IO.int[1023]]];
ViewerTools.SetContents[psTool.lry, IO.PutFR["%g", IO.int[0]]];
ChoiceButtons.UpdateChoiceButtons[container, psTool.formatViewer, "Portrait"];
ViewerTools.SetContents[psTool.borderViewer, IO.PutFR["%g", IO.int[2]]];
ViewerTools.SetContents[psTool.pageMarginViewer, IO.PutFR["%g", IO.real[0.75]]];
ViewerOps.PaintViewer[container, all];
};
MagnificationFactorTooLarge: PUBLIC SIGNAL = CODE;
The specified rectangle will not fit on an 8.5 by 11 inch page with the supplied margins and magnifications
AISPageAlignmentHackFailed: PUBLIC SIGNAL = CODE;
An internal error expected when the size of SirPress record definitions change (low probability)
AISPressScreen: PUBLIC PROCEDURE [pressFileName: ROPE,
sourceHeight: NAT ← ViewerSpecs.screenH,
sourceWidth: NAT ← ViewerSpecs.screenW,
sourceBottom: NAT ← 0,
sourceLeft: NAT ← 0,
magnification: REAL ← 0.5,
scaleToFit: MagnificationType ← useMagnification,
leftMarginInches, rightMarginInches: REAL ← 0.75,
landscape: BOOLEANFALSE,
borderWidth: REAL ← 2.0] RETURNS[fileName: ROPE] = TRUSTED {
Converts the specified region of the bit mapped screen into a combination AIS and Press file.
Such files can be used by CedarGraphics or printed by the TSetter.
AISPressScreen can raise two signals: MagnificationFactorTooLarge when the specified rectangle will not fit on an 8.5 by 11 inch page with the supplied margins and magnifications; and AISPageAlignmentHackFailed for an internal error expected when the size of SirPress record definitions change (low probability).
trueName: Rope.ROPEIF pressFileName = NIL THEN NewAISPressName[] ELSE pressFileName;
context: Graphics.Context ← Graphics.NewContext[];
outputStream: IO.STREAM ← FileIO.Open[trueName, overwrite];
bytesSoFar: INT;
screen: SirPress.PressHandle;
screenBitMap: GraphicsOps.BitmapRef ← GraphicsOps.ScreenBitmap[];
screenWidthInWords: NAT ← screenBitMap.width/16;
sourceLeftInWords: NATMIN[sourceLeft/16, screenWidthInWords];
sourceRightInWords: NATMIN[(sourceLeft+sourceWidth+15)/16, screenWidthInWords];
paperHeight: REALIF landscape THEN 8.5*2540 ELSE 11*2540;
paperWidth: REAL ← (11+8.5)*2540 - paperHeight;
pageBorder: REAL ← (leftMarginInches + rightMarginInches)*2540;
x: REAL;
y: REAL;
screenPtr: LONG POINTER ← UserTerminal.GetBitBltTable[].dst.word;
bytesPerPage: INT = 512;
wordsOfPressCommands: INT = 8; -- count of Press commands generated before dots so that the AIS image starts on a page boundary
AISHeader: TYPE = RECORD [
header: CGAIS.Header,
rasterPart: CGAIS.RasterPart,
uca: CGAIS.UCA];
aisHeader: AISHeader ← [
header: [
password: CGAIS.password,
attributeLength: 0],
rasterPart: [
aph: [
type: raster,
length: SIZE[CGAIS.RasterPart]],
scanCount: 0,
scanLength: 0,
scanDirection: 3,
samplesPerPixel: 1,
codingType: CGAIS.UCACodingType],
uca: [
bitsPerSample: 0,
wordsPerScanLine: 0,
scanLinesPerBlock: 177777B]];
aisBlock: IO.UnsafeBlock ← [
base: @aisHeader,
startIndex: 0,
stopIndexPlusOne: 2*SIZE[AISHeader]];
SELECT scaleToFit FROM
fullPage => {
magnification ← MIN[ (paperWidth-pageBorder)/(32.0*16.0*(sourceRightInWords-sourceLeftInWords)),
(paperHeight-pageBorder)/(32.0*sourceHeight)];
};
halfPage => {
magnification ← MIN[ (paperWidth-pageBorder)/(32.0*16.0*(sourceRightInWords-sourceLeftInWords)),
(paperHeight-3*pageBorder)/(2.0*32.0*sourceHeight)];
};
useMagnification => NULL;
ENDCASE;
x ← (paperWidth-32.0*16.0*(sourceRightInWords-sourceLeftInWords)*magnification)/2.0;
y ← (paperHeight-32.0*sourceHeight*magnification)/2.0;
IF x<0 OR y<0 OR x+32.0*16.0*(sourceRightInWords-sourceLeftInWords)*magnification>paperWidth OR y+32.0*sourceHeight*magnification>paperHeight THEN
SIGNAL MagnificationFactorTooLarge;
context.DrawBox[[sourceLeft, sourceBottom, sourceLeft+borderWidth, sourceBottom+sourceHeight]];
context.DrawBox[[sourceLeft+sourceWidth-borderWidth, sourceBottom, sourceLeft+sourceWidth, sourceBottom+sourceHeight]];
context.DrawBox[[sourceLeft, sourceBottom, sourceLeft+sourceWidth, sourceBottom+borderWidth]];
context.DrawBox[[sourceLeft, sourceBottom+sourceHeight-borderWidth, sourceLeft+sourceWidth, sourceBottom+sourceHeight]];
context.SetColor[Graphics.white];
context.DrawBox[[sourceLeft-16, sourceBottom, sourceLeft, sourceBottom+sourceHeight]];
context.DrawBox[[sourceLeft+sourceWidth, sourceBottom, sourceLeft+sourceWidth+16, sourceBottom+sourceHeight]];
Create the AIS Header from the screen rectangle information
aisHeader.uca.wordsPerScanLine ← sourceRightInWords-sourceLeftInWords;
aisHeader.rasterPart.scanLength ← aisHeader.uca.wordsPerScanLine*16;
aisHeader.rasterPart.scanCount ← sourceHeight;
IO.UnsafePutBlock[outputStream, aisBlock];
THROUGH [0..bytesPerPage - 2*(SIZE[AISHeader]+wordsOfPressCommands)) DO
IO.PutChar[outputStream, '$];
ENDLOOP;
define the screen rectangle in the Press file
screen ← SirPress.Create[
fileNameForHeaderPage: trueName,
outputStream: outputStream
];
IF landscape THEN screen.SetPageSize[height: 85, width: 110, unit: SirPress.in/10];
screen.BeginScannedRectangle[
x: Real.RoundLI[x], y: Real.RoundLI[y],
numberOfLines: sourceHeight,
dotsPerLine: (sourceRightInWords-sourceLeftInWords)*16,
height: Real.RoundLI[32.0*sourceHeight*magnification],
unit: SirPress.mica];
Stuff the current position of the Press file into the AIS Header
bytesSoFar ← IO.GetIndex[outputStream];
IF bytesSoFar # bytesPerPage THEN SIGNAL AISPageAlignmentHackFailed;
aisHeader.header.attributeLength ← bytesSoFar/2;
IO.SetIndex[outputStream, 0];
IO.UnsafePutBlock[outputStream, aisBlock];
IO.SetIndex[outputStream, bytesSoFar];
ViewerLocks.LockViewerTree[];
call ShowLine for each line of screen (or half-line, if left side)
FOR i: INT IN [0..sourceHeight) DO
offset: LONG CARDINAL ← (i+screenBitMap.height-sourceHeight-sourceBottom)*screenWidthInWords+sourceLeftInWords;
screen.UnsafeShowLine[screenPtr + offset];
ENDLOOP;
ViewerLocks.ReleaseViewerTree[];
finish the rectangle and close the file
screen.EndScannedRectangle[];
screen.ClosePress[];
ViewerOps.PaintEverything[];
RETURN [trueName];
};
aisFileNameTemplate: ROPE = "Screen#.AIS";
NewAISPressName: PUBLIC ENTRY PROCEDURE RETURNS [pressFileName: ROPE] = {
Returns a file name like "Screen1.ais", "Screen2.ais", etc.
ENABLE UNWIND => NULL;
i: INT = Rope.Find[s1: aisFileNameTemplate, s2: "#"];
pressFileName ← IF i = -1 THEN aisFileNameTemplate
ELSE aisFileNameTemplate.Replace[start: i, len: 1, with: Convert.ValueToRope[[signed[(count ← count + 1)]]]];
};
FlashImageButton: Buttons.ButtonProc = {
psTool: PressScreenTool ← NARROW[clientData];
FlashScreenArea[psTool];
};
flashTime: Process.Milliseconds ~ 600;
FlashScreenArea: PROCEDURE [psTool: PressScreenTool] = {
ulx, uly, lrx, lry: REAL;
context: Graphics.Context ← Graphics.NewContext[];
[] ← context.SetPaintMode[invert];
[ulx, uly, lrx, lry] ← ReadScreenCorners[psTool];
context.DrawBox[[lrx, lry, ulx, uly]];
Process.Pause[Process.MsecToTicks[flashTime]];
context.DrawBox[[lrx, lry, ulx, uly]];
};
SelectedImageButton: Buttons.ButtonProc = {
psTool: PressScreenTool ← NARROW[clientData];
ulx, uly, lrx, lry: REAL;
magnificationRope: ROPE ← ChoiceButtons.GetSelectedButton[psTool.magnificationChoice];
fileName: ROPE;
[ulx, uly, lrx, lry] ← ReadScreenCorners[psTool];
fileName ← AISPressScreen[
pressFileName: NewAISPressName[],
sourceHeight: Real.Fix[uly - lry + 1],
sourceWidth: Real.Fix[lrx - ulx + 1],
sourceBottom: Real.Fix[lry],
sourceLeft: Real.Fix[ulx],
magnification: ConvertRopeToReal[ViewerTools.GetContents[psTool.magnificationViewer]]/100.0,
scaleToFit: SELECT TRUE FROM
magnificationRope.Equal["UseFactor"] => useMagnification,
magnificationRope.Equal["HalfPage"] => halfPage,
magnificationRope.Equal["FullPage"] => fullPage,
ENDCASE => halfPage,
leftMarginInches: ConvertRopeToReal[ViewerTools.GetContents[psTool.borderViewer]],
rightMarginInches: ConvertRopeToReal[ViewerTools.GetContents[psTool.borderViewer]],
landscape: Rope.Equal[ChoiceButtons.GetSelectedButton[psTool.formatViewer], "Landscape"],
borderWidth: ConvertRopeToReal[ViewerTools.GetContents[psTool.pageMarginViewer]]
! MagnificationFactorTooLarge => GOTO ReportError];
AppendLogMessage[psTool, Rope.Concat[fileName, " written."]];
EXITS
ReportError =>
AppendLogMessage[NARROW[clientData], "Magnification factor too large for selected image"];
};
WholeScreenButton: Buttons.ButtonProc = {
psTool: PressScreenTool ← NARROW[clientData];
magnificationRope: ROPE ← ChoiceButtons.GetSelectedButton[psTool.magnificationChoice];
fileName: ROPE ← AISPressScreen[
pressFileName: NewAISPressName[],
sourceHeight: ViewerSpecs.screenH,
sourceWidth: ViewerSpecs.screenW,
sourceBottom: 0,
sourceLeft: 0,
magnification: ConvertRopeToReal[ViewerTools.GetContents[psTool.magnificationViewer]]/100.0,
scaleToFit: SELECT TRUE FROM
magnificationRope.Equal["UseFactor"] => useMagnification,
magnificationRope.Equal["HalfPage"] => halfPage,
magnificationRope.Equal["FullPage"] => fullPage,
ENDCASE => halfPage,
leftMarginInches: ConvertRopeToReal[ViewerTools.GetContents[psTool.borderViewer]],
rightMarginInches: ConvertRopeToReal[ViewerTools.GetContents[psTool.borderViewer]],
landscape: SELECT ChoiceButtons.GetSelectedButton[psTool.formatViewer] FROM
"Landscape" => TRUE,
ENDCASE => FALSE,
borderWidth: ConvertRopeToReal[ViewerTools.GetContents[psTool.pageMarginViewer]]
! MagnificationFactorTooLarge => GOTO ReportError];
AppendLogMessage[psTool, Rope.Concat[fileName, " written."]];
EXITS
ReportError =>
AppendLogMessage[NARROW[clientData], "Magnification factor too large for the whole screen"];
};
RightColumnButton: Buttons.ButtonProc = {
psTool: PressScreenTool ← NARROW[clientData];
magnificationRope: ROPE ← ChoiceButtons.GetSelectedButton[psTool.magnificationChoice];
fileName: ROPE ← AISPressScreen[
pressFileName: NewAISPressName[],
sourceHeight: ViewerSpecs.screenH,
sourceWidth: ViewerSpecs.openRightWidth,
sourceBottom: 0,
sourceLeft: ViewerSpecs.openRightLeftX,
magnification: ConvertRopeToReal[ViewerTools.GetContents[psTool.magnificationViewer]]/100.0,
scaleToFit: SELECT TRUE FROM
magnificationRope.Equal["UseFactor"] => useMagnification,
magnificationRope.Equal["HalfPage"] => halfPage,
magnificationRope.Equal["FullPage"] => fullPage,
ENDCASE => halfPage,
leftMarginInches: ConvertRopeToReal[ViewerTools.GetContents[psTool.borderViewer]],
rightMarginInches: ConvertRopeToReal[ViewerTools.GetContents[psTool.borderViewer]],
landscape: SELECT ChoiceButtons.GetSelectedButton[psTool.formatViewer] FROM
"Landscape" => TRUE,
ENDCASE => FALSE,
borderWidth: ConvertRopeToReal[ViewerTools.GetContents[psTool.pageMarginViewer]]
! MagnificationFactorTooLarge => GOTO ReportError];
AppendLogMessage[psTool, Rope.Concat[fileName, " written."]];
EXITS
ReportError =>
AppendLogMessage[NARROW[clientData], "Magnification factor too large for the right column"];
};
LeftColumnButton: Buttons.ButtonProc = {
psTool: PressScreenTool ← NARROW[clientData];
magnificationRope: ROPE ← ChoiceButtons.GetSelectedButton[psTool.magnificationChoice];
fileName: ROPE ← AISPressScreen[
pressFileName: NewAISPressName[],
sourceHeight: ViewerSpecs.screenH,
sourceWidth: ViewerSpecs.openLeftWidth,
sourceBottom: 0,
sourceLeft: ViewerSpecs.openLeftLeftX,
magnification: ConvertRopeToReal[ViewerTools.GetContents[psTool.magnificationViewer]]/100.0,
scaleToFit: SELECT TRUE FROM
magnificationRope.Equal["UseFactor"] => useMagnification,
magnificationRope.Equal["HalfPage"] => halfPage,
magnificationRope.Equal["FullPage"] => fullPage,
ENDCASE => halfPage,
leftMarginInches: ConvertRopeToReal[ViewerTools.GetContents[psTool.borderViewer]],
rightMarginInches: ConvertRopeToReal[ViewerTools.GetContents[psTool.borderViewer]],
landscape: SELECT ChoiceButtons.GetSelectedButton[psTool.formatViewer] FROM
"Landscape" => TRUE,
ENDCASE => FALSE,
borderWidth: ConvertRopeToReal[ViewerTools.GetContents[psTool.pageMarginViewer]]
! MagnificationFactorTooLarge => GOTO ReportError];
AppendLogMessage[psTool, Rope.Concat[fileName, " written."]];
EXITS
ReportError =>
AppendLogMessage[NARROW[clientData], "Magnification factor too large for the right column"];
};
MagnificationFactorButton: Buttons.ButtonProc = {
psTool: PressScreenTool ← NARROW[clientData];
IF mouseButton = blue THEN ViewerTools.SetContents[psTool.magnificationViewer, ""];
ViewerTools.SetSelection[psTool.magnificationViewer];
};
SetCornersButton: Buttons.ButtonProc = {
psTool: PressScreenTool ← NARROW[clientData];
IF mouseButton=red THEN {
sMin, fMin: INTEGER;
sSize, fSize: NAT;
[sMin, fMin, sSize, fSize] ← LFUtil.GetArea[ ! LFUtil.AbortAdjust => GOTO DoNothing];
ViewerTools.SetContents[psTool.ulx, IO.PutFR["%g", IO.int[fMin]]];
ViewerTools.SetContents[psTool.uly, IO.PutFR["%g", IO.int[sMin+sSize-1]]];
ViewerTools.SetContents[psTool.lrx, IO.PutFR["%g", IO.int[fMin+fSize-1]]];
ViewerTools.SetContents[psTool.lry, IO.PutFR["%g", IO.int[sMin]]];
};
FlashScreenArea[psTool];
EXITS
DoNothing => NULL;
};
BlackBorder: Buttons.ButtonProc = {
psTool: PressScreenTool ← NARROW[clientData];
IF mouseButton = blue THEN ViewerTools.SetContents[psTool.borderViewer, ""];
ViewerTools.SetSelection[psTool.borderViewer];
};
PageMarginButton: Buttons.ButtonProc = {
psTool: PressScreenTool ← NARROW[clientData];
IF mouseButton = blue THEN ViewerTools.SetContents[psTool.pageMarginViewer, ""];
ViewerTools.SetSelection[psTool.pageMarginViewer];
};
AppendLogMessage: PROCEDURE [psTool: PressScreenTool, msg: ROPE] = {
psTool.logMessage ← psTool.logMessage.Cat[msg, "\n"];
ViewerTools.SetContents[psTool.logViewer, psTool.logMessage];
[] ← psTool.logViewer.class.scroll[psTool.logViewer, thumb, 100];
};
ReadScreenCorners: PROCEDURE [psTool: PressScreenTool] RETURNS [ulx, uly, lrx, lry: REAL] = {
ulx ← ConvertRopeToReal[ViewerTools.GetContents[psTool.ulx]];
uly ← ConvertRopeToReal[ViewerTools.GetContents[psTool.uly]];
lrx ← ConvertRopeToReal[ViewerTools.GetContents[psTool.lrx]];
lry ← ConvertRopeToReal[ViewerTools.GetContents[psTool.lry]];
};
ConvertRopeToReal: PROCEDURE [rope: ROPE] RETURNS [value: REAL] = {
i : INT ← 0;
Get: PROCEDURE RETURNS [c: CHARACTER] = {
c ← IF i >= rope.Length THEN ' ELSE rope.Fetch[i];
i ← i + 1;
RETURN[c];
};
RETURN[Real.ReadReal[Get]];
};
PressScreenExecCommand: Commander.CommandProc = TRUSTED {
stream: IO.STREAMIO.RIS[cmd.commandLine];
serverName: ROPEIO.GetToken[stream, IO.IDProc];
[] ← NewPressScreenTool[serverName];
};
Commander.Register[
key: "PressScreen",
proc: PressScreenExecCommand,
doc: "Create a tool to make AIS/Press files of portions of the bitmap display screen"
];
}.
6-Apr-82 12:01:31 Teitelman fixed PressScreenButton to clear message window first.
May 4, 1982 4:39 pm Cattell: print msg saying whether half or full screen. Also, no longer need config 'cause SirPressPackage is external.
June 18, 1982 1:58 pm Cattell: convert to 3.2; leave a little left margin to avoid printer truncation.
November 15, 1982 12:30 pm Plass: Made client-callable interface.
November 15, 1982 2:30 pm Plass: Made rightSide work, removed button interface, made half-screen resolution match what Spruce can sometimes handle.
November 16, 1982 10:57 am Plass: Tracked SirPress changes.