XTkHelpStringsImpl.mesa
Copyright Ó 1992 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, March 9, 1992 3:33 pm PST
Christian Jacobi, March 10, 1992 3:57 pm PST
DIRECTORY
HelpStrings,
Rope,
XTk,
XTkHelpStrings,
XTkHelpWidgets,
XTkLabels;
XTkHelpStringsImpl: CEDAR MONITOR
IMPORTS XTk, XTkLabels
EXPORTS XTkHelpStrings, XTkHelpWidgets =
BEGIN
myKey: ATOM ~ $XTkHelpWidgetsImpl;
clear: Rope.ROPE ~ " ";
Create: PUBLIC PROC [widgetSpec: XTk.WidgetSpec ¬ []] RETURNS [w: XTk.Widget, h: HelpStrings.Handle] = {
w ¬ XTkLabels.CreateLabel[widgetSpec, clear];
h ¬ MyCreateHandle[w];
SetHandle[w, h];
};
GetHandle: PUBLIC PROC [w: XTk.Widget] RETURNS [HelpStrings.Handle ¬ NIL] = {
WITH XTk.GetWidgetProp[w, myKey] SELECT FROM
h: HelpStrings.Handle => RETURN [h];
ENDCASE => {};
w ¬ XTk.RootWidget[w];
IF w#NIL THEN {
WITH XTk.GetWidgetProp[w, myKey] SELECT FROM
h: HelpStrings.Handle => RETURN [h];
ENDCASE => {};
};
};
SetHandle: PUBLIC PROC [w: XTk.Widget, h: HelpStrings.Handle] = {
XTk.PutWidgetProp[w, myKey, h];
};
myHelpClass: REF HelpStrings.ClassRec ~ NEW[HelpStrings.ClassRec ¬ [
display: MyDisplay,
clear: MyClear,
makeVisible: NoVisible,
hide: NoVisible,
more: NIL
]];
MyData: TYPE = RECORD [
label: XTk.Widget ¬ NIL,
string: REF ¬ NIL,
key: REF ¬ NIL
];
MyCreateHandle: PROC [w: XTk.Widget] RETURNS [h: HelpStrings.Handle ¬ NIL] = {
md: REF MyData ~ NEW[MyData ¬ [label: w]];
h ¬ NEW [HelpStrings.HandleRec ¬ [myHelpClass, md]]
};
MyDisplay: PROC [h: HelpStrings.Handle, string: REF, key: REF ¬ NIL] = {
WITH h.data SELECT FROM
md: REF MyData => {
text: Rope.ROPE ¬ NIL;
WITH string SELECT FROM
r: Rope.ROPE => text ¬ r;
ENDCASE => RETURN;
md.string ¬ string; md.key ¬ key;
XTkLabels.SetText[md.label, text, immediately];
};
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 XTkLabels.SetText[md.label, clear, delayed];
};
ENDCASE => {}
};
NoVisible: PROC [h: HelpStrings.Handle, data: REF] = {};
END.