Buttons.mesa; Edited by McGregor on August 30, 1982 4:05 pm
Last Edited by: Maxwell, December 17, 1982 10:06 am
DIRECTORY
Menus USING [ClickProc],
Rope USING [ROPE],
VFonts USING [defaultFont, Font],
ViewerOps USING [DestroyViewer],
ViewerClasses USING [Viewer, ViewerRec];
Buttons: CEDAR DEFINITIONS IMPORTS VFonts, ViewerOps = BEGIN OPEN ViewerClasses;
Button: TYPE = Viewer; -- A button is a viewer that posts a message and when clicked, invokes a procedure.
Create: PROC [info: ViewerRec ← [], proc: ButtonProc, clientData: REF ANYNIL,
fork: BOOLTRUE, font: VFonts.Font ← VFonts.defaultFont, documentation: REF ANYNIL,
guarded: BOOLFALSE, paint: BOOLTRUE] 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.ROPE. Documentation will be posted for guarded buttons when the guard is removed on the first click. If the documentation is a Rope.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] = INLINE {ViewerOps.DestroyViewer[button]};
ReLabel: PROC [button: Button, newName: Rope.ROPE, paint: BOOLTRUE] = INLINE
{button.class.set[button, newName, paint]};
Change the text of a button (but alas, not the size)
SetDisplayStyle: PROC [button: Button, style: ATOM, paint: BOOLTRUE] = INLINE
{button.class.set[button, style, paint, $DisplayStyle]} ;
recognised display styles are:
$BlackOnWhite - black letters on white background (default)
$WhiteOnBlack - white letters on black background
$BlackOnGrey - black letters on grey background
ButtonProc: TYPE = Menus.ClickProc;
END.