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.