EBButtonClasses.mesa
Copyright Ó 1988, 1989, 1991, 1992 by Xerox Corporation. All rights reserved.
Goodisman, August 13, 1989 8:31:37 pm PDT
Bier, August 28, 1991 12:43 pm PDT
Doug Wyatt, April 15, 1992 2:31 pm PDT
Contents: Button Classes' interface to EmbeddedButtons, a framework for adding standardized behaviors to any application that is willing to support a set of button objects and to implement the behavior access routines.
DIRECTORY
EBTypes, Rope, ViewerClasses;
EBButtonClasses:
CEDAR
DEFINITIONS =
BEGIN
ActiveButton: TYPE = EBTypes.ActiveButton;
ActiveDoc: TYPE = EBTypes.ActiveDoc;
ButtonInfo: TYPE = EBTypes.ButtonInfo;
Event: TYPE = EBTypes.Event;
ROPE: TYPE = Rope.ROPE;
Viewer: TYPE = ViewerClasses.Viewer;
To register a new button class, implement the procedures the make up the ButtonClass record. Then call RegisterButtonClass using a new buttonClassName. To find out what button class names are in use, call ListButtonClasses from the interpreter.
RegisterButtonClass:
PROC [buttonClassName:
ATOM, buttonClass: ButtonClass];
Called by the implementation of a button class.
ListButtonClasses: PROC [] RETURNS [buttonClasses: LIST OF ATOM];
MarkButtonAsChanged: PROC [buttonInfo: ButtonInfo];
The ButtonClass record and the types of its procedures
ButtonClass: TYPE = REF ButtonClassObj;
ButtonClassObj:
TYPE =
RECORD [
name: ATOM,
instantiate: InstantiateProc,
unparseInstanceData: UnparseInstanceDataProc,
handleEvent: HandleEventProc,
getValue: GetValueProc,
setValue: SetValueProc,
defaultBehavior: DefaultBehaviorProc];
Note: A button class's unparseInstanceData may be NIL if the button class guarantees that the instance data for a button of this class will never change, especially if its setValue is also NIL.
InstantiateProc:
TYPE =
PROC [buttonInfo: ButtonInfo, language:
ATOM, languageVersion:
NAT, initFeedback:
BOOL ¬
FALSE]
RETURNS [instance:
REF];
Returns the runtime ButtonData corresponding to buttonData. If initFeedback is TRUE, causes the feedback on button in doc appropriate to this button being initialized.
UnparseInstanceDataProc:
TYPE =
PROC [instanceData:
REF, buttonInfo: ButtonInfo ¬
NIL, language:
ATOM ¬
NIL, languageVersion:
NAT ¬ 0]
RETURNS [
ROPE ¬
NIL];
Depending on the language and languageVersion, either returns the rope version of the instanceData or sets the field values of the buttonInfo to the rope versions of the fields of the instanceData.
HandleEventProc:
TYPE =
PROC [event: Event, instanceData:
REF, buttonInfo: ButtonInfo];
Handles the event by causing the button's behavior (changing state, popping up a menu, etc.), feedback (through FeedbackNotify), and function (through PassEventToApplication).
GetValueProc:
TYPE =
PROC[instanceData:
REF, buttonInfo: ButtonInfo]
RETURNS [value:
REF];
If the buttonClass provides for each button to have a value, returns the button's value. If the buttonClass does not provide for a value, returns NIL.
SetValueProc
:
TYPE =
PROC[instanceData:
REF, value:
REF, buttonInfo: ButtonInfo]
RETURNS[changed:
BOOL ¬
FALSE];
If the ButtonClass provides for each button to have a name and value, sets the value of button to val if button's name is "name". Returns TRUE if the button's value has actually changed.
DefaultBehaviorProc:
TYPE =
PROC[instanceData:
REF, buttonInfo: ButtonInfo];
In conditions where the default behavior of a button is appropriate, EmbeddedButtons will call this routine.
END.