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 libraries 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: HelpAccess.c /main/6 1996/08/28 16:46:12 drk $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 ** Project: Cache Creek (Rivers) Project
31 ** Description: This module handles all the help requests within a given
32 ** help dialog widget.
34 ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
36 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
37 ** (c) Copyright 1993, 1994 International Business Machines Corp.
38 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
39 ** (c) Copyright 1993, 1994 Novell, Inc.
43 ****************************************************************************
44 ************************************<+>*************************************/
49 #include <X11/Intrinsic.h>
50 #include <X11/Shell.h>
52 #include <Xm/RowColumnP.h>
53 #include <Xm/LabelG.h>
54 #include <Xm/PushBG.h>
55 #include <Xm/CascadeB.h>
56 #include <Xm/CascadeBG.h>
58 /* Help Library Includes */
59 #include "DisplayAreaI.h"
61 #include "StringFuncsI.h"
62 #include "HelpDialogI.h"
63 #include "HelpDialogP.h"
68 #include "HelpUtilI.h"
69 #include "HelpQuickD.h"
70 #include "HelpQuickDP.h"
71 #include "HelpQuickDI.h"
75 /******** Static Function Declarations ********/
76 static void CloseOnHelpCB(
78 XtPointer client_data,
80 static void SetupHelpDialog(
82 char *helpOnHelpVolume,
86 /******** End Static Function Declarations ********/
91 /*****************************************************************************
92 * Function: static void CloseOnHelpCB(
94 * XtPointer client_data,
95 * XtPointer call_data);
101 * Purpose: This routine closes the onhelp dialog Widget that we
102 * created for our help on help stuff.
104 ****************************************************************************/
105 static void CloseOnHelpCB(
107 XtPointer client_data,
108 XtPointer call_data )
118 /****************************************************************************
119 * Function: void _DtHelpCB ()
126 * Return Value: Void.
128 * Purpose: Called when any "F1" key is pressed in a help dialog
129 * widget, or a user selects any of the help buttons in
130 * any of the help dialogs dialogs.
132 ***************************************************************************/
135 XtPointer clientData,
140 DtHelpListStruct * pHelpInfo = (DtHelpListStruct *) clientData;
141 _DtHelpCommonHelpStuff * help = pHelpInfo->help;
143 /* If helpOnHelp resource is set use it, else post an error dialog */
144 if (help->helpOnHelpVolume != NULL)
146 SetupHelpDialog((Widget)pHelpInfo->widget, help->helpOnHelpVolume,
147 &(help->onHelpDialog), pHelpInfo->locationId);
151 /* We have no help available for the help stuff so generate an error */
152 /* Do NOT EVER provide a help button */
154 errorStr = XtNewString(((char *) _DTGETMESSAGE(6, 4,
155 "Help On Help not provided for this application!")));
156 _DtHelpErrorDialog(XtParent(pHelpInfo->widget), errorStr);
165 /*****************************************************************************
166 * Function: void SetupHelpDialog ();
171 * Return Value: Void.
173 * Purpose: Creates or re-uses a help on help quick help widget.
175 *****************************************************************************/
176 static void SetupHelpDialog(
178 char *helpOnHelpVolume,
184 XmString printString;
185 XmString closeString;
191 if (*helpDialog == NULL)
193 /* Create the QuickHelpDialog widget for help on help */
194 title = XtNewString(((char *)_DTGETMESSAGE(6, 1, "Help On Help")));
195 printString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
196 (6, 2,"Print ...")));
197 closeString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
199 backString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
200 (6, 5,"Backtrack")));
202 helpString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
206 XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
207 XtSetArg (args[n], XmNtitle, title); n++;
208 XtSetArg (args[n], DtNprintLabelString, printString); n++;
209 XtSetArg (args[n], DtNcloseLabelString, closeString); n++;
210 XtSetArg (args[n], DtNbackLabelString, backString); n++;
211 XtSetArg (args[n], DtNhelpLabelString, helpString); n++;
212 XtSetArg (args[n], DtNhelpVolume,helpOnHelpVolume); n++;
213 XtSetArg (args[n], DtNlocationId, locationId); n++;
214 *helpDialog = DtCreateHelpQuickDialog((Widget)parent,
215 "onHelpDialog", args, n);
216 XmStringFree(printString);
217 XmStringFree(closeString);
218 XmStringFree(backString);
219 XmStringFree(helpString);
220 XtFree((char*) title);
222 /* Catch the close callback so we can destroy the widget */
223 XtAddCallback(*helpDialog, DtNcloseCallback,
224 CloseOnHelpCB, (XtPointer) NULL);
226 /* Add the popup position callback to our history dialog */
227 XtAddCallback (XtParent(*helpDialog), XmNpopupCallback,
228 (XtCallbackProc)_DtHelpMapCB,
229 (XtPointer)XtParent(parent));
236 XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
237 XtSetArg (args[n], DtNhelpVolume,helpOnHelpVolume); n++;
238 XtSetArg (args[n], DtNlocationId, locationId); n++;
239 XtSetValues(*helpDialog, args, n);
243 /* Display the dialog */
244 XtManageChild(*helpDialog);
245 XtMapWidget(XtParent((Widget)*helpDialog));
250 /*****************************************************************************
251 * Function: void _DtHelpListFree (DtHelpListStruct * * pHead);
254 * Parameters: pHead Specifies the head pointer to the help list.
256 * Return Value: Void.
258 * Purpose: Frees all elements in a Help List.
260 *****************************************************************************/
261 void _DtHelpListFree(
262 DtHelpListStruct * * pHead)
264 DtHelpListStruct *pTemp = NULL;
265 DtHelpListStruct *pTmpHead = *pHead;
267 while (pTmpHead != NULL)
269 /* Free up each element in the current node */
271 pTmpHead = pTmpHead->pNext;
274 /* Free the id String */
275 XtFree(pTemp->locationId);
277 /* Now, free the whole node */
278 XtFree((char *)pTemp);
280 *pHead = NULL; /* reset pointer */
292 /*****************************************************************************
293 * Function: DtHelpListStruct * _DtHelpListAdd(
296 * DtHelpListStruct **pHead)
302 * Return Value: Void.
304 * Purpose: Adds an element to the top of the given topicList.
306 *****************************************************************************/
307 DtHelpListStruct * _DtHelpListAdd(
310 _DtHelpCommonHelpStuff * help,
311 DtHelpListStruct **pHead)
313 DtHelpListStruct *pTemp=NULL;
315 /* Add locationId as first element if pHead = NULL */
318 *pHead = (DtHelpListStruct *) XtMalloc((sizeof(DtHelpListStruct)));
320 /* Assign the passed in values to our first element */
321 (*pHead)->locationId = XtNewString(locationId);
322 (*pHead)->widget = widget;
323 (*pHead)->help = help;
324 (*pHead)->pNext = NULL;
325 (*pHead)->pPrevious = NULL;
329 { /* We have a list so add the new Help item to the top */
330 pTemp = (DtHelpListStruct *) XtMalloc((sizeof(DtHelpListStruct)));
332 pTemp->pNext = (*pHead);
333 pTemp->pPrevious = NULL;
335 (*pHead)->pPrevious = pTemp;
337 pTemp->locationId = XtNewString(locationId);
338 pTemp->widget = widget;
341 /* Re-Assign our head pointer to point to the new head of the list */