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 /* $TOG: helpDlg.c /main/4 1999/09/15 15:16:22 mgreess $ */
24 /**********************************<+>*************************************
25 ***************************************************************************
29 ** Project: HP DT dtpad, a memo maker type editor based on the
32 ** Description: Routines which manipulate the dialogs associated with
33 ** operations in the Help menu.
36 *******************************************************************
37 ** (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992. All rights are
38 ** reserved. Copying or other reproduction of this program
39 ** except for archival purposes is prohibited without prior
40 ** written consent of Hewlett-Packard Company.
41 ********************************************************************
43 *******************************************************************
44 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
45 ** (c) Copyright 1993, 1994 International Business Machines Corp.
46 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
47 ** (c) Copyright 1993, 1994 Novell, Inc.
48 ********************************************************************
51 **************************************************************************
52 **********************************<+>*************************************/
58 #include <Xm/DialogS.h>
60 #include <Xm/MwmUtil.h>
61 #include <Dt/HelpDialog.h>
64 /************************************************************************
65 * GetHelpDialog - obtains an "unused" help dialog from the cached list
66 * for the pad or, if one doesn't exist, creates a new help dialog
67 * and puts it in the cache.
68 ************************************************************************/
75 if (pPad->pHelpCache == (HelpStruct *)NULL) {
76 pHelp = pPad->pHelpCache = (HelpStruct *)XtMalloc(sizeof(HelpStruct));
77 pHelp->pNext = (HelpStruct *)NULL;
78 pHelp->pPrev = (HelpStruct *)NULL;
80 pHelp->dialog = CreateHelpDialog(pPad);
83 for (pHelp = pPad->pHelpCache; pHelp != (HelpStruct *)NULL;
84 pHelp = pHelp->pNext) {
85 if (pHelp->inUse == False) {
90 pHelp = (HelpStruct *) XtMalloc(sizeof(HelpStruct));
91 pPad->pHelpCache->pPrev = pHelp;
92 pHelp->pNext = pPad->pHelpCache;
93 pPad->pHelpCache = pHelp;
94 pHelp->pPrev = (HelpStruct *)NULL;
96 pHelp->dialog = CreateHelpDialog(pPad);
102 /************************************************************************
103 * SetHelpVolAndDisplayHelp - sets the help volume and displays the help
104 * text beginning at the specified location id within the volume
105 ************************************************************************/
107 SetHelpVolAndDisplayHelp(
113 if (helpVolume == (char *) NULL)
114 helpVolume = TEXTEDITOR_HELP_VOLUME;
116 DisplayHelp(pPad, helpVolume, locationId);
120 /************************************************************************
121 * DisplayHelp - is called to display all the "normal" help windows. It
122 * uses the one "MainHelp" dialog associated with the relevant pad.
123 ************************************************************************/
130 if (pPad->MainHelp == NULL) {
131 pPad->MainHelp = CreateHelpDialog(pPad);
134 DisplayHelpDialog(pPad, pPad->MainHelp, helpVolume, locationId);
139 /************************************************************************
140 * CreateHelpDialog - creates the "MainHelp" help for the pad and sets
141 * up the hyperLink and Close callbacks for it.
142 ************************************************************************/
151 dialog = DtCreateHelpDialog(pPad->app_shell, "helpDlg", args, n);
152 XtAddCallback(dialog, DtNhyperLinkCallback,
153 (XtCallbackProc)HelpHyperlinkCB, pPad);
154 XtAddCallback(dialog, DtNcloseCallback,
155 (XtCallbackProc)HelpCloseCB, pPad);
160 /************************************************************************
161 * DisplayNewHelpWindow - is called by the hyperLink callback,
162 * helpCB.c:HelpHyperlinkCB to open a new, cached, help dialog for
164 ************************************************************************/
166 DisplayNewHelpWindow(
171 DisplayHelpDialog(pPad, GetHelpDialog(pPad), helpVolume, locationId);
175 /************************************************************************
176 * DisplayHelpDialog - sets the help type topic, volume, location id and
177 * title for the specified help dialog.
178 ************************************************************************/
188 char *titleStr, *helpStr;
191 XtSetArg(args[n], DtNhelpType, DtHELP_TYPE_TOPIC);n++;
192 XtSetArg(args[n], DtNhelpVolume, helpVolume); n++;
193 XtSetArg(args[n], DtNlocationId, locationId); n++;
194 XtSetValues(helpDialog, args, n);
197 * It's a bit bogus to set the dialog title each time we display the
198 * dialog, but it's an easy way to make sure the title is right if the
199 * pad is reused and the previous user had a mainTitle specified.
201 helpStr = (char*)GETMESSAGE(2, 1, "Help");
202 titleStr = (char*)XtMalloc(strlen(helpStr)+strlen(DialogTitle(pPad))+1);
203 sprintf(titleStr, "%s%s", DialogTitle(pPad), helpStr);
205 XtSetArg (args[n], XmNtitle, titleStr); n++;
206 XtSetValues(XtParent(helpDialog), args, n);
208 XtManageChild(helpDialog);