Button installation procedures
ButtonSet: TYPE = REF ButtonSetBody;
ButtonSetBody:
TYPE =
RECORD[
container: Viewer,
new buttons will be created with container as their parent
vc: ViewerControl,
validFlag:
BOOLEAN,
Starts True. Set to False during subsequent destruction of the buttons. When false, most buttons should act as no-ops.
x, y: CARD,
colX: CARD,
lineH: CARD,
fixedWidth: CARD ¬ 0];
x and y will change as buttons are added
ButtonSize: TYPE = RECORD[w, h: CARD];
CreateButtonSet: PROC[container: Viewer, vc: ViewerControl, x, y: CARD, colX: CARD, lineH: CARD, fixedWidth: CARD ¬ 0] RETURNS[ButtonSet];
KillButtonSet:
PROC[bs: ButtonSet, paint:
BOOLEAN ¬
TRUE]
RETURNS[ButtonSet];
this will destroy the containing viewer.
Hence, the containing viewer should be a subviewer of the main viewer.
always returns NIL, for clearing a variable
NewLine: PROC[bs: ButtonSet];
MoveToY: PROC[bs: ButtonSet, y: CARD]; -- resets x to colX
SkipY: PROC[bs: ButtonSet, h: CARD];
MoveToX: PROC[bs: ButtonSet, x: CARD];
SkipX: PROC[bs: ButtonSet, w: CARD];
GetButtonSize: PROC[name: Rope.ROPE] RETURNS[ButtonSize];
InstallCommandButton:
PROC [
bs: ButtonSet,
name: Rope.ROPE, border: BOOL ¬ FALSE, guarded: BOOL ¬ FALSE,
clientData1: REF ANY,
choices: ChoiceList ¬ NIL,
proc1: PROC[button: Viewer, vc: ViewerControl, key, clientData1: REF ANY] RETURNS[clientData2: REF ANY] ¬ NIL,
proc2: PROC[button: Viewer, vc: ViewerControl, key, clientData1, clientData2: REF ANY]]
RETURNS[Viewer];
If proc1 is non-nil, then it gets called at (approx) button click time. proc2 will be called later, after all previously queued actions have been completed. If proc1 was nil, then clientData2 in proc2 will be nil, otherwise it will be the result of proc1.
It is expected that proc1 will perform no significant action. The purpose of proc1 is to record any significant visible information that may change before proc2 runs. For example, proc1 might record the contents of a current selection.
Few command buttons will require a proc1.
ChoiceList: TYPE = LIST OF Choice;
Choice: TYPE = RECORD [key: REF ANY, doc: Rope.ROPE];
InstallLabelButton: PROC[bs: ButtonSet, name: Rope.ROPE] RETURNS[Viewer];
InstallRule: PROC[bs: ButtonSet];