Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtcm / dtcm / help.c
1 /*******************************************************************************
2 **
3 **  help.c
4 **
5 **  $XConsortium: help.c /main/7 1996/04/19 15:47:41 rswiston $
6 **
7 **  RESTRICTED CONFIDENTIAL INFORMATION:
8 **
9 **  The information in this document is subject to special
10 **  restrictions in a confidential disclosure agreement between
11 **  HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
12 **  document outside HP, IBM, Sun, USL, SCO, or Univel without
13 **  Sun's specific written approval.  This document and all copies
14 **  and derivative works thereof must be returned or destroyed at
15 **  Sun's request.
16 **
17 **  Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
18 **
19 *******************************************************************************/
20
21 /*                                                                      *
22  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
23  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
24  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
25  * (c) Copyright 1993, 1994 Novell, Inc.                                *
26  */
27
28 #ifndef lint
29 static char sccsid[] = "@(#)help.c 1.19 95/03/28 Copyr 1991 Sun Microsystems, Inc.";
30 #endif
31
32 #include <EUSCompat.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <sys/stat.h>
36 #include <sys/param.h> /* MAXPATHLEN defined here */
37 #ifdef SVR4
38 #include <sys/utsname.h> /* SYS_NMLN */
39 #endif /* SVR4 specific includes */
40 #include <dirent.h>
41 #include <ctype.h>
42 #include <string.h>
43 #include <sys/time.h>
44 #include <sys/signal.h>
45 #include <rpc/rpc.h>
46 #include <sys/resource.h>
47 #include <sys/wait.h>
48 #include <netinet/in.h>
49 #include <X11/Xlib.h>
50 #include <Xm/Xm.h>
51 #include <Xm/Form.h>
52 #include <Xm/LabelG.h>
53 #include <Xm/List.h>
54 #include <Xm/DialogS.h>
55 #include <Xm/PushBG.h>
56 #include <Xm/RowColumn.h>
57 #include <Xm/Scale.h>
58 #include <Xm/SeparatoG.h>
59 #include <Xm/TextF.h>
60 #include <Xm/Text.h>
61 #include <Xm/ToggleB.h>
62 #include <Xm/ToggleBG.h>
63 #include <Dt/HourGlass.h>
64 #include <Dt/HelpDialog.h>
65 #include "calendar.h"
66 #include "revision.h"
67 #include "help.h"
68 #include "props_pu.h"
69
70 static void display_help(Calendar *, ArgList, int);
71
72 static void
73 display_help(Calendar *c, ArgList args, int nargs)
74 {
75   if (!c->mainhelpdialog)
76   {
77     Arg oneArg;
78     char *title = XtNewString(catgets(c->DT_catd, 1, 1076, "Calendar : Help"));
79
80     XtSetArg(oneArg, XmNtitle, title);
81     c->mainhelpdialog =
82       (Widget)DtCreateHelpDialog(c->frame, "mainhelpdialog", &oneArg, 1);
83     XtFree(title);
84   }
85
86   XtSetValues(c->mainhelpdialog, args, nargs);
87   XtManageChild(c->mainhelpdialog);
88 }
89
90 void show_main_help(Widget w, XtPointer clientData, XtPointer cbs)
91 {
92         int             ac;
93         Arg             al[10];
94         Calendar        *c = calendar;
95         Props_pu        *p = (Props_pu *) c->properties_pu;
96         Widget          selWidget = NULL;
97         int             status = DtHELP_SELECT_ERROR;
98  
99         ac = 0;
100         XtSetArg(al[ac], DtNhelpType, DtHELP_TYPE_TOPIC); ac++;
101         switch ((int)clientData) {
102             case HELP_OVERVIEW:
103                 XtSetArg(al[ac], DtNhelpVolume, "Calendar"); ac++;
104                 XtSetArg(al[ac], DtNlocationId, "_HOMETOPIC"); ac++;
105                 break;
106             case HELP_USINGHELP:
107                 XtSetArg(al[ac], DtNhelpVolume, "Help4Help"); ac++;
108                 XtSetArg(al[ac], DtNlocationId, "_HOMETOPIC"); ac++;
109                 break;
110             case HELP_TASKS:
111                 XtSetArg(al[ac], DtNhelpVolume, "Calendar"); ac++;
112                 XtSetArg(al[ac], DtNlocationId, "TASKS"); ac++;
113                 break;
114             case HELP_REFERENCE:
115                 XtSetArg(al[ac], DtNhelpVolume, "Calendar"); ac++;
116                 XtSetArg(al[ac], DtNlocationId, "REFERENCE"); ac++;
117                 break;
118             case HELP_ABOUTCALENDAR:
119                 XtSetArg(al[ac], DtNhelpVolume, "Help4Help"); ac++;
120                 XtSetArg(al[ac], DtNlocationId, "_COPYRIGHT"); ac++;
121                 break;
122             case HELP_TOC:
123                 XtSetArg(al[ac], DtNhelpVolume, "Calendar"); ac++;
124                 XtSetArg(al[ac], DtNlocationId, "TOC"); ac++;
125                 break;
126             case HELP_ONITEM:
127                while (!XtIsSubclass(w, applicationShellWidgetClass))
128                    w = XtParent(w);
129  
130                status = DtHelpReturnSelectedWidgetId(w, NULL, &selWidget);     
131                switch ((int)status)
132                   {
133                     case DtHELP_SELECT_ERROR:
134                       printf(catgets(c->DT_catd, 1, 350, "Selection Error, cannot continue\n"));
135                     break;
136                     case DtHELP_SELECT_VALID:
137                       while (selWidget != NULL)
138                         {
139                           if ((XtHasCallbacks(selWidget, XmNhelpCallback)                                            == XtCallbackHasSome))
140                             {
141                                XtCallCallbacks((Widget)selWidget,
142                                                XmNhelpCallback,NULL);
143                                break;
144                             }
145                           else
146                            selWidget = XtParent(selWidget);
147                         }
148                     break;
149                     case DtHELP_SELECT_ABORT:
150                       return;
151
152                     case DtHELP_SELECT_INVALID:
153                       {
154                         char *title = XtNewString(catgets(c->DT_catd, 1, 110, "Calendar : Error - Help"));
155                         char *text = XtNewString(catgets(c->DT_catd, 1, 352, "You must select a component within your application."));
156                         char *ident1 = XtNewString(catgets(c->DT_catd, 1, 95, "Continue"));
157                         dialog_popup(c->frame,
158                                      DIALOG_TITLE, title,
159                                      DIALOG_TEXT, text,
160                                      BUTTON_IDENT, 1, ident1,
161                                      DIALOG_IMAGE, p->xm_error_pixmap,
162                                      NULL);
163                         XtFree(ident1);
164                         XtFree(text);
165                         XtFree(title);
166                         return;
167                       }
168                   }
169  
170                break;
171  
172             default:
173                 XtSetArg(al[ac], DtNhelpVolume, "Calendar"); ac++;
174                 XtSetArg(al[ac], DtNlocationId, "_HOMETOPIC"); ac++;
175                 break;
176         }
177
178         display_help(c, al, ac);
179 }
180
181 extern void
182 help_cb(Widget w, XtPointer clientData, XtPointer callData)
183 {
184         int ac;
185         Arg al[10];
186         Calendar *c = calendar;
187         char *locationid = (char *) clientData;
188
189         ac = 0;
190         XtSetArg(al[ac], DtNhelpType, DtHELP_TYPE_TOPIC); ac++;
191         XtSetArg(al[ac], DtNhelpVolume, "Calendar"); ac++;
192         XtSetArg(al[ac], DtNlocationId, locationid); ac++;
193
194         display_help(c, al, ac);
195 }
196
197 /* special case where we must determine the view */
198 extern void
199 help_view_cb(Widget w, XtPointer clientData, XtPointer callData)
200 {
201         Calendar *c = calendar;
202
203         switch (c->view->glance) {
204                 case dayGlance:
205                         help_cb(w, (XtPointer)CALENDAR_HELP_DAY_WINDOW, callData);
206                         break;
207                 case weekGlance:
208                         help_cb(w, (XtPointer)CALENDAR_HELP_WEEK_WINDOW, callData);
209                         break;
210                 case monthGlance:
211                         help_cb(w, (XtPointer)CALENDAR_HELP_MONTH_WINDOW, callData);
212                         break;
213                 default:
214                         break;
215         }
216 }