QuickViewerDoc.tioga
Crow, September 11, 1986 2:23:15 pm PDT
QUICKVIEWER
CEDAR 6.0 — FOR INTERNAL XEROX USE ONLY
QuickViewer
Easy Graphics in the Convoluted World of Viewers
Frank Crow
© Copyright 1985 Xerox Corporation. All rights reserved.
Abstract: QuickViewer provides a relatively easy way to get (possibly interactive) graphics through the Imager. QuickViewer handles a simple button menu and mouse and keyboard input for you and requires only a few simple procedures and conventions in return.
Created by: Frank Crow
Maintained by: Frank Crow <Crow.pa>
Keywords: Viewers, Imager
XEROX  Xerox Corporation
   Palo Alto Research Center
   3333 Coyote Hill Road
   Palo Alto, California 94304

For Internal Xerox Use Only
1. Plain QuickViewer Interface
BuildViewer: PROC[ viewerTitle: Rope.ROPE,
       menuLabels: LIST OF Rope.ROPE,
       reDrawProc: PROC[ctx: Imager.Context, toDo: REF ANY],
       buttonProc: PROC[bttn, choice: ATOM, x, y: REAL],
       quitProc: PROC[]
       ]
   RETURNS [ quickView: REF QuickView ];
BuildViewer makes a viewer for you. A list of ROPE provides both the labels on the menu buttons and the basis for discriminating between buttons. When a button is clicked, the client-supplied ButtonProc will be called with an ATOM made from the button label, a second atom made from the state of the Control and Shift keys {$Control, $Shift, $ControlShift}, and the x and y coordinates of the mouse. Mouse button actions outside the menu will also generate calls to ButtonProc using predefined button atoms (eg. $LeftButton) and the Control-Shift atom. The predefined atoms are:
$LeftButton, $LeftHeld, $LeftUp,
$MiddleButton, $MiddleHeld, $MiddleUp, and
$RightButton, $RightHeld, $RightUp.
Look at the procedure, MenuHit, in QuickViewerExampleImpl.mesa for an example of a ButtonProc. Menu buttons are queued using ActionQueue described below. Menu labels ending with an exclamation point (!) cause "immediate" buttons which flush the queued actions and get executed at the end of the current operation (see the STOP! button in QuickViewerExampleImpl.mesa).
The client must provide two other procedures, a ReDrawProc and a QuitProc. The ReDrawProc is called whenever the viewer is moved (eg. moved to the color display) or changed (eg. when another viewer is opened or closed in the same column). If no changes are expected this can be a null procedure. The QuitProc can also be a null procedure. QuitProc will be called when the viewer is destroyed, allowing the client a clean way to save state or clean up when done.
DrawInViewer: PROCEDURE [proc: PROC [Imager.Context]];
DrawInViewer is the clients access path to using the imager procedures to draw in the viewer. A call on DrawInViewer is used to pass the name of the procedure you wish to execute to the viewers package. The viewers package will in turn call the supplied procedure, providing the imager context neede by all imager procedures. Again see QuickViewerExampleImpl.mesa for examples of the use of DrawInViewer.
2. Fancy QuickViewer Interface
Watch this space for future developments.
3. ActionQueue
ActionQueue is a small modification of MBqueue. An additional argument to CreateMenuEntry and CreateButton ("immediate") allows certain button clicks to flush the queue and get quick attention. See ActionQueue.mesa and the implementation for details.