16 #include <X11/StringDefs.h> 17 #include <X11/Xaw/AsciiText.h> 18 #include <X11/Xaw/Paned.h> 19 #include <X11/Xaw/Label.h> 20 #include <X11/Xaw/Viewport.h> 21 #include <X11/Xaw/Command.h> 22 #include <X11/Xaw/Toggle.h> 23 #include <X11/Xaw/Box.h> 24 #include <X11/Shell.h> 28 extern void ToTopOfSced(Widget,XtPointer,XEvent*,Boolean*);
30 extern void ToTopOfSced();
34 static void newtopic(Widget,XtPointer,XtPointer);
35 static void delete(Widget,XtPointer,XtPointer);
36 static void quit(Widget,XtPointer,XtPointer);
37 static void print(Widget,XtPointer,XtPointer);
38 static void save(Widget,XtPointer,XtPointer);
39 static void DoSave(Widget,XtPointer,XtPointer);
41 static void newtopic();
49 #define hlpx_def_ht 350 50 #define hlpx_def_wd 660 59 struct hlp_toplist *next;
60 struct hlp_toplist *prev;
62 static struct hlp_toplist *top_list;
80 struct hlp_toplist *tw;
83 tw =
alloc(
struct hlp_toplist);
98 top->xposition = top->parent->xposition +
X_INCR;
99 top->yposition = top->parent->yposition +
Y_INCR;
101 w->
shell = XtVaAppCreateShell(
NULL,
"Jspice3", applicationShellWidgetClass,
103 XtNx, top->xposition,
104 XtNy, top->yposition,
106 XtOverrideTranslations(w->
shell,
107 XtParseTranslationTable(
"<Message>WM_PROTOCOLS: quit_action()"));
110 XtAddEventHandler(w->
shell, VisibilityChangeMask,
113 w->
form = XtVaCreateManagedWidget(
"help", formWidgetClass,
116 w->
butbox = XtVaCreateManagedWidget(
"buttonbox", boxWidgetClass,
119 XtNbottom, XtChainTop,
120 XtNleft, XtChainLeft,
121 XtNright, XtChainLeft,
125 (void)XtVaCreateManagedWidget(
"titlelabel", labelWidgetClass,
127 XtNlabel, top->title,
131 button = XtVaCreateManagedWidget(
"quit", commandWidgetClass,
133 XtNlabel,
"quit help",
135 XtAddCallback(button, XtNcallback, quit, top);
137 button = XtVaCreateManagedWidget(
"delete", commandWidgetClass,
139 XtNlabel,
"delete window",
141 XtAddCallback(button, XtNcallback,
delete, top);
143 button = XtVaCreateManagedWidget(
"print", commandWidgetClass,
147 XtAddCallback(button, XtNcallback, print, top);
149 button = XtVaCreateManagedWidget(
"save", commandWidgetClass,
153 XtAddCallback(button, XtNcallback, save, top);
155 for (cnt = 0, wl = top->text; wl; wl = wl->
wl_next)
156 cnt += strlen(wl->
wl_word) + 2;
158 top->chartext[0] =
'\0';
160 for (wl = top->text; wl; wl = wl->
wl_next) {
167 w->
text = XtVaCreateManagedWidget(
"helptext", asciiTextWidgetClass,
169 XtNstring, top->chartext,
170 XtNallowResize,
True,
171 XtNscrollHorizontal, XawtextScrollWhenNeeded,
172 XtNscrollVertical, XawtextScrollWhenNeeded,
174 XtNwidth, hlpx_def_wd,
175 XtNheight, hlpx_def_ht,
176 XtNbottom, XtChainBottom,
177 XtNdisplayCaret,
False,
180 if (top->subtopics) {
181 sublabel = XtVaCreateManagedWidget(
"sublabel", labelWidgetClass,
183 XtNfromVert, w->
text,
185 XtNtop, XtChainBottom,
186 XtNbottom, XtChainBottom,
188 XtNlabel,
"Subtopics: ",
191 subbox = XtVaCreateManagedWidget(
"subbox", boxWidgetClass,
193 XtNwidth, hlpx_def_wd - 20,
194 XtNfromVert, sublabel,
195 XtNtop, XtChainBottom,
196 XtNbottom, XtChainBottom,
197 XtNleft, XtChainLeft,
198 XtNright, XtChainLeft,
201 for (tl = top->subtopics; tl; tl = tl->
next) {
206 tl->button = XtVaCreateManagedWidget(tl->
buttontext,
211 XtAddCallback(tl->button, XtNcallback, newtopic, tl);
216 Widget fromvert = (top->subtopics ? subbox : w->
text);
218 seelabel = XtVaCreateManagedWidget(
"seelabel", labelWidgetClass,
220 XtNfromVert, fromvert,
222 XtNtop, XtChainBottom,
223 XtNbottom, XtChainBottom,
225 XtNlabel,
"See also: ",
228 seebox = XtVaCreateManagedWidget(
"seebox", boxWidgetClass,
230 XtNwidth, hlpx_def_wd - 20,
231 XtNfromVert, seelabel,
232 XtNtop, XtChainBottom,
233 XtNbottom, XtChainBottom,
234 XtNleft, XtChainLeft,
235 XtNright, XtChainLeft,
238 for (tl = top->seealso; tl; tl = tl->
next) {
243 tl->button = XtVaCreateManagedWidget(tl->
buttontext,
248 XtAddCallback(tl->button, XtNcallback, newtopic, tl);
251 XtRealizeWidget(w->
shell);
262 newtopic(w, client_data, call_data)
265 XtPointer client_data, call_data;
271 if (result->newtop) {
272 delete(
NULL, (XtPointer)result->newtop,
NULL);
273 result->newtop =
NULL;
278 fprintf(stderr,
"Database error: bad link\n");
279 XtVaSetValues(result->button, XtNstate, 0,
NULL);
283 result->newtop = newtop;
290 fprintf(stderr,
"Couldn't open window\n");
298 delete(w, client_data, call_data)
301 XtPointer client_data, call_data;
304 struct hlp_toplist *tl;
309 for (tl = top_list; tl; tl = tl->next) {
310 if (tl->top == top) {
312 tl->prev->next = tl->next;
314 tl->next->prev = tl->prev;
324 if (tp->newtop == top) {
331 if (tp->newtop == top) {
338 XtVaSetValues(tp->button, XtNstate, 0,
NULL);
354 quit(w, client_data, call_data)
357 XtPointer client_data, call_data;
360 struct hlp_toplist *tl, *tn;
362 for (tl = top_list; tl; tl = tn) {
379 print(w, client_data, call_data)
382 XtPointer client_data, call_data;
390 if (XawAsciiSaveAsFile(XawTextGetSource(top->widgets.
text), fname)) {
400 PopUpMessage(
"Internal error: text not saved", &top->widgets);
407 save(w, client_data, call_data)
410 XtPointer client_data, call_data;
414 PopUpInput(
"",
"save", DoSave, &top->widgets);
418 DoSave(caller, client_data, call_data)
421 XtPointer client_data, call_data;
425 XawTextPosition begin, end;
433 if (fname && *fname) {
441 XawTextGetSelectionPos(w->
text, &begin, &end);
444 if (!XawAsciiSaveAsFile(XawTextGetSource(w->
text), fname)) {
451 if ((fp = fopen(fname,
"w")) ==
NULL) {
455 string = XFetchBytes(
Xdisplay, &len);
456 for (s =
string; len; s++,len--)
460 mesg =
"Selected block saved";
472 XtDestroyWidget(top->widgets.shell);
void cp_pathfix(char *buf)
static char buf[MAXPROMPT]
static char * sens_list[]
bool cp_getvar(char *n, int t, char *r)
void hlp_xkillwin(topic *top)
bool hlp_xdisplay(topic *top)
struct wordlist * wl_next