SlateControlsImpl.mesa
Copyright Ó 1993 by Xerox Corporation. All rights reserved.
Christian Jacobi, March 5, 1993 5:15 pm PST
Christian Jacobi, March 6, 1993 4:22 pm PST
DIRECTORY
RefTab,
Rope USING [ROPE],
SlateControls,
Slate,
XTk,
XTkOps,
XTkWidgets;
SlateControlsImpl:
CEDAR
MONITOR
IMPORTS RefTab, Slate, XTkOps, XTkWidgets
EXPORTS SlateControls ~
BEGIN
RegRec: TYPE = RECORD [name: Rope.ROPE, event: REF, registerData: REF];
RegList: TYPE = LIST OF RegRec;
tab: RefTab.Ref ¬ RefTab.Create[];
GetRow:
PROC [row:
REF]
RETURNS [RegList] = {
RETURN [NARROW[RefTab.Fetch[tab, row].val, RegList]]
};
AddToRow:
ENTRY
PROC [row:
REF, rr: RegRec]
= {
new: RegList ~ LIST[rr];
rl: RegList ¬ GetRow[row];
IF rl=
NIL
THEN [] ¬ RefTab.Store[tab, row, new]
ELSE {
WHILE rl.rest#NIL DO rl ¬ rl.rest ENDLOOP;
rl.rest ¬ new
};
};
RegisterButton:
PUBLIC
PROC [row:
REF, name: Rope.
ROPE, event:
REF ¬
NIL, registerData:
REF ¬
NIL] = {
AddToRow[row, [name, event, registerData]]
};
MakeRowWidget:
PUBLIC
PROC [instance: Slate.Instance, row:
REF]
RETURNS [XTk.Widget] = {
cont: XTk.Widget ¬ XTkWidgets.CreateXStack[];
list: RegList ¬ GetRow[row];
WHILE list#
NIL
DO
button: XTk.Widget ¬ XTkWidgets.CreateButton[text: list.first.name, hitProc: Hit, registerData: list, callData: instance];
XTkWidgets.AppendChild[cont, button, FALSE];
list ¬ list.rest;
ENDLOOP;
RETURN [cont];
};
Hit: XTk.WidgetNotifyProc = {
list: RegList ¬ NARROW[registerData];
instance: Slate.Instance ~ NARROW[callData];
Slate.CallGlobalEvent[instance, instance.session, list.first.event, widget.connection];
};
LimitLifetime:
PUBLIC
PROC [shell: XTk.Widget, instance: Slate.Instance] = {
XTkOps.SetupDestruction[shell, instance.surface];
};
END.