ViewerHelpStringsImpl.mesa
Copyright Ó 1992 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, March 9, 1992 3:33 pm PST
Christian Jacobi, May 7, 1992 11:16 am PDT
DIRECTORY
HelpStrings,
MessageWindow,
Rope,
ViewerHelpStrings;
ViewerHelpStringsImpl:
CEDAR
MONITOR
IMPORTS MessageWindow
EXPORTS ViewerHelpStrings =
BEGIN
myHelpClass:
REF HelpStrings.ClassRec ~
NEW[HelpStrings.ClassRec ¬ [
display: MyDisplay,
clear: MyClear,
makeVisible: NoVisible,
hide: NoVisible,
more: NIL
]];
MyData:
TYPE =
RECORD [
string: REF ¬ NIL,
text: Rope.ROPE ¬ NIL,
key: REF ¬ NIL
];
CreateHandle:
PROC []
RETURNS [h: HelpStrings.Handle ¬
NIL] = {
md: REF MyData ~ NEW[MyData ¬ []];
h ¬ NEW [HelpStrings.HandleRec ¬ [myHelpClass, md]]
};
theHandle: HelpStrings.Handle ¬ CreateHandle[];
GetHandle:
PUBLIC
PROC []
RETURNS [HelpStrings.Handle] = {
RETURN [theHandle];
};
MyDisplay:
PROC [h: HelpStrings.Handle, string:
REF, key:
REF ¬
NIL] = {
WITH h.data
SELECT
FROM
md:
REF MyData => {
previousText: Rope.ROPE ¬ md.text;
WITH string
SELECT
FROM
r: Rope.ROPE => md.text ¬ r;
ENDCASE => RETURN;
md.string ¬ string; md.key ¬ key;
MessageWindow.Append[md.text, TRUE]; --message window forks before locking viewer
};
ENDCASE => {}
};
MyClear:
PROC [h: HelpStrings.Handle, string:
REF, key:
REF ¬
NIL] = {
WITH h.data
SELECT
FROM
md:
REF MyData => {
IF md.string=string
OR md.key=key
THEN {
MessageWindow.Clear[];
md.text ¬ NIL;
};
};
ENDCASE => {}
};
NoVisible:
PROC [h: HelpStrings.Handle, data:
REF] = {
};
SetHelpWithMessageWindow: PUBLIC PROC [for: XTk.Widget] = {
IF for#NIL THEN XTkHelpStrings.SetHandle[for, theHandle];
};
X11ViewersWorldCreated: XTk.WidgetNotifyProc = {
w: XTk.Widget ¬ widget;
WHILE w.parent#NIL DO w ¬ w.parent ENDLOOP;
SetHelpWithMessageWindow[w];
};
XTkNotification.RegisterGlobal[$X11ViewersAfterWidgetCreation, X11ViewersWorldCreated];
END.