libdthelp: resolve 46 compiler warnings
[oweals/cde.git] / cde / lib / DtHelp / HelpDialog.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: HelpDialog.c /main/16 1996/11/22 12:24:49 cde-hp $ */
24 /************************************<+>*************************************
25  ****************************************************************************
26  **
27  **   File:        HelpDialog.c
28  **
29  **   Project:     Cde Help 1.0 Project
30  **
31  **   Description: 
32  ** 
33  **  (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
34  **
35  **  (c) Copyright 1993, 1994 Hewlett-Packard Company
36  **  (c) Copyright 1993, 1994 International Business Machines Corp.
37  **  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
38  **  (c) Copyright 1993, 1994 Novell, Inc.
39  **
40  ****************************************************************************
41  ************************************<+>*************************************/
42
43 #include <stdio.h>
44 #include <signal.h>
45 #include <unistd.h>  /* R_OK */
46
47 #include <X11/Intrinsic.h>
48 #include <X11/Shell.h>
49 #include <X11/Xatom.h>
50
51 /* These includes work in R4 and R5 */
52 #include <Xm/MwmUtil.h>
53 #include <Xm/Protocols.h>
54 #include <Xm/RepType.h>
55 #include <Xm/XmP.h>
56 #include <Xm/ScrolledW.h>
57 #include <Xm/DialogS.h>
58 #include <Xm/PanedW.h>
59 #include <Xm/List.h>
60 #include <Xm/RowColumnP.h>
61 #include <Xm/LabelG.h>
62 #include <Xm/Label.h>
63 #include <Xm/PushB.h>
64 #include <Xm/PushBG.h>
65 #include <Xm/SeparatoG.h>
66 #include <Xm/CascadeB.h>
67 #include <Xm/CascadeBG.h>
68
69 /* Copied from Xm/GeoUtilsI.h */
70 extern XmGeoMatrix _XmGeoMatrixAlloc( 
71                         unsigned int numRows,
72                         unsigned int numBoxes,
73                         unsigned int extSize) ;
74
75 /* Canvas Engine */
76 #include "CanvasP.h" /* for AccessI.h */
77
78 /* Help Dialog Widget Includes */
79 #include "Access.h"
80 #include "bufioI.h"
81 #include "AccessI.h"
82 #include "ActionsI.h"
83 #include "DisplayAreaI.h"
84
85 #include <Dt/Help.h>
86 #include "HelpI.h"
87 #include "HelpP.h"
88 #include "StringFuncsI.h"
89 #include "HelposI.h"
90 #include "HelpDialog.h"
91 #include "HelpDialogI.h"
92 #include "HelpDialogP.h"
93 #include "HistoryI.h"
94 #include "HelpUtilI.h"
95 #include "PathAreaI.h"
96 #include "HelpAccessI.h"
97 #include "HourGlassI.h"
98 #include "HyperTextI.h"
99 #include "FileUtilsI.h"
100 #include "Lock.h"
101
102 /* search dialogs */
103 #include "GlobSearchI.h"
104
105 /* print dialogs */
106 #include "PrintI.h"
107
108 /* Error Messages Includes */
109 #include "MessagesP.h"
110
111 /* Quick Help Widget Inlcudes */
112 #include "HelpQuickD.h"
113
114 /* Display Area Includes */
115 #include "XUICreateI.h"
116 #include "CallbacksI.h"
117 #include "DestroyI.h"
118 #include "FormatI.h"
119 #include "FormatManI.h"
120 #include "SetListI.h"
121 #include "ResizeI.h"
122
123
124 /*********** Global Variables **********/
125
126 /******** Messages *********/
127 /* Help Dialog Error message Defines */
128
129 #define HDMessage0      _DtHelpMsg_0000
130 #define HDMessage1      _DtHelpMsg_0001
131 #define HDMessage2      _DtHelpMsg_0002
132 #define HDMessage3      _DtHelpMsg_0003
133 #define HDMessage4      _DtHelpMsg_0004
134 #define HDMessage5      _DtHelpMsg_0005
135 #define HDMessage6      _DtHelpMsg_0006
136 #define HDMessage7      _DtHelpMsg_0007
137 #define HDMessage8      _DtHelpMsg_0008
138 #define HDMessage9      _DtHelpMsg_0009
139
140 \f
141 /********    Static Function Declarations    ********/
142
143 static void NavigationTypeDefault( 
144                         Widget widget,
145                         int offset,
146                         XrmValue *value) ;
147
148 static void ClassPartInitialize( 
149                         WidgetClass wc) ;
150 static void ClassInitialize( 
151                         void) ;
152 static void Initialize( 
153                         Widget rw,
154                         Widget nw,
155                         ArgList args,
156                         Cardinal *num_args);
157
158 static void Destroy(
159                         Widget w );
160 static Boolean SetValues( 
161                         Widget cw,
162                         Widget rw,
163                         Widget nw,
164                         ArgList args,
165                         Cardinal *num_args);
166 static void CloseHelpCB (
167                         Widget w,
168                         XtPointer clientData,
169                         XtPointer callData);
170 static void BuildDisplayArea(
171                         Widget parent,
172                         DtHelpDialogWidget nw);
173 static void ProcessJumpBack(
174                         DtHelpDialogWidget nw);
175 static void VariableInitialize(
176                         DtHelpDialogWidget nw);
177 static void CleanUpHelpDialog(
178                         Widget nw,
179                         int cleanUpKind);
180 static void CatchClose(Widget widget);
181 static void  DisplayTopLevelCB(
182                         Widget w,
183                         XtPointer client_data,
184                         XtPointer call_data );
185 static void  CopyTextCB(
186                         Widget w,
187                         XtPointer clientData,
188                         XtPointer callData );
189 static void  DisplayPrintCB(
190                         Widget w,
191                         XtPointer client_data,
192                         XtPointer call_data );
193 static void  ProcessBMenuBackCB(
194                         Widget w,
195                         XtPointer clientData,
196                         XButtonEvent * event,
197                         Boolean *continueToDispatch);
198 static void  ProcessJumpReuse(
199                         Widget nw,
200                         DtHelpHyperTextStruct *hyperData);
201 static Widget SetupHelpDialogMenus(
202                         Widget parent);
203 static Widget CreatePopupMenu(
204                         Widget parent);
205 static void ResizeHelpDialogCB (
206                         XtPointer clientData);
207 static void InitialPopupCB(
208                         Widget w,
209                         XtPointer clientData,
210                         XtPointer callData);
211
212
213 /********    End Static Function Declarations    ********/
214
215
216
217 /* Static variables */
218 \f
219 /* Supported resources for the HelpDialog Widget */
220
221 static XtResource resources[] = {
222    
223     {   DtNshowNewWindowButton,
224         DtCShowNewWindowButton,
225         XmRBoolean,
226         sizeof(Boolean),
227         XtOffset (DtHelpDialogWidget, help_dialog.menu.showDupBtn),
228         XmRImmediate,
229         (XtPointer) False
230     },
231
232     {   DtNshowTopLevelButton,
233         DtCShowTopLevelButton,
234         XmRBoolean,
235         sizeof(Boolean),
236         XtOffset (DtHelpDialogWidget, help_dialog.browser.showTopLevelBtn),
237         XmRImmediate,
238         (XtPointer) False
239     },
240
241     {
242         DtNscrollBarPolicy,
243         DtCScrollBarPolicy, DtRDtScrollBarPolicy, sizeof (unsigned char),
244         XtOffset (DtHelpDialogWidget, help_dialog.display.scrollBarPolicy),
245         XmRImmediate,  (XtPointer) DtHELP_AS_NEEDED_SCROLLBARS
246     },
247
248     {
249         DtNexecutionPolicy,
250         DtCExecutionPolicy, DtRDtExecutionPolicy, sizeof (unsigned char),
251         XtOffset (DtHelpDialogWidget, help_dialog.display.executionPolicy),
252         XmRImmediate,  (XtPointer) DtHELP_EXECUTE_QUERY_UNALIASED
253     },
254
255     {   DtNcolumns, 
256         DtCColumns, XmRShort, sizeof(short), 
257         XtOffset (DtHelpDialogWidget, help_dialog.display.textColumns), 
258         XmRImmediate, (XtPointer) 70
259      },
260     
261      {  DtNrows, 
262         DtCRows, XmRShort, sizeof(short), 
263         XtOffset (DtHelpDialogWidget, help_dialog.display.textRows), 
264         XmRImmediate, (XtPointer) 25
265      },
266      
267      {  DtNmarginWidth, 
268         DtCMarginWidth, XmRHorizontalDimension, sizeof (Dimension),
269         XtOffset (DtHelpDialogWidget, help_dialog.ghelp.marginWidth), 
270         XmRImmediate, (XtPointer) 1
271      },
272
273      {  DtNmarginHeight, 
274         DtCMarginHeight, XmRVerticalDimension, sizeof (Dimension),
275         XtOffset (DtHelpDialogWidget, help_dialog.ghelp.marginHeight), 
276         XmRImmediate, (XtPointer) 4
277      },
278
279     {   DtNvisiblePathCount, 
280         DtCVisiblePathCount, XmRInt, sizeof(int), 
281         XtOffset (DtHelpDialogWidget, help_dialog.browser.visiblePathCount), 
282         XmRImmediate, (XtPointer) 7
283      },
284
285      {  DtNlocationId, 
286         DtCLocationId, XmRString, sizeof (char*), 
287         XtOffset (DtHelpDialogWidget, help_dialog.display.locationId), 
288         XmRImmediate, (XtPointer) _DtHelpDefaultLocationId
289       }, 
290
291      {  DtNhelpPrint, 
292         DtCHelpPrint, XmRString, sizeof (char*), 
293         XtOffset (DtHelpDialogWidget, help_dialog.print.helpPrint), 
294         XmRImmediate, (XtPointer) _DtHelpDefaultHelpPrint
295       }, 
296
297      {  DtNprinter, 
298         DtCPrinter, XmRString, sizeof (char*), 
299         XtOffset (DtHelpDialogWidget, help_dialog.print.printer), 
300         XmRImmediate, (XtPointer) NULL
301       }, 
302
303      {  DtNpaperSize, 
304         DtCPaperSize, DtRDtPaperSize, sizeof (unsigned char), 
305         XtOffset (DtHelpDialogWidget, help_dialog.print.paperSize), 
306         XmRImmediate, (XtPointer) DtHELP_PAPERSIZE_LETTER
307       }, 
308
309      {  DtNsrchHitPrefixFont, 
310         DtCSrchHitPrefixFont, XmRString, sizeof (char *), 
311         XtOffset (DtHelpDialogWidget, help_dialog.srch.hitPrefixFont), 
312         XmRImmediate, (XtPointer) _DtHelpDefaultSrchHitPrefixFont
313       }, 
314
315      {  DtNhelpVolume, 
316         DtCHelpVolume, XmRString, sizeof (char*), 
317         XtOffset (DtHelpDialogWidget, help_dialog.display.helpVolume), 
318         XmRImmediate, (XtPointer) NULL
319       }, 
320
321       { DtNmanPage, 
322         DtCManPage, XmRString, sizeof (char*), 
323         XtOffset (DtHelpDialogWidget, help_dialog.display.manPage), 
324         XmRImmediate, (XtPointer) NULL
325       }, 
326
327       { DtNstringData, 
328         DtCStringData, XmRString, sizeof (char*), 
329         XtOffset (DtHelpDialogWidget, help_dialog.display.stringData), 
330         XmRImmediate, (XtPointer) NULL
331       }, 
332
333       { DtNhelpFile, 
334         DtCHelpFile, XmRString, sizeof (char*), 
335         XtOffset (DtHelpDialogWidget, help_dialog.display.helpFile), 
336         XmRImmediate, (XtPointer) NULL
337       }, 
338
339       { DtNtopicTitle, 
340         DtCTopicTitle, XmRString, sizeof (char*), 
341         XtOffset (DtHelpDialogWidget, help_dialog.display.topicTitleStr), 
342         XmRImmediate, (XtPointer) NULL
343       }, 
344
345       { DtNhelpOnHelpVolume, 
346         DtCHelpOnHelpVolume, XmRString, sizeof (char*), 
347         XtOffset (DtHelpDialogWidget, help_dialog.help.helpOnHelpVolume), 
348         XmRImmediate, (XtPointer) _DtHelpDefaultHelp4HelpVolume
349       }, 
350
351       { DtNhelpType, 
352         DtCHelpType, DtRDtHelpType, sizeof(unsigned char), 
353         XtOffset (DtHelpDialogWidget, help_dialog.display.helpType), 
354         XmRImmediate, (XtPointer) DtHELP_TYPE_TOPIC
355       },
356
357       { DtNhyperLinkCallback, 
358         DtCHyperLinkCallback, XmRCallback, sizeof (XtCallbackList), 
359         XtOffset (DtHelpDialogWidget, help_dialog.display.hyperLinkCallback), 
360         XmRImmediate, (XtPointer) NULL
361       }, 
362     
363       { DtNcloseCallback, 
364         DtCCloseCallback, XmRCallback, sizeof (XtCallbackList), 
365         XtOffset (DtHelpDialogWidget, help_dialog.ghelp.closeCallback), 
366         XmRImmediate, (XtPointer) NULL
367       },
368
369       { XmNnavigationType, XmCNavigationType, XmRNavigationType,
370         sizeof(unsigned char),
371         XtOffsetOf (XmManagerRec, manager.navigation_type),
372         XmRCallProc, (XtPointer) NavigationTypeDefault
373       },
374
375 };
376
377 /*
378  * attach the action list to the widget. Then it does not
379  * matter which Xt[App]Initialize an application does.
380  */
381 static XtActionsRec DrawnBActions[] =
382     {
383         {"DeSelectAll"    , _DtHelpDeSelectAll    },
384         {"SelectAll"      , _DtHelpSelectAll      },
385         {"ActivateLink"   , _DtHelpActivateLink   },
386         {"CopyToClipboard", _DtHelpCopyAction     },
387         {"PageUpOrDown"   , _DtHelpPageUpOrDown   },
388         {"PageLeftOrRight", _DtHelpPageLeftOrRight},
389         {"NextLink"       , _DtHelpNextLink       }
390     };
391
392
393 \f
394 /****************************************************************
395  *
396  * Full class record constant
397  *
398  ****************************************************************/
399
400 externaldef( dthelpdialogwidgetclassrec) DtHelpDialogWidgetClassRec dtHelpDialogWidgetClassRec =
401 {
402    {                                            /* core_class fields  */
403       (WidgetClass) &xmBulletinBoardClassRec,   /* superclass         */
404       "DtHelpDialog",                           /* class_name         */
405       sizeof(DtHelpDialogWidgetRec),            /* widget_size        */
406       ClassInitialize,                          /* class_initialize   */
407       ClassPartInitialize,                      /* class_part_init    */
408       FALSE,                                    /* class_inited       */
409       Initialize,                               /* initialize         */
410       NULL,                                     /* initialize_hook    */
411       XtInheritRealize,                         /* realize            */
412       DrawnBActions,                            /* actions            */
413       XtNumber(DrawnBActions),                  /* num_actions        */
414       resources,                                /* resources          */
415       XtNumber(resources),                      /* num_resources      */
416       NULLQUARK,                                /* xrm_class          */
417       TRUE,                                     /* compress_motion    */
418       XtExposeCompressMaximal,                  /* compress_exposure  */
419       FALSE,                                    /* compress_enterlv   */
420       FALSE,                                    /* visible_interest   */
421       Destroy,                                  /* destroy            */
422       XtInheritResize,                          /* resize             */
423       XtInheritExpose,                          /* expose             */
424       SetValues,                                /* set_values         */
425       NULL,                                     /* set_values_hook    */
426       XtInheritSetValuesAlmost,                 /* set_values_almost  */
427       NULL,                                     /* get_values_hook    */
428       XtInheritAcceptFocus,                     /* enter_focus        */
429       XtVersion,                                /* version            */
430       NULL,                                     /* callback_private   */
431       XtInheritTranslations,                    /* tm_table           */
432       XtInheritQueryGeometry,                   /* query_geometry     */
433       NULL,                                     /* display_accelerator*/
434       NULL,                                     /* extension          */
435    },
436
437    {                                            /* composite_class fields */
438       XtInheritGeometryManager,                 /* geometry_manager   */
439       XtInheritChangeManaged,                   /* change_managed     */
440       XtInheritInsertChild,                     /* insert_child       */
441       XtInheritDeleteChild,                     /* delete_child       */
442       NULL,                                     /* extension          */
443    },
444
445    {                                            /* constraint_class fields */
446       NULL,                                     /* resource list        */   
447       0,                                        /* num resources        */   
448       0,                                        /* constraint size      */   
449       NULL,                                     /* init proc            */   
450       NULL,                                     /* destroy proc         */   
451       NULL,                                     /* set values proc      */   
452       NULL,                                     /* extension            */
453    },
454
455    {                                            /* manager_class fields   */
456       XmInheritTranslations,                    /* translations           */
457       NULL,                                     /* syn_resources          */
458       0,                                        /* num_syn_resources      */
459       NULL,                                     /* syn_cont_resources     */
460       0,                                        /* num_syn_cont_resources */
461       XmInheritParentProcess,                   /* parent_process         */
462       NULL,                                     /* extension              */
463    },
464
465    {                                            /* bulletinBoard class  */
466       TRUE,                                     /*always_install_accelerators*/
467       _DtHelpDialogWidgetGeoMatrixCreate,      /* geo__matrix_create */
468       XmInheritFocusMovedProc,                  /* focus_moved_proc */
469       NULL                                      /* extension */
470    },   
471
472    {                                            /* messageBox class - none */
473       0                                         /* mumble */
474    }    
475 };
476
477 externaldef( dthelpdialogwidgetclass) WidgetClass dtHelpDialogWidgetClass
478                                 = (WidgetClass) &dtHelpDialogWidgetClassRec;
479
480 static char *HelpTypeNames[] =
481 {   "help_type_topic", 
482     "help_type_string",
483     "help_type_man_page",
484     "help_type_file",
485     "help_type_dynamic_string"
486 };
487
488 static char *ScrollBarValueNames[] =
489 {   "help_no_scrollbars",
490     "help_static_scrollbars", 
491     "help_as_needed_scrollbars"
492 };
493
494 static char *ExecutionValueNames[] =
495 {   "help_execute_none",
496     "help_execute_query_all",
497     "help_execute_query_unaliased",
498     "help_execute_all"
499 };
500
501 /* the _DtHelpPaperSizeNames[] are in Print.c */
502
503 #define NUM_NAMES( list )        (sizeof( list) / sizeof( char *))
504
505
506
507
508 \f
509 /*********************************************************************
510  *
511  * NavigationTypeDefault
512  *    
513  *
514  *********************************************************************/
515 static void 
516 NavigationTypeDefault(
517         Widget widget,
518         int offset,             /* unused */
519         XrmValue *value )
520 {
521     static XmNavigationType navigation_type;
522     Widget parent = XtParent(widget) ;
523
524     value->addr = (XPointer) &navigation_type;
525     if (XtIsShell(parent)) {
526         navigation_type = XmSTICKY_TAB_GROUP;
527     } else {
528         navigation_type = XmTAB_GROUP;
529     }
530       
531 }
532
533
534 /*****************************************************************************
535  * Function:        static void ClassInitialize (
536  *                      void)
537  *
538  * Parameters:      Void.
539  *
540  *
541  * Return Value:    Void.
542  *
543  * Purpose:   Register our representation types here 
544  *
545  *****************************************************************************/
546 static void ClassInitialize(void)
547 {
548   XmRepTypeId checkId;
549
550     /* First check to see if these have already been registered */
551      checkId = XmRepTypeGetId(DtRDtScrollBarPolicy);
552
553     if (checkId == XmREP_TYPE_INVALID)
554       {
555         /* Register the help representation types here */
556    
557         XmRepTypeRegister(DtRDtHelpType, HelpTypeNames, NULL,
558                                       NUM_NAMES(HelpTypeNames)) ;
559         XmRepTypeRegister(DtRDtScrollBarPolicy, ScrollBarValueNames, NULL,
560                                       NUM_NAMES(ScrollBarValueNames)) ;
561         XmRepTypeRegister(DtRDtExecutionPolicy, ExecutionValueNames, NULL,
562                                       NUM_NAMES(ExecutionValueNames)) ;
563         XmRepTypeRegister(DtRDtPaperSize, _DtHelpPaperSizeNames, NULL,
564                                       _DtHelpPaperSizeNamesCnt) ;
565       }
566
567     return ;
568 }
569
570
571 \f
572 /*****************************************************************************
573  * Function:        static void ClassPartInitialize (
574  *                      WidgetClass widgetClass)
575  *
576  * Parameters:      WidgetClass      
577  *
578  *
579  * Return Value:    Void.
580  *
581  * Purpose:         
582  *
583  *****************************************************************************/
584 static void ClassPartInitialize(
585     WidgetClass widgetClass)
586 {
587
588    return ;
589 }
590  
591
592
593  
594 \f
595 /*****************************************************************************
596  * Function:        static void VariableInitialize()
597  *                      
598  *
599  * Return Value:    Void.
600  *
601  * Purpose:         This routine initializes all global variables to valid
602  *                  starting values.
603  *
604  *****************************************************************************/
605 static void VariableInitialize(
606 DtHelpDialogWidget nw)
607 {
608
609   DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
610
611   /* Set our current topic variables to initial values */
612   _DtHelpCommonHelpInit(&hw->help_dialog.help);
613
614   /* Make local copies of all resource strings assigned by the user */
615   if (hw->help_dialog.display.locationId != NULL)
616     hw->help_dialog.display.locationId = XtNewString(hw->help_dialog.display.locationId);
617   if (hw->help_dialog.display.helpVolume != NULL)
618      hw->help_dialog.display.helpVolume = XtNewString(hw->help_dialog.display.helpVolume);
619   if (hw->help_dialog.display.manPage != NULL)
620     hw->help_dialog.display.manPage = XtNewString(hw->help_dialog.display.manPage);
621   if (hw->help_dialog.display.stringData != NULL)
622     hw->help_dialog.display.stringData = XtNewString(hw->help_dialog.display.stringData);
623   if (hw->help_dialog.display.helpFile != NULL)
624     hw->help_dialog.display.helpFile = XtNewString(hw->help_dialog.display.helpFile);
625
626   /*
627    * Initialize the topic title variables.
628    */
629   hw->help_dialog.display.count = 1;            
630   hw->help_dialog.display.topicTitleLbl = NULL;
631   if (hw->help_dialog.display.topicTitleStr != NULL)
632     hw->help_dialog.display.topicTitleStr =
633                         XtNewString(hw->help_dialog.display.topicTitleStr);
634   else
635     hw->help_dialog.display.topicTitleStr =
636                         XtNewString((char *)_DTGETMESSAGE(2, 70,
637                                                 "Nonexistent Topic Title."));
638   /*
639    * create the XmString version
640    */
641   if (hw->help_dialog.display.topicTitleStr != NULL)
642     hw->help_dialog.display.topicTitleLbl = XmStringCreateLocalized(
643                                         hw->help_dialog.display.topicTitleStr);
644
645   if (hw->help_dialog.print.printer != NULL)
646     hw->help_dialog.print.printer = XtNewString(hw->help_dialog.print.printer);
647
648   if (hw->help_dialog.print.helpPrint != _DtHelpDefaultHelpPrint)
649     hw->help_dialog.print.helpPrint = XtNewString(hw->help_dialog.print.helpPrint);
650
651
652   hw->bulletin_board.auto_unmanage  = FALSE;
653   hw->bulletin_board.resize_policy  = XmRESIZE_NONE;
654  
655
656   /* Setup some of our generic widget variables */
657   hw->help_dialog.print.printVolume = NULL;
658
659
660   /* Set our volume handle to an NULL initial value */
661   hw->help_dialog.display.volumeHandle       = NULL;
662   hw->help_dialog.ghelp.volumeFlag         = FALSE;
663
664   _DtHelpGlobSrchInitVars(&hw->help_dialog.srch);
665
666
667   /* Set our print display stuff to initial values */
668   hw->help_dialog.print.printForm      = NULL;
669
670   /* Set our map flag: true after we hit our popup callback, 
671    * false otherwise
672    */
673   hw->help_dialog.display.firstTimePopupFlag = FALSE;
674
675   
676   /* Set our history display stuff to initial vlaues */
677   hw->help_dialog.history.historyWidget     = NULL;
678   hw->help_dialog.history.volumeList = NULL;
679   hw->help_dialog.history.topicList  = NULL;
680   hw->help_dialog.history.pHistoryListHead  = NULL;
681
682   /* Set our path display stuff to initial values */
683   hw->help_dialog.history.pPathListHead     = NULL; 
684   hw->help_dialog.history.pPathListTale     = NULL;
685   hw->help_dialog.history.totalPathNodes    = 0;
686
687   /* Set our jump list display stuff to initial values */
688   hw->help_dialog.backtr.pJumpListHead     = NULL;
689   hw->help_dialog.backtr.pJumpListTale     = NULL;
690   hw->help_dialog.backtr.totalJumpNodes    = 0;
691   hw->help_dialog.backtr.scrollPosition    = -1;
692   /* Set our help dialog widgets to NULL starting values */
693   hw->help_dialog.menu.menuBar        = NULL;
694   hw->help_dialog.browser.panedWindow    = NULL;
695   hw->help_dialog.browser.pathArea       = NULL;
696   hw->help_dialog.menu.topBtn         = NULL;
697   hw->help_dialog.menu.popupTopBtn    = NULL;
698   hw->help_dialog.menu.keyBtn         = NULL;
699   hw->help_dialog.menu.backBtn        = NULL;
700   hw->help_dialog.menu.popupBackBtn   = NULL;
701   hw->help_dialog.menu.historyBtn     = NULL;
702   hw->help_dialog.menu.printBtn       = NULL;
703   hw->help_dialog.menu.closeBtn       = NULL;
704   hw->help_dialog.menu.helpBtn        = NULL;
705   hw->help_dialog.ghelp.definitionBox  = NULL;
706   hw->help_dialog.menu.newWindowBtn  = NULL;
707
708
709   hw->help_dialog.browser.btnBoxBackBtn    = NULL;
710   hw->help_dialog.browser.btnBoxHistoryBtn = NULL;
711   hw->help_dialog.browser.btnBoxIndexBtn   = NULL;
712  
713   /* Set our parentId to a null starting value */
714   hw->help_dialog.ghelp.parentId       = NULL;
715 }
716
717 \f
718 /*****************************************************************************
719  * Function:        static void Initialize (
720  *                      WidgetClass widgetClass)
721  *
722  * Parameters:      WidgetClass      
723  *
724  *
725  * Return Value:    Void.
726  *
727  * Purpose:         This is the Help Dialog widget initialize routine. This
728  *                  routine is responsible for the following:
729  *                      1) Validate all resources the user passed in.
730  *                      2) Over ride any invalid resources.
731  *                      3) Build the internal UI component for the Help Dialog.
732  *                      4) Add any internal callbacks for the UI components.
733  *
734  *****************************************************************************/
735 static void Initialize(
736     Widget rw,
737     Widget nw,
738     ArgList args_init,
739     Cardinal *num_args)
740 {
741
742   Arg           args[10];       /*  arg list            */
743   int           n;              /*  arg count           */
744   DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
745
746   /* Local variables */
747   DtHelpListStruct *pHelpInfo;
748  
749   /* Initialize all global variables */
750   VariableInitialize(hw);
751
752
753   /* Validate the incomming arguments to make sure they are ok */
754
755
756   /* Build the Menus bar */
757   hw->help_dialog.menu.menuBar = SetupHelpDialogMenus((Widget)hw);
758
759
760   /* Build the Paned Window to hold the path area and display area */
761   n = 0;
762   XtSetArg (args[n], XmNspacing, 10);  ++n;
763   hw->help_dialog.browser.panedWindow = 
764                  XmCreatePanedWindow ((Widget)hw, "panedWindow", args, n);
765   XtManageChild (hw->help_dialog.browser.panedWindow);
766
767
768   /* Call the setup routine to build the actual path area */
769   _DtHelpBuildPathArea(hw->help_dialog.browser.panedWindow, hw);
770
771
772   /* Force our keyboard traversal to start within the path area */
773   /*
774    * NOTE 04/25/96 : pathArea is NOT set by _DtHelpBuildPathArea().
775    * The test for NULL is a work-around for defect CDExc20246; but
776    * the proper widget should be given to XmProcessTraversal() someday.
777    */
778   if (hw->help_dialog.browser.pathArea != (Widget)NULL)
779     XmProcessTraversal(hw->help_dialog.browser.pathArea, XmTRAVERSE_HOME);
780
781   /* We build our display area last because we need the other UI 
782    * components created first.
783    */
784   
785   /* Call the setup routine to build the display area */
786   BuildDisplayArea(hw->help_dialog.browser.panedWindow, hw);
787  
788   
789   /* Add the proper help callback to the top level shell of our dialog */
790
791   /* Add all our help callbacks for each of the created widgets */
792   pHelpInfo = _DtHelpListAdd(DtHELP_dialogShell_STR,
793                          (Widget) hw, &hw->help_dialog.help,
794                         &hw->help_dialog.help.pHelpListHead);
795   XtAddCallback((Widget) hw, XmNhelpCallback,
796                  _DtHelpCB, (XtPointer) pHelpInfo);
797
798
799    /* Just for fun, lets make sure our sizes are correct */
800    XtAddCallback (XtParent(hw), XmNpopupCallback, (XtCallbackProc)
801                  InitialPopupCB, (XtPointer) hw);
802
803
804   return;
805 }
806
807 \f
808
809 /****************************************************************************
810  * Function:        static XtCallbackProc InitialPopupCB
811  *                   
812  *                            
813  *
814  * Parameters:  
815  *
816  * Return Value:    Void.
817  *
818  * Purpose:         We do some last minute sizing of our dialog on its first
819  *                  mapping, then we remove the callback.
820  *
821  ****************************************************************************/
822 static void InitialPopupCB(
823     Widget w,
824     XtPointer clientData,
825     XtPointer callData)
826 {
827    DtHelpDialogWidget hw = (DtHelpDialogWidget) clientData;
828  
829    /* set our firstTimePopupFlag to TRUE because we map it right after
830      this call */
831    hw->help_dialog.display.firstTimePopupFlag = TRUE;
832
833   _DtHelpResizeDisplayArea (XtParent(hw),
834                              hw->help_dialog.help.pDisplayArea, 
835                              hw->help_dialog.display.textRows,
836                              hw->help_dialog.display.textColumns);
837
838   XtRemoveCallback (XtParent(hw), XmNpopupCallback, (XtCallbackProc)
839                   InitialPopupCB, (XtPointer) hw);
840
841
842 }
843
844
845
846 \f
847 /*****************************************************************************
848  * Function:        static Boolean SetValues(
849  *                             Widget cw,
850  *                             Widget rw,
851  *                             Widget nw,
852  *                             ArgList args,
853  *                             Cardinal *num_args )
854  *
855  * Parameters:      cw       Specifies the current working widget.
856  *                  rw       Specifies the replacement working widget.
857  *                  nw       Specifies the new widget.
858  *                  args     Specifies the arguments to be applied to the
859  *                           New widget.
860  *                  numArgs  Number of argument/value pars in args.
861  *
862  * Return Value:    
863  *
864  * Purpose:         Set the attributes of the Help Dialog widget.
865
866  *
867  *****************************************************************************/
868 static Boolean SetValues(
869     Widget cw,
870     Widget rw,
871     Widget nw,
872     ArgList args,
873     Cardinal *numArgs)
874 {
875   DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
876   DtHelpDialogWidget current = (DtHelpDialogWidget) cw ;
877   Boolean updateRequest=FALSE;
878   Boolean newTitle=FALSE;
879
880   /* Validate the incomming arguments to make sure they are ok */
881
882
883
884   /* Setup some initial argument values we know we need on the B-board */
885   hw->bulletin_board.auto_unmanage  = FALSE;
886   hw->bulletin_board.resize_policy  = XmRESIZE_NONE;
887
888
889   /* Check DtNcolumns & or DtNrows  resource for change */
890   if ((current->help_dialog.display.textRows != hw->help_dialog.display.textRows) ||
891       (current->help_dialog.display.textColumns != hw->help_dialog.display.textColumns))
892     {
893       /* Perform a resize on our display area */
894       _DtHelpResizeDisplayArea (XtParent(hw),
895                              hw->help_dialog.help.pDisplayArea, 
896                              hw->help_dialog.display.textRows,
897                              hw->help_dialog.display.textColumns);
898     }
899
900
901   /* Check DtNhelpVolume resource for change */
902   if (current->help_dialog.display.helpVolume != hw->help_dialog.display.helpVolume) 
903     {
904       hw->help_dialog.display.helpVolume = XtNewString(hw->help_dialog.display.helpVolume);
905       XtFree(current->help_dialog.display.helpVolume);
906
907       /* Update our volumeFlag so we know to resolve our new help volume */
908       hw->help_dialog.ghelp.volumeFlag=FALSE;
909
910       updateRequest = TRUE;
911     }
912
913
914   /* Check DtNlocationId resource for change */
915   if (current->help_dialog.display.locationId != hw->help_dialog.display.locationId) 
916     {
917       hw->help_dialog.display.locationId = XtNewString(hw->help_dialog.display.locationId);
918       XtFree(current->help_dialog.display.locationId);
919       updateRequest = TRUE;
920     }
921
922    /* set the printing resources */
923    _DtHelpPrintSetValues(&current->help_dialog.print,&hw->help_dialog.print,
924              &hw->help_dialog.display,&hw->help_dialog.help);
925
926   /* Check XmhelpOnHelpVolume resource for change */
927   if (current->help_dialog.help.helpOnHelpVolume !=
928                    hw->help_dialog.help.helpOnHelpVolume) 
929     {
930       hw->help_dialog.help.helpOnHelpVolume =
931                            XtNewString(hw->help_dialog.help.helpOnHelpVolume);
932
933       if (current->help_dialog.help.helpOnHelpVolume != _DtHelpDefaultHelp4HelpVolume)
934          XtFree(current->help_dialog.help.helpOnHelpVolume);
935     }    
936
937   /* Check DtNmanPage resource for change */
938   if (current->help_dialog.display.manPage != hw->help_dialog.display.manPage) 
939     {
940       hw->help_dialog.display.manPage = XtNewString(hw->help_dialog.display.manPage);
941       XtFree(current->help_dialog.display.manPage);
942       updateRequest = TRUE;
943       newTitle      = TRUE;
944     }
945
946
947   /* Check DtNstringData resource for change */
948   if (current->help_dialog.display.stringData != hw->help_dialog.display.stringData) 
949     {
950       hw->help_dialog.display.stringData = XtNewString(hw->help_dialog.display.stringData);
951       XtFree(current->help_dialog.display.stringData);
952       updateRequest = TRUE;
953       newTitle      = TRUE;
954     }
955
956   /* Check DtNhelpFile resource for change */
957   if (current->help_dialog.display.helpFile != hw->help_dialog.display.helpFile) 
958     {
959       hw->help_dialog.display.helpFile = XtNewString(hw->help_dialog.display.helpFile);
960       XtFree(current->help_dialog.display.helpFile);
961       updateRequest = TRUE;
962       newTitle      = TRUE;
963     }
964
965   /* Check DtNtopicTitle resource for change */
966   if (hw->help_dialog.display.topicTitleStr != NULL &&
967         current->help_dialog.display.topicTitleStr !=
968                                         hw->help_dialog.display.topicTitleStr) 
969     {
970       /*
971        * copy the string and make a XmString version.
972        */
973       hw->help_dialog.display.topicTitleStr =
974                         XtNewString(hw->help_dialog.display.topicTitleStr);
975
976       XtFree(current->help_dialog.display.topicTitleStr);
977       updateRequest = TRUE;
978       newTitle      = TRUE;
979     }
980   else if (newTitle == True)
981     {
982       /*
983        * A new file, string or man page has been specified.
984        * But XmNtopicTitle has not been set or set to null (otherwise
985        * the if stmt would have been true). Therefore, create a new
986        * title for this entry for history and topic labels.
987        */
988       int len;
989       char *str;
990
991       str = (char *)_DTGETMESSAGE(2, 70, "Nonexistent Topic Title.");
992       len = strlen(str);
993       hw->help_dialog.display.topicTitleStr = XtMalloc(sizeof(char)*(len+10));
994       if (NULL != hw->help_dialog.display.topicTitleStr)
995         {
996           sprintf(hw->help_dialog.display.topicTitleStr, "%s%d", str, 
997                   hw->help_dialog.display.count++);
998           newTitle = TRUE;
999         }
1000     }
1001
1002   /*
1003    * Turn the string into an XmString and free the old
1004    */
1005   if (newTitle == TRUE)
1006     {
1007       hw->help_dialog.display.topicTitleLbl = XmStringCreateLocalized(
1008                                         hw->help_dialog.display.topicTitleStr);
1009
1010       if (current->help_dialog.display.topicTitleLbl != NULL)
1011           XmStringFree(current->help_dialog.display.topicTitleLbl);
1012     }
1013
1014   /* Check the help type for change */
1015   if (current->help_dialog.display.helpType != hw->help_dialog.display.helpType
1016         || updateRequest)
1017     {
1018       /* Setup and display our new topic */
1019       _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_AND_JUMP);
1020     }
1021
1022
1023   return(FALSE);
1024 }
1025
1026
1027
1028
1029 \f
1030 /*****************************************************************************
1031  * Function:        static void Destroy(Widget w );
1032  *
1033  * Parameters:      w       Specifies the widget to be  destroyed.
1034  *
1035  * Return Value:    
1036  *
1037  * Purpose:         Destroy any internally malloced memory.
1038  *
1039  *****************************************************************************/
1040 static void Destroy(
1041     Widget w)
1042 {
1043    DtHelpDialogWidget hw = (DtHelpDialogWidget) w;
1044
1045      /* This routine will clean up all malloc'ed stuff in our instance 
1046       * structure.  It does not remove any callbacks or delete any of the
1047       * widgets created in this instance of the help dialog.
1048       */
1049
1050      CleanUpHelpDialog((Widget) hw, DtCLEAN_FOR_DESTROY);
1051  
1052      /* Remove any of the callbacks added to the help dialog ??? */
1053
1054
1055 }
1056
1057 \f
1058 /*****************************************************************************
1059  * Function:        static void MenuBarFix( 
1060  *                            XmGeoMatrix geoSpec,
1061  *                            int action,
1062  *                            XmGeoRowLayout layoutPtr,
1063  *                            XmKidGeometry rowPtr)
1064  *                            
1065  *                         
1066  *
1067  * Parameters:   
1068  *
1069  * Return Value:    
1070  *
1071  * Purpose:       This routine is a fixup routine which can be used for rows 
1072  *                which consist of a single MenuBar RowColumn.  The effect of
1073  *                this routine is to have the RowColumn ignore the margin
1074  *                width and height.
1075  *
1076  *****************************************************************************/
1077 static void MenuBarFix(
1078     XmGeoMatrix geoSpec,
1079     int action,
1080     XmGeoMajorLayout layoutPtr,
1081     XmKidGeometry rowPtr )
1082 {
1083     register Dimension       marginW ;
1084     register Dimension       marginH ;
1085     register Dimension       twoMarginW ;
1086
1087
1088     marginW = geoSpec->margin_w ;
1089     twoMarginW = (marginW << 1) ;
1090     marginH = geoSpec->margin_h ;
1091
1092     switch(    action    )
1093     {
1094         case XmGEO_PRE_SET:
1095         {   rowPtr->box.x -= marginW ;
1096             rowPtr->box.width += twoMarginW ;
1097             rowPtr->box.y -= marginH ;
1098             break ;
1099             }
1100         default:
1101         {   if(    rowPtr->box.width > twoMarginW    )
1102             {
1103                 /* Avoid subtracting a margin from box width which would
1104                 *   result in underflow.
1105                 */
1106                 rowPtr->box.x += marginW ;
1107                 rowPtr->box.width -= twoMarginW ;
1108                 }
1109             if(    action == XmGET_PREFERRED_SIZE    )
1110             {
1111                 /* Set width to some small value so it does not
1112                 *   effect total width of matrix.
1113                 */
1114                 rowPtr->box.width = 1 ;
1115                 }
1116             break ;
1117             }
1118         }
1119     return ;
1120
1121
1122
1123 \f
1124 /*****************************************************************************
1125  * Function:         XmGeoMatrix _DtHelpDialogWidgeGeoMatrixCreate(
1126  *                           Widget wid,
1127  *                           Widget instigator,
1128  *                           XtWidgetGeometry *desired) 
1129  *
1130  * Parameters:   
1131  *
1132  * Return Value:    
1133  *
1134  * Purpose:       This routine is responsible for all the positioning of the
1135  *                the internal Help Dialog widgets.
1136  *
1137  *****************************************************************************/
1138 XmGeoMatrix _DtHelpDialogWidgetGeoMatrixCreate(
1139     Widget wid,
1140     Widget instigator,
1141     XtWidgetGeometry *desired )
1142 {
1143  
1144
1145              DtHelpDialogWidget hw = (DtHelpDialogWidget) wid ;
1146              XmGeoMatrix     geoSpec ;
1147     register XmGeoRowLayout  layoutPtr ;
1148     register XmKidGeometry   boxPtr ;
1149
1150     geoSpec = _XmGeoMatrixAlloc( TB_MAX_WIDGETS_VERT, TB_MAX_NUM_WIDGETS, 0) ;
1151     geoSpec->composite = (Widget) hw ;
1152     geoSpec->instigator = (Widget) instigator ;
1153     if(    desired    )
1154     {   geoSpec->instig_request = *desired ;
1155         } 
1156     geoSpec->margin_w = hw->help_dialog.ghelp.marginWidth
1157                         + hw->manager.shadow_thickness ;
1158     geoSpec->margin_h = hw->help_dialog.ghelp.marginHeight
1159                         + hw->manager.shadow_thickness ;
1160     geoSpec->no_geo_request = _DtHelpDialogWidgetNoGeoRequest ;
1161
1162     layoutPtr = (XmGeoRowLayout) geoSpec->layouts ;
1163     boxPtr = geoSpec->boxes ;
1164
1165     /* Menubar setup stuff */
1166       if( _XmGeoSetupKid( boxPtr, hw->help_dialog.menu.menuBar))
1167        {   
1168          layoutPtr->fix_up = MenuBarFix;
1169          boxPtr += 2;     
1170           ++layoutPtr; 
1171        } 
1172      
1173     
1174     /* Display area setup stuff */
1175     if( _XmGeoSetupKid(boxPtr, hw->help_dialog.browser.panedWindow))
1176     {   
1177         layoutPtr->space_above = 0;
1178         layoutPtr->stretch_height = TRUE ;
1179         layoutPtr->min_height = 100 ;
1180         boxPtr += 2 ;       /* For new row, add 2. */
1181         ++layoutPtr ;       /* For new row. */
1182         } 
1183
1184  
1185
1186     layoutPtr->space_above = hw->help_dialog.ghelp.marginWidth;
1187     layoutPtr->end = TRUE ;        /* Mark the last row. */
1188     return( geoSpec) ;
1189 }
1190
1191
1192
1193 \f
1194 /*****************************************************************************
1195  * Function:         Boolean _DtHelpDialogWidgetNoGeoRequest(geoSpec)
1196  *                          XmGeoMatrix geoSpec)
1197  *
1198  *
1199  * Parameters:   
1200  *
1201  * Return Value:    
1202  *
1203  * Purpose:       
1204  *
1205  ****************************************************************************/
1206 Boolean _DtHelpDialogWidgetNoGeoRequest(XmGeoMatrix geoSpec)
1207 {
1208
1209   if(    BB_InSetValues( geoSpec->composite)
1210       && (XtClass( geoSpec->composite) == dtHelpDialogWidgetClass)    )
1211     {   
1212       return( TRUE) ;
1213     } 
1214   return( FALSE) ;
1215 }
1216
1217
1218
1219 \f
1220 /*****************************************************************************
1221  * Function:       static void DisplayTopLevelCB(
1222  *                            Widget w,   
1223  *                            XtPointer client_data,
1224  *                            XtPointer call_data);
1225  *       
1226  * Parameters:   
1227  *
1228  * Return Value:    
1229  *
1230  * Purpose:        causes the top level topic to be displayed.
1231  *
1232  ****************************************************************************/
1233 static void  DisplayTopLevelCB(
1234     Widget w,
1235     XtPointer client_data,
1236     XtPointer call_data )
1237 {
1238
1239    DtHelpDialogWidget   hw = (DtHelpDialogWidget) client_data;
1240     
1241    /* Display the top level topic */
1242    if (hw->help_dialog.help.topLevelId != NULL)
1243      _DtHelpUpdateDisplayArea(hw->help_dialog.help.topLevelId, hw, TRUE,
1244                            DtHISTORY_AND_JUMP, DtHELP_TYPE_TOPIC);
1245    else
1246      _DtHelpUpdateDisplayArea(NULL, hw, TRUE, DtHISTORY_AND_JUMP,
1247                            DtHELP_TYPE_TOPIC); 
1248
1249 }
1250
1251   
1252
1253 \f
1254 /*****************************************************************************
1255  * Function:       extern void _DtHelpDisplayBackCB(
1256  *                            Widget w,   
1257  *                            XtPointer client_data,
1258  *                            XtPointer call_data);
1259  *       
1260  * Parameters:   
1261  *
1262  * Return Value:    
1263  *
1264  * Purpose:        This routine will cause the top element in the jump
1265  *                 stack to be displayed.
1266  *
1267  ****************************************************************************/
1268 void   _DtHelpDisplayBackCB(
1269     Widget w,
1270     XtPointer client_data,
1271     XtPointer call_data)
1272 {
1273
1274    DtHelpDialogWidget   hw = (DtHelpDialogWidget) client_data;
1275
1276    ProcessJumpBack(hw);
1277
1278 }
1279
1280
1281
1282 \f
1283
1284 /*****************************************************************************
1285  * Function:       extern void _DtHelpDuplicateWindowCB(
1286  *                             Widget w,   
1287  *                             XtPointer client_data,
1288  *                             XtPointer call_data);
1289  *       
1290  * Parameters:   
1291  *
1292  * Return Value:    
1293  *
1294  * Purpose:        This routine creates a new help widget by forcing the
1295  *                 equivelent of a Jump New hyper text call
1296  *
1297  ****************************************************************************/
1298 void  _DtHelpDuplicateWindowCB(
1299     Widget w,
1300     XtPointer clientData,
1301     XtPointer callData)
1302 {
1303    DtHelpDialogWidget   hw = (DtHelpDialogWidget) clientData;
1304    DtHelpDialogCallbackStruct callDataStruct;
1305   
1306
1307   /* Setup the DtHelpHyperProcStruct to pass back 
1308    * to the client as callData
1309    */
1310         
1311     _DtHelpTurnOnHourGlass(XtParent(hw));
1312
1313     if (hw->help_dialog.display.hyperLinkCallback != NULL)
1314     {
1315          /* Use the old one */
1316          callDataStruct.helpVolume     = XtNewString
1317                                               (hw->help_dialog.display.helpVolume);
1318          callDataStruct.reason         = DtCR_HELP_LINK_ACTIVATE;
1319          callDataStruct.event          = NULL; /* should be hyperData->event */
1320          callDataStruct.locationId     = XtNewString
1321                                              (hw->help_dialog.display.locationId);
1322          callDataStruct.specification  = NULL;
1323          callDataStruct.hyperType      = DtHELP_LINK_TOPIC;
1324          callDataStruct.windowHint     = DtHELP_NEW_WINDOW;
1325
1326          XtCallCallbackList((Widget)hw,hw->help_dialog.display.hyperLinkCallback,
1327                              &callDataStruct);
1328     }
1329     else
1330     {   /* The application did not register a hypertext callback so
1331          *  we must generate the proper warning message and continue!
1332          */
1333               XmeWarning((Widget)hw, (char*) HDMessage6); 
1334     }
1335
1336     _DtHelpTurnOffHourGlass(XtParent(hw));       
1337
1338 }
1339  
1340
1341 \f
1342 /*****************************************************************************
1343  * Function:       static void CopyTextCB(
1344  *                            Widget w,   
1345  *                            XtPointer client_data,
1346  *                            XtPointer call_data);
1347  *       
1348  * Parameters:   
1349  *
1350  * Return Value:    
1351  *
1352  * Purpose:        This routine will cause the display area to copy text to 
1353  *                 the clip-board.
1354  *
1355  ****************************************************************************/
1356 static void  CopyTextCB(
1357     Widget w,
1358     XtPointer clientData,
1359     XtPointer callData)
1360 {
1361
1362    DtHelpDialogWidget   hw = (DtHelpDialogWidget) clientData;
1363
1364    _DtHelpInitiateClipboard(hw->help_dialog.help.pDisplayArea);
1365
1366
1367 }
1368
1369
1370
1371 \f
1372 /*****************************************************************************
1373  * Function:       static void ProcessBMenuBackCB(
1374  *                            Widget w,   
1375  *                            XtPointer client_data,
1376  *                            XtPointer call_data);
1377  *       
1378  * Parameters:   
1379  *
1380  * Return Value:    
1381  *
1382  * Purpose:        This routine will cause the top element in the jump
1383  *                 stack to be displayed, if their is a top element.
1384  *
1385  ****************************************************************************/
1386 static void  ProcessBMenuBackCB(
1387     Widget w,
1388     XtPointer clientData,
1389     XButtonEvent * event,
1390     Boolean *continueToDispatch)
1391 {
1392
1393    DtHelpDialogWidget   hw = (DtHelpDialogWidget) clientData;
1394
1395    XmMenuPosition(hw->help_dialog.menu.popupMenu, event);
1396    XtManageChild(hw->help_dialog.menu.popupMenu);
1397
1398 }
1399  
1400
1401 \f
1402 /*****************************************************************************
1403  * Function:       extern void  _DtHelpDisplayHistoryCB(
1404  *                            Widget w,   
1405  *                            XtPointer client_data,
1406  *                            XtPointer call_data);
1407  *       
1408  * Parameters:   
1409  *
1410  * Return Value:    
1411  *
1412  * Purpose:        This routine will cause the history dialog to be 
1413  *                 posted.
1414  *
1415  ****************************************************************************/
1416 void   _DtHelpDisplayHistoryCB(
1417     Widget w,
1418     XtPointer client_data,
1419     XtPointer call_data )
1420 {
1421
1422    DtHelpDialogWidget   hw = (DtHelpDialogWidget) client_data;
1423  
1424
1425    XmUpdateDisplay((Widget) hw);
1426    _DtHelpTurnOnHourGlass(XtParent(hw));
1427
1428    _DtHelpDisplayHistoryInfo((Widget)hw);
1429
1430    _DtHelpTurnOffHourGlass(XtParent(hw));      
1431   
1432 }
1433
1434
1435
1436
1437
1438 \f
1439 /*****************************************************************************
1440  * Function:           void  _DtHelpDisplayBrowserHomeCB(
1441  *                            Widget w,   
1442  *                            XtPointer client_data,
1443  *                            XtPointer call_data);
1444  *       
1445  * Parameters:   
1446  *
1447  * Return Value:    
1448  *
1449  * Purpose:        This routine will cause the top level of the browser.hv 
1450  *                 help volume to be displayed.
1451  *
1452  ****************************************************************************/
1453 void   _DtHelpDisplayBrowserHomeCB(
1454     Widget w,
1455     XtPointer client_data,
1456     XtPointer call_data )
1457 {
1458
1459    DtHelpDialogWidget   hw = (DtHelpDialogWidget) client_data;
1460    XmUpdateDisplay((Widget) hw);
1461
1462    /* ??? Check to see if help volume is always fully expanded at this point
1463     * ??? if so, we will never have a match.
1464     */
1465    if (   hw->help_dialog.display.helpVolume == NULL
1466        || strstr (hw->help_dialog.display.helpVolume, DtBROWSER_NAME) == NULL) 
1467      {
1468        XtFree(hw->help_dialog.display.helpVolume);
1469        hw->help_dialog.display.helpVolume  = XtNewString(DtBROWSER_NAME);
1470      
1471        /* Set our help volume flag so we open the proper volume */
1472        hw->help_dialog.ghelp.volumeFlag         = FALSE;
1473      }
1474
1475    XtFree(hw->help_dialog.display.locationId);
1476    hw->help_dialog.display.locationId = XtNewString(DtBROWSER_HOME);
1477    hw->help_dialog.display.helpType = DtHELP_TYPE_TOPIC;
1478
1479    _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_AND_JUMP);   
1480 }
1481
1482
1483
1484
1485
1486 \f
1487 /*****************************************************************************
1488  * Function:           void _DtHelpDisplayIndexCB(
1489  *                            Widget w,   
1490  *                            XtPointer client_data,
1491  *                            XtPointer call_data);
1492  *       
1493  * Parameters:   
1494  *
1495  * Return Value:    
1496  *
1497  * Purpose:        This routine will cause the index dialog to be 
1498  *                 posted.
1499  *
1500  ****************************************************************************/
1501 void  _DtHelpDisplayIndexCB(
1502     Widget w,
1503     XtPointer client_data,
1504     XtPointer call_data )
1505 {
1506
1507    DtHelpDialogWidget   hw = (DtHelpDialogWidget) client_data;
1508     
1509    
1510    XmUpdateDisplay((Widget) hw);
1511    _DtHelpTurnOnHourGlass(XtParent(hw));
1512
1513    /* display the index search dialog */
1514    _DtHelpGlobSrchDisplayDialog((Widget)hw,NULL,hw->help_dialog.display.helpVolume);
1515    
1516    _DtHelpTurnOffHourGlass(XtParent(hw));       
1517       
1518 }
1519
1520
1521
1522 \f
1523 /*****************************************************************************
1524  * Function:       static void DisplayPrintCB(
1525  *                            Widget w,   
1526  *                            XtPointer client_data,
1527  *                            XtPointer call_data);
1528  *       
1529  * Parameters:   
1530  *
1531  * Return Value:    
1532  *
1533  * Purpose:        This routine will cause the history dialog to be 
1534  *                 posted.
1535  *
1536  ****************************************************************************/
1537 static void  DisplayPrintCB(
1538     Widget w,
1539     XtPointer client_data,
1540     XtPointer call_data )
1541 {
1542
1543   DtHelpDialogWidget    hw = (DtHelpDialogWidget) client_data;
1544
1545   XmUpdateDisplay((Widget) hw);
1546   _DtHelpTurnOnHourGlass(XtParent(hw));
1547   
1548   /* display the print dialog */
1549   _DtHelpDisplayPrintDialog((Widget) hw,&hw->help_dialog.print,
1550                 &hw->help_dialog.display,&hw->help_dialog.help);
1551
1552   _DtHelpTurnOffHourGlass(XtParent(hw));      
1553 }
1554
1555
1556
1557 \f
1558 /*****************************************************************************
1559  * Function:        Widget DtCreateHelpDialog(Widget parent,
1560  *                                             String name,
1561  *                                             ArgList arglist,
1562  *                                             Cardinal argcount);
1563  *
1564  * Parameters:      parent      Specifies the parent widget ID.
1565  *                  name        Specifies the name of the created dialog
1566  *                              shell widget.
1567  *                  arglis      Specifies the argument list.
1568  *                  argcount    Specifies the number of attribute/value pairs
1569  *                              in the argument list (arglist).
1570  *
1571  * Return Value:    Returns a Help Dialog shell widget ID.
1572  *
1573  * Purpose:         Create an instance of a Help Dialog.
1574  *
1575  *****************************************************************************/
1576 Widget DtCreateHelpDialog(
1577     Widget parent,
1578     char *name,
1579     ArgList al,
1580     Cardinal ac)
1581 {
1582     Widget w;
1583     _DtHelpWidgetToAppContext(parent);
1584     
1585     _DtHelpAppLock(app);
1586     w = XmeCreateClassDialog (dtHelpDialogWidgetClass, parent, name, al, ac);
1587
1588     /* Add the CatchClose here so we catch the window manager close requests */
1589     CatchClose(w);
1590
1591     _DtHelpAppUnlock(app);
1592     return w;
1593 }
1594
1595
1596 \f
1597 /*****************************************************************************
1598  * Function:        _DtHelpFilterExecCmdCB
1599  *
1600  *  clientData:     The general help dialog widget
1601  *  cmdStr:         cmd string to filter
1602  *  ret_filteredCmdStr:  string after filtering.  NULL if exec denied
1603  *
1604  * Return Value:    0: ok, < 0: error
1605  *
1606  * Purpose:         filter an execution command using executionPolicy rsrc
1607  *
1608  * Memory:
1609  *   The caller must free memory allocated for the ret_filteredCmdStr
1610  *****************************************************************************/
1611 int _DtHelpFilterExecCmdCB(
1612     void *   clientData,
1613     const char *   cmdStr,
1614     char * * ret_filteredCmdStr)
1615 {
1616      DtHelpDialogWidget    hw;
1617      char    *hv_path;
1618
1619      hw = (DtHelpDialogWidget) _DtHelpDisplayAreaData(clientData);
1620      hv_path = _DtHelpFileLocate(DtHelpVOLUME_TYPE,
1621                                  hw->help_dialog.display.helpVolume,
1622                                  _DtHelpFileSuffixList, False, R_OK);
1623
1624      return _DtHelpFilterExecCmd((Widget) hw, cmdStr, 
1625                  hw->help_dialog.display.executionPolicy, 
1626                  True, &hw->help_dialog.help, ret_filteredCmdStr, hv_path);
1627 }
1628
1629 \f
1630 /*****************************************************************************
1631  * Function:        void BuildDisplayArea(Widget parent,
1632  *                                 DtHelpDialogWidget nw);  
1633  *
1634  *
1635  * Parameters:      parent      Specifies the widget ID of the help dialog you
1636  *                              want to set the topic in.
1637  *                  nw          Specifies the current help dialog widget.
1638  *
1639  * Return Value:    Void.
1640  *
1641  * Purpose:         Creates the Display area in the help dialog.
1642  *
1643  *****************************************************************************/
1644 static void BuildDisplayArea(
1645     Widget parent,
1646     DtHelpDialogWidget nw)
1647 {
1648   Arg   args[2];        
1649   int   n;
1650   XmFontList  defaultList;
1651   DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
1652
1653
1654   /* Get our current fontlist value */
1655   n = 0;
1656   XtSetArg (args[n], XmNfontList, &(defaultList));  ++n;
1657   XtGetValues (hw->help_dialog.menu.topBtn, args, n);
1658
1659
1660   /* Build the Display Area */
1661   hw->help_dialog.help.pDisplayArea = _DtHelpCreateDisplayArea(parent,
1662                                    "DisplayArea",
1663                                     ((short) hw->help_dialog.display.scrollBarPolicy),
1664                                     ((short) hw->help_dialog.display.scrollBarPolicy),
1665                                     False,
1666                                     ((int) hw->help_dialog.display.textRows),
1667                                     ((int) hw->help_dialog.display.textColumns),
1668                                     _DtHelpDialogHypertextCB,
1669                                     ResizeHelpDialogCB,
1670                                     _DtHelpFilterExecCmdCB,
1671                                     (XtPointer) hw,
1672                                     defaultList);
1673
1674   /* Build the popup menu item for inside the display area */
1675   hw->help_dialog.menu.popupMenu =  CreatePopupMenu((Widget)hw);
1676
1677
1678   /* Determin what type of info we are going to display */
1679   _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_AND_JUMP);
1680   
1681 }
1682
1683
1684
1685
1686
1687 \f
1688 /*****************************************************************************
1689  * Function:        void _DtHelpSetupDisplayType(DtHelpDialogWidget nw,
1690  *                                            int updateType);  
1691  *
1692  *
1693  * Parameters:      nw          Specifies the current help dialog widget.
1694  *
1695  * Return Value:    Void.
1696  *
1697  * Purpose:         Determins the type of topic the user want's to display
1698  *                  in the current help dialog and sets it up for display.
1699  *
1700  *****************************************************************************/
1701 void _DtHelpSetupDisplayType(
1702      DtHelpDialogWidget nw,
1703      Boolean vol_changed,
1704      int updateType)
1705 {
1706    char                *templocationId;
1707    Boolean validAccessPath=FALSE;
1708    XtPointer           topicHandle;
1709    DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
1710    int                 status=VALID_STATUS;
1711    char                *tmpMessage;
1712    char                *tmpError;
1713    char                *locTitle;
1714    char                *volumeTitle;
1715    DtTopicListStruct  *tmpPtr;
1716    Boolean             adjustTopicTitle=TRUE;
1717                       /* This is a local flag that we use to determine 
1718                        * if we need to re-adjust the topic volume title 
1719                        * at the end of this 
1720                        *  Function: True == Modify title, False == leave alone.
1721                        */
1722    Boolean didWeHaveAnError=FALSE;
1723    XmString      labelString;
1724    Arg           args[10];
1725    int           n=0;
1726
1727
1728    /* Here we need to store away our current scroll position as the currentlly
1729     * displayed item is about replaced w/a new item.
1730     * We already have placed this item in the jump stack, and now are just adding
1731     * the proper value for our scrollPosition.
1732     */
1733
1734    if (hw->help_dialog.backtr.pJumpListHead != NULL)
1735      {
1736        tmpPtr = hw->help_dialog.backtr.pJumpListHead;
1737        tmpPtr->scrollPosition = 
1738                      _DtHelpGetScrollbarValue(hw->help_dialog.help.pDisplayArea);
1739      }
1740
1741
1742    /* Here we set our UP, and Home Topic buttons to FALSE, they should be
1743     * true then the following code will set them correctly.
1744     */
1745    XtSetSensitive(hw->help_dialog.menu.topBtn, FALSE);
1746    XtSetSensitive(hw->help_dialog.menu.popupTopBtn, FALSE);
1747         
1748
1749    switch (hw->help_dialog.display.helpType)
1750     {
1751       case DtHELP_TYPE_TOPIC:
1752
1753         /* Expand the helpVolume resource if needed */
1754         if ((hw->help_dialog.ghelp.volumeFlag) &&
1755            (hw->help_dialog.display.volumeHandle != NULL))
1756            validAccessPath = TRUE;
1757         else
1758           if (hw->help_dialog.display.helpVolume != NULL)
1759              validAccessPath = _DtHelpExpandHelpVolume((Widget)hw,
1760                                         &hw->help_dialog.display,
1761                                         &hw->help_dialog.help,
1762                                         &hw->help_dialog.print);
1763   
1764         /* If the developer gave us a valid Access Path then we can continue
1765          * else, we will do nothing
1766          */
1767         if (validAccessPath)
1768           {
1769 #if 0
1770              /* Update our keyword search dialog if needed */
1771              if ( FALSE == hw->help_dialog.ghelp.volumeFlag)
1772                  _DtHelpGlobSrchUpdateCurVol((Widget) hw);
1773
1774        
1775              /* We now set this to true after we update our volumeTitle
1776               * value in _DtHelpUpdateDisplayArea.
1777               */
1778           
1779              /* hw->help_dialog.ghelp.volumeFlag         = TRUE;*/
1780 #endif         
1781
1782              /* Setup all the proper lists and display area with the 
1783               * topic string 
1784               */
1785              templocationId = XtNewString(hw->help_dialog.display.locationId);
1786
1787              /* Set the initial locationId into the display area */
1788              _DtHelpUpdateDisplayArea(templocationId, hw, vol_changed, updateType,
1789                                    DtHELP_TYPE_TOPIC);
1790              XtFree(templocationId);
1791              adjustTopicTitle = FALSE;
1792
1793           }
1794         else
1795           {
1796              if (hw->help_dialog.display.helpVolume == NULL)
1797                {
1798                   didWeHaveAnError=TRUE;
1799                   tmpError = XtNewString((char *)_DTGETMESSAGE(2, 60,
1800                             "No help volume specified."));
1801                   _DtHelpDisplayFormatError(hw->help_dialog.help.pDisplayArea, 
1802                             (Widget)hw, tmpError, NULL);
1803
1804                   _DtHelpUpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING,
1805                                      (Widget) hw);
1806                   hw->help_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
1807                   hw->help_dialog.display.stringData = XtNewString(tmpError);
1808                   XtFree(tmpError);
1809                }
1810            else
1811                {
1812                  /* We cannot find our HelpVolume so display the proper error
1813                   * message in the help dialog and continue.
1814                   */
1815                  didWeHaveAnError=TRUE;
1816                  tmpMessage = XtNewString((char *)_DTGETMESSAGE(2, 58,
1817                                 "The requested online help is either not installed "
1818                                 "or not in the proper help search path.  For "
1819                                 "information on installing online help, consult "
1820                                 "the documentation for the product.\n"));
1821                  locTitle = XtNewString((char *)_DTGETMESSAGE(2, 62,
1822                                         "Location ID:"));
1823                  volumeTitle = XtNewString((char *)_DTGETMESSAGE(2, 61,
1824                                         "Help Volume:"));
1825                  tmpError = XtMalloc(strlen(tmpMessage) +
1826                                      strlen(locTitle) +
1827                                      strlen(volumeTitle) + 
1828                                      strlen(hw->help_dialog.display.locationId) +
1829                                      strlen(hw->help_dialog.display.helpVolume) + 4);
1830                  (void) strcpy(tmpError, tmpMessage);
1831                  (void) strcat(tmpError, volumeTitle);
1832                  (void) strcat(tmpError, " ");
1833                  (void) strcat(tmpError, hw->help_dialog.display.helpVolume);
1834                  (void) strcat(tmpError,"\n");
1835                  (void) strcat(tmpError, locTitle);
1836                  (void) strcat(tmpError, " ");
1837                  (void) strcat(tmpError, hw->help_dialog.display.locationId);
1838
1839                  /* Set current path area to null by giving it a null id */
1840                  _DtHelpUpdatePathArea(NULL, hw);
1841
1842                  _DtHelpDisplayFormatError(hw->help_dialog.help.pDisplayArea, 
1843                                         (Widget)hw, tmpError, NULL);
1844
1845                  _DtHelpUpdateJumpList(tmpError,DtHELP_TYPE_DYNAMIC_STRING,
1846                                     (Widget) hw);
1847                  hw->help_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
1848                  hw->help_dialog.display.stringData = XtNewString(tmpError);
1849
1850                  XtFree(tmpError);
1851                  XtFree(tmpMessage);
1852                  XtFree(locTitle);
1853                  XtFree(volumeTitle);
1854   
1855                }
1856           } 
1857       
1858         break;
1859
1860       case DtHELP_TYPE_STRING:
1861
1862
1863          _DtHelpUpdatePathArea(NULL, hw); 
1864
1865         /* Set the string to the current help dialog */
1866         status = _DtHelpFormatAsciiString(hw->help_dialog.help.pDisplayArea,
1867                                         hw->help_dialog.display.stringData,
1868                                        &topicHandle);
1869         if (status >= VALID_STATUS)
1870           {
1871      
1872             /* Update the History and Jump Lists */
1873             if (updateType == DtHISTORY_AND_JUMP)
1874               _DtHelpUpdateJumpList(hw->help_dialog.display.stringData,
1875                                  DtHELP_TYPE_STRING, (Widget) hw);
1876         
1877   
1878             _DtHelpUpdateHistoryList(hw->help_dialog.display.stringData,
1879                               DtHELP_TYPE_STRING, TRUE, (Widget)hw);
1880             
1881             _DtHelpDisplayAreaSetList (hw->help_dialog.help.pDisplayArea,
1882                                     topicHandle, FALSE, 
1883                                     hw->help_dialog.backtr.scrollPosition);
1884           }
1885         else
1886           {
1887             didWeHaveAnError=TRUE;
1888             tmpError = XtNewString((char *)_DTGETMESSAGE(2, 50,
1889                        "String data could not be formatted."));
1890
1891             _DtHelpDisplayFormatError(hw->help_dialog.help.pDisplayArea, (Widget)hw,
1892                                    tmpError, (char*)HDMessage0);
1893           
1894             _DtHelpUpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING, 
1895                                (Widget) hw);
1896             hw->help_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
1897             hw->help_dialog.display.stringData = XtNewString(tmpError);
1898             XtFree(tmpError);
1899           }
1900
1901         break;
1902
1903       case DtHELP_TYPE_DYNAMIC_STRING:
1904
1905         _DtHelpUpdatePathArea(NULL, hw);
1906
1907         /* Set the string to the current help dialog */
1908         status = _DtHelpFormatAsciiStringDynamic(
1909                                     hw->help_dialog.help.pDisplayArea,
1910                                     hw->help_dialog.display.stringData,
1911                                     &topicHandle);
1912             
1913         if (status >= VALID_STATUS)
1914           {
1915      
1916             /* Update the History and Jump Lists */
1917             if (updateType == DtHISTORY_AND_JUMP)
1918               _DtHelpUpdateJumpList(hw->help_dialog.display.stringData,
1919                                  DtHELP_TYPE_DYNAMIC_STRING, (Widget) hw);
1920         
1921             _DtHelpUpdateHistoryList(hw->help_dialog.display.stringData,
1922                               DtHELP_TYPE_DYNAMIC_STRING, TRUE, (Widget)hw);
1923             _DtHelpDisplayAreaSetList (hw->help_dialog.help.pDisplayArea,
1924                                     topicHandle, FALSE,
1925                                     hw->help_dialog.backtr.scrollPosition);
1926           }
1927         else
1928           {
1929             didWeHaveAnError=TRUE;
1930             tmpError = XtNewString((char *)_DTGETMESSAGE(2, 51,
1931                   "Dynamic string data could not be formatted."));
1932
1933             _DtHelpUpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING, 
1934                                (Widget) hw);
1935         
1936             hw->help_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
1937             hw->help_dialog.display.stringData = XtNewString(tmpError);
1938
1939             _DtHelpDisplayFormatError(hw->help_dialog.help.pDisplayArea,(Widget)hw,
1940                                     tmpError, (char*) HDMessage1);
1941             XtFree(tmpError);
1942            }
1943          break;
1944
1945       case DtHELP_TYPE_MAN_PAGE:
1946
1947         _DtHelpUpdatePathArea(NULL, hw);
1948
1949         /* Set the string to the current help dialog */
1950         status = _DtHelpFormatManPage(
1951                                 hw->help_dialog.help.pDisplayArea,
1952                                 hw->help_dialog.display.manPage, &topicHandle);
1953       
1954         if (status >= VALID_STATUS)
1955          {
1956             /* Update the History and Jump Lists */
1957
1958             if (updateType == DtHISTORY_AND_JUMP)
1959               _DtHelpUpdateJumpList(hw->help_dialog.display.manPage,
1960                                  DtHELP_TYPE_MAN_PAGE, (Widget)hw);
1961     
1962               _DtHelpUpdateHistoryList(hw->help_dialog.display.manPage,
1963                                DtHELP_TYPE_MAN_PAGE, TRUE, (Widget)hw);
1964               _DtHelpDisplayAreaSetList (hw->help_dialog.help.pDisplayArea,
1965                                       topicHandle, FALSE, 
1966                                       hw->help_dialog.backtr.scrollPosition);
1967           }
1968         else
1969           {
1970              didWeHaveAnError=TRUE;
1971              tmpError = XtNewString((char *)_DTGETMESSAGE(2, 52,
1972                                     "Man Page could not be formatted. The requested Man Page is either not present, or corrupt."));
1973
1974              _DtHelpUpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING,
1975                                 (Widget) hw);
1976              hw->help_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
1977              hw->help_dialog.display.stringData = XtNewString(tmpError);
1978
1979              _DtHelpDisplayFormatError(hw->help_dialog.help.pDisplayArea, (Widget)hw,
1980                 tmpError, (char*) HDMessage2);
1981              XtFree(tmpError);
1982
1983           }
1984          break;
1985
1986       case DtHELP_TYPE_FILE:
1987
1988         _DtHelpUpdatePathArea(NULL, hw);
1989       
1990         /* Set the string to the current help dialog */
1991         status = _DtHelpFormatAsciiFile(hw->help_dialog.help.pDisplayArea,
1992                                 hw->help_dialog.display.helpFile, &topicHandle);
1993            
1994         if (status >= VALID_STATUS)
1995           {
1996             /* Update the History and Jump Lists */
1997
1998             if (updateType == DtHISTORY_AND_JUMP)
1999               _DtHelpUpdateJumpList(hw->help_dialog.display.helpFile,
2000                                  DtHELP_TYPE_FILE,(Widget)hw);
2001     
2002             _DtHelpUpdateHistoryList(hw->help_dialog.display.helpFile,
2003                                   DtHELP_TYPE_FILE, TRUE, (Widget)hw);
2004             _DtHelpDisplayAreaSetList (hw->help_dialog.help.pDisplayArea,
2005                                     topicHandle, FALSE, 
2006                                     hw->help_dialog.backtr.scrollPosition);
2007           }
2008         else
2009           {
2010              didWeHaveAnError=TRUE;
2011              tmpError = XtNewString((char *)_DTGETMESSAGE(2, 53,
2012                                    "Text file data could not be formatted. The requested text file is either not present, or corrupt."));
2013
2014              _DtHelpUpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING, 
2015                                 (Widget) hw);
2016
2017              hw->help_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
2018              hw->help_dialog.display.stringData = XtNewString(tmpError);
2019
2020              _DtHelpDisplayFormatError(hw->help_dialog.help.pDisplayArea, (Widget)hw,
2021                 tmpError, (char*) HDMessage3);
2022
2023              XtFree(tmpError);
2024
2025            }
2026         break;
2027
2028
2029       default:  
2030
2031         /* ERROR-MESSAGE */
2032         /* This means the user used the wrong help type */
2033         didWeHaveAnError=TRUE;
2034         tmpError = XtNewString((char *)_DTGETMESSAGE(2, 80,
2035                               "The specified help type is invalid."));
2036
2037         _DtHelpUpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING, 
2038                            (Widget) hw);
2039
2040         hw->help_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
2041         hw->help_dialog.display.stringData = XtNewString(tmpError);
2042
2043         _DtHelpDisplayFormatError(hw->help_dialog.help.pDisplayArea, (Widget)hw,
2044            tmpError, (char*) HDMessage4);
2045
2046         XtFree(tmpError);
2047
2048         break;
2049
2050     }  /* End Switch Statement */
2051
2052
2053    if ((adjustTopicTitle == TRUE) && (didWeHaveAnError == FALSE))
2054      {
2055        /* We have a valid HelpType other than a volume and 
2056        * no error condition, so lets update the Topics title.
2057        */
2058        XtSetArg(args[0], XmNlabelString, hw->help_dialog.display.topicTitleLbl);
2059        XtSetValues (hw->help_dialog.browser.volumeLabel, args, 1);
2060      }
2061    else if (didWeHaveAnError)
2062      {
2063        /* error messages displayed, clear out the topics title */
2064        n=0;
2065        labelString = XmStringCreateLocalized(" ");
2066        XtSetArg (args[n], XmNlabelString, labelString);             n++;
2067        XtSetValues (hw->help_dialog.browser.volumeLabel, args, n);
2068        XmStringFree(labelString); 
2069        if (hw->help_dialog.history.topicList != NULL)
2070          XmListDeselectAllItems(hw->help_dialog.history.topicList);
2071        if (hw->help_dialog.history.volumeList != NULL)
2072          XmListDeselectAllItems(hw->help_dialog.history.volumeList);
2073
2074        /* Set current path area to null by giving it a null id */
2075        _DtHelpUpdatePathArea(NULL, hw);
2076      }
2077
2078      /* Update our keyword search dialog */
2079      _DtHelpGlobSrchUpdateCurVol((Widget) hw);
2080
2081      /* Update the print dialog */
2082      _DtHelpUpdatePrintDialog(&hw->help_dialog.print,
2083                 &hw->help_dialog.display,&hw->help_dialog.help,False);
2084
2085      /* covers error states and non-help topics; case of help topic but
2086         in/not in the top-level volume is covered elsewhere */
2087      if (    hw->help_dialog.browser.showTopLevelBtn == TRUE
2088          && hw->help_dialog.display.helpType != DtHELP_TYPE_TOPIC)
2089         XtSetSensitive(hw->help_dialog.browser.btnBoxTopLevelBtn, TRUE);
2090 }
2091
2092
2093 \f
2094 /*****************************************************************************
2095  * Function:        void _DtHelpUpdateDisplayArea(char *locationId,
2096  *                             DtHelpDialogWidget   nw,  
2097  *                             int                   listUpdateType, 
2098  *                             int                   topicUpdateType);
2099  *
2100  *
2101  * Parameters:      locationId Specifies the ID string for the new topic we
2102  *                              are going to display in the HelpDialog widget.
2103  *
2104  *                  nw          Specifies the current help dialog widget.
2105  *
2106  * Return Value:    Void.
2107  *
2108  * Purpose:         Updates the Display area with a new Cache Creek Topic.
2109  *                  
2110  *****************************************************************************/
2111 void _DtHelpUpdateDisplayArea(
2112     char *locationId,
2113     DtHelpDialogWidget nw,
2114     Boolean vol_changed,
2115     int listUpdateType,
2116     int topicUpdateType)
2117 {
2118    XtPointer     topicHandle;
2119    Boolean       validlocationId=FALSE;
2120    int           status=NON_VALID_STATUS;
2121    char          *userErrorStr=NULL;
2122    char          *sysErrorStr=NULL;
2123    char          *tmpMsg=NULL;
2124    char          *retTitle;
2125    XmString      labelString;
2126    Arg           args[10];
2127    int           n=0;
2128         
2129    DtHelpDialogWidget hw = (DtHelpDialogWidget) nw;
2130   
2131    _DtHelpTurnOnHourGlass(XtParent(hw));
2132    
2133     validlocationId = False;  /* default */
2134
2135     /* If we have a null idString, assign the top level topic to it */
2136     if (locationId == NULL
2137         && hw->help_dialog.help.topLevelId != NULL)
2138     {
2139          locationId = XtNewString(hw->help_dialog.help.topLevelId);
2140     }
2141
2142     if (locationId != NULL)
2143     {
2144        XmUpdateDisplay((Widget)hw);
2145         
2146        /* format the initial locationId info to display */
2147        status = _DtHelpFormatTopic (
2148                     hw->help_dialog.help.pDisplayArea,
2149                     hw->help_dialog.display.volumeHandle, 
2150                     locationId,
2151                     True,
2152                     &topicHandle);
2153         
2154        /* unless locationId not found, the topic is valid */
2155        if (status != -2) 
2156            validlocationId = True;
2157     }  /* if existing loc id, try to format it */
2158                 
2159     if (status == 0)  /* success */
2160     {
2161         if (hw->help_dialog.ghelp.volumeFlag == FALSE)
2162         {
2163            XmFontList  fontList;
2164            Boolean     mod = False;
2165
2166            XtSetArg(args[0], XmNfontList, &fontList);
2167            XtGetValues(hw->help_dialog.browser.volumeLabel, args, 1);
2168
2169            /* We have a new volume, so update the volume title */
2170         
2171            _DtHelpFormatVolumeTitle(hw->help_dialog.help.pDisplayArea,
2172                                         hw->help_dialog.display.volumeHandle,
2173                                         &labelString, &fontList, &mod);
2174         
2175            if(labelString == NULL && NULL != hw->help_dialog.display.helpVolume)
2176                 labelString = XmStringCreateLocalized(
2177                                         hw->help_dialog.display.helpVolume);
2178         
2179            if (NULL != labelString)
2180              {
2181                n = 0;
2182                XtSetArg (args[n], XmNlabelString, labelString); n++;
2183                if (mod == True)
2184                  { XtSetArg (args[n], XmNfontList, fontList);   n++; }
2185                XtSetValues (hw->help_dialog.browser.volumeLabel, args, n);
2186                XmStringFree(labelString); 
2187              }
2188
2189            if (True == mod)
2190                XmFontListFree(fontList);
2191
2192            /* Update our volumeFlag because we know that its we have just,
2193             * opened a new volume. It will get set to false when we need 
2194             * to process a different help volume, and remain true while
2195             * processing the current help volume.
2196            */
2197            hw->help_dialog.ghelp.volumeFlag = TRUE;
2198        }  /* if volumeFlag == False */
2199         
2200        /* Update our history and jump lists */
2201        if (listUpdateType == DtHISTORY_AND_JUMP)
2202        {
2203            _DtHelpUpdateHistoryList(locationId, topicUpdateType,
2204                                                 vol_changed, (Widget)hw);
2205            _DtHelpUpdateJumpList(locationId,  topicUpdateType,(Widget) hw);
2206        }
2207        else if (listUpdateType == DtHISTORY_ONLY)
2208            _DtHelpUpdateHistoryList(locationId, topicUpdateType,
2209                                                  vol_changed, (Widget)hw);
2210        else if (listUpdateType == DtJUMP_ONLY)
2211            _DtHelpUpdateJumpList(locationId,  topicUpdateType,(Widget)hw);
2212         
2213        /* Adjust our "Top Level" browser home buttons */
2214        if (hw->help_dialog.browser.showTopLevelBtn == TRUE)
2215        {
2216            if (strstr (hw->help_dialog.display.helpVolume, DtBROWSER_NAME) != NULL) 
2217            {
2218                 /* FIX: get top topic of the current volume & compare with locationId */
2219                if (strcmp (hw->help_dialog.display.locationId, DtBROWSER_HOME)== 0)
2220                     XtSetSensitive(hw->help_dialog.browser.btnBoxTopLevelBtn, FALSE);
2221                else
2222                     XtSetSensitive(hw->help_dialog.browser.btnBoxTopLevelBtn, TRUE);
2223             }
2224             else
2225                 XtSetSensitive(hw->help_dialog.browser.btnBoxTopLevelBtn, TRUE);
2226        }  /* if showTopLevelBtn */
2227         
2228        /* Check to see if we are going to display the top level is so */
2229        if (_DtHelpCeIsTopTopic(hw->help_dialog.display.volumeHandle,
2230                                hw->help_dialog.display.locationId) == 0)
2231        {
2232            XtSetSensitive(hw->help_dialog.menu.topBtn, FALSE);
2233            XtSetSensitive(hw->help_dialog.menu.popupTopBtn, FALSE);
2234        }
2235        else
2236        {
2237            XtSetSensitive(hw->help_dialog.menu.topBtn, TRUE);
2238            XtSetSensitive(hw->help_dialog.menu.popupTopBtn, TRUE);
2239        }
2240         
2241        /* Change the widget instance record locationId field to 
2242         *  represent the new locationId being desplayed.
2243         */
2244        XtFree(hw->help_dialog.display.locationId);
2245        hw->help_dialog.display.locationId = XtNewString(locationId);
2246         
2247     
2248        /* Update the current path area for the given topic */
2249        _DtHelpUpdatePathArea(hw->help_dialog.display.locationId, hw);
2250      
2251        _DtHelpDisplayAreaSetList (hw->help_dialog.help.pDisplayArea,
2252                  topicHandle, FALSE, hw->help_dialog.backtr.scrollPosition);
2253
2254     }  /* if status == 0 */
2255         
2256     if (status < 0) 
2257     {
2258         /* Invalid idString */
2259
2260         /* Clear the current volume title label */
2261         /* ??? Is this the best way to null out a label gadget ??? */
2262         labelString = XmStringCreateLocalized(" ");
2263         XtSetArg (args[n], XmNlabelString, labelString);        
2264         XtSetValues (hw->help_dialog.browser.volumeLabel, args, 1);
2265         XmStringFree(labelString); 
2266
2267         /* Clear our history dialog selected items */
2268         if (hw->help_dialog.history.topicList != NULL)
2269             XmListDeselectAllItems(hw->help_dialog.history.topicList);
2270         if (hw->help_dialog.history.volumeList != NULL)
2271             XmListDeselectAllItems(hw->help_dialog.history.volumeList);
2272
2273         /* Set current path area to null by giving it a null idStirng */
2274         _DtHelpUpdatePathArea(NULL, hw);
2275
2276         /* De-sensatize our buttons, they do not work 
2277          * with out valid topics.
2278          */
2279       
2280         XtSetSensitive(hw->help_dialog.menu.topBtn, FALSE);
2281         XtSetSensitive(hw->help_dialog.menu.popupTopBtn, FALSE);
2282
2283         if (hw->help_dialog.history.pHistoryListHead == NULL)
2284         {    
2285            XtSetSensitive(hw->help_dialog.menu.historyBtn, FALSE);
2286            XtSetSensitive(hw->help_dialog.browser.btnBoxHistoryBtn, FALSE);
2287         }
2288         else
2289         {
2290            /* in case they were desensitized for any reason */
2291            XtSetSensitive(hw->help_dialog.menu.historyBtn, TRUE);
2292            XtSetSensitive(hw->help_dialog.browser.btnBoxHistoryBtn, TRUE);
2293         }
2294
2295         if (hw->help_dialog.backtr.pJumpListHead != NULL)    
2296         {
2297            XtSetSensitive(hw->help_dialog.menu.backBtn, TRUE);
2298            XtSetSensitive(hw->help_dialog.menu.popupBackBtn, TRUE);
2299            XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, TRUE);
2300         } 
2301
2302         
2303         /* Determin the proper error message to give */
2304         if (!validlocationId)
2305         {
2306       
2307             if (locationId == NULL)
2308             {
2309                  tmpMsg = (char *)_DTGETMESSAGE(2, 59,
2310                                  "No location ID specified.");
2311                  userErrorStr = XtNewString(tmpMsg);
2312             }
2313             else
2314             {
2315                  tmpMsg = (char *)_DTGETMESSAGE(2, 55,
2316                                  "Nonexistent location ID:");
2317                  userErrorStr = XtMalloc(strlen(tmpMsg) + 
2318                                   strlen(hw->help_dialog.display.locationId)+ 2);
2319                  (void) strcpy(userErrorStr, tmpMsg);
2320                  (void) strcat(userErrorStr, " ");
2321                  (void) strcat(userErrorStr, hw->help_dialog.display.locationId);
2322                  sysErrorStr = XtNewString(HDMessage9);
2323             }
2324         }
2325         else
2326         {
2327             tmpMsg = (char*)_DTGETMESSAGE(2, 54,
2328                      "Help topic could not be formatted.");
2329             userErrorStr = XtNewString(tmpMsg);
2330             sysErrorStr = XtNewString(HDMessage5);
2331         }
2332
2333
2334         _DtHelpUpdateJumpList(userErrorStr, DtHELP_TYPE_DYNAMIC_STRING,
2335                            (Widget) hw);
2336
2337         hw->help_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
2338         hw->help_dialog.display.stringData = XtNewString(userErrorStr);
2339
2340         _DtHelpDisplayFormatError(hw->help_dialog.help.pDisplayArea, (Widget) hw,
2341                                userErrorStr, sysErrorStr);
2342         XtFree(userErrorStr);
2343         XtFree(sysErrorStr);
2344     }   /* if (status < 0) */
2345
2346     _DtHelpTurnOffHourGlass(XtParent(hw));          
2347 }
2348
2349
2350
2351 \f
2352 /*****************************************************************************
2353  * Function:        void _DtHelpUpdateJumpList(char *topicInfo,
2354  *                                 int topicType,
2355  *                                 DtHelpDialogWidget nw);  
2356  *
2357  *
2358  * Parameters:      topicInfo   Specifies the 
2359  *                  int         Specifies the topicInfo type.
2360  *
2361  *                  nw          Specifies the current help dialog widget.
2362  *
2363  * Return Value:    Void.
2364  *
2365  * Purpose:         Updates the Jump List with the new topic.
2366  *
2367  *****************************************************************************/
2368 void _DtHelpUpdateJumpList(
2369     char *topicInfo,
2370     int topicType,
2371     Widget nw)
2372 {
2373   DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
2374  
2375   /* Add the new topic to the top of the jump list */
2376   /* We add a -1 for the scrollbar position value, and will replace it with the
2377    * actual value just prior to changing the window to the new topic.
2378    */
2379   _DtHelpTopicListAddToHead(topicInfo, hw->help_dialog.display.topicTitleLbl,
2380                         topicType, DtJUMP_LIST_MAX,
2381                         hw->help_dialog.display.helpVolume,
2382                         &hw->help_dialog.backtr.pJumpListHead,
2383                         &hw->help_dialog.backtr.pJumpListTale,
2384                         &hw->help_dialog.backtr.totalJumpNodes,
2385                         -1);
2386
2387   if (hw->help_dialog.backtr.totalJumpNodes <= 1) 
2388     {
2389       XtSetSensitive(hw->help_dialog.menu.backBtn, FALSE);
2390       XtSetSensitive(hw->help_dialog.menu.popupBackBtn, FALSE);
2391       XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, FALSE);
2392     }
2393   else
2394     {
2395       XtSetSensitive(hw->help_dialog.menu.backBtn, TRUE);
2396       XtSetSensitive(hw->help_dialog.menu.popupBackBtn, TRUE);
2397       XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, TRUE);
2398     }
2399 }
2400
2401
2402
2403 \f
2404 /*****************************************************************************
2405  * Function:        void ProcessJumpBack(DtHelpDialogWidget nw);  
2406  *
2407  *
2408  * Parameters:      helpDialogWidget  Specifies the current help dialog widget.
2409  *
2410  * Return Value:    Void.
2411  *
2412  * Purpose:         Pops the top element in the jump list off the stack
2413  *                  and jumps
2414  *
2415  *                  back to that topic.
2416  *
2417  *****************************************************************************/
2418 static void ProcessJumpBack(
2419     DtHelpDialogWidget nw)
2420 {
2421  
2422   DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
2423   DtTopicListStruct *pTemp= NULL;
2424
2425
2426   /* Pop the top element off our jump list and display the new top element */
2427   _DtHelpTopicListDeleteHead(&hw->help_dialog.backtr.pJumpListHead,
2428                           &hw->help_dialog.backtr.pJumpListTale,
2429                           &hw->help_dialog.backtr.totalJumpNodes);
2430                           
2431                           
2432
2433   /* Assign pTemp to the current head pointer for or jump list */
2434   pTemp = hw->help_dialog.backtr.pJumpListHead;
2435
2436   if (hw->help_dialog.backtr.totalJumpNodes <= 1)
2437     {
2438       XtSetSensitive(hw->help_dialog.menu.backBtn, FALSE);
2439       XtSetSensitive(hw->help_dialog.menu.popupBackBtn, FALSE);
2440       XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, FALSE);
2441     }
2442   else
2443     {
2444       XtSetSensitive(hw->help_dialog.menu.backBtn, TRUE);
2445       XtSetSensitive(hw->help_dialog.menu.popupBackBtn, TRUE);
2446        XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, TRUE);
2447     }
2448
2449
2450   /* Assign the jump values to or instance structure variables */
2451   if (NULL != pTemp->helpVolume &&
2452         strcmp (hw->help_dialog.display.helpVolume, pTemp->helpVolume) != 0)
2453     {
2454       XtFree(hw->help_dialog.display.helpVolume);
2455       hw->help_dialog.display.helpVolume  = XtNewString(pTemp->helpVolume);
2456       
2457       /* Set our help volume flag so we open the proper volume */
2458       hw->help_dialog.ghelp.volumeFlag         = FALSE;
2459
2460    }
2461
2462    /* grab the current backtracs's topic title value */
2463    XmStringFree(hw->help_dialog.display.topicTitleLbl);
2464    hw->help_dialog.display.topicTitleLbl = XmStringCopy(pTemp->topicTitleLbl); 
2465
2466
2467   /* Assign our scrollbar value to our instance structure  so we jump to the
2468    * proper location 
2469    */
2470  
2471   hw->help_dialog.backtr.scrollPosition = pTemp->scrollPosition;
2472
2473
2474   hw->help_dialog.display.helpType = pTemp->topicType;
2475
2476   switch (pTemp->topicType)
2477     {
2478       case DtHELP_TYPE_TOPIC:
2479
2480         /* Update our help dialog with top jump element */
2481         XtFree(hw->help_dialog.display.locationId);
2482         hw->help_dialog.display.locationId = XtNewString(pTemp->locationId);
2483         
2484         _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_ONLY);
2485       
2486         break;
2487
2488       case DtHELP_TYPE_STRING:
2489       case DtHELP_TYPE_DYNAMIC_STRING:
2490         XtFree(hw->help_dialog.display.stringData);
2491         hw->help_dialog.display.stringData = XtNewString(pTemp->locationId);
2492         
2493         _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_ONLY);
2494      
2495         break;
2496
2497       case DtHELP_TYPE_MAN_PAGE:
2498         XtFree(hw->help_dialog.display.manPage);
2499         hw->help_dialog.display.manPage = XtNewString(pTemp->locationId);
2500         
2501         _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_ONLY);
2502      
2503         break;
2504
2505       case DtHELP_TYPE_FILE:
2506         XtFree(hw->help_dialog.display.helpFile);
2507         hw->help_dialog.display.helpFile = XtNewString(pTemp->locationId);
2508         
2509         _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_ONLY);
2510      
2511         break;
2512
2513
2514       default:  
2515
2516         /* ERROR-MESSAGE */
2517         /* This means the user used the worng help type */
2518         XmeWarning((Widget)hw, (char*) HDMessage4);
2519
2520         break;
2521
2522     }  /* End Switch Statement */
2523     
2524     /* reset our scrollPosition back to its default here so in any other case,
2525      * we jump to the top of the topic 
2526      */
2527    hw->help_dialog.backtr.scrollPosition = -1;
2528
2529 }
2530
2531 \f
2532 /*****************************************************************************
2533  * Function:        void _DtHelpDialogHypertextCB(
2534  *                              XtPointer pDisplayAreaStruct,
2535  *                              XtPointer clientData, 
2536  *                              DtHelpHyperTextStruct *hyperData.) 
2537  *
2538  * Parameters:      pDisplayAreaStruct  Specifies the curretn display are info.
2539  *
2540  *                  clientData          Specifies the client data passed into
2541  *                                      the hypertext callback. 
2542  *
2543  *                  hyperData           Specifies the current hypertext info
2544  *                                      structure.
2545  *
2546  * Return Value:    Void.
2547  *
2548  * Purpose:         Process all hypertext requests in a given Help Dialogs
2549  *                  display area.
2550  *
2551  ****************************************************************************/
2552 void _DtHelpDialogHypertextCB (
2553     XtPointer pDisplayAreaStruct,
2554     XtPointer clientData,
2555     DtHelpHyperTextStruct *hyperData)
2556 {
2557   char         *pTempAccessPath;
2558   char         *pTempLocationId;  
2559   DtHelpDialogCallbackStruct callData;
2560   char         *tmpErrorMsg;
2561
2562   DtHelpDialogWidget hw = (DtHelpDialogWidget) clientData ;
2563    
2564   /* We allow users to force a new window and override the jump-reuse
2565    * hyper type and force a new window to be used
2566    */
2567    if (   (   ButtonRelease == hyperData->event->type 
2568            && hyperData->event->xbutton.state & (ControlMask|ShiftMask))
2569        || (   KeyPress == hyperData->event->type 
2570            && hyperData->event->xkey.state & (ControlMask|ShiftMask)))
2571      hyperData->window_hint = _DtCvWindowHint_NewWindow;
2572
2573
2574  
2575   switch (hyperData->hyper_type)
2576     {
2577
2578       case _DtCvLinkType_SameVolume:
2579       case _DtCvLinkType_CrossLink:
2580
2581
2582          switch (hyperData->window_hint)
2583            {
2584
2585              case _DtCvWindowHint_CurrentWindow:
2586                ProcessJumpReuse((Widget)hw, hyperData);
2587              break;
2588
2589              case _DtCvWindowHint_NewWindow:
2590         
2591                _DtHelpTurnOnHourGlass(XtParent(hw));
2592   
2593                if (hw->help_dialog.display.hyperLinkCallback != NULL)
2594                  {
2595                     pTempAccessPath = 
2596                       _DtHelpParseAccessFile(hyperData->specification);
2597          
2598                     if (pTempAccessPath != NULL)       /* Use the New one */
2599                       callData.helpVolume = pTempAccessPath;
2600                     else                               /* Use the old one */
2601                       callData.helpVolume =
2602                                 XtNewString(hw->help_dialog.display.helpVolume);
2603
2604
2605                     callData.reason        = DtCR_HELP_LINK_ACTIVATE;
2606                     callData.event         = hyperData->event;
2607                     callData.locationId    =  _DtHelpParseIdString
2608                                                   (hyperData->specification);
2609                     callData.specification = NULL;
2610                     callData.hyperType     = DtHELP_LINK_TOPIC;
2611                     callData.windowHint    = DtHELP_NEW_WINDOW;
2612                    
2613                     /* Now, envoke the apps hyper callback */
2614                     XtCallCallbackList(
2615                      (Widget)hw,hw->help_dialog.display.hyperLinkCallback,&callData);
2616                  }
2617                else
2618                  {  /* The application did not register a hypertext callback so
2619                      *  we must generate the proper warning message and 
2620                      *  continue!
2621                      */
2622                     XmeWarning((Widget)hw, (char*) HDMessage6); 
2623
2624                     /* Call jump-reuse procedure for default */
2625                     ProcessJumpReuse((Widget)hw, hyperData);
2626                   }
2627               
2628                _DtHelpTurnOffHourGlass(XtParent(hw));       
2629  
2630              break;
2631
2632              case _DtCvWindowHint_PopupWindow:
2633
2634                _DtHelpTurnOnHourGlass(XtParent(hw));
2635
2636                pTempAccessPath = 
2637                          _DtHelpParseAccessFile(hyperData->specification);
2638          
2639                if (pTempAccessPath == NULL)  /* Use the old one */  
2640                  pTempAccessPath = XtNewString(hw->help_dialog.display.helpVolume);
2641
2642                pTempLocationId = _DtHelpParseIdString(hyperData->specification);
2643
2644                _DtHelpDisplayDefinitionBox((Widget)hw,
2645                                  (Widget **)&(hw->help_dialog.ghelp.definitionBox),
2646                                  pTempAccessPath, pTempLocationId);
2647
2648                XtFree(pTempLocationId);
2649                XtFree(pTempAccessPath);
2650
2651                _DtHelpTurnOffHourGlass(XtParent(hw));       
2652
2653              break;
2654
2655              default:  
2656
2657                /* Non valid window hint generage the proper
2658                 *  error message.
2659                 */
2660              
2661                 /* ERROR-MESSAGE */
2662               break;
2663
2664
2665             }  /* End Window_hint Switch Statement */
2666
2667         break;
2668
2669
2670
2671        case _DtCvLinkType_Execute:
2672           _DtHelpExecFilteredCmd((Widget) hw, 
2673                     hyperData->specification, DtHELP_ExecutionPolicy_STR, 
2674                     &hw->help_dialog.display, &hw->help_dialog.help);
2675          break;
2676
2677
2678       case _DtCvLinkType_ManPage:
2679       case _DtCvLinkType_AppDefine:     
2680       case _DtCvLinkType_TextFile:
2681        
2682         /* Process Application Man page link or App Defined link types */
2683         _DtHelpTurnOnHourGlass(XtParent(hw));
2684
2685         /* If the application registered a hypertext callback use it! */
2686         if (hw->help_dialog.display.hyperLinkCallback != NULL)
2687           {
2688   
2689             /* Setup the DtHyperProcStructer to pass back to the 
2690              * client as callData. 
2691              */
2692              callData.reason        = DtCR_HELP_LINK_ACTIVATE;
2693              callData.event         = hyperData->event;
2694              callData.locationId    = NULL;
2695              callData.helpVolume    = NULL;
2696              if (_DtCvLinkType_AppDefine == hyperData->hyper_type)
2697                {
2698                  callData.locationId =
2699                                 _DtHelpParseIdString(hyperData->specification);
2700                  callData.helpVolume =
2701                                 XtNewString(hw->help_dialog.display.helpVolume);
2702                }
2703              callData.specification = hyperData->specification;
2704              callData.hyperType     = hyperData->hyper_type;
2705              callData.windowHint    = hyperData->window_hint;
2706           
2707              XtCallCallbackList ((Widget) hw,
2708                              hw->help_dialog.display.hyperLinkCallback, &callData);
2709           }
2710         else
2711           { 
2712              /* The application did not register a hypertext 
2713               * callback so we must generate the proper error 
2714               * message and continue!
2715               */
2716               XmeWarning((Widget)hw, (char*) HDMessage8); 
2717
2718               if (hyperData->hyper_type == DtHELP_LINK_APP_DEFINE)
2719                 {
2720                   tmpErrorMsg = XtNewString((char *)_DTGETMESSAGE(2, 56,
2721                         "The selected Hypertext link is not supported within this application."));
2722                   _DtHelpErrorDialog(XtParent(hw),tmpErrorMsg);
2723                 }
2724               else
2725                 {
2726                   tmpErrorMsg = XtNewString((char *)_DTGETMESSAGE(2, 57,
2727                         "Links to Man Pages are not supported by this application."));
2728                   _DtHelpErrorDialog(XtParent(hw),tmpErrorMsg);
2729
2730                 }
2731               XtFree(tmpErrorMsg);
2732              
2733            }
2734
2735         _DtHelpTurnOffHourGlass(XtParent(hw));  
2736         break;
2737
2738         default:  /* This catches bogus link types */
2739
2740             /* Non valid link type so we are dropping it and are generating
2741              * the  proper error message.
2742              */
2743              
2744              /* ERROR-MESSAGE */
2745              XmeWarning((Widget)hw, (char*) HDMessage7);
2746              break;
2747
2748
2749     }  /* End Switch Statement */
2750
2751
2752 }  /* End _DtHelpDialogHypertextCB */
2753
2754
2755
2756  
2757 \f
2758 /*****************************************************************************
2759  * Function:        void ResizeHelpDialogCB()
2760  *
2761  *
2762  * Return Value:    Void.
2763  *
2764  * Purpose:         Adjust the widget instance values for rows and columns.
2765  *
2766  ****************************************************************************/
2767 static void ResizeHelpDialogCB (
2768     XtPointer clientData)
2769 {
2770   DtHelpDialogWidget hw = (DtHelpDialogWidget) clientData ;
2771     
2772
2773   /* Re-Set our rows and colums values */
2774   if ((hw->help_dialog.help.pDisplayArea != NULL) &&
2775        hw->help_dialog.display.firstTimePopupFlag == TRUE)
2776      _DtHelpDisplayAreaDimensionsReturn (hw->help_dialog.help.pDisplayArea,
2777                                    &(hw->help_dialog.display.textRows),
2778                                    &(hw->help_dialog.display.textColumns));
2779 }
2780
2781
2782 \f
2783 /*****************************************************************************
2784  * Function:        static void  ProcessJumpReuse(nw, hyperData)
2785  *                                  Widget nw;
2786  *                                  DtHelpHyperTextStruct *hyperData;
2787  *
2788  * Parameters:      nw    Specifies the widget ID of the current help dialog
2789  *                        widget.
2790  * 
2791  *                  hyperData Specifies the hypertext data callback struct.
2792  *
2793  * Return Value:    Void.
2794  *
2795  * Purpose:         Process the jump-reuse hypertext link data.
2796  *
2797  *****************************************************************************/
2798 static void  ProcessJumpReuse(
2799     Widget nw,
2800     DtHelpHyperTextStruct *hyperData)
2801 {
2802
2803   DtHelpDialogWidget hw = (DtHelpDialogWidget) nw;
2804   char         *pTempAccessPath;
2805   char         *pTempLocationId;  
2806
2807  
2808   /* Parse our specification into the proper fields in our instance 
2809    * record.  
2810    */
2811
2812    pTempAccessPath = _DtHelpParseAccessFile(hyperData->specification);
2813          
2814    if (pTempAccessPath != NULL) 
2815      {
2816        /* Free the old one and assign the new path */
2817        XtFree(hw->help_dialog.display.helpVolume);
2818        hw->help_dialog.display.helpVolume = pTempAccessPath;
2819        hw->help_dialog.ghelp.volumeFlag = FALSE;
2820      }
2821  
2822     /* Free old copy fisrt ??? */
2823     pTempLocationId = _DtHelpParseIdString(hyperData->specification);
2824     XtFree(hw->help_dialog.display.locationId);
2825     hw->help_dialog.display.locationId = pTempLocationId;
2826     hw->help_dialog.display.helpType = DtHELP_TYPE_TOPIC;
2827    
2828     _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_AND_JUMP);
2829  
2830 }
2831
2832
2833 \f
2834 /*****************************************************************************
2835  * Function:        void _DtHelpTopicListFree (DtTopicListStruct *pHead);  
2836  *
2837  *
2838  * Parameters:      pHead   Specifies the head pointer to the topic list.
2839  *
2840  * Return Value:    Void.
2841  *
2842  * Purpose:         Frees all elements in a Topic List.
2843  *
2844  *****************************************************************************/
2845 void _DtHelpTopicListFree(
2846     DtTopicListStruct *pHead)
2847 {
2848   DtTopicListStruct *pTemp=NULL;
2849
2850
2851    while (pHead != NULL)
2852      {
2853        /* Free up each element in the current node */
2854        pTemp            = pHead;
2855        pHead            = pHead->pNext;
2856        pTemp->pNext     = NULL;
2857        pTemp->pPrevious = NULL;
2858
2859        /* Free the id String and AccessPath elements */
2860        XtFree(pTemp->locationId);
2861        XtFree(pTemp->helpVolume);
2862        XmStringFree(pTemp->topicTitleLbl);
2863
2864        /* Now, free the whole node */
2865        XtFree((char *)pTemp);
2866
2867     }
2868
2869
2870
2871 }
2872
2873
2874 \f
2875 /*****************************************************************************
2876  * Function:        void CleanUpHelpDialog(DtHelpDialogWidget nw,
2877  *                                         int cleanUpKind);  
2878  *
2879  *
2880  * Parameters:      nw  Specifies the current help dialog widget.
2881  *                  cleanUpKind Specifies the type of clean up we are doing, 
2882  *                  celan up and reuse or clean up and destroy.
2883  *
2884  * Return Value:    Void.
2885  *
2886  * Purpose:         This function will re-initializes a Help Dialog Widget to 
2887  *                  known good starting values or clean up in prepretion for 
2888  *                  an impending destroy.
2889  *
2890  *****************************************************************************/
2891 static void CleanUpHelpDialog(
2892     Widget nw,
2893     int cleanUpKind)
2894 {
2895   Arg        args[10];
2896
2897   DtHistoryListStruct *pTempVolume=NULL;
2898   DtHistoryListStruct *pTempVolumeCurrent=NULL;
2899
2900   DtHelpDialogWidget hw = (DtHelpDialogWidget) nw;
2901
2902
2903   XtFree(hw->help_dialog.print.printVolume);
2904   hw->help_dialog.print.printVolume    = NULL;
2905
2906   /* must clean volume list and topic list from history */
2907   pTempVolume = hw->help_dialog.history.pHistoryListHead;
2908   while (pTempVolume != NULL)
2909   {
2910       _DtHelpTopicListFree(pTempVolume->pTopicHead);
2911       pTempVolumeCurrent = pTempVolume;   
2912       pTempVolume = pTempVolume->pNext;
2913      
2914       XmStringFree(pTempVolumeCurrent->itemTitle); 
2915       XtFree((char *)pTempVolumeCurrent);
2916   }
2917   hw->help_dialog.history.pHistoryListHead  = NULL;
2918  
2919   _DtHelpTopicListFree(hw->help_dialog.history.pPathListHead);
2920   hw->help_dialog.history.pPathListHead     = NULL; 
2921   hw->help_dialog.history.pPathListTale     = NULL;
2922   hw->help_dialog.history.totalPathNodes    = 0;
2923
2924
2925   /* Free our jump list display stuff */
2926   _DtHelpTopicListFree(hw->help_dialog.backtr.pJumpListHead);
2927   hw->help_dialog.backtr.pJumpListHead     = NULL;
2928   hw->help_dialog.backtr.pJumpListTale     = NULL;
2929   hw->help_dialog.backtr.totalJumpNodes    = 0;
2930
2931
2932   /* do nothing for index search dialog on a Clean for Reuse */
2933
2934   /* Close our current help volume */
2935   if (hw->help_dialog.display.volumeHandle != NULL)
2936     {
2937       _DtHelpCloseVolume(hw->help_dialog.display.volumeHandle);
2938       hw->help_dialog.display.volumeHandle = NULL;
2939     }
2940
2941   /* Depending on weither we are just closing this help dialog or destroying 
2942    * it we will do the following!
2943    */
2944   
2945   if (cleanUpKind == DtCLEAN_FOR_DESTROY)
2946     {
2947
2948       /* Free any remaining char * values we malloc'ed in our help dialog */
2949       XtFree(hw->help_dialog.display.locationId);
2950       XtFree(hw->help_dialog.display.helpVolume); 
2951      
2952       XtFree(hw->help_dialog.display.manPage);
2953       XtFree(hw->help_dialog.display.stringData);
2954       XtFree(hw->help_dialog.display.helpFile);
2955       XtFree(hw->help_dialog.display.topicTitleStr);
2956       if (hw->help_dialog.display.topicTitleLbl != NULL)
2957           XmStringFree(hw->help_dialog.display.topicTitleLbl);
2958
2959       XtFree(hw->help_dialog.ghelp.parentId);
2960
2961       XtFree(hw->help_dialog.print.printer);
2962       if (hw->help_dialog.print.helpPrint != _DtHelpDefaultHelpPrint)
2963         XtFree(hw->help_dialog.print.helpPrint);
2964
2965       /* Clean and close and destroy (True) our index search dialog */
2966       _DtHelpGlobSrchCleanAndClose(&hw->help_dialog.srch,True);
2967
2968       /* Set our current topic variables to initial values */
2969       _DtHelpCommonHelpClean(&hw->help_dialog.help,True);
2970     }
2971   else
2972     {
2973
2974       /* Reset our buttons to the proper state */
2975       XtSetSensitive(hw->help_dialog.menu.backBtn, FALSE);
2976       XtSetSensitive(hw->help_dialog.menu.popupBackBtn, FALSE);
2977       XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, FALSE);
2978
2979       /* Clean and close our index search dialog */
2980       _DtHelpGlobSrchCleanAndClose(&hw->help_dialog.srch,False);
2981     
2982       if (hw->help_dialog.history.historyWidget != NULL)
2983         {
2984           XtUnmanageChild(hw->help_dialog.history.historyWidget);
2985         }
2986
2987      if (hw->help_dialog.print.printForm != NULL)
2988         {
2989           XtUnmanageChild(hw->help_dialog.print.printForm);
2990         }
2991
2992       /* Free our history display stuff */
2993       if (hw->help_dialog.history.volumeList != NULL)
2994         {
2995           XtSetArg(args[0], XmNitems, NULL);
2996           XtSetArg(args[1], XmNitemCount, 0);
2997           XtSetValues(hw->help_dialog.history.volumeList, args, 2);
2998         }
2999       if (hw->help_dialog.history.topicList != NULL)
3000         {
3001           XtSetArg(args[0], XmNitems, NULL);
3002           XtSetArg(args[1], XmNitemCount, 0);
3003           XtSetValues(hw->help_dialog.history.topicList, args, 2);
3004         }
3005              
3006       /* Set our toc areay area to a null starting vlaues */
3007       _DtHelpDisplayAreaClean(hw->help_dialog.browser.pTocArea);
3008   
3009       /* Set our current topic variables to initial values */
3010       _DtHelpCommonHelpClean(&hw->help_dialog.help,False);
3011     }
3012
3013 }
3014
3015
3016
3017 \f
3018 /****************************************************************************
3019  * Function:         CatchClose( Widget w);
3020  *                          
3021  * Parameters:      
3022  *
3023  * Return Value:    Void.
3024  *
3025  * Purpose:         Catches the window manager close requests and assigns our
3026  *                  CloseHelpCB to handel them.
3027  *
3028  ***************************************************************************/
3029 static void CatchClose (
3030     Widget widget)
3031 {
3032
3033   Atom      wm_delete_window;
3034   Arg       args[2];
3035
3036   /* Grab the window mgr close */
3037   wm_delete_window = XmInternAtom(XtDisplay(XtParent(widget)),
3038                                             "WM_DELETE_WINDOW", FALSE);
3039   XtSetArg(args[0], XmNdeleteResponse, XmDO_NOTHING);
3040
3041   /* Current Help Dialog Window */
3042   XmAddWMProtocolCallback(XtParent(widget),wm_delete_window,
3043                           (XtCallbackProc)CloseHelpCB, (XtPointer) widget);
3044   XtSetValues(XtParent(widget), args, 1);
3045   
3046
3047
3048
3049
3050 \f
3051 /************************************************************************
3052  * Function: CloseHelpCB()
3053  *
3054  *      Close the Help Dialog Window
3055  *
3056  ************************************************************************/
3057 static void CloseHelpCB (
3058     Widget w,
3059     XtPointer clientData,
3060     XtPointer callData)
3061 {
3062
3063   DtHelpDialogWidget hw = (DtHelpDialogWidget) clientData;
3064   DtHelpDialogCallbackStruct callDataInfo;
3065   XmPushButtonCallbackStruct *callbackStruct = 
3066                                (XmPushButtonCallbackStruct*) callData; 
3067
3068   /*
3069    * Check to see if a selection is in process.
3070    * If so, cancel the selection and don't close the dialog
3071    */
3072   if (_DtHelpCancelSelection(hw->help_dialog.help.pDisplayArea) == True)
3073         return;
3074
3075   /* No selection in progress. Close the dialog.
3076    *
3077    * ??? By definition, when a user closes a Help Dialog if it is 
3078    * used again by the application the state will be new. So we should 
3079    * flush out any info currently in the help, history, and search dialogs.
3080    */
3081  
3082   CleanUpHelpDialog((Widget)hw, DtCLEAN_FOR_REUSE);
3083
3084   /* Look to see if they registered their own close callback */
3085   if (hw->help_dialog.ghelp.closeCallback != NULL)
3086     {
3087        callDataInfo.reason = DtCR_HELP_CLOSE;
3088        callDataInfo.event = callbackStruct->event;
3089        callDataInfo.locationId = NULL;
3090        callDataInfo.helpVolume = NULL;
3091        callDataInfo.specification = NULL;
3092        callDataInfo.hyperType = 0;
3093    
3094        
3095        /* All we do is envoke the applications close callback */
3096        XtCallCallbackList((Widget)hw,hw->help_dialog.ghelp.closeCallback,
3097                          (XtPointer) &callDataInfo);
3098     }
3099   else
3100    XtUnmanageChild((Widget)hw);
3101
3102         
3103 }
3104
3105
3106
3107
3108
3109
3110
3111  
3112 \f
3113 /*********************************************************************
3114  * Function:  SetupHelpDialogMenus
3115  *
3116  *   This procedure build the menubar pulldows buttons for the Index
3117  * Browser and the Topic Viewer.
3118  *
3119  * Called by: MakeIndexWindow, and MakeTopicWindow.
3120  *********************************************************************/
3121 static Widget SetupHelpDialogMenus(
3122     Widget parent)
3123 {
3124    Widget       menuBar;
3125    Widget       c[10];
3126    Widget       cascadeB5;
3127    Widget       menupane1, menupane2, menupane3, menupane4, menupane5;
3128    Widget       helpBtn1, helpBtn2, helpBtn3, helpBtn4, helpBtn5, helpBtn6;
3129    Arg          args[10];       
3130    int          n;
3131    XmString     labelStr;
3132    char        *mnemonic;
3133    DtHelpListStruct *pHelpInfo;
3134    DtHelpDialogWidget hw = (DtHelpDialogWidget) parent;
3135
3136
3137    /* Build the menubar */
3138
3139    n = 0;
3140    menuBar = XmCreateMenuBar (parent, "menuBar", args, n); 
3141    XtManageChild (menuBar);
3142
3143
3144   /*******************************************************
3145    * Menupane:  Close, and related buttons 
3146    *******************************************************/
3147    
3148   n = 0;
3149   XtSetArg(args[n], XmNmarginWidth, 0);         ++n;
3150   XtSetArg(args[n], XmNmarginHeight, 0);                ++n;
3151   menupane1 = XmCreatePulldownMenu(menuBar, "fileMenu", args, n);
3152   
3153   /* Add callback for File Menu */
3154   pHelpInfo = _DtHelpListAdd(DtHELP_FileMenu_STR,
3155                        (Widget) hw, &hw->help_dialog.help,
3156                         &hw->help_dialog.help.pHelpListHead);
3157   XtAddCallback((Widget) menupane1, XmNhelpCallback,
3158                  _DtHelpCB, (XtPointer) pHelpInfo);
3159
3160
3161   /* Print button */
3162   labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 1,"Print...")));
3163   mnemonic = ((char *)_DTGETMESSAGE(2, 2,"P"));
3164   n = 0;
3165   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3166   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3167   c[0] = hw->help_dialog.menu.printBtn = XmCreatePushButtonGadget(menupane1,
3168                                                   "print", args, n);
3169   XtAddCallback(hw->help_dialog.menu.printBtn,XmNactivateCallback, 
3170                  DisplayPrintCB, (XtPointer) hw);
3171    
3172   XmStringFree(labelStr);
3173   
3174
3175   if (hw->help_dialog.menu.showDupBtn == True)
3176     {
3177       /* Duplicate button */
3178       labelStr = XmStringCreateLocalized(((char *)
3179                  _DTGETMESSAGE(2, 5,"New Window...")));
3180       mnemonic = ((char *)_DTGETMESSAGE(2, 6,"W"));
3181       n = 0;
3182       XtSetArg(args[n], XmNlabelString, labelStr); n++;
3183       XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3184       c[1] = hw->help_dialog.menu.newWindowBtn = 
3185                   XmCreatePushButtonGadget(menupane1,"newWindowBtn", args, n);
3186       XtAddCallback(hw->help_dialog.menu.newWindowBtn,XmNactivateCallback, 
3187                     _DtHelpDuplicateWindowCB, (XtPointer) hw); 
3188       XmStringFree(labelStr);
3189
3190       /* Exit button */
3191       labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 3,"Close")));
3192       mnemonic = ((char *)_DTGETMESSAGE(2, 4,"C"));
3193       n = 0;
3194       XtSetArg(args[n], XmNlabelString, labelStr); n++;
3195       XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3196       c[2] = hw->help_dialog.menu.closeBtn =
3197                XmCreatePushButtonGadget(menupane1,"close", args, n);
3198   
3199       XtAddCallback(hw->help_dialog.menu.closeBtn,XmNactivateCallback, 
3200                     CloseHelpCB, (XtPointer) hw); 
3201       XmStringFree(labelStr); 
3202
3203       /* set the cancel button (for KCancel) */
3204       hw->bulletin_board.cancel_button= hw->help_dialog.menu.closeBtn;
3205
3206  
3207       /* Manage the children for the File menu pane */ 
3208       XtManageChildren(c, 3);
3209        
3210     }
3211   else
3212     {
3213       /* Exit button */
3214       labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 3,"Close")));
3215       mnemonic = ((char *)_DTGETMESSAGE(2, 4,"C"));
3216       n = 0;
3217       XtSetArg(args[n], XmNlabelString, labelStr); n++;
3218       XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3219       c[1] = hw->help_dialog.menu.closeBtn =
3220              XmCreatePushButtonGadget(menupane1,"close", args, n);
3221   
3222       XtAddCallback(hw->help_dialog.menu.closeBtn,XmNactivateCallback, 
3223                  CloseHelpCB, (XtPointer) hw); 
3224       XmStringFree(labelStr); 
3225  
3226       /* set the cancel button (for KCancel) */
3227       hw->bulletin_board.cancel_button= hw->help_dialog.menu.closeBtn;
3228   
3229       /* Manage the children for the File menu pane */ 
3230       XtManageChildren(c, 2);
3231     }
3232
3233
3234   /*******************************************************
3235    * Menupane:  Edit, (Copy)
3236    *******************************************************/
3237
3238   n = 0;
3239   XtSetArg(args[n], XmNmarginWidth, 0);         ++n;
3240   XtSetArg(args[n], XmNmarginHeight, 0);                ++n;
3241   menupane2 = XmCreatePulldownMenu(menuBar, "editMenu", args, n);
3242
3243   /* Add callback for Edit Menu */
3244   pHelpInfo = _DtHelpListAdd(DtHELP_EditMenu_STR,
3245                        (Widget) hw, &hw->help_dialog.help,
3246                         &hw->help_dialog.help.pHelpListHead);
3247   XtAddCallback((Widget) menupane2, XmNhelpCallback,
3248                  _DtHelpCB, (XtPointer) pHelpInfo);
3249
3250   /* Edit button */
3251   labelStr = XmStringCreateLocalized((
3252                     (char *)_DTGETMESSAGE(2,7,"Copy")));
3253   mnemonic = ((char *)_DTGETMESSAGE(2, 8,"C"));
3254   n = 0;
3255   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3256   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3257   c[0] = hw->help_dialog.menu.copyBtn = XmCreatePushButtonGadget
3258                                         (menupane2, "copy", args, n);
3259   XtAddCallback(hw->help_dialog.menu.copyBtn,XmNactivateCallback, 
3260                  CopyTextCB, (XtPointer) hw); 
3261  
3262   XmStringFree(labelStr); 
3263    
3264   XtManageChildren(c, 1);
3265
3266
3267   /*******************************************************
3268    * Menupane:  Search, (Topic Index)
3269    *******************************************************/
3270
3271   n = 0;
3272   XtSetArg(args[n], XmNmarginWidth, 0);         ++n;
3273   XtSetArg(args[n], XmNmarginHeight, 0);                ++n;
3274   menupane3 = XmCreatePulldownMenu(menuBar, "searchMenu", args, n);
3275
3276   /* Add callback for Search Menu */
3277   pHelpInfo = _DtHelpListAdd(DtHELP_SearchMenu_STR,
3278                        (Widget) hw, &hw->help_dialog.help,
3279                         &hw->help_dialog.help.pHelpListHead);
3280   XtAddCallback((Widget) menupane3, XmNhelpCallback,
3281                  _DtHelpCB, (XtPointer) pHelpInfo);
3282
3283   /* Search button */
3284   labelStr = XmStringCreateLocalized((
3285                     (char *)_DTGETMESSAGE(2, 9,"Index...")));
3286   mnemonic = ((char *)_DTGETMESSAGE(2, 10,"I"));
3287   n = 0;
3288   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3289   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3290   c[0] = hw->help_dialog.menu.keyBtn = XmCreatePushButtonGadget
3291                                         (menupane3, "keyword", args, n);
3292   XtAddCallback(hw->help_dialog.menu.keyBtn,XmNactivateCallback, 
3293                  _DtHelpDisplayIndexCB, (XtPointer) hw); 
3294  
3295   XmStringFree(labelStr); 
3296    
3297   XtManageChildren(c, 1);
3298
3299
3300
3301   /*******************************************************
3302    * Menupane:  Navigate, and related buttons 
3303    *******************************************************/
3304
3305   n = 0;
3306   XtSetArg(args[n], XmNmarginWidth, 0);         ++n;
3307   XtSetArg(args[n], XmNmarginHeight, 0);                ++n;
3308   menupane4 = XmCreatePulldownMenu(menuBar, "navigateMenu", args, n);
3309
3310   /* Add callback for Navigate Menu */
3311   pHelpInfo = _DtHelpListAdd(DtHELP_NavigateMenu_STR,
3312                        (Widget) hw, &hw->help_dialog.help,
3313                         &hw->help_dialog.help.pHelpListHead);
3314   XtAddCallback((Widget) menupane4 , XmNhelpCallback,
3315                  _DtHelpCB, (XtPointer) pHelpInfo);
3316
3317  
3318   /* Back Button */
3319   labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 13,"Backtrack")));
3320   mnemonic = ((char *)_DTGETMESSAGE(2, 14,"B"));
3321   n = 0; 
3322   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3323   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3324   c[0] =  hw->help_dialog.menu.backBtn  = XmCreatePushButtonGadget(menupane4,
3325                                             "backTrack", args, n);
3326   XtAddCallback(hw->help_dialog.menu.backBtn,XmNactivateCallback, 
3327                   _DtHelpDisplayBackCB, (XtPointer) hw); 
3328   XtSetSensitive(hw->help_dialog.menu.backBtn, FALSE);
3329
3330   XmStringFree(labelStr); 
3331
3332
3333   /* Top Button */
3334   labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 11,"Home Topic")));
3335   mnemonic = ((char *)_DTGETMESSAGE(2, 12,"T"));
3336   n = 0; 
3337   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3338   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3339   c[1] =  hw->help_dialog.menu.topBtn  = XmCreatePushButtonGadget(menupane4,
3340                                             "homeTopic", args, n);
3341   XtAddCallback(hw->help_dialog.menu.topBtn,XmNactivateCallback, 
3342                  DisplayTopLevelCB, (XtPointer) hw); 
3343
3344   XmStringFree(labelStr); 
3345
3346
3347   /* Place a menu break here  */
3348   n = 0;
3349   c[2] = XmCreateSeparatorGadget(menupane4, "seporator",args, n);
3350
3351   /* History Button */
3352   labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 15,"History...")));
3353   mnemonic = ((char *)_DTGETMESSAGE(2, 16,"H"));
3354   n = 0;
3355   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3356   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3357   c[3] = hw->help_dialog.menu.historyBtn = XmCreatePushButtonGadget(menupane4,
3358                                           "history",args, n);
3359
3360   XtAddCallback(hw->help_dialog.menu.historyBtn,XmNactivateCallback, 
3361                  _DtHelpDisplayHistoryCB, (XtPointer) hw); 
3362
3363   XmStringFree(labelStr); 
3364  
3365
3366   /* Manage all the children of this manu pane */ 
3367   XtManageChildren(c, 4);
3368
3369
3370
3371
3372   /*******************************************************
3373    * Menupane:  Help, and related buttons 
3374    *******************************************************/
3375   n = 0;
3376   XtSetArg(args[n], XmNmarginWidth, 0);         ++n;
3377   XtSetArg(args[n], XmNmarginHeight, 0);                ++n;
3378   menupane5 = XmCreatePulldownMenu(menuBar, "helpMenu", args, n);
3379
3380   /* Add callback for Help Menu */
3381   pHelpInfo = _DtHelpListAdd(DtHELP_HelpMenu_STR,
3382                        (Widget) hw, &hw->help_dialog.help,
3383                         &hw->help_dialog.help.pHelpListHead);
3384   XtAddCallback((Widget) menupane5, XmNhelpCallback,
3385                  _DtHelpCB, (XtPointer) pHelpInfo);
3386
3387   /* On HELP button */
3388   labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 17,"Overview - Using Help")));
3389   mnemonic = ((char *)_DTGETMESSAGE(2, 18,"v"));
3390   n = 0; 
3391   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3392   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3393   c[0] = helpBtn1 = XmCreatePushButtonGadget(menupane5,
3394                                             "usingHelp", args, n);
3395   pHelpInfo = _DtHelpListAdd(DtHELP_onHelpMenu_STR,
3396                        (Widget) hw, &hw->help_dialog.help,
3397                         &hw->help_dialog.help.pHelpListHead);
3398   XtAddCallback(helpBtn1, XmNactivateCallback,
3399                 _DtHelpCB, (XtPointer) pHelpInfo);
3400   
3401   XmStringFree(labelStr); 
3402
3403
3404   /* Place a menu break here  */
3405   n = 0;
3406   c[1] = XmCreateSeparatorGadget(menupane5, "seporator",args, n);
3407
3408
3409   /* On Table Of Contents Help button */
3410   labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2,19,"Table Of Contents")));
3411   mnemonic = ((char *)_DTGETMESSAGE(2, 20, "C"));
3412   n = 0; 
3413   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3414   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3415   c[2] = helpBtn2 = XmCreatePushButtonGadget(menupane5,
3416                                             "tableOfContents", args, n);
3417   pHelpInfo = _DtHelpListAdd(DtHELP_onTableOfContenseMenu_STR,
3418                        (Widget) hw, &hw->help_dialog.help,
3419                         &hw->help_dialog.help.pHelpListHead);
3420   XtAddCallback(helpBtn2, XmNactivateCallback,
3421                 _DtHelpCB, (XtPointer) pHelpInfo);
3422   
3423   XmStringFree(labelStr); 
3424
3425
3426   /* On Tasks Help button */
3427   labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 21,"Tasks")));
3428   mnemonic = ((char *)_DTGETMESSAGE(2, 22, "T"));
3429   n = 0; 
3430   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3431   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3432   c[3] = helpBtn3 = XmCreatePushButtonGadget(menupane5,
3433                                             "tasks", args, n);
3434   pHelpInfo = _DtHelpListAdd(DtHELP_onTasksMenu_STR,
3435                        (Widget) hw, &hw->help_dialog.help,
3436                         &hw->help_dialog.help.pHelpListHead);
3437   XtAddCallback(helpBtn3, XmNactivateCallback,
3438                 _DtHelpCB, (XtPointer) pHelpInfo);
3439   XmStringFree(labelStr); 
3440
3441
3442   /* On Reference button */
3443   labelStr = XmStringCreateLocalized(((char *)
3444              _DTGETMESSAGE(2, 23,"Reference")));
3445   mnemonic = ((char *)_DTGETMESSAGE(2, 24,"R"));
3446   n = 0;
3447   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3448   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3449   c[4] = helpBtn4 = XmCreatePushButtonGadget(menupane5,
3450                                           "reference",args, n);
3451   pHelpInfo = _DtHelpListAdd(DtHELP_onReferenceMenu_STR,
3452                         (Widget) hw,  &hw->help_dialog.help,
3453                         &hw->help_dialog.help.pHelpListHead);
3454   XtAddCallback(helpBtn4, XmNactivateCallback, 
3455                 _DtHelpCB, (XtPointer) pHelpInfo);
3456   XmStringFree(labelStr); 
3457
3458
3459   /* On Mouse & Keyboard button */
3460   labelStr = XmStringCreateLocalized(((char *)
3461              _DTGETMESSAGE(2, 25,"Mouse and Keyboard")));
3462   mnemonic = ((char *)_DTGETMESSAGE(2, 26,"M"));
3463   n = 0;
3464   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3465   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3466   c[5] = helpBtn5 = XmCreatePushButtonGadget(menupane5,
3467                                           "reference",args, n);
3468   pHelpInfo = _DtHelpListAdd(DtHELP_onMouseAndKeysMenu_STR,
3469                         (Widget) hw,  &hw->help_dialog.help,
3470                         &hw->help_dialog.help.pHelpListHead);
3471   XtAddCallback(helpBtn5, XmNactivateCallback, 
3472                 _DtHelpCB, (XtPointer) pHelpInfo);
3473   XmStringFree(labelStr); 
3474
3475
3476   /* Place a menu break here  */
3477   n = 0;
3478   c[6] = XmCreateSeparatorGadget(menupane5, "seporator",args, n);
3479
3480   /* On Version */
3481   labelStr = XmStringCreateLocalized(((char *)
3482              _DTGETMESSAGE(2, 27,"About Help")));
3483   mnemonic = ((char *)_DTGETMESSAGE(2, 28,"A"));
3484   n = 0;
3485   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3486   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3487   c[7] = helpBtn6 = XmCreatePushButtonGadget(menupane5,
3488                                           "reference",args, n);
3489   pHelpInfo = _DtHelpListAdd(DtHELP_onVersionMenu_STR,
3490                         (Widget) hw,  &hw->help_dialog.help,
3491                         &hw->help_dialog.help.pHelpListHead);
3492   XtAddCallback(helpBtn6, XmNactivateCallback, 
3493                 _DtHelpCB, (XtPointer) pHelpInfo);
3494   XmStringFree(labelStr); 
3495
3496
3497   /* Manage the children for the Help menu pane */
3498   XtManageChildren(c, 8);
3499  
3500
3501
3502   /* Create Cascade buttons for menubar */
3503
3504   /* File Menu */
3505   labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 29,"File")));
3506   mnemonic = ((char *)_DTGETMESSAGE(2, 30,"F"));
3507   n = 0;
3508   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3509   XtSetArg(args[n], XmNsubMenuId, menupane1); n++;
3510   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3511   c[0] = XmCreateCascadeButton(menuBar,"file",args, n); 
3512   XmStringFree(labelStr); 
3513
3514   /* Edit Menu */
3515   labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 37,"Edit")));
3516   mnemonic = ((char *)_DTGETMESSAGE(2, 38,"E"));
3517   n = 0;
3518   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3519   XtSetArg(args[n], XmNsubMenuId, menupane2); n++;
3520   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3521   c[1] = XmCreateCascadeButton(menuBar, "edit", args, n); 
3522   XmStringFree(labelStr); 
3523
3524   /* Search Menu */
3525   labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 31,"Search")));
3526   mnemonic = ((char *)_DTGETMESSAGE(2, 32,"S"));
3527   n = 0;
3528   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3529   XtSetArg(args[n], XmNsubMenuId, menupane3); n++;
3530   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3531   c[2] = XmCreateCascadeButton(menuBar, "search", args, n); 
3532   XmStringFree(labelStr); 
3533
3534   /* Navigate Menu */
3535   labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 33,"Navigate")));
3536   mnemonic = ((char *)_DTGETMESSAGE(2, 34,"N"));
3537   n = 0;
3538   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3539   XtSetArg(args[n], XmNsubMenuId, menupane4); n++;
3540   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3541   c[3] = XmCreateCascadeButton(menuBar, "navigate", args, n); 
3542   XmStringFree(labelStr); 
3543
3544   /* Help Menu */
3545   labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 35,"Help")));
3546   mnemonic = ((char *)_DTGETMESSAGE(2, 36,"H"));
3547   n = 0;
3548   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3549   XtSetArg(args[n], XmNsubMenuId, menupane5); n++;
3550   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3551   c[4] = cascadeB5 = XmCreateCascadeButton(menuBar, "help", args, n); 
3552   XmStringFree(labelStr); 
3553
3554   XtManageChildren(c, 5);
3555
3556    
3557   /* Attaches the Help menupane to the right side */
3558   n = 0;
3559   XtSetArg (args[n], XmNmenuHelpWidget, cascadeB5);  n++;
3560   XtSetValues (menuBar, args, n);
3561
3562
3563   return(menuBar);
3564
3565
3566 }  /* End SetupHelpDialogMenus */
3567
3568
3569
3570 \f
3571 /*********************************************************************
3572  * Function:  CreatePopupMenu
3573  *
3574  *   This procedure builds the popup menu for the display area
3575  *
3576  **********************************************************************/
3577 static Widget CreatePopupMenu(
3578     Widget nw)
3579 {
3580    Widget       popup;
3581    Widget       c[10];
3582    Arg          args[10];       
3583    int          n;
3584    XmString     labelStr;
3585    DtHelpDialogWidget hw = (DtHelpDialogWidget) nw;
3586    DtHelpListStruct *pHelpInfo;
3587    char        *mnemonic;
3588    int numButtons = XGetPointerMapping(XtDisplay(nw),(unsigned char *)NULL, 0);
3589
3590    /* Build the popup */
3591    /* If no Btn3 then use Btn2 to post the menu */
3592    n = 0;
3593    if (numButtons < 3) {
3594       XtSetArg(args[n], XmNwhichButton, Button2); n++;
3595    }
3596    popup = XmCreatePopupMenu (
3597                 _DtHelpDisplayAreaWidget(hw->help_dialog.help.pDisplayArea),
3598                              "popup", args, n); 
3599
3600    /* Add our button three event handler to our newly created display area */
3601    XtAddEventHandler(
3602                 _DtHelpDisplayAreaWidget(hw->help_dialog.help.pDisplayArea), 
3603                     ButtonPressMask, FALSE, 
3604                     (XtEventHandler)ProcessBMenuBackCB, hw);
3605
3606   /* Add Help callback for Popup Menu */
3607   pHelpInfo = _DtHelpListAdd(DtHELP_PopupMenu_STR,
3608                        (Widget) hw, &hw->help_dialog.help,
3609                         &hw->help_dialog.help.pHelpListHead);
3610   XtAddCallback((Widget) popup, XmNhelpCallback,
3611                  _DtHelpCB, (XtPointer) pHelpInfo);
3612
3613    /* Build the popup menu items */
3614
3615   /* Popup Label*/
3616    labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(3, 4,"Help")));
3617    n = 0; 
3618    XtSetArg(args[n], XmNlabelString, labelStr); n++;
3619    c[0] = XmCreateLabelGadget(popup, "popupLabel", args, n);
3620    XmStringFree(labelStr); 
3621
3622    /* Place a menu break here  */
3623    n = 0;
3624    c[1] = XmCreateSeparatorGadget(popup, "seporator",args, n);
3625
3626  
3627    /* Back Button */
3628    labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 13,"Backtrack")));
3629    mnemonic = ((char *)_DTGETMESSAGE(2, 14,"B"));
3630    n = 0; 
3631    XtSetArg(args[n], XmNlabelString, labelStr); n++;
3632    XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3633    c[2] =  hw->help_dialog.menu.popupBackBtn  = XmCreatePushButtonGadget(popup,
3634                                             "backTrack", args, n);
3635    XmStringFree(labelStr); 
3636  
3637    XtAddCallback(hw->help_dialog.menu.popupBackBtn,XmNactivateCallback, 
3638                    _DtHelpDisplayBackCB, (XtPointer) hw); 
3639    XtSetSensitive(hw->help_dialog.menu.popupBackBtn, FALSE);
3640
3641
3642    /* Top Button */
3643    labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 11,"Home Topic")));
3644    mnemonic = ((char *)_DTGETMESSAGE(2, 12,"T"));
3645    n = 0; 
3646    XtSetArg(args[n], XmNlabelString, labelStr); n++;
3647    XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3648    c[3] = hw->help_dialog.menu.popupTopBtn  = XmCreatePushButtonGadget(popup,
3649                                                      "homeTopic", args, n);
3650    XmStringFree(labelStr); 
3651    XtAddCallback(hw->help_dialog.menu.popupTopBtn,XmNactivateCallback, 
3652                   DisplayTopLevelCB, (XtPointer) hw); 
3653    
3654    XtManageChildren(c, 4);
3655
3656   return(popup);
3657
3658
3659 }