2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
26 * $XConsortium: Help.C /main/7 1996/10/11 20:04:16 cde-hp $
28 * RESTRICTED CONFIDENTIAL INFORMATION:
30 * The information in this document is subject to special
31 * restrictions in a confidential disclosure agreement between
32 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
33 * document outside HP, IBM, Sun, USL, SCO, or Univel without
34 * Sun's specific written approval. This document and all copies
35 * and derivative works thereof must be returned or destroyed at
38 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
47 #include <Dt/HelpDialog.h>
48 #include <Dt/HelpQuickD.h>
50 #include <Dt/Editor.h>
58 void DisplayMain( Widget, char *, char *);
59 static Widget helpMain = NULL;
60 static Widget helpError = NULL;
61 static Widget versionMain = NULL;
64 getErrorHelpWidget(void)
70 clearErrorHelpWidget(void)
83 if (XtParent(w) == NULL) {
84 helpId = (char *) malloc(1000);
89 *index++ = toupper(*buf);
90 } else if ('_' == *buf) {
98 helpId = getHelpId (XtParent(w));
103 helpId[i++] = toupper(*buf);
104 } else if ('_' == *buf) {
127 if (versionMain != NULL) {
129 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 4,
130 "DtMail Version Dialog")); n++;
131 if (helpVolume != NULL) {
132 XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
134 XtSetArg (args[n], DtNlocationId, locationId); n++;
135 XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
136 XtSetValues(versionMain, args, n);
137 XtManageChild(versionMain);
139 while (!XtIsSubclass(parent, applicationShellWidgetClass))
140 parent = XtParent(parent);
142 // Build a new one in our cached list
144 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 5,
145 "DtMail Version Dialog")); n++;
146 if (helpVolume != NULL) {
147 XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
149 XtSetArg (args[n], DtNlocationId, locationId); n++;
150 XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
151 versionMain = DtCreateQuickHelpDialog(parent, "versionWidget", args, n);
152 XtAddCallback(versionMain, XmNokCallback,
153 CloseMainCB, (XtPointer) versionMain);
155 // We do not want a print button for now so we unmap it
156 printWidget = DtHelpQuickDialogGetChild (versionMain,
157 DtHELP_QUICK_PRINT_BUTTON);
158 XtUnmanageChild (printWidget);
160 // We do not want a help button for now so we unmap it
162 helpWidget = DtHelpQuickDialogGetChild (versionMain,
163 DtHELP_QUICK_PRINT_BUTTON);
164 XtUnmanageChild (helpWidget);
165 XtManageChild(versionMain);
171 // The callback for the Help Menu in the combo window.
176 XtPointer clientdata,
179 Widget selWidget = NULL;
180 int status = DtHELP_SELECT_ERROR;
182 // Determine which help button was activated and display the
183 // appropriate help information.
185 switch ((long) clientdata) {
187 while (!XtIsSubclass(widget, applicationShellWidgetClass))
188 widget = XtParent(widget);
189 status = DtHelpReturnSelectedWidgetId(widget, NULL, &selWidget);
191 switch ((int) status) {
192 case DtHELP_SELECT_ERROR:
193 printf(GETMSG(catd, 2, 1, "Selection Error, cannot continue\n"));
195 case DtHELP_SELECT_VALID:
196 while (selWidget != NULL) {
197 if ((XtHasCallbacks(selWidget, XmNhelpCallback)
198 == XtCallbackHasSome)) {
199 XtCallCallbacks((Widget)selWidget,
200 XmNhelpCallback, NULL);
203 selWidget = XtParent(selWidget);
207 case DtHELP_SELECT_ABORT:
208 printf(GETMSG(catd, 2, 2, "Selection aborted by user.\n"));
210 case DtHELP_SELECT_INVALID:
211 printf(GETMSG(catd, 1, 6,
212 "You must select a component withing your app.\n"));
217 DisplayMain(widget, NULL, APP_MENU_ID);
219 case HELP_ON_VERSION:
220 DisplayVersion(widget, NULL, VER_MENU_ID);
226 #endif /* DEAD_WOOD */
229 // Callback to process JUMP-NEW and APP-LINK hypertext requests in a
230 // given Help Dialog Window.
232 // This is the callback used for the DtNhyperLinkCallback
233 // on each of the help dialog widgets created.
242 // Position xPos, yPos;
245 DtHelpDialogCallbackStruct * hyperData =
246 (DtHelpDialogCallbackStruct *) callData;
260 if (helpMain != NULL) {
263 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 7, "DtMail Help")); n++;
265 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 12, "Mailer : Help")); n++;
266 if (helpVolume != NULL) {
267 XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
269 XtSetArg (args[n], DtNlocationId, locationId); n++;
270 XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
271 XtSetValues (helpMain, args, n);
272 XtUnmanageChild(helpMain);
273 XtManageChild(helpMain);
275 while (!XtIsSubclass(parent, applicationShellWidgetClass))
276 parent = XtParent(parent);
278 // Build a new one in our cached list
280 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 12, "Mailer : Help")); n++;
281 if (helpVolume != NULL) {
282 XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
284 XtSetArg (args[n], DtNlocationId, locationId); n++;
285 XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
286 helpMain = DtCreateHelpDialog(parent, "Mailer", args, n);
288 XtAddCallback(helpMain, DtNhyperLinkCallback, ProcessLinkCB, NULL);
291 DtNcloseCallback, CloseMainCB, (XtPointer) helpMain);
293 XtManageChild(helpMain);
309 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 7, "DtMail Help")); n++;
311 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 12, "Mailer : Help")); n++;
312 if (helpVolume != NULL) {
313 XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
315 XtSetArg (args[n], DtNlocationId, locationId); n++;
316 XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
317 //XtSetArg (args[n], DtNlocationId, "DTMAILVIEWMAINWINDOWWORK-AREA"); n++;
318 XtSetValues (helpError, args, n);
319 XtManageChild(helpError);
322 // Create a new help on the error dialogs each time, destroy it
326 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 8, "DtMail Help")); n++;
328 XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 12, "Mailer : Help")); n++;
329 if (helpVolume != NULL) {
330 XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
332 //XtSetArg (args[n], DtNlocationId, "DTMAILVIEWMAINWINDOWWORK-AREAPANEDWFORM2ROWCOLUMNPREVIOUS"); n++;
333 XtSetArg (args[n], DtNlocationId, locationId); n++;
334 XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
335 helpError = DtCreateHelpDialog(parent, "Mailer", args, n);
337 XtAddCallback(helpError, DtNhyperLinkCallback, ProcessLinkCB, NULL);
339 XtAddCallback(helpError, DtNcloseCallback,
340 CloseMainCB, (XtPointer) helpError);
342 XtUnmanageChild(helpError);
343 XtManageChild(helpError);
348 // The Help Callback for when the F1 key is pressed or when On Item
349 // Help is selected from the Help menu.
354 XtPointer clientData,
357 char *locationId = (char *) clientData;
359 // printf("locationId = %s\n", locationId);
360 // Just display the proper help based on the id string passed in.
362 // We pass in a NULL for our helpVolume and let the value defined
363 // in the app-defaults file be used.
365 DisplayMain (w, "Mailer", locationId);
371 XtPointer clientData,
374 char *locationId = (char *) clientData;
376 // printf("locationId = %s\n", locationId);
377 // Just display the proper help based on the id string passed in.
379 // We pass in a NULL for our helpVolume and let the value defined
380 // in the app-defaults file be used.
382 DisplayErrorHelp (w, "Mailer", locationId);
388 XtPointer clientData,
392 char *locationId = NULL;
393 Widget wEditor = (Widget) clientData;
394 DtEditorHelpCallbackStruct *editorHelp =
395 (DtEditorHelpCallbackStruct *) callData;
397 switch (editorHelp->reason) {
399 /* -----> edit area */
400 case DtEDITOR_HELP_EDIT_WINDOW:
401 locationId = EDIT_AREA_HELP;
404 /* -----> status line area and fields */
405 case DtEDITOR_HELP_STATUS_LINE:
406 locationId = STATUS_LINE_HELP;
408 case DtEDITOR_HELP_STATUS_CURRENT_LINE:
409 locationId = STATUS_CURRENT_LINE_HELP;
411 case DtEDITOR_HELP_STATUS_TOTAL_LINES:
412 locationId = STATUS_TOTAL_LINES_HELP;
414 case DtEDITOR_HELP_STATUS_MESSAGE:
415 locationId = STATUS_MESSAGE_HELP;
417 case DtEDITOR_HELP_STATUS_OVERSTRIKE:
418 locationId = STATUS_OVERSTRIKE_HELP;
420 /* -----> Format Settings dialog and dialog fields */
421 case DtEDITOR_HELP_FORMAT_DIALOG:
422 locationId = FORMAT_SETTINGS_HELP;
424 case DtEDITOR_HELP_FORMAT_LEFT_MARGIN:
425 locationId = FORMAT_LEFT_MARGIN_HELP;
427 case DtEDITOR_HELP_FORMAT_RIGHT_MARGIN:
428 locationId = FORMAT_RIGHT_MARGIN_HELP;
430 case DtEDITOR_HELP_FORMAT_ALIGNMENT:
431 locationId = FORMAT_ALIGNMENT_HELP;
434 /* -----> Find/Change dialog and dialog fields */
435 case DtEDITOR_HELP_CHANGE_DIALOG:
436 locationId = FINDCHANGE_HELP;
438 case DtEDITOR_HELP_CHANGE_FIND:
439 locationId = FINDCHANGE_FIND_HELP;
441 case DtEDITOR_HELP_CHANGE_CHANGE:
442 locationId = FINDCHANGE_CHANGETO_HELP;
445 /* -----> Check Spelling dialog and dialog fields */
446 case DtEDITOR_HELP_SPELL_DIALOG:
447 locationId = SPELL_HELP;
449 case DtEDITOR_HELP_SPELL_MISSPELLED_WORDS:
450 locationId = SPELL_MISSPELLED_WORDS_HELP;
452 case DtEDITOR_HELP_SPELL_CHANGE:
453 locationId = SPELL_CHANGETO_HELP;
459 } /* switch (editorHelp->reason) */
461 DisplayMain (w, "Textedit", locationId);
465 // Callback to process close requests on our main help dialog.
470 XtPointer clientData,
473 Widget currentDialog = (Widget) clientData;
475 // Unmap and clean up help widget
477 XtUnmanageChild(currentDialog);
480 #if defined(PRINT_HELPIDS)
483 printHelpId (char *w_name, Widget w)
487 helpId = getHelpId (w);
488 printf("%s = %s\n", w_name, helpId);
496 printHelpId (char *, Widget)