SilDisplayUtils.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Tracy Larrabee: March 29, 1984 1:31:39 pm PST
Last Edited by: Ken Pier, August 15, 1985 5:00:10 pm PDT
A module defining the display service routines.
DIRECTORY
Geom2D USING [Rect],
Imager USING [Context],
ImagerFont USING [Font],
Rope USING [ROPE],
SilDisplayInternal USING [CommandChange, defaultColor],
SilFile USING [Color, InternalFonts, SilObject, SilObjectRec, UserFonts],
SilKernel USING [SilData, SilDisplayData, SilModel, SilUIData],
SilUserInput USING [Face],
ViewerClasses USING [Viewer]
;
SilDisplayUtils: CEDAR DEFINITIONS = BEGIN
ROPE: TYPE = Rope.ROPE;
SilData: TYPE = SilKernel.SilData;
SilDisplayData: TYPE = SilKernel.SilDisplayData;
SilModel: TYPE = SilKernel.SilModel;
SilUIData: TYPE = SilKernel.SilUIData;
SilObjectRec: TYPE = SilFile.SilObjectRec;
CommandChange: TYPE = SilDisplayInternal.CommandChange;
DisplayChoice: TYPE = {show, erase, select};
ContextChoice: TYPE = {normal, magnified};
ColorFontOrFace: TYPE = {color, font, face, invalid};
AttributeRec: TYPE = RECORD [
referenced: ColorFontOrFace,
color: SilFile.Color ← SilDisplayInternal.defaultColor,
font: SilFile.UserFonts ← 0,
face: SilUserInput.Face ← italic
];
Orientation: TYPE = {vertical, horizontal};
BoxEnd: TYPE = {long, short};
FileType: TYPE = {input, output, largeOutput};
SilUtilsInit: PROC [];
Set global variables necessary to the correct functioning of the Display service routines ( various font refs).
GetFont: PROC [font: SilFile.InternalFonts, italic: BOOLFALSE] RETURNS [fontRef: ImagerFont.Font];
Return the font description for a given internal Font( number).
SwapFonts: PROC [data: SilData, ctx: Imager.Context];
toggle display font between "normal" and "hardcopy" display
ModifyContext: PROC [makeContext: ContextChoice ← normal, dData: SilDisplayData, ctx: Imager.Context];
Modify the context to reflect the current state of the window as supplied in the display data.
MagnifyDrawing: PROC [data: SilData, ctx: Imager.Context, xMin, yMin, xMax, yMax: INTEGER];
Enter Magnify mode. Modify the display of the drawing and the state of the display data to reflect the change. Send the boundin box of the region intended to be magnified.
SilRebuild: PROC [data: SilData, ctx: Imager.Context];
Rebuild the display inside the box given in dData.
MergeRebuild: PROC[dData: SilDisplayData, model: SilModel, xMin, yMin, xMax, yMax: INTEGER, selectedOnly: BOOLFALSE];
Set the fields in dData to reflect the fact that any current rebuilds should include the box defined by xMin, yMin, xMax, yMax. If SelectedOnly then only rebuild the selected objects.
PaintObject: PROC [model: SilModel, sobr: SilFile.SilObjectRec, dMode: DisplayChoice, ctx: Imager.Context, oneLevel, foregroundOnly: BOOLEANFALSE, print: BOOLEANFALSE];
Paint one Sil Object on the screen
ChangeCommandLineData: PROC [data: SilData, ctx: Imager.Context, change: SilDisplayInternal.CommandChange ← Pos, boolArg: BOOLFALSE, intArg1: INTEGER ← 0, intArg2: INTEGER ← 0];
Modify the Command Line data for this window to reflect the new info. Depending on change one or more of the arguments will be used to supply interesting values. In all cases except when change is pos, the display data of the Sil will be updated.
ExpandMacro: PROC[model: SilModel, char: CHAR, x, y: INTEGER, oneLevel: BOOL, ctx: Imager.Context];
Expand the Macro Given. If oneLevel then don't expand any contained macros.
EraseArea: PROC[xMin, yMin, xMax, yMax: INTEGER, ctx: Imager.Context];
Erase an area of the screen. Used for making sure the screen starts from scratch.
MergeArea: PROC[dData: SilDisplayData, model: SilModel, xMin, yMin, xMax, yMax: INTEGER, ctx: Imager.Context];
merge an area into the area needing rebuilding
BBoxFilter: PROC[xMin, yMin, xMax, yMax: INTEGER, sobr: SilFile.SilObjectRec] RETURNS [passed: BOOL];
TRUE if some part of sobr appears inside the box defined in dData. Can make this an inline when the need arises.
AttributeFromChar: PROC[char: CHAR] RETURNS [AR: AttributeRec];
Return information about which attribute is referenced by the given char.
char = 0-9 => font.
char = D,R,O,Y,L,G,T,C,A,V,U,M,P,S,N,or W => color.
char = b,B,i,or I => face.
AttributeFilter: PROC[AR: AttributeRec, sobr: SilFile.SilObjectRec] RETURNS [passed: BOOL];
The AttributeRec contains a discription of certain attributes which sobr may or may not have Return TRUE if sobr has the attribute described in AR.
OffsetFilter: PUBLIC PROC[sobr: SilObjectRec, offsetDirection: Orientation, offset, xMin, yMin, xMax, yMax: INTEGER] RETURNS [passed: BOOLFALSE, bEnd: BoxEnd ← long];
Return TRUE if sobr represents a box with just one end inside the box defined by xMin, yMin, xMax, yMax and could be appropriately shortened or lengthened in the direction and by the amount given.
StretchBox: PUBLIC PROC[sob: SilFile.SilObject, offsetDirection: Orientation, bEnd: BoxEnd, offset: INTEGER];
Stretch the box given by sob by the amount given by offset in the direction given by offsetDirection at the box end given by bEnd.
FixBoxConnectivity: PUBLIC PROC[dData: SilDisplayData, sobrIn: SilObjectRec, boxDir: Orientation] RETURNS [sobr: SilObjectRec];
Figure out from the dData given if the current box is going to have to be extended by a box length in order to provide a nice connection in the lower right hand corner (you may have to draw a few boxes in Sil to feel comfortable with this statement).
BoundingBoxOfContext: PROC [ctx: Imager.Context] RETURNS[xMin, yMin, xMax, yMax: INTEGER];
Return the bounding box of the context given, in integer coordinates.
DeselectAndPaintAll: PROC [model: SilModel, ctx: Imager.Context];
Deselect all of the objects which are currently selected.
PaintAllSelectedAsDeselected: PROC [model: SilModel, ctx: Imager.Context];
If there are objects selected from this model, paint all of them as deselected, but dont change the data structure.
DisplayGrid: PROC [eraseOrShow: SilDisplayUtils.DisplayChoice, dData: SilDisplayData, model: SilModel, ctx: Imager.Context];
Erase or display the grids as specified in dData.
DisplayFrames: PROC [eraseOrShow: SilDisplayUtils.DisplayChoice, dData: SilDisplayData, model: SilModel, ctx: Imager.Context];
Erase or display the page frames as specified in dData.
AbortRopeInput: PROC[data: SilData, markX, markY: INTEGER, ctx: Imager.Context];
Call this if the user was inputting a rope, but changed his mind for some reason.
BoundingBoxOfObject: PROC[model: SilModel, sobr: SilObjectRec] RETURNS [xMin, yMin, xMax, yMax: INTEGER];
Return the bounding box of the Object given. Do not assume that the bounding box given in sobr is correct.
BoundingBoxOfModel: PROC[dData: SilDisplayData, model: SilModel, mapArea: BOOLEANTRUE] RETURNS [rect: Geom2D.Rect];
Return the bounding box of the model given, in Client Coordinates.
GuessFileName: PROC[data: SilData, file: FileType];
Guess as to the appropriate file name for input or output. Set appropriate data values and place file name in message window for user to edit.
GuessHardFileName: PROC[data: SilData, c: CHAR];
Guess as to the appropriate file name to produce for hardcopy output. Set appropriate data values and place file name in message window for user to edit. C will indicate what type of device to produce the PD file fo:
R for Raven, H for Hornet, G for Gnat, P for PlateMaker, R for ReticleMaker, U for Puffin, and C for ColorVersatec.
InputNamedFile: PROC[data: SilData, name: ROPE, ctx: Imager.Context];
Input a named Sil file. It should be noted that a Sil file maybe read in more than once, and will result in two copies of each file object existing in the Sil environment (any number of different files can also be read in and co-exist).
OutputNamedFile: PROC[data: SilData, name: ROPE, viewer: ViewerClasses.Viewer];
Output a named Sil file.
KillConfirmedFile: PROC[data: SilData, ctx: Imager.Context, viewer: ViewerClasses.Viewer];
Kill a Sil file. User has already confirmed this kill.
HardcopyFile: PROC[data: SilData, name: ROPE];
Produce a hardcopy file (PD file) with the name given for the sil data given.
DefineConfirmedMacro: PROC[data: SilData, name: CHAR, ctx: Imager.Context];
Define a macro from the selected objects. User has already confirmed this definition.
ClearConfirmedMacroDefs: PROC[data: SilData, ctx: Imager.Context];
Clear all Macro Definitions. User has already confirmed this drastic act.
CheckFileExtension: PROC[name: ROPE, type: FileType] RETURNS[nameAndExt: ROPE];
If the filename given has no extension and no dot on the end add an appropriate extension to the name.
MarkFileAsEdited: PROC[data: SilData, ctx: Imager.Context, viewer: ViewerClasses.Viewer];
Mark the file as edited. This may involve the removal of "build marks." (Visual cues put in Sil files by post processing DA programs.
EditText: PROC [EditThis: REF TEXT, c: CHAR] RETURNS [Edited: REF TEXT, Finished: BOOLFALSE, Aborted: BOOLFALSE, BackedUp: BOOLFALSE];
Reflect the effect of this input char on the text given. If the input character implies that this rope has been aborted or finished, return the apropriate values. Return BackedUp TRUE if the some characters in the rope had to be removed.
END.