libdthelp: Resolve 65 -Wunused-variable 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    XmString      labelString;
2125    Arg           args[10];
2126    int           n=0;
2127         
2128    DtHelpDialogWidget hw = (DtHelpDialogWidget) nw;
2129   
2130    _DtHelpTurnOnHourGlass(XtParent(hw));
2131    
2132     validlocationId = False;  /* default */
2133
2134     /* If we have a null idString, assign the top level topic to it */
2135     if (locationId == NULL
2136         && hw->help_dialog.help.topLevelId != NULL)
2137     {
2138          locationId = XtNewString(hw->help_dialog.help.topLevelId);
2139     }
2140
2141     if (locationId != NULL)
2142     {
2143        XmUpdateDisplay((Widget)hw);
2144         
2145        /* format the initial locationId info to display */
2146        status = _DtHelpFormatTopic (
2147                     hw->help_dialog.help.pDisplayArea,
2148                     hw->help_dialog.display.volumeHandle, 
2149                     locationId,
2150                     True,
2151                     &topicHandle);
2152         
2153        /* unless locationId not found, the topic is valid */
2154        if (status != -2) 
2155            validlocationId = True;
2156     }  /* if existing loc id, try to format it */
2157                 
2158     if (status == 0)  /* success */
2159     {
2160         if (hw->help_dialog.ghelp.volumeFlag == FALSE)
2161         {
2162            XmFontList  fontList;
2163            Boolean     mod = False;
2164
2165            XtSetArg(args[0], XmNfontList, &fontList);
2166            XtGetValues(hw->help_dialog.browser.volumeLabel, args, 1);
2167
2168            /* We have a new volume, so update the volume title */
2169         
2170            _DtHelpFormatVolumeTitle(hw->help_dialog.help.pDisplayArea,
2171                                         hw->help_dialog.display.volumeHandle,
2172                                         &labelString, &fontList, &mod);
2173         
2174            if(labelString == NULL && NULL != hw->help_dialog.display.helpVolume)
2175                 labelString = XmStringCreateLocalized(
2176                                         hw->help_dialog.display.helpVolume);
2177         
2178            if (NULL != labelString)
2179              {
2180                n = 0;
2181                XtSetArg (args[n], XmNlabelString, labelString); n++;
2182                if (mod == True)
2183                  { XtSetArg (args[n], XmNfontList, fontList);   n++; }
2184                XtSetValues (hw->help_dialog.browser.volumeLabel, args, n);
2185                XmStringFree(labelString); 
2186              }
2187
2188            if (True == mod)
2189                XmFontListFree(fontList);
2190
2191            /* Update our volumeFlag because we know that its we have just,
2192             * opened a new volume. It will get set to false when we need 
2193             * to process a different help volume, and remain true while
2194             * processing the current help volume.
2195            */
2196            hw->help_dialog.ghelp.volumeFlag = TRUE;
2197        }  /* if volumeFlag == False */
2198         
2199        /* Update our history and jump lists */
2200        if (listUpdateType == DtHISTORY_AND_JUMP)
2201        {
2202            _DtHelpUpdateHistoryList(locationId, topicUpdateType,
2203                                                 vol_changed, (Widget)hw);
2204            _DtHelpUpdateJumpList(locationId,  topicUpdateType,(Widget) hw);
2205        }
2206        else if (listUpdateType == DtHISTORY_ONLY)
2207            _DtHelpUpdateHistoryList(locationId, topicUpdateType,
2208                                                  vol_changed, (Widget)hw);
2209        else if (listUpdateType == DtJUMP_ONLY)
2210            _DtHelpUpdateJumpList(locationId,  topicUpdateType,(Widget)hw);
2211         
2212        /* Adjust our "Top Level" browser home buttons */
2213        if (hw->help_dialog.browser.showTopLevelBtn == TRUE)
2214        {
2215            if (strstr (hw->help_dialog.display.helpVolume, DtBROWSER_NAME) != NULL) 
2216            {
2217                 /* FIX: get top topic of the current volume & compare with locationId */
2218                if (strcmp (hw->help_dialog.display.locationId, DtBROWSER_HOME)== 0)
2219                     XtSetSensitive(hw->help_dialog.browser.btnBoxTopLevelBtn, FALSE);
2220                else
2221                     XtSetSensitive(hw->help_dialog.browser.btnBoxTopLevelBtn, TRUE);
2222             }
2223             else
2224                 XtSetSensitive(hw->help_dialog.browser.btnBoxTopLevelBtn, TRUE);
2225        }  /* if showTopLevelBtn */
2226         
2227        /* Check to see if we are going to display the top level is so */
2228        if (_DtHelpCeIsTopTopic(hw->help_dialog.display.volumeHandle,
2229                                hw->help_dialog.display.locationId) == 0)
2230        {
2231            XtSetSensitive(hw->help_dialog.menu.topBtn, FALSE);
2232            XtSetSensitive(hw->help_dialog.menu.popupTopBtn, FALSE);
2233        }
2234        else
2235        {
2236            XtSetSensitive(hw->help_dialog.menu.topBtn, TRUE);
2237            XtSetSensitive(hw->help_dialog.menu.popupTopBtn, TRUE);
2238        }
2239         
2240        /* Change the widget instance record locationId field to 
2241         *  represent the new locationId being desplayed.
2242         */
2243        XtFree(hw->help_dialog.display.locationId);
2244        hw->help_dialog.display.locationId = XtNewString(locationId);
2245         
2246     
2247        /* Update the current path area for the given topic */
2248        _DtHelpUpdatePathArea(hw->help_dialog.display.locationId, hw);
2249      
2250        _DtHelpDisplayAreaSetList (hw->help_dialog.help.pDisplayArea,
2251                  topicHandle, FALSE, hw->help_dialog.backtr.scrollPosition);
2252
2253     }  /* if status == 0 */
2254         
2255     if (status < 0) 
2256     {
2257         /* Invalid idString */
2258
2259         /* Clear the current volume title label */
2260         /* ??? Is this the best way to null out a label gadget ??? */
2261         labelString = XmStringCreateLocalized(" ");
2262         XtSetArg (args[n], XmNlabelString, labelString);        
2263         XtSetValues (hw->help_dialog.browser.volumeLabel, args, 1);
2264         XmStringFree(labelString); 
2265
2266         /* Clear our history dialog selected items */
2267         if (hw->help_dialog.history.topicList != NULL)
2268             XmListDeselectAllItems(hw->help_dialog.history.topicList);
2269         if (hw->help_dialog.history.volumeList != NULL)
2270             XmListDeselectAllItems(hw->help_dialog.history.volumeList);
2271
2272         /* Set current path area to null by giving it a null idStirng */
2273         _DtHelpUpdatePathArea(NULL, hw);
2274
2275         /* De-sensatize our buttons, they do not work 
2276          * with out valid topics.
2277          */
2278       
2279         XtSetSensitive(hw->help_dialog.menu.topBtn, FALSE);
2280         XtSetSensitive(hw->help_dialog.menu.popupTopBtn, FALSE);
2281
2282         if (hw->help_dialog.history.pHistoryListHead == NULL)
2283         {    
2284            XtSetSensitive(hw->help_dialog.menu.historyBtn, FALSE);
2285            XtSetSensitive(hw->help_dialog.browser.btnBoxHistoryBtn, FALSE);
2286         }
2287         else
2288         {
2289            /* in case they were desensitized for any reason */
2290            XtSetSensitive(hw->help_dialog.menu.historyBtn, TRUE);
2291            XtSetSensitive(hw->help_dialog.browser.btnBoxHistoryBtn, TRUE);
2292         }
2293
2294         if (hw->help_dialog.backtr.pJumpListHead != NULL)    
2295         {
2296            XtSetSensitive(hw->help_dialog.menu.backBtn, TRUE);
2297            XtSetSensitive(hw->help_dialog.menu.popupBackBtn, TRUE);
2298            XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, TRUE);
2299         } 
2300
2301         
2302         /* Determin the proper error message to give */
2303         if (!validlocationId)
2304         {
2305       
2306             if (locationId == NULL)
2307             {
2308                  tmpMsg = (char *)_DTGETMESSAGE(2, 59,
2309                                  "No location ID specified.");
2310                  userErrorStr = XtNewString(tmpMsg);
2311             }
2312             else
2313             {
2314                  tmpMsg = (char *)_DTGETMESSAGE(2, 55,
2315                                  "Nonexistent location ID:");
2316                  userErrorStr = XtMalloc(strlen(tmpMsg) + 
2317                                   strlen(hw->help_dialog.display.locationId)+ 2);
2318                  (void) strcpy(userErrorStr, tmpMsg);
2319                  (void) strcat(userErrorStr, " ");
2320                  (void) strcat(userErrorStr, hw->help_dialog.display.locationId);
2321                  sysErrorStr = XtNewString(HDMessage9);
2322             }
2323         }
2324         else
2325         {
2326             tmpMsg = (char*)_DTGETMESSAGE(2, 54,
2327                      "Help topic could not be formatted.");
2328             userErrorStr = XtNewString(tmpMsg);
2329             sysErrorStr = XtNewString(HDMessage5);
2330         }
2331
2332
2333         _DtHelpUpdateJumpList(userErrorStr, DtHELP_TYPE_DYNAMIC_STRING,
2334                            (Widget) hw);
2335
2336         hw->help_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
2337         hw->help_dialog.display.stringData = XtNewString(userErrorStr);
2338
2339         _DtHelpDisplayFormatError(hw->help_dialog.help.pDisplayArea, (Widget) hw,
2340                                userErrorStr, sysErrorStr);
2341         XtFree(userErrorStr);
2342         XtFree(sysErrorStr);
2343     }   /* if (status < 0) */
2344
2345     _DtHelpTurnOffHourGlass(XtParent(hw));          
2346 }
2347
2348
2349
2350 \f
2351 /*****************************************************************************
2352  * Function:        void _DtHelpUpdateJumpList(char *topicInfo,
2353  *                                 int topicType,
2354  *                                 DtHelpDialogWidget nw);  
2355  *
2356  *
2357  * Parameters:      topicInfo   Specifies the 
2358  *                  int         Specifies the topicInfo type.
2359  *
2360  *                  nw          Specifies the current help dialog widget.
2361  *
2362  * Return Value:    Void.
2363  *
2364  * Purpose:         Updates the Jump List with the new topic.
2365  *
2366  *****************************************************************************/
2367 void _DtHelpUpdateJumpList(
2368     char *topicInfo,
2369     int topicType,
2370     Widget nw)
2371 {
2372   DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
2373  
2374   /* Add the new topic to the top of the jump list */
2375   /* We add a -1 for the scrollbar position value, and will replace it with the
2376    * actual value just prior to changing the window to the new topic.
2377    */
2378   _DtHelpTopicListAddToHead(topicInfo, hw->help_dialog.display.topicTitleLbl,
2379                         topicType, DtJUMP_LIST_MAX,
2380                         hw->help_dialog.display.helpVolume,
2381                         &hw->help_dialog.backtr.pJumpListHead,
2382                         &hw->help_dialog.backtr.pJumpListTale,
2383                         &hw->help_dialog.backtr.totalJumpNodes,
2384                         -1);
2385
2386   if (hw->help_dialog.backtr.totalJumpNodes <= 1) 
2387     {
2388       XtSetSensitive(hw->help_dialog.menu.backBtn, FALSE);
2389       XtSetSensitive(hw->help_dialog.menu.popupBackBtn, FALSE);
2390       XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, FALSE);
2391     }
2392   else
2393     {
2394       XtSetSensitive(hw->help_dialog.menu.backBtn, TRUE);
2395       XtSetSensitive(hw->help_dialog.menu.popupBackBtn, TRUE);
2396       XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, TRUE);
2397     }
2398 }
2399
2400
2401
2402 \f
2403 /*****************************************************************************
2404  * Function:        void ProcessJumpBack(DtHelpDialogWidget nw);  
2405  *
2406  *
2407  * Parameters:      helpDialogWidget  Specifies the current help dialog widget.
2408  *
2409  * Return Value:    Void.
2410  *
2411  * Purpose:         Pops the top element in the jump list off the stack
2412  *                  and jumps
2413  *
2414  *                  back to that topic.
2415  *
2416  *****************************************************************************/
2417 static void ProcessJumpBack(
2418     DtHelpDialogWidget nw)
2419 {
2420  
2421   DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
2422   DtTopicListStruct *pTemp= NULL;
2423
2424
2425   /* Pop the top element off our jump list and display the new top element */
2426   _DtHelpTopicListDeleteHead(&hw->help_dialog.backtr.pJumpListHead,
2427                           &hw->help_dialog.backtr.pJumpListTale,
2428                           &hw->help_dialog.backtr.totalJumpNodes);
2429                           
2430                           
2431
2432   /* Assign pTemp to the current head pointer for or jump list */
2433   pTemp = hw->help_dialog.backtr.pJumpListHead;
2434
2435   if (hw->help_dialog.backtr.totalJumpNodes <= 1)
2436     {
2437       XtSetSensitive(hw->help_dialog.menu.backBtn, FALSE);
2438       XtSetSensitive(hw->help_dialog.menu.popupBackBtn, FALSE);
2439       XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, FALSE);
2440     }
2441   else
2442     {
2443       XtSetSensitive(hw->help_dialog.menu.backBtn, TRUE);
2444       XtSetSensitive(hw->help_dialog.menu.popupBackBtn, TRUE);
2445        XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, TRUE);
2446     }
2447
2448
2449   /* Assign the jump values to or instance structure variables */
2450   if (NULL != pTemp->helpVolume &&
2451         strcmp (hw->help_dialog.display.helpVolume, pTemp->helpVolume) != 0)
2452     {
2453       XtFree(hw->help_dialog.display.helpVolume);
2454       hw->help_dialog.display.helpVolume  = XtNewString(pTemp->helpVolume);
2455       
2456       /* Set our help volume flag so we open the proper volume */
2457       hw->help_dialog.ghelp.volumeFlag         = FALSE;
2458
2459    }
2460
2461    /* grab the current backtracs's topic title value */
2462    XmStringFree(hw->help_dialog.display.topicTitleLbl);
2463    hw->help_dialog.display.topicTitleLbl = XmStringCopy(pTemp->topicTitleLbl); 
2464
2465
2466   /* Assign our scrollbar value to our instance structure  so we jump to the
2467    * proper location 
2468    */
2469  
2470   hw->help_dialog.backtr.scrollPosition = pTemp->scrollPosition;
2471
2472
2473   hw->help_dialog.display.helpType = pTemp->topicType;
2474
2475   switch (pTemp->topicType)
2476     {
2477       case DtHELP_TYPE_TOPIC:
2478
2479         /* Update our help dialog with top jump element */
2480         XtFree(hw->help_dialog.display.locationId);
2481         hw->help_dialog.display.locationId = XtNewString(pTemp->locationId);
2482         
2483         _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_ONLY);
2484       
2485         break;
2486
2487       case DtHELP_TYPE_STRING:
2488       case DtHELP_TYPE_DYNAMIC_STRING:
2489         XtFree(hw->help_dialog.display.stringData);
2490         hw->help_dialog.display.stringData = XtNewString(pTemp->locationId);
2491         
2492         _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_ONLY);
2493      
2494         break;
2495
2496       case DtHELP_TYPE_MAN_PAGE:
2497         XtFree(hw->help_dialog.display.manPage);
2498         hw->help_dialog.display.manPage = XtNewString(pTemp->locationId);
2499         
2500         _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_ONLY);
2501      
2502         break;
2503
2504       case DtHELP_TYPE_FILE:
2505         XtFree(hw->help_dialog.display.helpFile);
2506         hw->help_dialog.display.helpFile = XtNewString(pTemp->locationId);
2507         
2508         _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_ONLY);
2509      
2510         break;
2511
2512
2513       default:  
2514
2515         /* ERROR-MESSAGE */
2516         /* This means the user used the worng help type */
2517         XmeWarning((Widget)hw, (char*) HDMessage4);
2518
2519         break;
2520
2521     }  /* End Switch Statement */
2522     
2523     /* reset our scrollPosition back to its default here so in any other case,
2524      * we jump to the top of the topic 
2525      */
2526    hw->help_dialog.backtr.scrollPosition = -1;
2527
2528 }
2529
2530 \f
2531 /*****************************************************************************
2532  * Function:        void _DtHelpDialogHypertextCB(
2533  *                              XtPointer pDisplayAreaStruct,
2534  *                              XtPointer clientData, 
2535  *                              DtHelpHyperTextStruct *hyperData.) 
2536  *
2537  * Parameters:      pDisplayAreaStruct  Specifies the curretn display are info.
2538  *
2539  *                  clientData          Specifies the client data passed into
2540  *                                      the hypertext callback. 
2541  *
2542  *                  hyperData           Specifies the current hypertext info
2543  *                                      structure.
2544  *
2545  * Return Value:    Void.
2546  *
2547  * Purpose:         Process all hypertext requests in a given Help Dialogs
2548  *                  display area.
2549  *
2550  ****************************************************************************/
2551 void _DtHelpDialogHypertextCB (
2552     XtPointer pDisplayAreaStruct,
2553     XtPointer clientData,
2554     DtHelpHyperTextStruct *hyperData)
2555 {
2556   char         *pTempAccessPath;
2557   char         *pTempLocationId;  
2558   DtHelpDialogCallbackStruct callData;
2559   char         *tmpErrorMsg;
2560
2561   DtHelpDialogWidget hw = (DtHelpDialogWidget) clientData ;
2562    
2563   /* We allow users to force a new window and override the jump-reuse
2564    * hyper type and force a new window to be used
2565    */
2566    if (   (   ButtonRelease == hyperData->event->type 
2567            && hyperData->event->xbutton.state & (ControlMask|ShiftMask))
2568        || (   KeyPress == hyperData->event->type 
2569            && hyperData->event->xkey.state & (ControlMask|ShiftMask)))
2570      hyperData->window_hint = _DtCvWindowHint_NewWindow;
2571
2572
2573  
2574   switch (hyperData->hyper_type)
2575     {
2576
2577       case _DtCvLinkType_SameVolume:
2578       case _DtCvLinkType_CrossLink:
2579
2580
2581          switch (hyperData->window_hint)
2582            {
2583
2584              case _DtCvWindowHint_CurrentWindow:
2585                ProcessJumpReuse((Widget)hw, hyperData);
2586              break;
2587
2588              case _DtCvWindowHint_NewWindow:
2589         
2590                _DtHelpTurnOnHourGlass(XtParent(hw));
2591   
2592                if (hw->help_dialog.display.hyperLinkCallback != NULL)
2593                  {
2594                     pTempAccessPath = 
2595                       _DtHelpParseAccessFile(hyperData->specification);
2596          
2597                     if (pTempAccessPath != NULL)       /* Use the New one */
2598                       callData.helpVolume = pTempAccessPath;
2599                     else                               /* Use the old one */
2600                       callData.helpVolume =
2601                                 XtNewString(hw->help_dialog.display.helpVolume);
2602
2603
2604                     callData.reason        = DtCR_HELP_LINK_ACTIVATE;
2605                     callData.event         = hyperData->event;
2606                     callData.locationId    =  _DtHelpParseIdString
2607                                                   (hyperData->specification);
2608                     callData.specification = NULL;
2609                     callData.hyperType     = DtHELP_LINK_TOPIC;
2610                     callData.windowHint    = DtHELP_NEW_WINDOW;
2611                    
2612                     /* Now, envoke the apps hyper callback */
2613                     XtCallCallbackList(
2614                      (Widget)hw,hw->help_dialog.display.hyperLinkCallback,&callData);
2615                  }
2616                else
2617                  {  /* The application did not register a hypertext callback so
2618                      *  we must generate the proper warning message and 
2619                      *  continue!
2620                      */
2621                     XmeWarning((Widget)hw, (char*) HDMessage6); 
2622
2623                     /* Call jump-reuse procedure for default */
2624                     ProcessJumpReuse((Widget)hw, hyperData);
2625                   }
2626               
2627                _DtHelpTurnOffHourGlass(XtParent(hw));       
2628  
2629              break;
2630
2631              case _DtCvWindowHint_PopupWindow:
2632
2633                _DtHelpTurnOnHourGlass(XtParent(hw));
2634
2635                pTempAccessPath = 
2636                          _DtHelpParseAccessFile(hyperData->specification);
2637          
2638                if (pTempAccessPath == NULL)  /* Use the old one */  
2639                  pTempAccessPath = XtNewString(hw->help_dialog.display.helpVolume);
2640
2641                pTempLocationId = _DtHelpParseIdString(hyperData->specification);
2642
2643                _DtHelpDisplayDefinitionBox((Widget)hw,
2644                                  (Widget **)&(hw->help_dialog.ghelp.definitionBox),
2645                                  pTempAccessPath, pTempLocationId);
2646
2647                XtFree(pTempLocationId);
2648                XtFree(pTempAccessPath);
2649
2650                _DtHelpTurnOffHourGlass(XtParent(hw));       
2651
2652              break;
2653
2654              default:  
2655
2656                /* Non valid window hint generage the proper
2657                 *  error message.
2658                 */
2659              
2660                 /* ERROR-MESSAGE */
2661               break;
2662
2663
2664             }  /* End Window_hint Switch Statement */
2665
2666         break;
2667
2668
2669
2670        case _DtCvLinkType_Execute:
2671           _DtHelpExecFilteredCmd((Widget) hw, 
2672                     hyperData->specification, DtHELP_ExecutionPolicy_STR, 
2673                     &hw->help_dialog.display, &hw->help_dialog.help);
2674          break;
2675
2676
2677       case _DtCvLinkType_ManPage:
2678       case _DtCvLinkType_AppDefine:     
2679       case _DtCvLinkType_TextFile:
2680        
2681         /* Process Application Man page link or App Defined link types */
2682         _DtHelpTurnOnHourGlass(XtParent(hw));
2683
2684         /* If the application registered a hypertext callback use it! */
2685         if (hw->help_dialog.display.hyperLinkCallback != NULL)
2686           {
2687   
2688             /* Setup the DtHyperProcStructer to pass back to the 
2689              * client as callData. 
2690              */
2691              callData.reason        = DtCR_HELP_LINK_ACTIVATE;
2692              callData.event         = hyperData->event;
2693              callData.locationId    = NULL;
2694              callData.helpVolume    = NULL;
2695              if (_DtCvLinkType_AppDefine == hyperData->hyper_type)
2696                {
2697                  callData.locationId =
2698                                 _DtHelpParseIdString(hyperData->specification);
2699                  callData.helpVolume =
2700                                 XtNewString(hw->help_dialog.display.helpVolume);
2701                }
2702              callData.specification = hyperData->specification;
2703              callData.hyperType     = hyperData->hyper_type;
2704              callData.windowHint    = hyperData->window_hint;
2705           
2706              XtCallCallbackList ((Widget) hw,
2707                              hw->help_dialog.display.hyperLinkCallback, &callData);
2708           }
2709         else
2710           { 
2711              /* The application did not register a hypertext 
2712               * callback so we must generate the proper error 
2713               * message and continue!
2714               */
2715               XmeWarning((Widget)hw, (char*) HDMessage8); 
2716
2717               if (hyperData->hyper_type == DtHELP_LINK_APP_DEFINE)
2718                 {
2719                   tmpErrorMsg = XtNewString((char *)_DTGETMESSAGE(2, 56,
2720                         "The selected Hypertext link is not supported within this application."));
2721                   _DtHelpErrorDialog(XtParent(hw),tmpErrorMsg);
2722                 }
2723               else
2724                 {
2725                   tmpErrorMsg = XtNewString((char *)_DTGETMESSAGE(2, 57,
2726                         "Links to Man Pages are not supported by this application."));
2727                   _DtHelpErrorDialog(XtParent(hw),tmpErrorMsg);
2728
2729                 }
2730               XtFree(tmpErrorMsg);
2731              
2732            }
2733
2734         _DtHelpTurnOffHourGlass(XtParent(hw));  
2735         break;
2736
2737         default:  /* This catches bogus link types */
2738
2739             /* Non valid link type so we are dropping it and are generating
2740              * the  proper error message.
2741              */
2742              
2743              /* ERROR-MESSAGE */
2744              XmeWarning((Widget)hw, (char*) HDMessage7);
2745              break;
2746
2747
2748     }  /* End Switch Statement */
2749
2750
2751 }  /* End _DtHelpDialogHypertextCB */
2752
2753
2754
2755  
2756 \f
2757 /*****************************************************************************
2758  * Function:        void ResizeHelpDialogCB()
2759  *
2760  *
2761  * Return Value:    Void.
2762  *
2763  * Purpose:         Adjust the widget instance values for rows and columns.
2764  *
2765  ****************************************************************************/
2766 static void ResizeHelpDialogCB (
2767     XtPointer clientData)
2768 {
2769   DtHelpDialogWidget hw = (DtHelpDialogWidget) clientData ;
2770     
2771
2772   /* Re-Set our rows and colums values */
2773   if ((hw->help_dialog.help.pDisplayArea != NULL) &&
2774        hw->help_dialog.display.firstTimePopupFlag == TRUE)
2775      _DtHelpDisplayAreaDimensionsReturn (hw->help_dialog.help.pDisplayArea,
2776                                    &(hw->help_dialog.display.textRows),
2777                                    &(hw->help_dialog.display.textColumns));
2778 }
2779
2780
2781 \f
2782 /*****************************************************************************
2783  * Function:        static void  ProcessJumpReuse(nw, hyperData)
2784  *                                  Widget nw;
2785  *                                  DtHelpHyperTextStruct *hyperData;
2786  *
2787  * Parameters:      nw    Specifies the widget ID of the current help dialog
2788  *                        widget.
2789  * 
2790  *                  hyperData Specifies the hypertext data callback struct.
2791  *
2792  * Return Value:    Void.
2793  *
2794  * Purpose:         Process the jump-reuse hypertext link data.
2795  *
2796  *****************************************************************************/
2797 static void  ProcessJumpReuse(
2798     Widget nw,
2799     DtHelpHyperTextStruct *hyperData)
2800 {
2801
2802   DtHelpDialogWidget hw = (DtHelpDialogWidget) nw;
2803   char         *pTempAccessPath;
2804   char         *pTempLocationId;  
2805
2806  
2807   /* Parse our specification into the proper fields in our instance 
2808    * record.  
2809    */
2810
2811    pTempAccessPath = _DtHelpParseAccessFile(hyperData->specification);
2812          
2813    if (pTempAccessPath != NULL) 
2814      {
2815        /* Free the old one and assign the new path */
2816        XtFree(hw->help_dialog.display.helpVolume);
2817        hw->help_dialog.display.helpVolume = pTempAccessPath;
2818        hw->help_dialog.ghelp.volumeFlag = FALSE;
2819      }
2820  
2821     /* Free old copy fisrt ??? */
2822     pTempLocationId = _DtHelpParseIdString(hyperData->specification);
2823     XtFree(hw->help_dialog.display.locationId);
2824     hw->help_dialog.display.locationId = pTempLocationId;
2825     hw->help_dialog.display.helpType = DtHELP_TYPE_TOPIC;
2826    
2827     _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_AND_JUMP);
2828  
2829 }
2830
2831
2832 \f
2833 /*****************************************************************************
2834  * Function:        void _DtHelpTopicListFree (DtTopicListStruct *pHead);  
2835  *
2836  *
2837  * Parameters:      pHead   Specifies the head pointer to the topic list.
2838  *
2839  * Return Value:    Void.
2840  *
2841  * Purpose:         Frees all elements in a Topic List.
2842  *
2843  *****************************************************************************/
2844 void _DtHelpTopicListFree(
2845     DtTopicListStruct *pHead)
2846 {
2847   DtTopicListStruct *pTemp=NULL;
2848
2849
2850    while (pHead != NULL)
2851      {
2852        /* Free up each element in the current node */
2853        pTemp            = pHead;
2854        pHead            = pHead->pNext;
2855        pTemp->pNext     = NULL;
2856        pTemp->pPrevious = NULL;
2857
2858        /* Free the id String and AccessPath elements */
2859        XtFree(pTemp->locationId);
2860        XtFree(pTemp->helpVolume);
2861        XmStringFree(pTemp->topicTitleLbl);
2862
2863        /* Now, free the whole node */
2864        XtFree((char *)pTemp);
2865
2866     }
2867
2868
2869
2870 }
2871
2872
2873 \f
2874 /*****************************************************************************
2875  * Function:        void CleanUpHelpDialog(DtHelpDialogWidget nw,
2876  *                                         int cleanUpKind);  
2877  *
2878  *
2879  * Parameters:      nw  Specifies the current help dialog widget.
2880  *                  cleanUpKind Specifies the type of clean up we are doing, 
2881  *                  celan up and reuse or clean up and destroy.
2882  *
2883  * Return Value:    Void.
2884  *
2885  * Purpose:         This function will re-initializes a Help Dialog Widget to 
2886  *                  known good starting values or clean up in prepretion for 
2887  *                  an impending destroy.
2888  *
2889  *****************************************************************************/
2890 static void CleanUpHelpDialog(
2891     Widget nw,
2892     int cleanUpKind)
2893 {
2894   Arg        args[10];
2895
2896   DtHistoryListStruct *pTempVolume=NULL;
2897   DtHistoryListStruct *pTempVolumeCurrent=NULL;
2898
2899   DtHelpDialogWidget hw = (DtHelpDialogWidget) nw;
2900
2901
2902   XtFree(hw->help_dialog.print.printVolume);
2903   hw->help_dialog.print.printVolume    = NULL;
2904
2905   /* must clean volume list and topic list from history */
2906   pTempVolume = hw->help_dialog.history.pHistoryListHead;
2907   while (pTempVolume != NULL)
2908   {
2909       _DtHelpTopicListFree(pTempVolume->pTopicHead);
2910       pTempVolumeCurrent = pTempVolume;   
2911       pTempVolume = pTempVolume->pNext;
2912      
2913       XmStringFree(pTempVolumeCurrent->itemTitle); 
2914       XtFree((char *)pTempVolumeCurrent);
2915   }
2916   hw->help_dialog.history.pHistoryListHead  = NULL;
2917  
2918   _DtHelpTopicListFree(hw->help_dialog.history.pPathListHead);
2919   hw->help_dialog.history.pPathListHead     = NULL; 
2920   hw->help_dialog.history.pPathListTale     = NULL;
2921   hw->help_dialog.history.totalPathNodes    = 0;
2922
2923
2924   /* Free our jump list display stuff */
2925   _DtHelpTopicListFree(hw->help_dialog.backtr.pJumpListHead);
2926   hw->help_dialog.backtr.pJumpListHead     = NULL;
2927   hw->help_dialog.backtr.pJumpListTale     = NULL;
2928   hw->help_dialog.backtr.totalJumpNodes    = 0;
2929
2930
2931   /* do nothing for index search dialog on a Clean for Reuse */
2932
2933   /* Close our current help volume */
2934   if (hw->help_dialog.display.volumeHandle != NULL)
2935     {
2936       _DtHelpCloseVolume(hw->help_dialog.display.volumeHandle);
2937       hw->help_dialog.display.volumeHandle = NULL;
2938     }
2939
2940   /* Depending on weither we are just closing this help dialog or destroying 
2941    * it we will do the following!
2942    */
2943   
2944   if (cleanUpKind == DtCLEAN_FOR_DESTROY)
2945     {
2946
2947       /* Free any remaining char * values we malloc'ed in our help dialog */
2948       XtFree(hw->help_dialog.display.locationId);
2949       XtFree(hw->help_dialog.display.helpVolume); 
2950      
2951       XtFree(hw->help_dialog.display.manPage);
2952       XtFree(hw->help_dialog.display.stringData);
2953       XtFree(hw->help_dialog.display.helpFile);
2954       XtFree(hw->help_dialog.display.topicTitleStr);
2955       if (hw->help_dialog.display.topicTitleLbl != NULL)
2956           XmStringFree(hw->help_dialog.display.topicTitleLbl);
2957
2958       XtFree(hw->help_dialog.ghelp.parentId);
2959
2960       XtFree(hw->help_dialog.print.printer);
2961       if (hw->help_dialog.print.helpPrint != _DtHelpDefaultHelpPrint)
2962         XtFree(hw->help_dialog.print.helpPrint);
2963
2964       /* Clean and close and destroy (True) our index search dialog */
2965       _DtHelpGlobSrchCleanAndClose(&hw->help_dialog.srch,True);
2966
2967       /* Set our current topic variables to initial values */
2968       _DtHelpCommonHelpClean(&hw->help_dialog.help,True);
2969     }
2970   else
2971     {
2972
2973       /* Reset our buttons to the proper state */
2974       XtSetSensitive(hw->help_dialog.menu.backBtn, FALSE);
2975       XtSetSensitive(hw->help_dialog.menu.popupBackBtn, FALSE);
2976       XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, FALSE);
2977
2978       /* Clean and close our index search dialog */
2979       _DtHelpGlobSrchCleanAndClose(&hw->help_dialog.srch,False);
2980     
2981       if (hw->help_dialog.history.historyWidget != NULL)
2982         {
2983           XtUnmanageChild(hw->help_dialog.history.historyWidget);
2984         }
2985
2986      if (hw->help_dialog.print.printForm != NULL)
2987         {
2988           XtUnmanageChild(hw->help_dialog.print.printForm);
2989         }
2990
2991       /* Free our history display stuff */
2992       if (hw->help_dialog.history.volumeList != NULL)
2993         {
2994           XtSetArg(args[0], XmNitems, NULL);
2995           XtSetArg(args[1], XmNitemCount, 0);
2996           XtSetValues(hw->help_dialog.history.volumeList, args, 2);
2997         }
2998       if (hw->help_dialog.history.topicList != NULL)
2999         {
3000           XtSetArg(args[0], XmNitems, NULL);
3001           XtSetArg(args[1], XmNitemCount, 0);
3002           XtSetValues(hw->help_dialog.history.topicList, args, 2);
3003         }
3004              
3005       /* Set our toc areay area to a null starting vlaues */
3006       _DtHelpDisplayAreaClean(hw->help_dialog.browser.pTocArea);
3007   
3008       /* Set our current topic variables to initial values */
3009       _DtHelpCommonHelpClean(&hw->help_dialog.help,False);
3010     }
3011
3012 }
3013
3014
3015
3016 \f
3017 /****************************************************************************
3018  * Function:         CatchClose( Widget w);
3019  *                          
3020  * Parameters:      
3021  *
3022  * Return Value:    Void.
3023  *
3024  * Purpose:         Catches the window manager close requests and assigns our
3025  *                  CloseHelpCB to handel them.
3026  *
3027  ***************************************************************************/
3028 static void CatchClose (
3029     Widget widget)
3030 {
3031
3032   Atom      wm_delete_window;
3033   Arg       args[2];
3034
3035   /* Grab the window mgr close */
3036   wm_delete_window = XmInternAtom(XtDisplay(XtParent(widget)),
3037                                             "WM_DELETE_WINDOW", FALSE);
3038   XtSetArg(args[0], XmNdeleteResponse, XmDO_NOTHING);
3039
3040   /* Current Help Dialog Window */
3041   XmAddWMProtocolCallback(XtParent(widget),wm_delete_window,
3042                           (XtCallbackProc)CloseHelpCB, (XtPointer) widget);
3043   XtSetValues(XtParent(widget), args, 1);
3044   
3045
3046
3047
3048
3049 \f
3050 /************************************************************************
3051  * Function: CloseHelpCB()
3052  *
3053  *      Close the Help Dialog Window
3054  *
3055  ************************************************************************/
3056 static void CloseHelpCB (
3057     Widget w,
3058     XtPointer clientData,
3059     XtPointer callData)
3060 {
3061
3062   DtHelpDialogWidget hw = (DtHelpDialogWidget) clientData;
3063   DtHelpDialogCallbackStruct callDataInfo;
3064   XmPushButtonCallbackStruct *callbackStruct = 
3065                                (XmPushButtonCallbackStruct*) callData; 
3066
3067   /*
3068    * Check to see if a selection is in process.
3069    * If so, cancel the selection and don't close the dialog
3070    */
3071   if (_DtHelpCancelSelection(hw->help_dialog.help.pDisplayArea) == True)
3072         return;
3073
3074   /* No selection in progress. Close the dialog.
3075    *
3076    * ??? By definition, when a user closes a Help Dialog if it is 
3077    * used again by the application the state will be new. So we should 
3078    * flush out any info currently in the help, history, and search dialogs.
3079    */
3080  
3081   CleanUpHelpDialog((Widget)hw, DtCLEAN_FOR_REUSE);
3082
3083   /* Look to see if they registered their own close callback */
3084   if (hw->help_dialog.ghelp.closeCallback != NULL)
3085     {
3086        callDataInfo.reason = DtCR_HELP_CLOSE;
3087        callDataInfo.event = callbackStruct->event;
3088        callDataInfo.locationId = NULL;
3089        callDataInfo.helpVolume = NULL;
3090        callDataInfo.specification = NULL;
3091        callDataInfo.hyperType = 0;
3092    
3093        
3094        /* All we do is envoke the applications close callback */
3095        XtCallCallbackList((Widget)hw,hw->help_dialog.ghelp.closeCallback,
3096                          (XtPointer) &callDataInfo);
3097     }
3098   else
3099    XtUnmanageChild((Widget)hw);
3100
3101         
3102 }
3103
3104
3105
3106
3107
3108
3109
3110  
3111 \f
3112 /*********************************************************************
3113  * Function:  SetupHelpDialogMenus
3114  *
3115  *   This procedure build the menubar pulldows buttons for the Index
3116  * Browser and the Topic Viewer.
3117  *
3118  * Called by: MakeIndexWindow, and MakeTopicWindow.
3119  *********************************************************************/
3120 static Widget SetupHelpDialogMenus(
3121     Widget parent)
3122 {
3123    Widget       menuBar;
3124    Widget       c[10];
3125    Widget       cascadeB5;
3126    Widget       menupane1, menupane2, menupane3, menupane4, menupane5;
3127    Widget       helpBtn1, helpBtn2, helpBtn3, helpBtn4, helpBtn5, helpBtn6;
3128    Arg          args[10];       
3129    int          n;
3130    XmString     labelStr;
3131    char        *mnemonic;
3132    DtHelpListStruct *pHelpInfo;
3133    DtHelpDialogWidget hw = (DtHelpDialogWidget) parent;
3134
3135
3136    /* Build the menubar */
3137
3138    n = 0;
3139    menuBar = XmCreateMenuBar (parent, "menuBar", args, n); 
3140    XtManageChild (menuBar);
3141
3142
3143   /*******************************************************
3144    * Menupane:  Close, and related buttons 
3145    *******************************************************/
3146    
3147   n = 0;
3148   XtSetArg(args[n], XmNmarginWidth, 0);         ++n;
3149   XtSetArg(args[n], XmNmarginHeight, 0);                ++n;
3150   menupane1 = XmCreatePulldownMenu(menuBar, "fileMenu", args, n);
3151   
3152   /* Add callback for File Menu */
3153   pHelpInfo = _DtHelpListAdd(DtHELP_FileMenu_STR,
3154                        (Widget) hw, &hw->help_dialog.help,
3155                         &hw->help_dialog.help.pHelpListHead);
3156   XtAddCallback((Widget) menupane1, XmNhelpCallback,
3157                  _DtHelpCB, (XtPointer) pHelpInfo);
3158
3159
3160   /* Print button */
3161   labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 1,"Print...")));
3162   mnemonic = ((char *)_DTGETMESSAGE(2, 2,"P"));
3163   n = 0;
3164   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3165   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3166   c[0] = hw->help_dialog.menu.printBtn = XmCreatePushButtonGadget(menupane1,
3167                                                   "print", args, n);
3168   XtAddCallback(hw->help_dialog.menu.printBtn,XmNactivateCallback, 
3169                  DisplayPrintCB, (XtPointer) hw);
3170    
3171   XmStringFree(labelStr);
3172   
3173
3174   if (hw->help_dialog.menu.showDupBtn == True)
3175     {
3176       /* Duplicate button */
3177       labelStr = XmStringCreateLocalized(((char *)
3178                  _DTGETMESSAGE(2, 5,"New Window...")));
3179       mnemonic = ((char *)_DTGETMESSAGE(2, 6,"W"));
3180       n = 0;
3181       XtSetArg(args[n], XmNlabelString, labelStr); n++;
3182       XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3183       c[1] = hw->help_dialog.menu.newWindowBtn = 
3184                   XmCreatePushButtonGadget(menupane1,"newWindowBtn", args, n);
3185       XtAddCallback(hw->help_dialog.menu.newWindowBtn,XmNactivateCallback, 
3186                     _DtHelpDuplicateWindowCB, (XtPointer) hw); 
3187       XmStringFree(labelStr);
3188
3189       /* Exit button */
3190       labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 3,"Close")));
3191       mnemonic = ((char *)_DTGETMESSAGE(2, 4,"C"));
3192       n = 0;
3193       XtSetArg(args[n], XmNlabelString, labelStr); n++;
3194       XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3195       c[2] = hw->help_dialog.menu.closeBtn =
3196                XmCreatePushButtonGadget(menupane1,"close", args, n);
3197   
3198       XtAddCallback(hw->help_dialog.menu.closeBtn,XmNactivateCallback, 
3199                     CloseHelpCB, (XtPointer) hw); 
3200       XmStringFree(labelStr); 
3201
3202       /* set the cancel button (for KCancel) */
3203       hw->bulletin_board.cancel_button= hw->help_dialog.menu.closeBtn;
3204
3205  
3206       /* Manage the children for the File menu pane */ 
3207       XtManageChildren(c, 3);
3208        
3209     }
3210   else
3211     {
3212       /* Exit button */
3213       labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 3,"Close")));
3214       mnemonic = ((char *)_DTGETMESSAGE(2, 4,"C"));
3215       n = 0;
3216       XtSetArg(args[n], XmNlabelString, labelStr); n++;
3217       XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3218       c[1] = hw->help_dialog.menu.closeBtn =
3219              XmCreatePushButtonGadget(menupane1,"close", args, n);
3220   
3221       XtAddCallback(hw->help_dialog.menu.closeBtn,XmNactivateCallback, 
3222                  CloseHelpCB, (XtPointer) hw); 
3223       XmStringFree(labelStr); 
3224  
3225       /* set the cancel button (for KCancel) */
3226       hw->bulletin_board.cancel_button= hw->help_dialog.menu.closeBtn;
3227   
3228       /* Manage the children for the File menu pane */ 
3229       XtManageChildren(c, 2);
3230     }
3231
3232
3233   /*******************************************************
3234    * Menupane:  Edit, (Copy)
3235    *******************************************************/
3236
3237   n = 0;
3238   XtSetArg(args[n], XmNmarginWidth, 0);         ++n;
3239   XtSetArg(args[n], XmNmarginHeight, 0);                ++n;
3240   menupane2 = XmCreatePulldownMenu(menuBar, "editMenu", args, n);
3241
3242   /* Add callback for Edit Menu */
3243   pHelpInfo = _DtHelpListAdd(DtHELP_EditMenu_STR,
3244                        (Widget) hw, &hw->help_dialog.help,
3245                         &hw->help_dialog.help.pHelpListHead);
3246   XtAddCallback((Widget) menupane2, XmNhelpCallback,
3247                  _DtHelpCB, (XtPointer) pHelpInfo);
3248
3249   /* Edit button */
3250   labelStr = XmStringCreateLocalized((
3251                     (char *)_DTGETMESSAGE(2,7,"Copy")));
3252   mnemonic = ((char *)_DTGETMESSAGE(2, 8,"C"));
3253   n = 0;
3254   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3255   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3256   c[0] = hw->help_dialog.menu.copyBtn = XmCreatePushButtonGadget
3257                                         (menupane2, "copy", args, n);
3258   XtAddCallback(hw->help_dialog.menu.copyBtn,XmNactivateCallback, 
3259                  CopyTextCB, (XtPointer) hw); 
3260  
3261   XmStringFree(labelStr); 
3262    
3263   XtManageChildren(c, 1);
3264
3265
3266   /*******************************************************
3267    * Menupane:  Search, (Topic Index)
3268    *******************************************************/
3269
3270   n = 0;
3271   XtSetArg(args[n], XmNmarginWidth, 0);         ++n;
3272   XtSetArg(args[n], XmNmarginHeight, 0);                ++n;
3273   menupane3 = XmCreatePulldownMenu(menuBar, "searchMenu", args, n);
3274
3275   /* Add callback for Search Menu */
3276   pHelpInfo = _DtHelpListAdd(DtHELP_SearchMenu_STR,
3277                        (Widget) hw, &hw->help_dialog.help,
3278                         &hw->help_dialog.help.pHelpListHead);
3279   XtAddCallback((Widget) menupane3, XmNhelpCallback,
3280                  _DtHelpCB, (XtPointer) pHelpInfo);
3281
3282   /* Search button */
3283   labelStr = XmStringCreateLocalized((
3284                     (char *)_DTGETMESSAGE(2, 9,"Index...")));
3285   mnemonic = ((char *)_DTGETMESSAGE(2, 10,"I"));
3286   n = 0;
3287   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3288   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3289   c[0] = hw->help_dialog.menu.keyBtn = XmCreatePushButtonGadget
3290                                         (menupane3, "keyword", args, n);
3291   XtAddCallback(hw->help_dialog.menu.keyBtn,XmNactivateCallback, 
3292                  _DtHelpDisplayIndexCB, (XtPointer) hw); 
3293  
3294   XmStringFree(labelStr); 
3295    
3296   XtManageChildren(c, 1);
3297
3298
3299
3300   /*******************************************************
3301    * Menupane:  Navigate, and related buttons 
3302    *******************************************************/
3303
3304   n = 0;
3305   XtSetArg(args[n], XmNmarginWidth, 0);         ++n;
3306   XtSetArg(args[n], XmNmarginHeight, 0);                ++n;
3307   menupane4 = XmCreatePulldownMenu(menuBar, "navigateMenu", args, n);
3308
3309   /* Add callback for Navigate Menu */
3310   pHelpInfo = _DtHelpListAdd(DtHELP_NavigateMenu_STR,
3311                        (Widget) hw, &hw->help_dialog.help,
3312                         &hw->help_dialog.help.pHelpListHead);
3313   XtAddCallback((Widget) menupane4 , XmNhelpCallback,
3314                  _DtHelpCB, (XtPointer) pHelpInfo);
3315
3316  
3317   /* Back Button */
3318   labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 13,"Backtrack")));
3319   mnemonic = ((char *)_DTGETMESSAGE(2, 14,"B"));
3320   n = 0; 
3321   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3322   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3323   c[0] =  hw->help_dialog.menu.backBtn  = XmCreatePushButtonGadget(menupane4,
3324                                             "backTrack", args, n);
3325   XtAddCallback(hw->help_dialog.menu.backBtn,XmNactivateCallback, 
3326                   _DtHelpDisplayBackCB, (XtPointer) hw); 
3327   XtSetSensitive(hw->help_dialog.menu.backBtn, FALSE);
3328
3329   XmStringFree(labelStr); 
3330
3331
3332   /* Top Button */
3333   labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 11,"Home Topic")));
3334   mnemonic = ((char *)_DTGETMESSAGE(2, 12,"T"));
3335   n = 0; 
3336   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3337   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3338   c[1] =  hw->help_dialog.menu.topBtn  = XmCreatePushButtonGadget(menupane4,
3339                                             "homeTopic", args, n);
3340   XtAddCallback(hw->help_dialog.menu.topBtn,XmNactivateCallback, 
3341                  DisplayTopLevelCB, (XtPointer) hw); 
3342
3343   XmStringFree(labelStr); 
3344
3345
3346   /* Place a menu break here  */
3347   n = 0;
3348   c[2] = XmCreateSeparatorGadget(menupane4, "seporator",args, n);
3349
3350   /* History Button */
3351   labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 15,"History...")));
3352   mnemonic = ((char *)_DTGETMESSAGE(2, 16,"H"));
3353   n = 0;
3354   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3355   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3356   c[3] = hw->help_dialog.menu.historyBtn = XmCreatePushButtonGadget(menupane4,
3357                                           "history",args, n);
3358
3359   XtAddCallback(hw->help_dialog.menu.historyBtn,XmNactivateCallback, 
3360                  _DtHelpDisplayHistoryCB, (XtPointer) hw); 
3361
3362   XmStringFree(labelStr); 
3363  
3364
3365   /* Manage all the children of this manu pane */ 
3366   XtManageChildren(c, 4);
3367
3368
3369
3370
3371   /*******************************************************
3372    * Menupane:  Help, and related buttons 
3373    *******************************************************/
3374   n = 0;
3375   XtSetArg(args[n], XmNmarginWidth, 0);         ++n;
3376   XtSetArg(args[n], XmNmarginHeight, 0);                ++n;
3377   menupane5 = XmCreatePulldownMenu(menuBar, "helpMenu", args, n);
3378
3379   /* Add callback for Help Menu */
3380   pHelpInfo = _DtHelpListAdd(DtHELP_HelpMenu_STR,
3381                        (Widget) hw, &hw->help_dialog.help,
3382                         &hw->help_dialog.help.pHelpListHead);
3383   XtAddCallback((Widget) menupane5, XmNhelpCallback,
3384                  _DtHelpCB, (XtPointer) pHelpInfo);
3385
3386   /* On HELP button */
3387   labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 17,"Overview - Using Help")));
3388   mnemonic = ((char *)_DTGETMESSAGE(2, 18,"v"));
3389   n = 0; 
3390   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3391   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3392   c[0] = helpBtn1 = XmCreatePushButtonGadget(menupane5,
3393                                             "usingHelp", args, n);
3394   pHelpInfo = _DtHelpListAdd(DtHELP_onHelpMenu_STR,
3395                        (Widget) hw, &hw->help_dialog.help,
3396                         &hw->help_dialog.help.pHelpListHead);
3397   XtAddCallback(helpBtn1, XmNactivateCallback,
3398                 _DtHelpCB, (XtPointer) pHelpInfo);
3399   
3400   XmStringFree(labelStr); 
3401
3402
3403   /* Place a menu break here  */
3404   n = 0;
3405   c[1] = XmCreateSeparatorGadget(menupane5, "seporator",args, n);
3406
3407
3408   /* On Table Of Contents Help button */
3409   labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2,19,"Table Of Contents")));
3410   mnemonic = ((char *)_DTGETMESSAGE(2, 20, "C"));
3411   n = 0; 
3412   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3413   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3414   c[2] = helpBtn2 = XmCreatePushButtonGadget(menupane5,
3415                                             "tableOfContents", args, n);
3416   pHelpInfo = _DtHelpListAdd(DtHELP_onTableOfContenseMenu_STR,
3417                        (Widget) hw, &hw->help_dialog.help,
3418                         &hw->help_dialog.help.pHelpListHead);
3419   XtAddCallback(helpBtn2, XmNactivateCallback,
3420                 _DtHelpCB, (XtPointer) pHelpInfo);
3421   
3422   XmStringFree(labelStr); 
3423
3424
3425   /* On Tasks Help button */
3426   labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 21,"Tasks")));
3427   mnemonic = ((char *)_DTGETMESSAGE(2, 22, "T"));
3428   n = 0; 
3429   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3430   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3431   c[3] = helpBtn3 = XmCreatePushButtonGadget(menupane5,
3432                                             "tasks", args, n);
3433   pHelpInfo = _DtHelpListAdd(DtHELP_onTasksMenu_STR,
3434                        (Widget) hw, &hw->help_dialog.help,
3435                         &hw->help_dialog.help.pHelpListHead);
3436   XtAddCallback(helpBtn3, XmNactivateCallback,
3437                 _DtHelpCB, (XtPointer) pHelpInfo);
3438   XmStringFree(labelStr); 
3439
3440
3441   /* On Reference button */
3442   labelStr = XmStringCreateLocalized(((char *)
3443              _DTGETMESSAGE(2, 23,"Reference")));
3444   mnemonic = ((char *)_DTGETMESSAGE(2, 24,"R"));
3445   n = 0;
3446   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3447   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3448   c[4] = helpBtn4 = XmCreatePushButtonGadget(menupane5,
3449                                           "reference",args, n);
3450   pHelpInfo = _DtHelpListAdd(DtHELP_onReferenceMenu_STR,
3451                         (Widget) hw,  &hw->help_dialog.help,
3452                         &hw->help_dialog.help.pHelpListHead);
3453   XtAddCallback(helpBtn4, XmNactivateCallback, 
3454                 _DtHelpCB, (XtPointer) pHelpInfo);
3455   XmStringFree(labelStr); 
3456
3457
3458   /* On Mouse & Keyboard button */
3459   labelStr = XmStringCreateLocalized(((char *)
3460              _DTGETMESSAGE(2, 25,"Mouse and Keyboard")));
3461   mnemonic = ((char *)_DTGETMESSAGE(2, 26,"M"));
3462   n = 0;
3463   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3464   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3465   c[5] = helpBtn5 = XmCreatePushButtonGadget(menupane5,
3466                                           "reference",args, n);
3467   pHelpInfo = _DtHelpListAdd(DtHELP_onMouseAndKeysMenu_STR,
3468                         (Widget) hw,  &hw->help_dialog.help,
3469                         &hw->help_dialog.help.pHelpListHead);
3470   XtAddCallback(helpBtn5, XmNactivateCallback, 
3471                 _DtHelpCB, (XtPointer) pHelpInfo);
3472   XmStringFree(labelStr); 
3473
3474
3475   /* Place a menu break here  */
3476   n = 0;
3477   c[6] = XmCreateSeparatorGadget(menupane5, "seporator",args, n);
3478
3479   /* On Version */
3480   labelStr = XmStringCreateLocalized(((char *)
3481              _DTGETMESSAGE(2, 27,"About Help")));
3482   mnemonic = ((char *)_DTGETMESSAGE(2, 28,"A"));
3483   n = 0;
3484   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3485   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3486   c[7] = helpBtn6 = XmCreatePushButtonGadget(menupane5,
3487                                           "reference",args, n);
3488   pHelpInfo = _DtHelpListAdd(DtHELP_onVersionMenu_STR,
3489                         (Widget) hw,  &hw->help_dialog.help,
3490                         &hw->help_dialog.help.pHelpListHead);
3491   XtAddCallback(helpBtn6, XmNactivateCallback, 
3492                 _DtHelpCB, (XtPointer) pHelpInfo);
3493   XmStringFree(labelStr); 
3494
3495
3496   /* Manage the children for the Help menu pane */
3497   XtManageChildren(c, 8);
3498  
3499
3500
3501   /* Create Cascade buttons for menubar */
3502
3503   /* File Menu */
3504   labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 29,"File")));
3505   mnemonic = ((char *)_DTGETMESSAGE(2, 30,"F"));
3506   n = 0;
3507   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3508   XtSetArg(args[n], XmNsubMenuId, menupane1); n++;
3509   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3510   c[0] = XmCreateCascadeButton(menuBar,"file",args, n); 
3511   XmStringFree(labelStr); 
3512
3513   /* Edit Menu */
3514   labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 37,"Edit")));
3515   mnemonic = ((char *)_DTGETMESSAGE(2, 38,"E"));
3516   n = 0;
3517   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3518   XtSetArg(args[n], XmNsubMenuId, menupane2); n++;
3519   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3520   c[1] = XmCreateCascadeButton(menuBar, "edit", args, n); 
3521   XmStringFree(labelStr); 
3522
3523   /* Search Menu */
3524   labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 31,"Search")));
3525   mnemonic = ((char *)_DTGETMESSAGE(2, 32,"S"));
3526   n = 0;
3527   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3528   XtSetArg(args[n], XmNsubMenuId, menupane3); n++;
3529   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3530   c[2] = XmCreateCascadeButton(menuBar, "search", args, n); 
3531   XmStringFree(labelStr); 
3532
3533   /* Navigate Menu */
3534   labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 33,"Navigate")));
3535   mnemonic = ((char *)_DTGETMESSAGE(2, 34,"N"));
3536   n = 0;
3537   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3538   XtSetArg(args[n], XmNsubMenuId, menupane4); n++;
3539   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3540   c[3] = XmCreateCascadeButton(menuBar, "navigate", args, n); 
3541   XmStringFree(labelStr); 
3542
3543   /* Help Menu */
3544   labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 35,"Help")));
3545   mnemonic = ((char *)_DTGETMESSAGE(2, 36,"H"));
3546   n = 0;
3547   XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3548   XtSetArg(args[n], XmNsubMenuId, menupane5); n++;
3549   XtSetArg(args[n], XmNlabelString, labelStr); n++;
3550   c[4] = cascadeB5 = XmCreateCascadeButton(menuBar, "help", args, n); 
3551   XmStringFree(labelStr); 
3552
3553   XtManageChildren(c, 5);
3554
3555    
3556   /* Attaches the Help menupane to the right side */
3557   n = 0;
3558   XtSetArg (args[n], XmNmenuHelpWidget, cascadeB5);  n++;
3559   XtSetValues (menuBar, args, n);
3560
3561
3562   return(menuBar);
3563
3564
3565 }  /* End SetupHelpDialogMenus */
3566
3567
3568
3569 \f
3570 /*********************************************************************
3571  * Function:  CreatePopupMenu
3572  *
3573  *   This procedure builds the popup menu for the display area
3574  *
3575  **********************************************************************/
3576 static Widget CreatePopupMenu(
3577     Widget nw)
3578 {
3579    Widget       popup;
3580    Widget       c[10];
3581    Arg          args[10];       
3582    int          n;
3583    XmString     labelStr;
3584    DtHelpDialogWidget hw = (DtHelpDialogWidget) nw;
3585    DtHelpListStruct *pHelpInfo;
3586    char        *mnemonic;
3587    int numButtons = XGetPointerMapping(XtDisplay(nw),(unsigned char *)NULL, 0);
3588
3589    /* Build the popup */
3590    /* If no Btn3 then use Btn2 to post the menu */
3591    n = 0;
3592    if (numButtons < 3) {
3593       XtSetArg(args[n], XmNwhichButton, Button2); n++;
3594    }
3595    popup = XmCreatePopupMenu (
3596                 _DtHelpDisplayAreaWidget(hw->help_dialog.help.pDisplayArea),
3597                              "popup", args, n); 
3598
3599    /* Add our button three event handler to our newly created display area */
3600    XtAddEventHandler(
3601                 _DtHelpDisplayAreaWidget(hw->help_dialog.help.pDisplayArea), 
3602                     ButtonPressMask, FALSE, 
3603                     (XtEventHandler)ProcessBMenuBackCB, hw);
3604
3605   /* Add Help callback for Popup Menu */
3606   pHelpInfo = _DtHelpListAdd(DtHELP_PopupMenu_STR,
3607                        (Widget) hw, &hw->help_dialog.help,
3608                         &hw->help_dialog.help.pHelpListHead);
3609   XtAddCallback((Widget) popup, XmNhelpCallback,
3610                  _DtHelpCB, (XtPointer) pHelpInfo);
3611
3612    /* Build the popup menu items */
3613
3614   /* Popup Label*/
3615    labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(3, 4,"Help")));
3616    n = 0; 
3617    XtSetArg(args[n], XmNlabelString, labelStr); n++;
3618    c[0] = XmCreateLabelGadget(popup, "popupLabel", args, n);
3619    XmStringFree(labelStr); 
3620
3621    /* Place a menu break here  */
3622    n = 0;
3623    c[1] = XmCreateSeparatorGadget(popup, "seporator",args, n);
3624
3625  
3626    /* Back Button */
3627    labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 13,"Backtrack")));
3628    mnemonic = ((char *)_DTGETMESSAGE(2, 14,"B"));
3629    n = 0; 
3630    XtSetArg(args[n], XmNlabelString, labelStr); n++;
3631    XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3632    c[2] =  hw->help_dialog.menu.popupBackBtn  = XmCreatePushButtonGadget(popup,
3633                                             "backTrack", args, n);
3634    XmStringFree(labelStr); 
3635  
3636    XtAddCallback(hw->help_dialog.menu.popupBackBtn,XmNactivateCallback, 
3637                    _DtHelpDisplayBackCB, (XtPointer) hw); 
3638    XtSetSensitive(hw->help_dialog.menu.popupBackBtn, FALSE);
3639
3640
3641    /* Top Button */
3642    labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 11,"Home Topic")));
3643    mnemonic = ((char *)_DTGETMESSAGE(2, 12,"T"));
3644    n = 0; 
3645    XtSetArg(args[n], XmNlabelString, labelStr); n++;
3646    XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
3647    c[3] = hw->help_dialog.menu.popupTopBtn  = XmCreatePushButtonGadget(popup,
3648                                                      "homeTopic", args, n);
3649    XmStringFree(labelStr); 
3650    XtAddCallback(hw->help_dialog.menu.popupTopBtn,XmNactivateCallback, 
3651                   DisplayTopLevelCB, (XtPointer) hw); 
3652    
3653    XtManageChildren(c, 4);
3654
3655   return(popup);
3656
3657
3658 }