XTkNotificationImpl.mesa
Copyright Ó 1991 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, August 20, 1991 3:11:06 pm PDT
Christian Jacobi, August 20, 1991 3:49 pm PDT
DIRECTORY
RefTab, XTk, XTkNotification;
XTkNotificationImpl: CEDAR MONITOR
IMPORTS RefTab
EXPORTS XTkNotification ~
BEGIN
NotifierList: TYPE = LIST OF NofierRec;
NofierRec: TYPE = RECORD [proc: XTk.WidgetNotifyProc, registerData: REF ¬ NIL];
registry: RefTab.Ref ~ RefTab.Create[];
RegisterGlobal: PUBLIC ENTRY PROC [key: REF, proc: XTk.WidgetNotifyProc, registerData: REF ¬ NIL, front: BOOL] = {
new: NotifierList ~ LIST[[proc, registerData]];
WITH RefTab.Fetch[registry, key].val SELECT FROM
nl: NotifierList => {
IF front
THEN new.rest ¬ nl
ELSE {
FOR l: NotifierList ¬ nl, l.rest DO
IF l.rest=NIL THEN {l.rest¬new; RETURN}
ENDLOOP
};
};
ENDCASE => {};
[] ¬ RefTab.Store[registry, key, new];
};
CallNotifierList: PROC [list: NotifierList, widget: XTk.Widget, callData: REF ¬ NIL, event: XTk.Event ¬ NIL] = {
FOR l: NotifierList ¬ list, l.rest WHILE l#NIL DO
l.first.proc[widget: widget, registerData: l.first.registerData, callData: callData, event: event];
ENDLOOP
};
CallAll: PUBLIC PROC [key: REF, widget: XTk.Widget, callData: REF ¬ NIL, event: XTk.Event ¬ NIL] = {
WITH RefTab.Fetch[registry, key].val SELECT FROM
nl: NotifierList => CallNotifierList[nl, widget, callData, event];
ENDCASE => {};
};
END.