Buttons.mesa
Copyright Ó 1985, 1986, 1987, 1991 by Xerox Corporation. All rights reserved.
Edited by McGregor on August 30, 1982 4:05 pm
Last Edited by: Maxwell, December 17, 1982 10:06 am
Doug Wyatt, January 19, 1987 10:32:25 pm PST
DIRECTORY
Imager USING [Font],
Rope USING [ROPE],
ViewerClasses USING [ClickProc, Viewer, ViewerRec];
A button is a viewer that posts a message and, when clicked, invokes a procedure.
Buttons: CEDAR DEFINITIONS
= BEGIN OPEN ViewerClasses;
Button: TYPE = Viewer;
ButtonProc: TYPE = ViewerClasses.ClickProc;
Create: PROC [info: ViewerRec ¬ [],
proc: ButtonProc,
clientData: REF ANY ¬ NIL,
fork: BOOL ¬ TRUE,
font: Imager.Font ¬ NIL,
documentation: REF ANY ¬ NIL,
guarded: BOOL ¬ FALSE,
paint: BOOL ¬ TRUE
] RETURNS [button: Button];
info.name contains the message displayed within the button. If the info.wh and info.ww are defaulted, aesthetic values will be chosen based on the height and width of the name. Defaulting the info.wx and info.wy, with parent=NIL creates a "system" button appended after the most recent system button after the message window. fork tells whether to create and detach a new process on calling. clientData is the info that will be passed to proc on invocation. Guarded buttons must be confirmed by the user before invocation.
documentation may either be a REF ButtonProc or a ROPE. Documentation will be posted for guarded buttons when the guard is removed on the first click. If the documentation is a ROPE then it will be posted in the MessageWindow, otherwise the client's proc will be called.
Implementation guide: the proc that calls a button proc has an ! ABORT => CONTINUE catch phrase so that the client may make use of Process.Abort to cancel execution. If fork=FALSE then proc will be called at Process.priorityForeground!
Destroy: PROC [button: Button];
ReLabel: PROC [button: Button, newName: Rope.ROPE, paint: BOOL ¬ TRUE];
Change the text of a button (but alas, not the size)
SetDisplayStyle: PROC [button: Button, style: ATOM, paint: BOOL ¬ TRUE];
recognised display styles are:
$BlackOnWhite - black letters on white background (default)
$WhiteOnBlack - white letters on black background
$BlackOnGrey - black letters on grey background
END.