AtomButtons.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Last edited by Bier on April 30, 1987 2:07:41 pm PDT.
Contents: Some Useful Button Classes.
Pier, July 1, 1986 2:12:59 pm PDT
DIRECTORY
AtomButtonsTypes, Buttons, Imager, Menus, Rope, TiogaButtons, ViewerClasses;
AtomButtons: CEDAR DEFINITIONS = BEGIN
HandleButtonProc: TYPE = AtomButtonsTypes.HandleButtonProc;
UpdateProc: TYPE = AtomButtonsTypes.InitButtonProc;
Viewer: TYPE = ViewerClasses.Viewer;
ConfirmProc: TYPE = AtomButtonsTypes.ConfirmProc;
InitButtonProc: TYPE = AtomButtonsTypes.InitButtonProc;
Buttons, PopUpButtons, Labels, and Text Viewers.
Action: TYPE = LIST OF REF ANY;
ButtonType: TYPE = {button, label, text, popUpButton};
PopUpChoices: TYPE = LIST OF PopUpChoice;
PopUpChoice: TYPE = RECORD [action: LIST OF REF ANY, actionImage: Rope.ROPE, doc: Rope.ROPE, font: Imager.Font ← NIL];
Choices should be specified in the order left, middle, right, shift-left, shift-middle, shift-right, ctrl-left, ctrl-middle, ctrl-right, ctrl-shift-left, ctrl-shift-middle, ctrl-shift-right.
ButtonLineEntry:
TYPE =
RECORD [
SELECT type: ButtonType
FROM
button => [name: Rope.ROPE, actions: LIST OF Action, wxRelative: INTEGER ← -1, border: BOOL ← FALSE, font: Imager.Font ← NIL, confirmProc: ConfirmProc ← NIL, initProc: InitButtonProc ← NIL, ww: NAT ← 0],
popUpButton => [name: Rope.ROPE, choices: PopUpChoices, wxRelative: INTEGER ← -1, border: BOOL ← FALSE, font: Imager.Font ← NIL, confirmProc: ConfirmProc ← NIL, initProc: InitButtonProc ← NIL, ww: NAT ← 0],
label => [name: Rope.ROPE, initProc: InitButtonProc ← NIL, ww: NAT ← 0, wxRelative: INTEGER ← -1, border: BOOL ← FALSE, font: Imager.Font ← NIL],
text => [name: Rope.ROPE, initProc: InitButtonProc ← NIL, ww: NAT ← 0, wxRelative: INTEGER ← -1, border: BOOL ← FALSE, font: Imager.Font ← NIL],
ENDCASE
];
In all four variants, name is the string that will be displayed on the button, the actions will be passed to the handleProc when the button is pressed (see BuildButtonLine below), wxRelative positions the button relative to the leftmost button on this line (rather than spacing it from its neighboring button) allowing tidy columns, border says whether a rectangle should be drawn around the button, font changes the font that the button itself will be displayed in. If confirmProc is not NIL, then the button is guarded and the confirmProc will be called after the first button press. The initProc allows the client to store a pointer to the button in its data structures and to initialize its values.
UnQueuedButtonLineEntry: TYPE = RECORD [name: Rope.ROPE, type: ButtonType, clickProc: Menus.ClickProc, updateProc: UpdateProc ← NIL, ww: NAT ← 0, wxRelative: INTEGER ← -1, border: BOOL ← FALSE, confirmProc: ConfirmProc ← NIL, font: Imager.Font ← NIL];
BuildButtonLine:
PROC [container: Viewer, x, y:
NAT, clientData:
REF
ANY, handleProc: HandleButtonProc, entries:
LIST
OF ButtonLineEntry, horizontalSpace:
INTEGER ← 2, lineHeight:
INTEGER ← 15]
RETURNS [nextX:
INTEGER];
Builds a line of assorted buttons (type can be button, label, or text). When the button is pressed (if type = button), clientData and action are sent to handleProc.
BuildUnQueuedButtonLine:
PROC [container: Viewer, x, y:
NAT, clientData:
REF
ANY, entries:
LIST
OF UnQueuedButtonLineEntry, horizontalSpace:
INTEGER ← 2, lineHeight:
INTEGER ← 15]
RETURNS [nextX:
INTEGER];
Builds a line of assorted buttons (type can be button, label, or text). When the button is pressed (if type = button), clientData and action are sent to handleProc.
Two State (on/off) Buttons.
StateType: TYPE = AtomButtonsTypes.StateType;
TwoState: TYPE = REF TwoStateObj;
TwoStateObj: TYPE = AtomButtonsTypes.TwoStateObj;
BuildTwoStateButton:
PROC [viewer: Viewer, x, y:
NAT ← 0, clientData:
REF
ANY, handleProc: HandleButtonProc, name: Rope.
ROPE, border:
BOOL ←
TRUE, init: StateType ← off, action:
LIST
OF
REF
ANY, lineHeight:
INTEGER ← 15]
RETURNS [stateInfo: TwoState, nextX:
INTEGER];
Makes a button at position x, y. The button will always be black when stateInfo.state = on and white when stateInfo.state = off.
SetButtonState: PROC [twoState: TwoState, state: StateType];
GetButtonState:
PROC [twoState: TwoState]
RETURNS [state: StateType];
Sets the state of the variable and updates the button looks.
SwitchState: PROC [handle: TwoState];
ScalarButton: TYPE = RECORD [name: Rope.ROPE, value: REAL, action: LIST OF REF ANY, init: StateType];
ScalarButtonHandle: TYPE = REF ScalarButtonHandleObj;
ScalarButtonHandleObj: TYPE = AtomButtonsTypes.ScalarButtonHandleObj;
ScalarButtonClient: TYPE = REF ScalarButtonClientObj;
ScalarButtonClientObj:
TYPE = AtomButtonsTypes
.ScalarButtonClientObj
;
[Artwork node; type 'ArtworkInterpress on' to command tool]
BuildScalarButtons:
PROC [handle: ScalarButtonHandle, clientData:
REF
ANY, handleProc: HandleButtonProc, header: Rope.
ROPE, scalarButtonList:
LIST
OF ScalarButton];
Fills a scalar button viewer with buttons.
CreateScalarButtonViewer:
PROC [container: Viewer, x, y:
NAT, lineHeight:
INTEGER ← 15]
RETURNS [ScalarButtonHandle];
Creates a viewer that spans the container from x to the right hand edge of the container.
Builds a list of TiogaButtons and a parallel list of ScalarButtonClient records. The first TiogaButton is a dummy and has no corresponding ScalarButtonClient, as shown above.
Order: TYPE = {incr, decr};
AddValueSorted:
PROC [clientData:
REF
ANY, scalarButtonHandle: ScalarButtonHandle, value: ScalarButton, order: Order ← incr]
RETURNS [oldFoundButton: ScalarButtonClient ←
NIL];
Adds a new scalar button to the list, sort in increasing order or decreasing order as requested.
RebuildScalarButtons:
PROC [viewer: Viewer, headerButton: TiogaButtons.TiogaButton, clientData:
REF
ANY, handleProc: HandleButtonProc, scalarButtonList:
LIST
OF ScalarButton]
RETURNS [buttons: ScalarButtonClient];
ButtonList: TYPE = AtomButtonsTypes.ButtonList;
EnumTypeRef: TYPE = REF EnumTypeRec;
EnumTypeRec: TYPE = AtomButtonsTypes.EnumTypeRec;
StyleChoice: TYPE = AtomButtonsTypes.StyleChoice;
DisplayStyle: TYPE = AtomButtonsTypes.DisplayStyle;
BuildEnumTypeSelection: PROC [viewer: ViewerClasses.Viewer, x, y: NAT, maxWidth: NAT, clientData: REF ANY, handleProc: HandleButtonProc, title: Rope.ROPE, default: Rope.ROPE, borderOnButtons: BOOL, style: StyleChoice, allInOneRow: BOOL, buttonNames: ButtonList, atom: ATOM, horizontalSpace: INTEGER ← 2, lineHeight: INTEGER ← 15] RETURNS [EnumTypeRef];
TimeToFlipThru: PROC [event: LIST OF REF ANY];
END.