QuickViewer.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Last Edited by: Frank Crow September 22, 1986 5:11:55 pm PDT
Rick Beach, June 13, 1986 5:10:16 pm PDT
DIRECTORY
Imager  USING [Context],
CedarProcess USING [Process],
ViewerClasses USING [Viewer],
ActionQueue USING [Queue],
Terminal  USING [Virtual],
Rope   USING [ ROPE ];
QuickViewer: CEDAR DEFINITIONS
~ BEGIN
BuildViewer: PROC[ viewerTitle: Rope.ROPE,
       menuLabels: LIST OF Rope.ROPE,
       reDrawProc: PROC[imagerCtx: Imager.Context, toDo: REF ANY],
       buttonProc: PROC[bttn, choice: ATOM, x, y: REAL],
       quitProc: PROC[]
       ]
   RETURNS [ quickView: REF QuickView ];
Make a viewer with the supplied menu labels. Use the supplied ReDrawProc when the screen must be redrawn (because the viewer changes size, etc.). Use the supplied QuitProc to clean up on program termination (which occurs when the viewer is destroyed). The ButtonProc will be called with the button name, an atom representing a choice from a pop-up menu or the state of the control and shift keys and the mouse position whenever the state of an input device (keyboard, mouse) changes.
DrawInViewer: PUBLIC PROCEDURE [view: REF QuickView, proc: PROC[Imager.Context]];
Callback procedure used to draw on display. QuickViewer will supply the Imager context to the supplied procedure then call it.
CountedCondition: TYPE ~ RECORD [ count: NAT ← 0, condition: CONDITION ];
QuickView: TYPE = RECORD [
outer: ViewerClasses.Viewer,       -- enclosing container
viewer: ViewerClasses.Viewer,      -- graphics area within
terminal: Terminal.Virtual,       -- virtual terminal
changed: BOOLEANFALSE,      -- has viewer size, etc. changed
menuQueue: ActionQueue.Queue,    -- queued menu clicks
newEvent: CountedCondition,      -- prevents pile-up of mouse positions
eventProcess: CedarProcess.Process,    -- event action process
inputEvent: ATOM,         -- Action from tip table
choice: ATOM,          -- from pop-up menu or ctrl-shift
x, y: REAL ← 0,          -- mouse coordinates
drawProc: PROC[Imager.Context, REF ANY],  -- procedure for redrawing window
buttProc: PROC[ATOM, ATOM, REAL, REAL],  -- procedure for button actions
exitProc: PROC[]          -- procedure for cleaning up on exit
];
END.