1 /* $XConsortium: helpCB.c /main/4 1996/04/16 16:42:13 mgreess $ */
2 /**********************************<+>*************************************
3 ***************************************************************************
7 ** Project: DT dtpad, a memo maker type editor based on the Dt Editor
13 ** This file contains the all the Text Editor help related callbacks:
15 ** o 'XmNhelpCallback' callbacks for:
16 ** - the menu bar and the individual menus within the bar
17 ** - file selection boxes, dialogs and dialog components relating to
19 ** - the DtEditor widget
20 ** o 'XmNActivateCallback' callbacks for each item in the [Help]
22 ** o 'DtNhyperLinkCallback' and 'DtNcloseCallback' callbacks passed to
23 ** DtCreateHelpDialog() (via helpDlg.c:CreateHelpDialog()).
25 ** All 'XmNhelpCallback' and 'XmNActivateCallback' callbacks, except for
26 ** [Help] menu [On Item...], simply set the help location id to correspond
27 ** to help text on the widget for which the callback was set. The On Item
28 ** 'XmNActivateCallback' callback determines the widget on which it was
29 ** invoked and then calls the 'XmNhelpCallback' callback directly. If no
30 ** 'XmNhelpCallback' is installed, it searches up the widget's parentage
31 * until it finds one and then calls it.
33 ** NOTE: All dialogs relating to the [Edit] and [Format] menus are
34 ** controlled directly by the DtEditor widget. Consequently,
35 ** all of the help location ids for the "Find/Change", "Check
36 ** Spelling" and "Format Settings" dialogs are set in the
37 ** in the DtEditor widget's 'XmNhelpCallback' callback
38 ** (i.e. in, HelpEditorWidgetCB).
40 *******************************************************************
41 ** (c) Copyright Hewlett-Packard Company, 1991, 1992, 1993. All rights are
42 ** reserved. Copying or other reproduction of this program
43 ** except for archival purposes is prohibited without prior
44 ** written consent of Hewlett-Packard Company.
45 ********************************************************************
47 ********************************************************************
48 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
49 ** (c) Copyright 1993, 1994 International Business Machines Corp.
50 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
51 ** (c) Copyright 1993, 1994 Novell, Inc.
52 ********************************************************************
55 **************************************************************************
56 **********************************<+>*************************************/
59 #include <Dt/HelpDialog.h>
62 /************************************************************************
63 * The following callbacks are set as the 'XmNhelpCallback' for the menu
64 * menu bar and for the individual pulldown menus within the menu bar.
65 ************************************************************************/
73 SetHelpVolAndDisplayHelp((Editor *)client_data, MENUBAR_HELP,
83 SetHelpVolAndDisplayHelp((Editor *)client_data, FILE_MENU_HELP,
93 SetHelpVolAndDisplayHelp((Editor *)client_data, EDIT_MENU_HELP,
103 SetHelpVolAndDisplayHelp((Editor *)client_data, FORMAT_MENU_HELP,
113 SetHelpVolAndDisplayHelp((Editor *)client_data, OPTIONS_MENU_HELP,
123 SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_HELP,
129 /************************************************************************
130 * The following callbacks are set as the 'XmNhelpCallback' on file
131 * selection boxes and prompt dialogs relating to the [File] menu.
132 ************************************************************************/
140 SetHelpVolAndDisplayHelp((Editor *)client_data, FILE_OPEN_DIALOG_HELP,
150 SetHelpVolAndDisplayHelp((Editor *)client_data, FILE_INCLUDE_DIALOG_HELP,
160 Editor *pPad = (Editor *) client_data;
162 if (pPad->xrdb.nameChange) {
163 SetHelpVolAndDisplayHelp(pPad, FILE_SAVEAS_DIALOG_HELP,
166 SetHelpVolAndDisplayHelp(pPad, FILE_COPYTOFILE_DIALOG_HELP,
172 HelpAskIfSaveDialogCB(
177 SetHelpVolAndDisplayHelp((Editor *)client_data, FILE_ASKIFSAVE_DIALOG_HELP,
182 HelpFileAlreadyExistsCB(
187 SetHelpVolAndDisplayHelp((Editor *)client_data, FILE_EXISTS_DIALOG_HELP,
192 /************************************************************************
193 * The following callback is set as the 'XmNhelpCallback' on the DtEditor
194 * widget. It controls help for the "Find/Change", "Check Spelling" and
195 * "Format Settings" dialogs and dialog components.
196 ************************************************************************/
205 DtEditorHelpCallbackStruct *editorHelp =
206 (DtEditorHelpCallbackStruct *) call_data;
208 switch (editorHelp->reason) {
210 /* -----> edit area */
211 case DtEDITOR_HELP_EDIT_WINDOW:
212 SetHelpVolAndDisplayHelp((Editor *)client_data,
217 /* -----> status line area and fields */
218 case DtEDITOR_HELP_STATUS_LINE:
219 SetHelpVolAndDisplayHelp((Editor *)client_data,
223 case DtEDITOR_HELP_STATUS_CURRENT_LINE:
224 SetHelpVolAndDisplayHelp((Editor *)client_data,
225 STATUS_CURRENT_LINE_HELP,
228 case DtEDITOR_HELP_STATUS_TOTAL_LINES:
229 SetHelpVolAndDisplayHelp((Editor *)client_data,
230 STATUS_TOTAL_LINES_HELP,
233 case DtEDITOR_HELP_STATUS_MESSAGE:
234 SetHelpVolAndDisplayHelp((Editor *)client_data,
238 case DtEDITOR_HELP_STATUS_OVERSTRIKE:
239 SetHelpVolAndDisplayHelp((Editor *)client_data,
240 STATUS_OVERSTRIKE_HELP,
244 /* -----> Format Settings dialog and dialog fields */
245 case DtEDITOR_HELP_FORMAT_DIALOG:
246 SetHelpVolAndDisplayHelp((Editor *)client_data,
247 FORMAT_SETTINGS_HELP,
250 case DtEDITOR_HELP_FORMAT_LEFT_MARGIN:
251 SetHelpVolAndDisplayHelp((Editor *)client_data,
252 FORMAT_LEFT_MARGIN_HELP,
255 case DtEDITOR_HELP_FORMAT_RIGHT_MARGIN:
256 SetHelpVolAndDisplayHelp((Editor *)client_data,
257 FORMAT_RIGHT_MARGIN_HELP,
260 case DtEDITOR_HELP_FORMAT_ALIGNMENT:
261 SetHelpVolAndDisplayHelp((Editor *)client_data,
262 FORMAT_ALIGNMENT_HELP,
266 /* -----> Find/Change dialog and dialog fields */
267 case DtEDITOR_HELP_CHANGE_DIALOG:
268 SetHelpVolAndDisplayHelp((Editor *)client_data,
272 case DtEDITOR_HELP_CHANGE_FIND:
273 SetHelpVolAndDisplayHelp((Editor *)client_data,
274 FINDCHANGE_FIND_HELP,
277 case DtEDITOR_HELP_CHANGE_CHANGE:
278 SetHelpVolAndDisplayHelp((Editor *)client_data,
279 FINDCHANGE_CHANGETO_HELP,
283 /* -----> Check Spelling dialog and dialog fields */
284 case DtEDITOR_HELP_SPELL_DIALOG:
285 SetHelpVolAndDisplayHelp((Editor *)client_data,
289 case DtEDITOR_HELP_SPELL_MISSPELLED_WORDS:
290 SetHelpVolAndDisplayHelp((Editor *)client_data,
291 SPELL_MISSPELLED_WORDS_HELP,
294 case DtEDITOR_HELP_SPELL_CHANGE:
295 SetHelpVolAndDisplayHelp((Editor *)client_data,
303 } /* switch (editorHelp->reason) */
308 /************************************************************************
309 * The following callbacks are set as the 'XmNhelpCallback' on the print
310 * setup dialogs accessible from the [File] [Print...] menu button.
311 ************************************************************************/
314 HelpPrintSetupDialogCB(
316 XtPointer client_data,
317 XtPointer call_data )
319 SetHelpVolAndDisplayHelp((Editor *)client_data, PRINT_SETUP_DIALOG_HELP,
324 HelpPrintSetupAppSpecificCB(
326 XtPointer client_data,
327 XtPointer call_data )
329 SetHelpVolAndDisplayHelp((Editor *)client_data, PRINT_APP_SPECIFIC_OPTIONS,
334 HelpPrintSetupGenericCB(
336 XtPointer client_data,
337 XtPointer call_data )
339 SetHelpVolAndDisplayHelp((Editor *)client_data, PRINT_GENERIC_OPTIONS,
344 HelpPrintSetupPageHeadersFootersCB(
346 XtPointer client_data,
347 XtPointer call_data )
349 SetHelpVolAndDisplayHelp((Editor *)client_data, PRINT_PAGE_HEADERS_FOOTERS,
354 HelpPrintSetupPageMargins(
356 XtPointer client_data,
357 XtPointer call_data )
359 SetHelpVolAndDisplayHelp((Editor *)client_data, PRINT_PAGE_MARGINS,
365 /************************************************************************
366 * The following callbacks are set (in dtpad.c:CreateHelpMenu) as the
367 * 'XmNactivateCallback' for each of the items in the Help menu:
371 * Table of Contents...
378 * About Text Editor...
380 ************************************************************************/
388 SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_OVERVIEW_HELP,
398 SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_TASKS_HELP,
408 SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_TOC_HELP,
418 SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_REFERENCE_HELP,
428 Editor *pPad = (Editor *)client_data;
431 switch(DtHelpReturnSelectedWidgetId(pPad->app_shell, (Cursor)NULL, &widget))
434 * There are additional cases (e.g. user aborts request) but I
435 * don't feel they warrant an error dialog.
437 case DtHELP_SELECT_VALID:
438 while (!XtIsShell(widget)) {
439 if (XtHasCallbacks(widget, XmNhelpCallback) == XtCallbackHasSome) {
440 XtCallCallbacks(widget, XmNhelpCallback, (XtPointer)pPad);
443 widget = XtParent(widget);
446 case DtHELP_SELECT_INVALID:
448 GETMESSAGE(12, 1, "You must select an item within the Text Editor."),
449 XmDIALOG_INFORMATION);
460 SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_USING_HELP_HELP,
461 HELP_ON_HELP_VOLUME);
470 SetHelpVolAndDisplayHelp((Editor *) client_data, HELP_MENU_ABOUT_HELP,
476 /************************************************************************
477 * HelpHyperlinkCB - is the 'DtNhyperLinkCallback' passed to
478 * DtCreateHelpDialog (in CreateHelpDialog).
479 ************************************************************************/
486 DtHelpDialogCallbackStruct *pHyper =
487 (DtHelpDialogCallbackStruct *) call_data;
489 switch(pHyper->hyperType)
491 case DtHELP_LINK_JUMP_NEW:
492 DisplayNewHelpWindow((Editor *)client_data, pHyper->helpVolume,
497 /* application defined link code goes here */
503 /************************************************************************
504 * HelpCloseCB - is the 'DtNcloseCallback' passed to DtCreateHelpDialog
505 * (in CreateHelpDialog) to close/unmap all help dialogs, both cached
506 * and uncached. It checks to see if the referenced dialog is in the
507 * uncached help for the current pad.
508 ************************************************************************/
515 Editor *pPad = (Editor *)client_data;
518 if(w != pPad->MainHelp)
521 * empty for loop just marches pHelp to the right place
523 for(pHelp = pPad->pHelpCache;
524 pHelp != (HelpStruct *)NULL && pHelp->dialog != w;
525 pHelp = pHelp->pNext)
528 if(pHelp != (HelpStruct *)NULL)
530 /* this should always happen */
531 pHelp->inUse = False;