ViewerOps.mesa; Written by S. McGregor
Edited by McGregor on July 26, 1983 9:58 am
Last Edited by: Maxwell, January 13, 1983 2:46 pm
Last Edited by: Pausch, August 17, 1983 11:07 am
Last Edited by: Wyatt, October 26, 1983 11:37 am
DIRECTORY
Imager USING [Color, Context],
Rope USING [ROPE],
TIPUser USING [TIPScreenCoords],
ViewerClasses USING [Viewer, ViewerClass, ViewerFlavor, ViewerRec, Column],
ViewerSpecs USING [openBottomY, openLeftWidth];
ViewerOps: CEDAR DEFINITIONS
IMPORTS ViewerSpecs
SHARES ViewerClasses
= BEGIN OPEN ViewerClasses, ViewerSpecs;
RegisterViewerClass: PROC [flavor: ViewerFlavor, class: ViewerClass,
superClassFlavor: ViewerFlavor ← NIL];
Let the Viewers package know about a new class of viewer.
If superClassFlavor is not NIL, fill in NIL values in the class record with values from the superClass. Non-NIL values in the class record are left alone.
FetchViewerClass: PROC [flavor: ViewerFlavor] RETURNS [ViewerClass];
Class information from an existing viewer class.
IsClass: PROC [viewer: Viewer, class: ViewerFlavor] RETURNS[BOOL];
Returns TRUE iff viewer has the given class or is a sub-class of the given class.
CreateViewer: PROC [flavor: ViewerFlavor, info: ViewerRec ← [], paint: BOOLTRUE]
RETURNS [new: Viewer] ;
Create a new viewer instance. Caller may set selected fields in info. If parent # NIL then the new viewer will be recursively embedded in the parent. Do not directly set the following ViewerRec fields (they are either computed or private): cx, cy, cw, ch, visible, destroyed, unUsed, link, menu, position, sibling, child, props
OpenIcon: PROC [icon: Viewer, closeOthers: BOOLFALSE, bottom: BOOLTRUE,
paint: BOOLTRUE] ;
Open an icon. If closeOthers then other viewers in that column will first be closed. If bottom then the newly opened icon will be placed at the bottom of the column, otherwise at the top. If paint is FALSE then the caller has the responsibility to repaint the column via ComputeColumn.
CloseViewer: PROC [viewer: Viewer, paint: BOOLTRUE] ;
Make iconic.
GrowViewer: PROC [viewer: Viewer, paint: BOOLTRUE] ;
Close all other viewers in the column. Assumes viewer is not iconic.
TopViewer: PROC [viewer: Viewer, paint: BOOLTRUE] ;
Move viewer to top of column.
BottomViewer: PROC [viewer: Viewer, paint: BOOLTRUE] ;
Move viewer to bottom of column.
MoveAboveViewer: PROC [altered, static: Viewer, paint: BOOLTRUE] ;
Move the altered viewer above the static viewer in the column.
MoveBelowViewer: PROC [altered, static: Viewer, paint: BOOLTRUE] ;
Move the altered viewer below the static viewer in the column.
CopyViewer: PROC [viewer: Viewer, x, y: INTEGER, w, h: INTEGER] RETURNS [new: Viewer] ;
MoveViewer: PROC [viewer: Viewer, x, y: INTEGER, w, h: INTEGER, paint: BOOLTRUE] ;
Only meaningful on static or embedded viewers.
Adjust: PROC [viewer: ViewerClasses.Viewer] ;
interactively adjust the viewer boundaries
DestroyViewer: PROC [viewer: Viewer, paint: BOOLTRUE] ;
Destroy viewer and subordinate children chain.
PaintViewer: PROC [viewer: Viewer, hint: PaintHint, clearClient: BOOLTRUE,
whatChanged: REF ANYNIL] ;
Suggests that the window package repaint the contents of a viewer. The whatChanged field is simply passed through to the client. Note that there is no guarantee that the client's paintProc will actually be called; the viewer could be iconic or currently invisible.
The hint is an accelerator that enables repaint of selective regions of a viewer, as listed in the table below.
all   client & menu & caption & borders & children
client  client (& children if clearClient)
menu  menu portion of header (clearClient ignored)
caption caption portion of header (clearClient ignored)
PaintHint: TYPE = { all, client, menu, caption } ;
NotifyViewer: PROC [viewer: Viewer, input: LIST OF REF ANY] = INLINE
{IF viewer.class.notify#NIL THEN viewer.class.notify[viewer, input]} ;
Mouse and keyboard TIP notifications.
SetViewer: PROC [viewer: Viewer, data: REF ANY, finalise: BOOLTRUE, op: ATOMNIL] =
INLINE {IF viewer.class.set#NIL THEN viewer.class.set[viewer, data, finalise, op]} ;
Set the contents of a viewer.
GetViewer: PROC [viewer: Viewer, op: ATOMNIL] RETURNS [data: REF ANY] = INLINE
{RETURN[IF viewer.class.get#NIL THEN viewer.class.get[viewer, op] ELSE NIL]} ;
Get the contents of a viewer.
SaveViewer: PROC [viewer: Viewer] ;
Save viewer data to file.
RestoreViewer: PROC [viewer: Viewer] ;
Restore viewer data from original file.
ReplaceViewer: PROC [new, old: Viewer] ;
Replace a current viewer with a new one. (This proc is intended for wizards). The old viewer is destroyed. The new one should not yet be painted.
SwapIconAndViewer: PROC [icon, openViewer: Viewer, paint: BOOLTRUE] ;
Swap positions of an icon and an open viewer.
ChangeColumn: PROC [viewer: Viewer, newColumn: Column] ;
Move viewer to another column.
EnumerateViewers: PROC [enum: EnumProc] ;
Enumerate all top level viewers.
EnumerateChildren: PROC [viewer: Viewer, enum: EnumProc] ;
Enumerate all children bottom up.
EnumProc: TYPE = PROC [v: Viewer] RETURNS [BOOLTRUE] ;
Return false to terminate enumeration.
FindViewer: PROC [name: Rope.ROPE] RETURNS [viewer: Viewer] ;
Locate an instance of a named viewer.
Visible: PROC[viewer: Viewer] RETURNS[BOOLEAN] ;
is the viewer visible on the screen?
InstallClientContext: PROC [viewer: Viewer, context: Imager.Context] = INLINE
{viewer.clientContext ← TRUE; AddProp[viewer, $ViewerClientContext, context]} ;
Associate a context with a viewer
AddProp: PROC [viewer: Viewer, prop: ATOM, val: REF ANY];
Associate a property with a viewer
FetchProp: PROC [viewer: Viewer, prop: ATOM] RETURNS [val: REF ANY];
Get back a property associated with a viewer
UserToScreenCoords: PROC [self: Viewer, vx, vy: INTEGER ← 0] RETURNS [sx, sy: INTEGER] ;
Maps viewer-relative coords to screen-relative coords.
MouseInViewer: PROC [tsc: TIPUser.TIPScreenCoords] RETURNS [viewer: Viewer, client: BOOL] ;
Maps screen-relative coords to viewer and viewer-relative coords.
Top2Bottom: PROC [v: Viewer, y: INTEGER] RETURNS [INTEGER] = INLINE
{RETURN[v.ch - y]};
Returns coord relative to top given coord relative to bottom of viewer
Bottom2Top: PROC [v: Viewer, y: INTEGER] RETURNS [INTEGER] = INLINE
{RETURN[Top2Bottom[v, y]]};
Returns coord relative to bottom given coord relative to top of viewer
SetNewVersion: PROC [viewer: Viewer] = INLINE
{IF ~(viewer.newVersion OR viewer.newFile) THEN IndicateNewVersion[viewer]};
Marks a viewer as a new version of the file
IndicateNewVersion: PRIVATE PROC [viewer: Viewer] ;
SetNewFile: PROC [viewer: Viewer] ;
Marks a viewer as a new file
SetOpenHeight: PROC [viewer: Viewer, clientHeight: INTEGER] ;
Set a hint for the WMgr. Should be called from InitProc or when viewer is iconic, otherwise call ComputeColumn to reflect new size on the screen.
EstablishViewerPosition: PROC [viewer: Viewer, x,y,w,h: INTEGER] ;
Recomputes client info when changing "scrollable", menu, size, etc. This proc is intended for wizards.
ComputeColumn: PROC [column: Column, paint: BOOLTRUE] ;
Recompute viewer sizes in a column. Useful after calling SetOpenHeight[] on an open viewer.
ViewerColumn: PROC [viewer: Viewer] RETURNS [column: Column] = INLINE
{RETURN[IF viewer.iconic THEN static ELSE viewer.column]};
SaveAllEdits: PROC ;
Lives in ViewerOpsImpl. Call this from the debugger if you crash and want a "poor man's" crash recovery. Calls the SaveProc of all viewers that have the NewVersion bit set. Catches all signals and attempts to press on.
MoveBoundary: PROC [newLeftWidth: INTEGER ← openLeftWidth,
newBottomY: INTEGER ← openBottomY] ;
Change the position of the vertical separator bar that controls the width of the right and left documents. This interface is intended for wizards.
PaintEverything: PROC ;
Repaint the entire screen.
BlinkIcon: PROC [viewer: Viewer, count: NAT ← 1, interval: NAT ← 2000] ;
Blinks (inverts twice) a viewer.
If count # 1, wait interval millseconds between blinks.
If count = 0, blink until the icon is opened or another icon is selected.
Private window management stuff; no user serviceable parts below.
DisablePainting: PRIVATE PROC [wait: BOOLTRUE] ;
Blocks further painting attempts and returns when all is quiet.
EnablePainting: PRIVATE PROC ;
Enables painting to begin again.
WaitForPaintingToFinish: PRIVATE PROC ;
Returns when all is quiet.
ResetPaintCache: PRIVATE PROC [viewer: Viewer ← NIL, wait: BOOLTRUE] ;
Internal monitored reset of context caches; NIL => flush all cached contexts.
InitialiseColorPainting: PRIVATE PROC ;
Enables viewer operations on the color display. See WindowManager.StartColorViewers for client callable interface.
InvertForMenus: PRIVATE PROC [viewer: Viewer, x,y: INTEGER, w,h: INTEGER] ;
Back door for menus to invert screen areas faster than normal paint mechanism
GreyScreen: PRIVATE PROC [x,y,w,h: INTEGER, color, icon: BOOL, stipple: Imager.Color ← NIL] ;
Grey an arbitrary rectangle on the black&white or color display.
AcquireContext: PRIVATE PROC [viewer: Viewer, color: BOOLFALSE]
RETURNS [allocated: Imager.Context] ;
Allocate and configure a cached context. May raise InvisiblePaint in which case the client must UNWIND, then give up or retry.
InvisiblePaint: SIGNAL ;
ReleaseContext: PRIVATE PROC [free: Imager.Context];
Release a context back to the cache.
ColumnInfo: PRIVATE PROC[column: Column]
RETURNS[totalSpace, leftX, width, bottomY, nextY: INTEGER];
Compute the shape of a column; used by ViewerBLTImpl
END.