GenericTool.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Demers, January 31, 1986 3:41:46 pm PST
DIRECTORY
Abutters USING [Abutter],
IO USING [STREAM],
Rope USING [ROPE],
ViewerClasses USING [Viewer];
~
BEGIN
ROPE: TYPE ~ Rope.ROPE;
STREAM: TYPE ~ IO.STREAM;
Viewer:
TYPE ~ ViewerClasses.Viewer;
ToolHandle: TYPE ~ REF ToolObject;
ToolObject:
TYPE ~
RECORD[
Generic tool info
abutter: Abutters.Abutter,
controlsViewer: Viewer,
logViewer: Viewer,
in, out: STREAM,
preDestroy: ButtonProc ← NIL,
Client data structure
control: REF ANY,
data: REF ANY];
ButtonProc:
TYPE ~
PROC [tH: ToolHandle];
The PROCs in the client's controls object should be ButtonProcs. CreateInstance arranges to pass the ToolHandle to each ButtonProc "invisibly"; the ButtonProc can access the controls and client data records through it.
OptionList: TYPE ~ LIST OF Option;
Option:
TYPE ~
RECORD [
name: ROPE,
it:
SELECT kind: *
FROM
readonly => [],
invisible => [],
notify => [proc: ButtonProc]
ENDCASE
];
CreateInstance:
PROC [
toolName:
ROPE,
control:
REF
ANY,
options: OptionList,
data:
REF
ANY ←
NIL,
preDestroy: ButtonProc ←
NIL]
RETURNS [tH: ToolHandle];
Create a tool instance. The record to be displayed by ViewRec is control^. Display of individual fields is controlled by options. Client data can go either in data^ or in invisible fields of control^. Each ButtonProc invocation provides a ToolHandle, from which control and data can be recovered. If supplied, preDestroy will be called just prior to destroying the viewer (in response to the user's clicking "destroy" in the caption bar).
PutMsgRope:
PROC [tH: ToolHandle, rope:
ROPE, clear:
BOOL ←
FALSE];
Print message on the ViewRec message (sub-)viewer. If clear is TRUE, clear the (sub-)viewer first.
END.