4 * $XConsortium: Help.C /main/7 1996/10/11 20:04:16 cde-hp $
6 * RESTRICTED CONFIDENTIAL INFORMATION:
8 * The information in this document is subject to special
9 * restrictions in a confidential disclosure agreement between
10 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
11 * document outside HP, IBM, Sun, USL, SCO, or Univel without
12 * Sun's specific written approval. This document and all copies
13 * and derivative works thereof must be returned or destroyed at
16 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
25 #include <Dt/HelpDialog.h>
26 #include <Dt/HelpQuickD.h>
28 #include <Dt/Editor.h>
36 void DisplayMain( Widget, char *, char *);
37 static Widget helpMain = NULL;
38 static Widget helpError = NULL;
39 static Widget versionMain = NULL;
42 getErrorHelpWidget(void)
48 clearErrorHelpWidget(void)
61 if (XtParent(w) == NULL) {
62 helpId = (char *) malloc(1000);
67 *index++ = toupper(*buf);
68 } else if ('_' == *buf) {
76 helpId = getHelpId (XtParent(w));
81 helpId[i++] = toupper(*buf);
82 } else if ('_' == *buf) {
105 if (versionMain != NULL) {
107 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 4,
108 "DtMail Version Dialog")); n++;
109 if (helpVolume != NULL) {
110 XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
112 XtSetArg (args[n], DtNlocationId, locationId); n++;
113 XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
114 XtSetValues(versionMain, args, n);
115 XtManageChild(versionMain);
117 while (!XtIsSubclass(parent, applicationShellWidgetClass))
118 parent = XtParent(parent);
120 // Build a new one in our cached list
122 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 5,
123 "DtMail Version Dialog")); n++;
124 if (helpVolume != NULL) {
125 XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
127 XtSetArg (args[n], DtNlocationId, locationId); n++;
128 XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
129 versionMain = DtCreateQuickHelpDialog(parent, "versionWidget", args, n);
130 XtAddCallback(versionMain, XmNokCallback,
131 CloseMainCB, (XtPointer) versionMain);
133 // We do not want a print button for now so we unmap it
134 printWidget = DtHelpQuickDialogGetChild (versionMain,
135 DtHELP_QUICK_PRINT_BUTTON);
136 XtUnmanageChild (printWidget);
138 // We do not want a help button for now so we unmap it
140 helpWidget = DtHelpQuickDialogGetChild (versionMain,
141 DtHELP_QUICK_PRINT_BUTTON);
142 XtUnmanageChild (helpWidget);
143 XtManageChild(versionMain);
149 // The callback for the Help Menu in the combo window.
154 XtPointer clientdata,
157 Widget selWidget = NULL;
158 int status = DtHELP_SELECT_ERROR;
160 // Determine which help button was activated and display the
161 // appropriate help information.
163 switch ((long) clientdata) {
165 while (!XtIsSubclass(widget, applicationShellWidgetClass))
166 widget = XtParent(widget);
167 status = DtHelpReturnSelectedWidgetId(widget, NULL, &selWidget);
169 switch ((int) status) {
170 case DtHELP_SELECT_ERROR:
171 printf(GETMSG(catd, 2, 1, "Selection Error, cannot continue\n"));
173 case DtHELP_SELECT_VALID:
174 while (selWidget != NULL) {
175 if ((XtHasCallbacks(selWidget, XmNhelpCallback)
176 == XtCallbackHasSome)) {
177 XtCallCallbacks((Widget)selWidget,
178 XmNhelpCallback, NULL);
181 selWidget = XtParent(selWidget);
185 case DtHELP_SELECT_ABORT:
186 printf(GETMSG(catd, 2, 2, "Selection aborted by user.\n"));
188 case DtHELP_SELECT_INVALID:
189 printf(GETMSG(catd, 1, 6,
190 "You must select a component withing your app.\n"));
195 DisplayMain(widget, NULL, APP_MENU_ID);
197 case HELP_ON_VERSION:
198 DisplayVersion(widget, NULL, VER_MENU_ID);
204 #endif /* DEAD_WOOD */
207 // Callback to process JUMP-NEW and APP-LINK hypertext requests in a
208 // given Help Dialog Window.
210 // This is the callback used for the DtNhyperLinkCallback
211 // on each of the help dialog widgets created.
220 // Position xPos, yPos;
223 DtHelpDialogCallbackStruct * hyperData =
224 (DtHelpDialogCallbackStruct *) callData;
238 if (helpMain != NULL) {
241 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 7, "DtMail Help")); n++;
243 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 12, "Mailer : Help")); n++;
244 if (helpVolume != NULL) {
245 XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
247 XtSetArg (args[n], DtNlocationId, locationId); n++;
248 XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
249 XtSetValues (helpMain, args, n);
250 XtUnmanageChild(helpMain);
251 XtManageChild(helpMain);
253 while (!XtIsSubclass(parent, applicationShellWidgetClass))
254 parent = XtParent(parent);
256 // Build a new one in our cached list
258 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 12, "Mailer : Help")); n++;
259 if (helpVolume != NULL) {
260 XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
262 XtSetArg (args[n], DtNlocationId, locationId); n++;
263 XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
264 helpMain = DtCreateHelpDialog(parent, "Mailer", args, n);
266 XtAddCallback(helpMain, DtNhyperLinkCallback, ProcessLinkCB, NULL);
269 DtNcloseCallback, CloseMainCB, (XtPointer) helpMain);
271 XtManageChild(helpMain);
287 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 7, "DtMail Help")); n++;
289 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 12, "Mailer : Help")); n++;
290 if (helpVolume != NULL) {
291 XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
293 XtSetArg (args[n], DtNlocationId, locationId); n++;
294 XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
295 //XtSetArg (args[n], DtNlocationId, "DTMAILVIEWMAINWINDOWWORK-AREA"); n++;
296 XtSetValues (helpError, args, n);
297 XtManageChild(helpError);
300 // Create a new help on the error dialogs each time, destroy it
304 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 8, "DtMail Help")); n++;
306 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 12, "Mailer : Help")); n++;
307 if (helpVolume != NULL) {
308 XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
310 //XtSetArg (args[n], DtNlocationId, "DTMAILVIEWMAINWINDOWWORK-AREAPANEDWFORM2ROWCOLUMNPREVIOUS"); n++;
311 XtSetArg (args[n], DtNlocationId, locationId); n++;
312 XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
313 helpError = DtCreateHelpDialog(parent, "Mailer", args, n);
315 XtAddCallback(helpError, DtNhyperLinkCallback, ProcessLinkCB, NULL);
317 XtAddCallback(helpError, DtNcloseCallback,
318 CloseMainCB, (XtPointer) helpError);
320 XtUnmanageChild(helpError);
321 XtManageChild(helpError);
326 // The Help Callback for when the F1 key is pressed or when On Item
327 // Help is selected from the Help menu.
332 XtPointer clientData,
335 char *locationId = (char *) clientData;
337 // printf("locationId = %s\n", locationId);
338 // Just display the proper help based on the id string passed in.
340 // We pass in a NULL for our helpVolume and let the value defined
341 // in the app-defaults file be used.
343 DisplayMain (w, "Mailer", locationId);
349 XtPointer clientData,
352 char *locationId = (char *) clientData;
354 // printf("locationId = %s\n", locationId);
355 // Just display the proper help based on the id string passed in.
357 // We pass in a NULL for our helpVolume and let the value defined
358 // in the app-defaults file be used.
360 DisplayErrorHelp (w, "Mailer", locationId);
366 XtPointer clientData,
370 char *locationId = NULL;
371 Widget wEditor = (Widget) clientData;
372 DtEditorHelpCallbackStruct *editorHelp =
373 (DtEditorHelpCallbackStruct *) callData;
375 switch (editorHelp->reason) {
377 /* -----> edit area */
378 case DtEDITOR_HELP_EDIT_WINDOW:
379 locationId = EDIT_AREA_HELP;
382 /* -----> status line area and fields */
383 case DtEDITOR_HELP_STATUS_LINE:
384 locationId = STATUS_LINE_HELP;
386 case DtEDITOR_HELP_STATUS_CURRENT_LINE:
387 locationId = STATUS_CURRENT_LINE_HELP;
389 case DtEDITOR_HELP_STATUS_TOTAL_LINES:
390 locationId = STATUS_TOTAL_LINES_HELP;
392 case DtEDITOR_HELP_STATUS_MESSAGE:
393 locationId = STATUS_MESSAGE_HELP;
395 case DtEDITOR_HELP_STATUS_OVERSTRIKE:
396 locationId = STATUS_OVERSTRIKE_HELP;
398 /* -----> Format Settings dialog and dialog fields */
399 case DtEDITOR_HELP_FORMAT_DIALOG:
400 locationId = FORMAT_SETTINGS_HELP;
402 case DtEDITOR_HELP_FORMAT_LEFT_MARGIN:
403 locationId = FORMAT_LEFT_MARGIN_HELP;
405 case DtEDITOR_HELP_FORMAT_RIGHT_MARGIN:
406 locationId = FORMAT_RIGHT_MARGIN_HELP;
408 case DtEDITOR_HELP_FORMAT_ALIGNMENT:
409 locationId = FORMAT_ALIGNMENT_HELP;
412 /* -----> Find/Change dialog and dialog fields */
413 case DtEDITOR_HELP_CHANGE_DIALOG:
414 locationId = FINDCHANGE_HELP;
416 case DtEDITOR_HELP_CHANGE_FIND:
417 locationId = FINDCHANGE_FIND_HELP;
419 case DtEDITOR_HELP_CHANGE_CHANGE:
420 locationId = FINDCHANGE_CHANGETO_HELP;
423 /* -----> Check Spelling dialog and dialog fields */
424 case DtEDITOR_HELP_SPELL_DIALOG:
425 locationId = SPELL_HELP;
427 case DtEDITOR_HELP_SPELL_MISSPELLED_WORDS:
428 locationId = SPELL_MISSPELLED_WORDS_HELP;
430 case DtEDITOR_HELP_SPELL_CHANGE:
431 locationId = SPELL_CHANGETO_HELP;
437 } /* switch (editorHelp->reason) */
439 DisplayMain (w, "Textedit", locationId);
443 // Callback to process close requests on our main help dialog.
448 XtPointer clientData,
451 Widget currentDialog = (Widget) clientData;
453 // Unmap and clean up help widget
455 XtUnmanageChild(currentDialog);
458 #if defined(PRINT_HELPIDS)
461 printHelpId (char *w_name, Widget w)
465 helpId = getHelpId (w);
466 printf("%s = %s\n", w_name, helpId);
474 printHelpId (char *, Widget)