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