AtomButtons.mesa
Copyright Ó 1989, 1992 by Xerox Corporation. All rights reserved.
Last edited by Bier on June 25, 1987 1:02:17 pm PDT.
Contents: Some Useful Button Classes.
Pier, July 1, 1986 2:12:59 pm PDT
Aaron Goodisman, June 13, 1989 10:50:40 am PDT
Michael Plass, March 25, 1992 10:58 am PST
DIRECTORY
AtomButtonsTypes, Basics, Buttons, Imager, Menus, PopUpButtons, Rope, TiogaButtons, ViewerClasses;
AtomButtons: CEDAR DEFINITIONS = BEGIN
ConfirmProc: TYPE = AtomButtonsTypes.ConfirmProc;
Event: TYPE = AtomButtonsTypes.Event;
HandleButtonProc: TYPE = AtomButtonsTypes.HandleButtonProc;
InitButtonProc: TYPE = AtomButtonsTypes.InitButtonProc;
InitTwoStateProc: TYPE = AtomButtonsTypes.InitTwoStateProc;
SortedButtonClient: TYPE = AtomButtonsTypes.SortedButtonClient;
SortedButtonHandle: TYPE = AtomButtonsTypes.SortedButtonHandle;
TwoState: TYPE = AtomButtonsTypes.TwoState;
UpdateProc: TYPE = AtomButtonsTypes.InitButtonProc;
Viewer: TYPE = ViewerClasses.Viewer;
Buttons, PopUpButtons, Labels, and Text Viewers
ButtonType: TYPE = {button, label, text, popUpButton, twoState};
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, events: LIST OF Event, 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, help: PopUpButtons.Help, disableDecoding: BOOL ¬ FALSE, headMenu: BOOL ¬ TRUE, 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],
twoState => [name: Rope.ROPE, event: LIST OF REF ANY, on: BOOL ¬ FALSE, initProc: InitTwoStateProc ¬ NIL, ww: NAT ¬ 0, wxRelative: INTEGER ¬ -1, border: BOOL ¬ TRUE, font: Imager.Font ¬ NIL]
ENDCASE
];
In all five 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.
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.
Binary (on/off) Buttons.
BuildTwoStateButton: PROC [viewer: Viewer, x, y: NAT ← 0, clientData: REF ANY, handleProc: HandleButtonProc, name: Rope.ROPE, border: BOOLTRUE, 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.
SetBinaryState: PROC [twoState: TwoState, on: BOOL];
Sets the state of the variable and updates the button looks.
GetBinaryState: PROC [twoState: TwoState] RETURNS [on: BOOL];
SwitchBinaryState: PROC [handle: TwoState];
Extensible Sorted Button List
Make a list of buttons each of which displays some kind of value. There is some ordering on the buttons that the client describes with a Compare proc. We manage the process of splicing in new buttons and splicing out old buttons while keeping the buttons sorted. Each button has an on/off state which we indicate by video-reversing. The client determines which state each button is in using the state changing routines provided.
CreateSortedButtonViewer: PROC [container: Viewer, x, y: NAT, lineHeight: INTEGER ¬ 15] RETURNS [SortedButtonHandle];
Creates a viewer that spans the container from x to the right hand edge of the container.
SortedButtonEntry: TYPE = RECORD [name: Rope.ROPE, value: REF ANY, events: LIST OF Event, on: BOOL];
CompareProc: TYPE = PROC [aName: Rope.ROPE, aValue: REF ANY, bName: Rope.ROPE, bValue: REF ANY] RETURNS [compare: Basics.Comparison];
FindProc: TYPE = PROC [state: BOOL, name: Rope.ROPE, value: REF ANY, clientData: REF ANY] RETURNS [found: BOOL, done: BOOL ¬ FALSE];
ReadSortedProc: TYPE = PROC [state: BOOL, name: Rope.ROPE, value: REF ANY, clientData: REF ANY] RETURNS [done: BOOL ¬ FALSE];
WriteSortedProc: TYPE = PROC [state: BOOL, name: Rope.ROPE, value: REF ANY, clientData: REF ANY] RETURNS [newState: BOOL, newName: Rope.ROPE ¬ NIL, newValue: REF ANY, done: BOOL ¬ FALSE];
BuildSortedButtons: PROC [handle: SortedButtonHandle, clientData: REF ANY, handleProc: HandleButtonProc, header: Rope.ROPE, sortedButtonList: LIST OF SortedButtonEntry];
Builds a list of TiogaButtons and a parallel list of SortedButtonClient records. The first TiogaButton is a dummy and has no corresponding SortedButtonClient, as shown above. sortedButtonList is assumed to be already in the proper order.
ReadSortedButtons: PROC [handle: SortedButtonHandle, readProc: ReadSortedProc, clientData: REF ANY ¬ NIL];
WriteSortedButtons: PROC [handle: SortedButtonHandle, writeProc: WriteSortedProc, clientData: REF ANY ¬ NIL];
AddSortedButton: PROC [clientData: REF ANY, handle: SortedButtonHandle, entry: SortedButtonEntry, compareProc: CompareProc] RETURNS [oldFoundButton: SortedButtonClient ¬ NIL];
DeleteSortedButtons: PROC [clientData: REF ANY, handle: SortedButtonHandle, findProc: FindProc];
Extensible Scalar (REAL valued) Button List
ScalarButton: TYPE = RECORD [name: Rope.ROPE, value: REAL, events: LIST OF Event, on: BOOL];
[Artwork node; type 'ArtworkInterpress on' to command tool]
BuildScalarButtons: PROC [handle: SortedButtonHandle, clientData: REF ANY, handleProc: HandleButtonProc, header: Rope.ROPE, scalarButtonList: LIST OF ScalarButton];
Builds a list of TiogaButtons and a parallel list of SortedButtonClient records. The first TiogaButton is a dummy and has no corresponding SortedButtonClient, as shown above.
Order: TYPE = {incr, decr};
SetAllScalarStates: PROC [clientData: REF ANY, handle: SortedButtonHandle, on: BOOL];
SetScalarState: PROC [clientData: REF ANY, handle: SortedButtonHandle, scalar: REAL, on: BOOL, epsilon: REAL ¬ 0.001];
GetScalarState: PROC [clientData: REF ANY, handle: SortedButtonHandle, scalar: REAL, epsilon: REAL ¬ 0.001] RETURNS [on: BOOL];
ToggleScalarState: PROC [clientData: REF ANY, handle: SortedButtonHandle, scalar: REAL, epsilon: REAL ¬ 0.001] RETURNS [newState: BOOL];
AddScalarSorted: PROC [clientData: REF ANY, handle: SortedButtonHandle, button: ScalarButton, order: Order ¬ incr] RETURNS [oldFoundButton: SortedButtonClient ¬ 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: SortedButtonClient];
Enumerated Type (Cycling) Button
EnumTypeRef: TYPE = AtomButtonsTypes.EnumTypeRef;
ButtonList: TYPE = AtomButtonsTypes.ButtonList;
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];
PopUp Button
HandlePopUpProc: TYPE = PROC [button: REF ANY, clientData: REF ANY, event: LIST OF REF ANY];
BuildPopUp: PROC [clientData: REF, handleProc: HandlePopUpProc, paint: PopUpButtons.PaintProc, inButton: PopUpButtons.InTestProc, entry: ButtonLineEntry, clientPackageName: Rope.ROPE] RETURNS [instance: REF];
Build a pop-up menu with no associated button. The button will be provided (as the "view" argument) when PopUpButtons.RawPop is called.
Old-fashioned callback proc buttons. Use is discouraged.
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];
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.
END.