ViewerEvents.mesa
Copyright Ó 1985, 1986, 1991 by Xerox Corporation. All rights reserved.
Edited by McGregor on October 25, 1982 10:01 am
Last Edited by: Maxwell, January 11, 1983 12:26 pm
Last Edited by: Paul Rovner, July 20, 1983 2:01 pm
Doug Wyatt, April 24, 1985 10:36:51 pm PST
DIRECTORY
ViewerClasses USING [Viewer];
ViewerEvents: CEDAR DEFINITIONS
= BEGIN
Viewer: TYPE ~ ViewerClasses.Viewer;
EventProc: TYPE = PROC [viewer: Viewer, event: ViewerEvent, before: BOOL]
RETURNS [abort: BOOL ¬ FALSE];
abort will abort the event and the remaining EventProcs
This interface, while fairly easy to use, requires some understanding of the viewer tree and paint locking mechanisms. All of the calls to client code occur outside of the locking mechanism. To be absolutely safe, the client should lock the appropriate resources and retest the initial condition. Consult a Viewers wizard for more information.
ViewerEvent: TYPE = {save, edit, destroy, create, close, open, grow, changeColumn, setInputFocus, killInputFocus, spare1, spare2, spare3, spare4};
There are two calls for each event: before anything happens and after everything (including the painting) is complete. The first call of a create occurs after the ViewerRec is NEW'ed but before the parameters are checked. Parameters can be changed if desired.
EventRegistration: TYPE = REF;
RegisterEventProc: PROC [proc: EventProc, event: ViewerEvent,
filter: REF ANY ¬ NIL, before: BOOL ¬ TRUE] RETURNS [EventRegistration];
Register a procedure that can be called before or after the specified event occurs. The filter can be a particular viewer, the atom for a class, or NIL. When before is TRUE the EventProc can abort the event. If the client wishes to unregister the procedure at some point, they should save the EventRegistration returned. N.B. - many of the EventProcs are called from within the Viewer tree write lock. If you attempt to perform a ViewerOps function that requires the write lock from within your EventProc then you will deadlock. Some of the events may additionally have acquired the paint lock. If you are concerned about deadlocks or if you plan to do anything time-consuming in an EventProc, consider forking a separate process so as not to adversely affect system performance.
UnRegisterEventProc: PROC [proc: EventRegistration, event: ViewerEvent];
Unregister an EventProc registered via RegisterEventProc.
ProcessEvent: PRIVATE PROC [event: ViewerEvent, viewer: Viewer, before: BOOL]
RETURNS[abort: BOOL];
Window manager internal use only. Called once before and once after each event.
END.