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
DIRECTORY
Atom USING [GetPropFromList, PutPropOnList],
Imager USING [Context],
Menus USING [Menu],
Rope USING [ROPE],
TIPUser USING [TIPScreenCoords],
ViewerClasses USING [Viewer, ViewerClass, ViewerFlavor, ViewerRec, Column],
ViewerSpecs USING [openBottomY, openLeftWidth];
ViewerOps: CEDAR DEFINITIONS IMPORTS Atom, ViewerSpecs SHARES ViewerClasses =
BEGIN OPEN ViewerClasses, ViewerSpecs;
RegisterViewerClass:
PROC [flavor: ViewerFlavor, class: ViewerClass];
Let the Viewers package know about a new class of viewer.
FetchViewerClass:
PROC [flavor: ViewerFlavor]
RETURNS [ViewerClass];
Class information from an existing viewer class.
CreateViewer:
PROC [flavor: ViewerFlavor, info: ViewerRec ← [], paint:
BOOL ←
TRUE]
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, position, sibling, child, props
OpenIcon:
PROC [icon: Viewer, closeOthers:
BOOL ←
FALSE, bottom:
BOOL ←
TRUE,
paint: BOOL ← TRUE] ;
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:
BOOL ←
TRUE] ;
Make iconic.
GrowViewer:
PROC [viewer: Viewer, paint:
BOOL ←
TRUE] ;
Close all other viewers in the column. Assumes viewer is not iconic.
TopViewer:
PROC [viewer: Viewer, paint:
BOOL ←
TRUE] ;
Move viewer to top of column.
BottomViewer:
PROC [viewer: Viewer, paint:
BOOL ←
TRUE] ;
Move viewer to bottom of column.
MoveAboveViewer:
PROC [altered, static: Viewer, paint:
BOOL ←
TRUE] ;
Move the altered viewer above the static viewer in the column.
MoveBelowViewer:
PROC [altered, static: Viewer, paint:
BOOL ←
TRUE] ;
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:
BOOL ←
TRUE] ;
Only meaningful on static or embedded viewers.
DestroyViewer:
PROC [viewer: Viewer, paint:
BOOL ←
TRUE] ;
Destroy viewer and subordinate children chain.
PaintViewer:
PROC [viewer: Viewer, hint: PaintHint, clearClient:
BOOL ←
TRUE,
whatChanged: REF ANY ← NIL] ;
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:
BOOL ←
TRUE, op:
ATOM ←
NIL] =
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:
ATOM ←
NIL]
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:
BOOL ←
TRUE] ;
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 [
BOOL ←
TRUE] ;
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] =
INLINE
{viewer.props ← Atom.PutPropOnList[viewer.props, prop, val]} ;
Associate a property with a viewer
FetchProp:
PROC [viewer: Viewer, prop:
ATOM]
RETURNS [val:
REF
ANY] =
INLINE
{RETURN[Atom.GetPropFromList[viewer.props, prop]]} ;
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
SetMenu:
PROC [viewer: Viewer, menu: Menus.Menu ←
NIL, paint:
BOOL ←
TRUE] ;
Change a viewer menu.
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:
BOOL ←
TRUE] ;
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:
BOOL ←
TRUE] ;
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:
BOOL ←
TRUE] ;
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:
REF
CARDINAL ←
NIL] ;
Grey an arbitrary rectangle on the black&white or color display.
AcquireContext:
PRIVATE
PROC [viewer: Viewer, color:
BOOL ←
FALSE]
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.
END.