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
23 /* $XConsortium: helpCB.c /main/4 1996/04/16 16:42:13 mgreess $ */
24 /**********************************<+>*************************************
25 ***************************************************************************
29 ** Project: DT dtpad, a memo maker type editor based on the Dt Editor
35 ** This file contains the all the Text Editor help related callbacks:
37 ** o 'XmNhelpCallback' callbacks for:
38 ** - the menu bar and the individual menus within the bar
39 ** - file selection boxes, dialogs and dialog components relating to
41 ** - the DtEditor widget
42 ** o 'XmNActivateCallback' callbacks for each item in the [Help]
44 ** o 'DtNhyperLinkCallback' and 'DtNcloseCallback' callbacks passed to
45 ** DtCreateHelpDialog() (via helpDlg.c:CreateHelpDialog()).
47 ** All 'XmNhelpCallback' and 'XmNActivateCallback' callbacks, except for
48 ** [Help] menu [On Item...], simply set the help location id to correspond
49 ** to help text on the widget for which the callback was set. The On Item
50 ** 'XmNActivateCallback' callback determines the widget on which it was
51 ** invoked and then calls the 'XmNhelpCallback' callback directly. If no
52 ** 'XmNhelpCallback' is installed, it searches up the widget's parentage
53 * until it finds one and then calls it.
55 ** NOTE: All dialogs relating to the [Edit] and [Format] menus are
56 ** controlled directly by the DtEditor widget. Consequently,
57 ** all of the help location ids for the "Find/Change", "Check
58 ** Spelling" and "Format Settings" dialogs are set in the
59 ** in the DtEditor widget's 'XmNhelpCallback' callback
60 ** (i.e. in, HelpEditorWidgetCB).
62 *******************************************************************
63 ** (c) Copyright Hewlett-Packard Company, 1991, 1992, 1993. All rights are
64 ** reserved. Copying or other reproduction of this program
65 ** except for archival purposes is prohibited without prior
66 ** written consent of Hewlett-Packard Company.
67 ********************************************************************
69 ********************************************************************
70 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
71 ** (c) Copyright 1993, 1994 International Business Machines Corp.
72 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
73 ** (c) Copyright 1993, 1994 Novell, Inc.
74 ********************************************************************
77 **************************************************************************
78 **********************************<+>*************************************/
81 #include <Dt/HelpDialog.h>
84 /************************************************************************
85 * The following callbacks are set as the 'XmNhelpCallback' for the menu
86 * menu bar and for the individual pulldown menus within the menu bar.
87 ************************************************************************/
95 SetHelpVolAndDisplayHelp((Editor *)client_data, MENUBAR_HELP,
105 SetHelpVolAndDisplayHelp((Editor *)client_data, FILE_MENU_HELP,
115 SetHelpVolAndDisplayHelp((Editor *)client_data, EDIT_MENU_HELP,
125 SetHelpVolAndDisplayHelp((Editor *)client_data, FORMAT_MENU_HELP,
135 SetHelpVolAndDisplayHelp((Editor *)client_data, OPTIONS_MENU_HELP,
145 SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_HELP,
151 /************************************************************************
152 * The following callbacks are set as the 'XmNhelpCallback' on file
153 * selection boxes and prompt dialogs relating to the [File] menu.
154 ************************************************************************/
162 SetHelpVolAndDisplayHelp((Editor *)client_data, FILE_OPEN_DIALOG_HELP,
172 SetHelpVolAndDisplayHelp((Editor *)client_data, FILE_INCLUDE_DIALOG_HELP,
182 Editor *pPad = (Editor *) client_data;
184 if (pPad->xrdb.nameChange) {
185 SetHelpVolAndDisplayHelp(pPad, FILE_SAVEAS_DIALOG_HELP,
188 SetHelpVolAndDisplayHelp(pPad, FILE_COPYTOFILE_DIALOG_HELP,
194 HelpAskIfSaveDialogCB(
199 SetHelpVolAndDisplayHelp((Editor *)client_data, FILE_ASKIFSAVE_DIALOG_HELP,
204 HelpFileAlreadyExistsCB(
209 SetHelpVolAndDisplayHelp((Editor *)client_data, FILE_EXISTS_DIALOG_HELP,
214 /************************************************************************
215 * The following callback is set as the 'XmNhelpCallback' on the DtEditor
216 * widget. It controls help for the "Find/Change", "Check Spelling" and
217 * "Format Settings" dialogs and dialog components.
218 ************************************************************************/
227 DtEditorHelpCallbackStruct *editorHelp =
228 (DtEditorHelpCallbackStruct *) call_data;
230 switch (editorHelp->reason) {
232 /* -----> edit area */
233 case DtEDITOR_HELP_EDIT_WINDOW:
234 SetHelpVolAndDisplayHelp((Editor *)client_data,
239 /* -----> status line area and fields */
240 case DtEDITOR_HELP_STATUS_LINE:
241 SetHelpVolAndDisplayHelp((Editor *)client_data,
245 case DtEDITOR_HELP_STATUS_CURRENT_LINE:
246 SetHelpVolAndDisplayHelp((Editor *)client_data,
247 STATUS_CURRENT_LINE_HELP,
250 case DtEDITOR_HELP_STATUS_TOTAL_LINES:
251 SetHelpVolAndDisplayHelp((Editor *)client_data,
252 STATUS_TOTAL_LINES_HELP,
255 case DtEDITOR_HELP_STATUS_MESSAGE:
256 SetHelpVolAndDisplayHelp((Editor *)client_data,
260 case DtEDITOR_HELP_STATUS_OVERSTRIKE:
261 SetHelpVolAndDisplayHelp((Editor *)client_data,
262 STATUS_OVERSTRIKE_HELP,
266 /* -----> Format Settings dialog and dialog fields */
267 case DtEDITOR_HELP_FORMAT_DIALOG:
268 SetHelpVolAndDisplayHelp((Editor *)client_data,
269 FORMAT_SETTINGS_HELP,
272 case DtEDITOR_HELP_FORMAT_LEFT_MARGIN:
273 SetHelpVolAndDisplayHelp((Editor *)client_data,
274 FORMAT_LEFT_MARGIN_HELP,
277 case DtEDITOR_HELP_FORMAT_RIGHT_MARGIN:
278 SetHelpVolAndDisplayHelp((Editor *)client_data,
279 FORMAT_RIGHT_MARGIN_HELP,
282 case DtEDITOR_HELP_FORMAT_ALIGNMENT:
283 SetHelpVolAndDisplayHelp((Editor *)client_data,
284 FORMAT_ALIGNMENT_HELP,
288 /* -----> Find/Change dialog and dialog fields */
289 case DtEDITOR_HELP_CHANGE_DIALOG:
290 SetHelpVolAndDisplayHelp((Editor *)client_data,
294 case DtEDITOR_HELP_CHANGE_FIND:
295 SetHelpVolAndDisplayHelp((Editor *)client_data,
296 FINDCHANGE_FIND_HELP,
299 case DtEDITOR_HELP_CHANGE_CHANGE:
300 SetHelpVolAndDisplayHelp((Editor *)client_data,
301 FINDCHANGE_CHANGETO_HELP,
305 /* -----> Check Spelling dialog and dialog fields */
306 case DtEDITOR_HELP_SPELL_DIALOG:
307 SetHelpVolAndDisplayHelp((Editor *)client_data,
311 case DtEDITOR_HELP_SPELL_MISSPELLED_WORDS:
312 SetHelpVolAndDisplayHelp((Editor *)client_data,
313 SPELL_MISSPELLED_WORDS_HELP,
316 case DtEDITOR_HELP_SPELL_CHANGE:
317 SetHelpVolAndDisplayHelp((Editor *)client_data,
325 } /* switch (editorHelp->reason) */
330 /************************************************************************
331 * The following callbacks are set as the 'XmNhelpCallback' on the print
332 * setup dialogs accessible from the [File] [Print...] menu button.
333 ************************************************************************/
336 HelpPrintSetupDialogCB(
338 XtPointer client_data,
339 XtPointer call_data )
341 SetHelpVolAndDisplayHelp((Editor *)client_data, PRINT_SETUP_DIALOG_HELP,
346 HelpPrintSetupAppSpecificCB(
348 XtPointer client_data,
349 XtPointer call_data )
351 SetHelpVolAndDisplayHelp((Editor *)client_data, PRINT_APP_SPECIFIC_OPTIONS,
356 HelpPrintSetupGenericCB(
358 XtPointer client_data,
359 XtPointer call_data )
361 SetHelpVolAndDisplayHelp((Editor *)client_data, PRINT_GENERIC_OPTIONS,
366 HelpPrintSetupPageHeadersFootersCB(
368 XtPointer client_data,
369 XtPointer call_data )
371 SetHelpVolAndDisplayHelp((Editor *)client_data, PRINT_PAGE_HEADERS_FOOTERS,
376 HelpPrintSetupPageMargins(
378 XtPointer client_data,
379 XtPointer call_data )
381 SetHelpVolAndDisplayHelp((Editor *)client_data, PRINT_PAGE_MARGINS,
387 /************************************************************************
388 * The following callbacks are set (in dtpad.c:CreateHelpMenu) as the
389 * 'XmNactivateCallback' for each of the items in the Help menu:
393 * Table of Contents...
400 * About Text Editor...
402 ************************************************************************/
410 SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_OVERVIEW_HELP,
420 SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_TASKS_HELP,
430 SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_TOC_HELP,
440 SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_REFERENCE_HELP,
450 Editor *pPad = (Editor *)client_data;
453 switch(DtHelpReturnSelectedWidgetId(pPad->app_shell, (Cursor)NULL, &widget))
456 * There are additional cases (e.g. user aborts request) but I
457 * don't feel they warrant an error dialog.
459 case DtHELP_SELECT_VALID:
460 while (!XtIsShell(widget)) {
461 if (XtHasCallbacks(widget, XmNhelpCallback) == XtCallbackHasSome) {
462 XtCallCallbacks(widget, XmNhelpCallback, (XtPointer)pPad);
465 widget = XtParent(widget);
468 case DtHELP_SELECT_INVALID:
470 GETMESSAGE(12, 1, "You must select an item within the Text Editor."),
471 XmDIALOG_INFORMATION);
482 SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_USING_HELP_HELP,
483 HELP_ON_HELP_VOLUME);
492 SetHelpVolAndDisplayHelp((Editor *) client_data, HELP_MENU_ABOUT_HELP,
498 /************************************************************************
499 * HelpHyperlinkCB - is the 'DtNhyperLinkCallback' passed to
500 * DtCreateHelpDialog (in CreateHelpDialog).
501 ************************************************************************/
508 DtHelpDialogCallbackStruct *pHyper =
509 (DtHelpDialogCallbackStruct *) call_data;
511 switch(pHyper->hyperType)
513 case DtHELP_LINK_JUMP_NEW:
514 DisplayNewHelpWindow((Editor *)client_data, pHyper->helpVolume,
519 /* application defined link code goes here */
525 /************************************************************************
526 * HelpCloseCB - is the 'DtNcloseCallback' passed to DtCreateHelpDialog
527 * (in CreateHelpDialog) to close/unmap all help dialogs, both cached
528 * and uncached. It checks to see if the referenced dialog is in the
529 * uncached help for the current pad.
530 ************************************************************************/
537 Editor *pPad = (Editor *)client_data;
540 if(w != pPad->MainHelp)
543 * empty for loop just marches pHelp to the right place
545 for(pHelp = pPad->pHelpCache;
546 pHelp != (HelpStruct *)NULL && pHelp->dialog != w;
547 pHelp = pHelp->pNext)
550 if(pHelp != (HelpStruct *)NULL)
552 /* this should always happen */
553 pHelp->inUse = False;