ViewerClasses.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Edited by McGregor on October 26, 1982 10:07 am
Last Edited by: Maxwell, January 3, 1983 2:14 pm
Doug Wyatt, April 24, 1985 10:34:09 pm PST
DIRECTORY
Atom USING [PropList],
Cursors USING [CursorType],
Icons USING [IconFlavor],
Imager USING [Context],
Menus USING [Menu],
Rope USING [ROPE],
TIPUser USING [TIPTable];
ViewerClasses: CEDAR DEFINITIONS
= BEGIN
Viewer: TYPE = REF ViewerRec;
ViewerRec: TYPE = RECORD [ -- 36 words
class: ViewerClass ← NIL, -- static info for all Viewers of this class **
wx, wy: INTEGER ← 0, -- position of viewer window wrt parent's client space
ww, wh: INTEGER ← 0, -- size of viewer window area
cx, cy: INTEGER ← 0, -- position of client space wrt window **
cw, ch: INTEGER ← 0, -- size of viewer client space **
lock: Lock ← [NIL, 0], -- locking information used by ViewerLocks * **
tipTable: TIPUser.TIPTable ← NIL, -- mouse and keyboard events, initialised from class
name: Rope.ROPENIL, -- Viewer name, displayed in caption (optional)
file: Rope.ROPENIL, -- backing file name (optional)
label: Rope.ROPENIL, -- icon label (optional)
menu: Menus.Menu ← NIL, -- copied from class; set with ViewerOps.SetMenu
icon: Icons.IconFlavor ← unInit, -- picture to display when small, initialised from class
column: Column ← left, -- screen space algorithm used when viewer is open
caption: BOOLFALSE, -- viewer has a caption bar at the top
scrollable: BOOLTRUE, -- viewer has a vertical scroll bar
hscrollable: BOOLFALSE, -- viewer has a horizontal scroll bar
iconic: BOOLTRUE, -- small or large representation on screen
border: BOOLTRUE, -- viewer has a surrounding black border
newVersion: BOOLFALSE, -- hint that the user has made new edits **
newFile: BOOLFALSE, -- hint that a backing file does not yet exist **
visible: BOOLTRUE, -- WMgr maintained hint for repaint use * **
offDeskTop: BOOLFALSE, -- is viewer off of the current desktop? **
destroyed: BOOLFALSE, -- hint that viewer has been flushed from window tree **
init: BOOLFALSE, -- init proc call has been completed after creation * **
saveInProgress: BOOLFALSE, -- the saveProc has been called but not yet returned **
inhibitDestroy: BOOLFALSE, -- if TRUE then window menu will not permit destroy
guardDestroy: BOOLFALSE, -- if TRUE then window menu will always guard destroy
paintingWedged: BOOLFALSE, -- used to mark a viewer whose paint proc has died * **
spare0, spare1, spare2, spare3, spare4, spare5, spare6: BOOLFALSE, -- spares
position: [0..256) ← 0, -- icon position * **
openHeight: INTEGER ← 0, -- "ideal" height hint for open viewer
link: Viewer ← NIL, -- ring of linked viewers **
parent: Viewer ← NIL, -- NIL if top level viewer **
sibling: Viewer ← NIL, -- sibling chain **
child: Viewer ← NIL, -- head of children chain **
props: Atom.PropList ← NIL, -- clients can associate properties with viewers **
data: REF ANYNIL -- data slot for Viewer Class implementor
];
Instance data for a viewer; please treat * entries as PRIVATE and ** entries as READONLY.
ViewerClass: TYPE = REF ViewerClassRec;
ViewerClassRec: TYPE = RECORD [
flavor: ViewerFlavor ← NIL, -- name of viewer's class
notify: NotifyProc ← NIL, -- TIP input events parsed from tipTable
paint: PaintProc ← NIL, -- called whenever the Viewer should repaint its contents
modify: ModifyProc ← NIL, -- reports InputFocus changes
destroy: DestroyProc ← NIL, -- called before Viewer structures freed on destroy
copy: CopyProc ← NIL, -- copy data to new Viewer
set: SetProc ← NIL, -- set the viewer contents
get: GetProc ← NIL, -- get the viewer contents
init: InitProc ← NIL, -- called on creation or reset to init client data
save: SaveProc ← NIL, -- requests client to write contents to disk
scroll: ScrollProc ← NIL, -- vertical scrolling
hscroll: HScrollProc ← NIL, -- horizontal scrolling
caption: CaptionProc ← NIL, -- display caption
adjust: AdjustProc ← NIL, -- called when viewer size is changed
menu: Menus.Menu ← NIL, -- template menu used for top-level viewers
tipTable: TIPUser.TIPTable ← NIL, -- table to parse mouse & keyboard events
topDownCoordSys: BOOLFALSE, -- TRUE => children positioned wrt top of client space
bltH: HBltRule ← none, -- use blt to copy screen contents (see comment below)
bltV: VBltRule ← none, -- use blt to copy screen contents (see comment below)
icon: Icons.IconFlavor ← document, -- picture to display when small
cursor: Cursors.CursorType ← textPointer, -- standard cursor when mouse is in viewer
props: Atom.PropList ← NIL
];
Class data for a viewer:
HBltRule: TYPE = { none, left, center, right };
VBltRule: TYPE = { none, top, center, bottom };
The bltH and bltV fields in the class request that the window package attempt to save some of the current screen contents of a viewer by moving the bits to the new viewer location (e.g. when the viewer is moved). These rectangle that was thus saved will show up as the whatChanged parameter, as a convenience to clients that keep caches of screen contents. Client that scale their image to fit the viewer bounding box should not use this feature.
PaintRectangle: TYPE = REF PaintRectangleRec;
PaintRectangleRec: TYPE = RECORD[
x, y, w, h: INTEGER ← 0
];
ViewerFlavor: TYPE = ATOM;
ViewerFlavors predefined by the Viewer package include: $Label, $MessageWindow, $Button, $Container, $Rule. Tioga implements $Text and $Typescript.
Lock: TYPE = RECORD [ -- process-reentrant viewer lock
process: UNSAFE PROCESSNIL, -- current write process
count: CARDINAL ← 0 -- number of locks currently granted for this viewer
];
Column: TYPE = {static, left, right, color};
Static documents, such as the message window, may not be open/closed
PaintProc: TYPE = PROC [self: Viewer, context: Imager.Context, whatChanged: REF, clear: BOOL]
RETURNS [quit: BOOLFALSE];
Called by the window manager when the client should repaint the data on the screen. The context is clipped to the client screen area. whatChanged is just passed from the call to ViewerOps.PaintViewer, but will be NIL when the window manager requires a full repaint after moving a viewer on the screen. clear is a hint that the client background is white, so that the client can paint on the black bits if it so chooses. See comments for paintRectangles bit in the viewer class. Return quit~TRUE to stop without painting children.
NotifyProc: TYPE = PROC [self: Viewer, input: LIST OF REF ANY];
Input events from the class TIPTable. Mouse events get passed whenever the mouse is over the viewer, keyboard events get passed if the vviewer own the input focus (see the InputFocus interface). N.B. Called at Process.priorityForeground!
ModifyProc: TYPE = PROC [self: Viewer, change: ModifyAction];
ModifyAction: TYPE = {set, push, pop, kill};
Called when the input focus ownership is changing so that the client can modify things like selection feedback on the screen or private data structures and state.
DestroyProc: TYPE = PROC [self: Viewer];
Called when the viewer has been destroyed for some reason.
CopyProc: TYPE = PROC [self, new: Viewer];
Copy implementor private data structures.
SetProc: TYPE = PROC [self: Viewer, data: REF ANY, finalise: BOOLTRUE, op: ATOMNIL];
GetProc: TYPE = PROC [self: Viewer, op: ATOMNIL] RETURNS [data: REF ANY];
The op atom for SetProc and GetProc is for private client agreements to get things like selection contents or content representations other than ropes.
InitProc: TYPE = PROC [self: Viewer];
Called by the window manager shortly after a viewer is created so that the client can create and initialise private data structures. Also called on the "Reset" menu command.
SaveProc: TYPE = PROC [self: Viewer, force: BOOLFALSE];
Requests client to save data structures on the disk. force should only be true when called from the emergency backup code on error recovery and requests that the client consider overriding monitors or locks that might otherwise prevent saving the data.
SaveAborted: ERROR[error: Rope.ROPE];
ScrollProc: TYPE = PROC [self: Viewer, op: ScrollOp, amount: INTEGER,
shift, control: BOOLFALSE] RETURNS [top, bottom: INTEGERLAST[INTEGER]];
ScrollOp: TYPE = {query, up, down, thumb};
Client scrolling and scrolling feedback. If op is 'query' the client should return the percentage of the scrollable document at the top and bottom of the screen, or default if unknown. If op is 'up' or 'down' then amount is number of pixels to glitch. If op is 'thumb' then amount is percentage into document to scroll. The shift and control information reflects the state of the shift and control keys during the up, down, and thumb ops and may be interpreted by the client as desired.
HScrollProc: TYPE = PROC [self: Viewer, op: HScrollOp, amount: INTEGER,
shift, control: BOOLFALSE] RETURNS [left, right: INTEGERLAST[INTEGER]];
HScrollOp: TYPE = {query, left, right, thumb};
Like ScrollProc, for horizontal scrolling.
CaptionProc: TYPE = PROC [self: Viewer, context: Imager.Context];
Allows client to draw caption legend.
AdjustProc: TYPE = PROC [self: Viewer] RETURNS [adjusted: BOOLFALSE];
Called whenever a viewer's size is changed. Return adjusted~TRUE to indicate that children were rearranged; ViewerBLT will assume that a full repaint is required if adjusted=TRUE.
END.