Link with C++ linker
[oweals/cde.git] / cde / programs / dtstyle / HelpCB.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /* $XConsortium: HelpCB.c /main/5 1996/03/25 00:51:28 pascale $ */
24 /*
25  ****************************************************************************
26  **
27  **   File:        HelpCB.c
28  **
29  **   Project:     DT 3.0
30  **
31  **   Description: Contains the callbacks for Help
32  **
33  **
34  ****************************************************************************/
35 /*
36  * (c) Copyright 1996 Digital Equipment Corporation.
37  * (c) Copyright 1990, 1996 Hewlett-Packard Company.
38  * (c) Copyright 1996 International Business Machines Corp.
39  * (c) Copyright 1996 Sun Microsystems, Inc.
40  * (c) Copyright 1996 Novell, Inc. 
41  * (c) Copyright 1996 FUJITSU LIMITED.
42  * (c) Copyright 1996 Hitachi.
43  */
44
45 #include <Dt/HelpDialog.h>
46
47 #include "Main.h"
48 #include "Help.h"
49
50 void
51 HelpRequestCB(
52         Widget w,
53         caddr_t client_data,
54         caddr_t call_data )
55 {
56     char *helpVolume, *locationId;
57     int topic;
58     
59     topic = (int) client_data;
60     helpVolume = HELP_VOLUME;
61
62     switch (topic)
63     {
64         case HELP_MAIN_WINDOW:
65             locationId = HELP_MAIN_WINDOW_STR;
66             break;
67         case HELP_MENUBAR:
68             locationId = HELP_MENUBAR_STR;
69             break;
70         case HELP_FILE_BUTTON:
71             locationId = HELP_FILE_BUTTON_STR;
72             break;
73         case HELP_HELP_BUTTON:
74             locationId = HELP_HELP_BUTTON_STR;
75             break;
76         case HELP_FILE_MENU:
77             locationId = HELP_FILE_MENU_STR;
78             break;
79         case HELP_HELP_MENU:
80             locationId = HELP_HELP_MENU_STR;
81             break;
82         case HELP_EXIT:
83             locationId = HELP_EXIT_STR;
84             break;
85         case HELP_INTRODUCTION:
86             locationId = HELP_INTRODUCTION_STR;
87             break;
88         case HELP_TASKS:        
89             locationId = HELP_TASKS_STR;
90             break;
91         case HELP_REFERENCE:
92             locationId = HELP_REFERENCE_STR;
93             break;
94         case HELP_ITEM:
95             locationId = HELP_ITEM_STR;
96             break;
97         case HELP_USING:
98             locationId = HELP_USING_STR;
99             helpVolume = HELP_USING_HELP_VOLUME;
100             break;
101         case HELP_VERSION:
102             locationId = HELP_VERSION_STR;
103             break;
104         case HELP_COLOR_BUTTON:
105             locationId = HELP_COLOR_BUTTON_STR;
106             break;
107         case HELP_FONT_BUTTON:
108             locationId = HELP_FONT_BUTTON_STR;
109             break;
110         case HELP_BACKDROP_BUTTON:
111             locationId = HELP_BACKDROP_BUTTON_STR;
112             break;
113         case HELP_KEYBOARD_BUTTON:
114             locationId = HELP_KEYBOARD_BUTTON_STR;
115             break;
116         case HELP_MOUSE_BUTTON:
117             locationId = HELP_MOUSE_BUTTON_STR;
118             break;
119         case HELP_AUDIO_BUTTON:
120             locationId = HELP_AUDIO_BUTTON_STR;
121             break;
122         case HELP_SCREEN_BUTTON:
123             locationId = HELP_SCREEN_BUTTON_STR;
124             break;
125         case HELP_DTWM_BUTTON:
126             locationId = HELP_DTWM_BUTTON_STR;
127             break;
128         case HELP_STARTUP_BUTTON:
129             locationId = HELP_STARTUP_BUTTON_STR;
130             break;
131         case HELP_I18N_BUTTON:
132             locationId = HELP_I18N_BUTTON_STR;
133             break;
134         case HELP_COLOR_DIALOG:
135             locationId = HELP_COLOR_DIALOG_STR;
136             break;
137         case HELP_ADD_PALETTE_DIALOG:
138             locationId = HELP_ADD_PALETTE_DIALOG_STR;
139             break;
140         case HELP_ADD_PALETTE_WARNING_DIALOG:
141             locationId = HELP_ADD_PALETTE_WARNING_DIALOG_STR;
142             break;
143         case HELP_DELETE_PALETTE_DIALOG:
144             locationId = HELP_DELETE_PALETTE_DIALOG_STR;
145             break;
146         case HELP_DELETE_PALETTE_WARNING_DIALOG:
147             locationId = HELP_DELETE_PALETTE_WARNING_DIALOG_STR;
148             break;
149         case HELP_MODIFY_PALETTE_DIALOG:
150             locationId = HELP_MODIFY_PALETTE_DIALOG_STR;
151             break;
152         case HELP_COLOR_USE_DIALOG:
153             locationId = HELP_COLOR_USE_DIALOG_STR;
154             break;
155         case HELP_FONT_DIALOG:
156             locationId = HELP_FONT_DIALOG_STR;
157             break;
158         case HELP_BACKDROP_DIALOG:
159             locationId = HELP_BACKDROP_DIALOG_STR;
160             break;
161         case HELP_KEYBOARD_DIALOG:
162             locationId = HELP_KEYBOARD_DIALOG_STR;
163             break;
164         case HELP_MOUSE_DIALOG:
165             locationId = HELP_MOUSE_DIALOG_STR;
166             break;
167         case HELP_AUDIO_DIALOG:
168             locationId = HELP_AUDIO_DIALOG_STR;
169             break;
170         case HELP_SCREEN_DIALOG:
171             locationId = HELP_SCREEN_DIALOG_STR;
172             break;
173         case HELP_DTWM_DIALOG:
174             locationId = HELP_DTWM_DIALOG_STR;
175             break;
176         case HELP_STARTUP_DIALOG:
177             locationId = HELP_STARTUP_DIALOG_STR;
178             break;
179         case HELP_I18N_DIALOG:
180             locationId = HELP_I18N_DIALOG_STR;
181             break;
182     }
183
184     Help(helpVolume, locationId);
185 }
186
187 void
188 QuickHelpRequestCB(
189         Widget w,
190         caddr_t client_data,
191         caddr_t call_data )
192 {
193
194 }
195
196 void
197 HelpModeCB(
198         Widget w,
199         caddr_t client_data,
200         caddr_t call_data )
201 {
202    Widget widget;
203
204    switch(DtHelpReturnSelectedWidgetId(style.shell, (Cursor)NULL, &widget))
205    {
206       /*
207        * There are additional cases (e.g. user aborts request) but I
208        * don't feel they warrant an error dialog.
209        */
210       case DtHELP_SELECT_VALID:
211
212           while (!XtIsShell(widget))
213           {
214              if (XtHasCallbacks(widget, XmNhelpCallback) == XtCallbackHasSome)
215              {
216                 XtCallCallbacks(widget, XmNhelpCallback, (XtPointer)NULL);
217                 return;
218              }
219              widget = XtParent(widget);
220           }
221           break;
222
223       case DtHELP_SELECT_INVALID:
224
225           ErrDialog((char *)GETMESSAGE(2, 8, "You must select an item\nwithin the Style Manager."), style.shell);
226           break;
227
228    }
229 }
230
231 void
232 HelpHyperlinkCB(
233         Widget w,
234         caddr_t client_data,
235         caddr_t call_data )
236 {
237     DtHelpDialogCallbackStruct *pHyper = 
238             (DtHelpDialogCallbackStruct *) call_data;
239
240     switch(pHyper->hyperType)
241     {
242         case DtHELP_LINK_JUMP_NEW:
243             DisplayHelp(pHyper->helpVolume, pHyper->locationId);
244             break;
245         default:
246             ;
247             /* application defined link code goes here */
248     }
249 }
250
251 void
252 HelpCloseCB(
253         Widget w,
254         caddr_t client_data,
255         caddr_t call_data )
256 {
257
258     HelpStruct *pHelpCache = (HelpStruct *)client_data;
259     HelpStruct *pHelp;
260
261     /*
262      * empty for loop just marches pHelp to the right place
263      */
264     for(pHelp = pHelpCache; 
265         pHelp != (HelpStruct *)NULL && pHelp->dialog != w;
266         pHelp = pHelp->pNext);
267
268     if(pHelp != (HelpStruct *)NULL)
269     {
270         /* this should always happen */
271         pHelp->inUse = False;
272     }
273
274     XtUnmapWidget(XtParent(w));
275
276 }