Remove NOTDONE code
[oweals/cde.git] / cde / lib / DtHelp / HelpQuickD.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 libraries 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: HelpQuickD.c /main/15 1996/08/29 14:34:56 drk $ */
24 /************************************<+>*************************************
25  ****************************************************************************
26  **
27  **   File:        HelpQuickD.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
44 #include <stdio.h>
45 #include <signal.h>
46 #include <unistd.h>  /* R_OK */
47
48 #include <X11/Intrinsic.h>
49 #include <X11/Shell.h>
50 #include <X11/Xatom.h>
51
52 /* These includes work in R4 and R5 */
53 #include <Xm/MwmUtil.h>
54 #include <Xm/Protocols.h>
55
56 #include <Xm/Xm.h>
57 #include <Xm/AtomMgr.h>
58
59 #include <Xm/XmP.h>
60 #include <Xm/DialogS.h>
61 #include <Xm/PushBG.h>
62 #include <Xm/SeparatoG.h>
63 #include <Xm/Frame.h>
64 #include <Xm/RepType.h>
65 #include <Xm/XmPrivate.h>
66
67 /* Copied from Xm/GeoUtilsI.h */
68 extern XmGeoMatrix _XmGeoMatrixAlloc( 
69                         unsigned int numRows,
70                         unsigned int numBoxes,
71                         unsigned int extSize) ;
72
73 /* Canvas Engine incudes */
74 #include "CanvasP.h"  /* for the link types */
75
76 /* Help Dialog Widget Includes */
77 #include "Access.h"
78 #include "bufioI.h"
79
80 #include <Dt/Help.h>
81 #include "HelpP.h"
82 #include "DisplayAreaI.h"
83 #include "DisplayAreaP.h"
84 #include "StringFuncsI.h"
85 #include "HelpQuickDP.h"
86 #include "HelpQuickDI.h"
87 #include "HelpQuickD.h"
88 #include "HelposI.h"
89 #include "HelpAccessI.h"
90 #include "Lock.h"
91
92 /* Display Area Includes */
93 #include "ActionsI.h"
94 #include "HelpI.h"
95 #include "CallbacksI.h"
96 #include "DestroyI.h"
97 #include "FormatI.h"
98 #include "HelpDialogI.h"
99 #include "HourGlassI.h"
100 #include "HyperTextI.h"
101 #include "ResizeI.h"
102 #include "FormatManI.h"
103 #include "HelpUtilI.h"
104 #include "MessagesP.h"
105 #include "SetListI.h"
106 #include "XUICreateI.h"
107 #include "FileUtilsI.h"
108
109 /* print dialogs */
110 #include "PrintI.h"
111
112 /* message catalog set */
113 #define HQSET  11
114
115 /* Quick Help Dialog Error message Defines */
116 #define QHDMessage1     _DtHelpMsg_0008
117 #define QHDMessage2     _DtHelpMsg_0007
118 #define QHDMessage3     _DtHelpMsg_0000
119 #define QHDMessage4     _DtHelpMsg_0001
120 #define QHDMessage5     _DtHelpMsg_0002
121 #define QHDMessage6     _DtHelpMsg_0003
122 #define QHDMessage7     _DtHelpMsg_0004
123 #define QHDMessage8     _DtHelpMsg_0010
124 #define QHDMessage9     _DtHelpMsg_0009
125 #define QHDMessage10    _DtHelpMsg_0005
126
127 \f
128 /********    Static Function Declarations    ********/
129
130 static void NavigationTypeDefault( 
131                         Widget widget,
132                         int offset,
133                         XrmValue *value) ;
134
135 static void ClassPartInitialize( 
136                         WidgetClass wc);
137 static void ClassInitialize( 
138                         void) ;
139 static void Initialize( 
140                         Widget rw,
141                         Widget nw,
142                         ArgList args,
143                         Cardinal *num_args);
144
145 static void Destroy(
146                         Widget w );
147 static Boolean SetValues( 
148                         Widget cw,
149                         Widget rw,
150                         Widget nw,
151                         ArgList args,
152                         Cardinal *num_args);
153 static void CloseQuickCB (
154                         Widget w,
155                         XtPointer clientData,
156                         XtPointer callData);
157 static void HelpButtonCB (
158                         Widget w,
159                         XtPointer clientData,
160                         XtPointer callData);
161 static void PrintQuickHelpCB (
162                         Widget w,
163                         XtPointer clientData,
164                         XtPointer callData);
165 static void VariableInitialize(
166                         DtHelpQuickDialogWidget nw);
167 static void FreeQuickHelpInfo(
168                         Widget nw,
169                         int cleanUpKind);
170 static void CatchClose(Widget widget); 
171 static void SetupTopic(
172                        Widget nw,
173                        int updateKind);
174 static void SetupDisplayType (
175                        Widget nw,
176                        int updateKind);
177 static void  ProcessJumpReuse(
178                         Widget nw,
179                         DtHelpHyperTextStruct *hyperData);
180 static void  ProcessBackCB(
181                         Widget w,
182                         XtPointer clientData,
183                         XtPointer callData );
184 static void UpdateJumpList(
185                         char *topicInfo,
186                         int topicType,
187                         Widget nw);
188 static void ResizeQuickDialogCB (
189                         XtPointer clientData);
190 static void InitialPopupCB(
191                         Widget w,
192                         XtPointer clientData,
193                         XtPointer callData);
194
195
196 /********    End Static Function Declarations    ********/
197
198
199
200 /* Static variables */
201
202 \f
203 /* Supported resources for the HelpQuickDialog Widget */
204
205 static XtResource resources[] = {
206
207     {   DtNminimizeButtons,
208         DtCMinimizeButtons,
209         XmRBoolean,
210         sizeof(Boolean),
211         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.qhelp.minimize_buttons),
212         XmRImmediate,
213         (XtPointer) False
214     },
215
216     {
217         DtNscrollBarPolicy,
218         DtCScrollBarPolicy, DtRDtScrollBarPolicy, sizeof (unsigned char),
219         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.display.scrollBarPolicy),
220         XmRImmediate,  (XtPointer) DtHELP_AS_NEEDED_SCROLLBARS
221     },
222    
223     {
224         DtNexecutionPolicy,
225         DtCExecutionPolicy, DtRDtExecutionPolicy, sizeof (unsigned char),
226         XtOffset (DtHelpDialogWidget, help_dialog.display.executionPolicy),
227         XmRImmediate,  (XtPointer) DtHELP_EXECUTE_QUERY_UNALIASED
228     },
229
230     {   DtNcolumns, 
231         DtCColumns, XmRShort, sizeof(short), 
232         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.display.textColumns), 
233         XmRImmediate, (XtPointer) 50
234      },
235     
236      {  DtNrows, 
237         DtCRows, XmRShort, sizeof(short), 
238         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.display.textRows), 
239         XmRImmediate, (XtPointer) 15
240      },
241
242      {  DtNlocationId, 
243         DtCLocationId, XmRString, sizeof (char*), 
244         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.display.locationId), 
245         XmRImmediate, (XtPointer) _DtHelpDefaultLocationId
246       }, 
247
248      {  DtNhelpPrint, 
249         DtCHelpPrint, XmRString, sizeof (char*), 
250         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.print.helpPrint), 
251         XmRImmediate, (XtPointer) _DtHelpDefaultHelpPrint
252       }, 
253
254      {  DtNprinter, 
255         DtCPrinter, XmRString, sizeof (char*), 
256         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.print.printer), 
257         XmRImmediate, (XtPointer) NULL
258       }, 
259
260      {  DtNpaperSize,
261         DtCPaperSize, DtRDtPaperSize, sizeof (unsigned char),
262         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.print.paperSize),
263         XmRImmediate, (XtPointer) DtHELP_PAPERSIZE_LETTER
264       },
265
266      {  DtNhelpVolume, 
267         DtCHelpVolume, XmRString, sizeof (char*), 
268         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.display.helpVolume), 
269         XmRImmediate, (XtPointer) NULL
270       }, 
271
272       { DtNmanPage, 
273         DtCManPage, XmRString, sizeof (char*), 
274         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.display.manPage), 
275         XmRImmediate, (XtPointer) NULL
276       }, 
277
278       { DtNstringData, 
279         DtCStringData, XmRString, sizeof (char*), 
280         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.display.stringData), 
281         XmRImmediate, (XtPointer) NULL
282       }, 
283
284       { DtNhelpFile, 
285         DtCHelpFile, XmRString, sizeof (char*), 
286         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.display.helpFile), 
287         XmRImmediate, (XtPointer) NULL
288       }, 
289
290       { DtNtopicTitle,
291         DtCTopicTitle, XmRString, sizeof (char*),
292         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.display.topicTitleStr),
293         XmRImmediate, (XtPointer) NULL
294       },
295
296       { DtNhelpType, 
297         DtCHelpType, DtRDtHelpType, sizeof(unsigned char), 
298         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.display.helpType), 
299         XmRImmediate, (XtPointer) DtHELP_TYPE_TOPIC
300       },
301      
302       { DtNhelpOnHelpVolume,
303         DtCHelpOnHelpVolume, XmRString, sizeof (char*),
304         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.help.helpOnHelpVolume),
305         XmRImmediate, (XtPointer) _DtHelpDefaultHelp4HelpVolume
306       },
307
308       { DtNhyperLinkCallback, 
309         DtCHyperLinkCallback, XmRCallback, sizeof (XtCallbackList), 
310         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.display.hyperLinkCallback), 
311         XmRImmediate, (XtPointer) NULL
312       }, 
313
314       { DtNcloseCallback, 
315         DtCCloseCallback, XmRCallback, sizeof (XtCallbackList), 
316         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.qhelp.closeCallback), 
317         XmRImmediate, (XtPointer) NULL
318       },
319
320       { DtNcloseLabelString,
321         DtCCloseLabelString, XmRXmString, sizeof (XmString), 
322         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.qhelp.closeLabelString), 
323         XmRString, NULL
324       }, 
325  
326       { DtNmoreLabelString,
327         DtCMoreLabelString, XmRXmString, sizeof (XmString), 
328         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.qhelp.moreLabelString), 
329         XmRString, NULL
330       }, 
331  
332       { DtNbackLabelString,
333         DtCBackLabelString, XmRXmString, sizeof (XmString), 
334         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.qhelp.backLabelString), 
335         XmRString, NULL
336       }, 
337
338       { DtNhelpLabelString, 
339         DtCHelpLabelString, XmRXmString, sizeof (XmString), 
340         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.qhelp.helpLabelString), 
341         XmRString, NULL
342         }, 
343       
344       { DtNprintLabelString, 
345         DtCPrintLabelString, XmRXmString, sizeof (XmString), 
346         XtOffset (DtHelpQuickDialogWidget, qhelp_dialog.qhelp.printLabelString), 
347         XmRString, NULL
348         }, 
349
350       { XmNnavigationType, XmCNavigationType, XmRNavigationType,
351         sizeof(unsigned char),
352         XtOffsetOf (XmManagerRec, manager.navigation_type),
353         XmRCallProc, (XtPointer) NavigationTypeDefault
354       },
355 };
356
357 /*
358  * attach the action list to the widget. Then it does not
359  * matter which Xt[App]Initialize an application does.
360  */
361 static XtActionsRec DrawnBActions[] =
362     {
363         {"DeSelectAll"    , _DtHelpDeSelectAll    },
364         {"SelectAll"      , _DtHelpSelectAll      },
365         {"ActivateLink"   , _DtHelpActivateLink   },
366         {"CopyToClipboard", _DtHelpCopyAction     },
367         {"PageUpOrDown"   , _DtHelpPageUpOrDown   },
368         {"PageLeftOrRight", _DtHelpPageLeftOrRight},
369         {"NextLink"       , _DtHelpNextLink       }
370     };
371
372 \f
373 /****************************************************************
374  *
375  * Full class record constant
376  *
377  ****************************************************************/
378
379 externaldef( dthelpquickdialogwidgetclassrec) DtHelpQuickDialogWidgetClassRec dtHelpQuickDialogWidgetClassRec =
380 {
381    {                                            /* core_class fields  */
382       (WidgetClass) &xmBulletinBoardClassRec,   /* superclass         */
383       "DtHelpQuickDialog",                      /* class_name         */
384       sizeof(DtHelpQuickDialogWidgetRec),       /* widget_size        */
385       ClassInitialize,                          /* class_initialize   */
386       ClassPartInitialize,                      /* class_part_init    */
387       FALSE,                                    /* class_inited       */
388       Initialize,                               /* initialize         */
389       NULL,                                     /* initialize_hook    */
390       XtInheritRealize,                         /* realize            */
391       DrawnBActions,                            /* actions            */
392       XtNumber(DrawnBActions),                  /* num_actions        */
393       resources,                                /* resources          */
394       XtNumber(resources),                      /* num_resources      */
395       NULLQUARK,                                /* xrm_class          */
396       TRUE,                                     /* compress_motion    */
397       XtExposeCompressMaximal,                  /* compress_exposure  */
398       FALSE,                                    /* compress_enterlv   */
399       FALSE,                                    /* visible_interest   */
400       Destroy,                                  /* destroy            */
401       XtInheritResize,                          /* resize             */
402       XtInheritExpose,                          /* expose             */
403       SetValues,                                /* set_values         */
404       NULL,                                     /* set_values_hook    */
405       XtInheritSetValuesAlmost,                 /* set_values_almost  */
406       NULL,                                     /* get_values_hook    */
407       XtInheritAcceptFocus,                     /* enter_focus        */
408       XtVersion,                                /* version            */
409       NULL,                                     /* callback_private   */
410       XtInheritTranslations,                    /* tm_table           */
411       XtInheritQueryGeometry,                   /* query_geometry     */
412       NULL,                                     /* display_accelerator*/
413       NULL,                                     /* extension          */
414    },
415
416    {                                            /* composite_class fields */
417       XtInheritGeometryManager,                 /* geometry_manager   */
418       XtInheritChangeManaged,                   /* change_managed     */
419       XtInheritInsertChild,                     /* insert_child       */
420       XtInheritDeleteChild,                     /* delete_child       */
421       NULL,                                     /* extension          */
422    },
423
424    {                                            /* constraint_class fields */
425       NULL,                                     /* resource list        */   
426       0,                                        /* num resources        */   
427       0,                                        /* constraint size      */   
428       NULL,                                     /* init proc            */   
429       NULL,                                     /* destroy proc         */   
430       NULL,                                     /* set values proc      */   
431       NULL,                                     /* extension            */
432    },
433
434    {                                            /* manager_class fields   */
435       XmInheritTranslations,                    /* translations           */
436       NULL,                                     /* syn_resources          */
437       0,                                        /* num_syn_resources      */
438       NULL,                                     /* syn_cont_resources     */
439       0,                                        /* num_syn_cont_resources */
440       XmInheritParentProcess,                   /* parent_process         */
441       NULL,                                     /* extension              */
442    },
443
444    {                                            /* bulletinBoard class  */
445       TRUE,                                     /*always_install_accelerators*/
446       _DtHelpQuickDialogWidgetGeoMatrixCreate,      /* geo__matrix_create */
447       XmInheritFocusMovedProc,                  /* focus_moved_proc */
448       NULL                                      /* extension */
449    },   
450
451    {                                            /* messageBox class - none */
452       0                                         /* mumble */
453    }    
454 };
455
456 externaldef( dthelpquickdialogwidgetclass) WidgetClass 
457           dtHelpQuickDialogWidgetClass = 
458                        (WidgetClass) &dtHelpQuickDialogWidgetClassRec;
459
460
461 static char *HelpTypeNames[] =
462 {   "help_type_topic", 
463     "help_type_string",
464     "help_type_man_page",
465     "help_type_file",
466     "help_type_dynamic_string"
467 };
468
469 static char *ScrollBarValueNames[] =
470 {   "help_no_scrollbars",
471     "help_static_scrollbars", 
472     "help_as_needed_scrollbars"
473 };
474
475 static char *ExecutionValueNames[] =
476 {   "help_execute_none",
477     "help_execute_query_all",
478     "help_execute_query_unaliased",
479     "help_execute_all"
480 };
481
482 /* the _DtHelpPaperSizeNames[] are in Print.c */
483
484 #define NUM_NAMES( list )        (sizeof( list) / sizeof( char *))
485
486
487
488 \f
489 /*********************************************************************
490  *
491  * NavigationTypeDefault
492  *    
493  *
494  *********************************************************************/
495 static void 
496 NavigationTypeDefault(
497         Widget widget,
498         int offset,             /* unused */
499         XrmValue *value )
500 {
501     static XmNavigationType navigation_type;
502     Widget parent = XtParent(widget) ;
503
504     value->addr = (XPointer) &navigation_type;
505     if (XtIsShell(parent)) {
506         navigation_type = XmSTICKY_TAB_GROUP;
507     } else {
508         navigation_type = XmTAB_GROUP;
509     }
510       
511 }
512
513 /*****************************************************************************
514  * Function:        static void ClassPartInitialize (
515  *                      WidgetClass widgetClass)
516  *
517  * Parameters:      WidgetClass      
518  *
519  *
520  * Return Value:    Void.
521  *
522  * Purpose:         
523  *
524  *****************************************************************************/
525 static void ClassPartInitialize(
526     WidgetClass widgetClass)
527 {
528
529   /* _XmFastSubclassInit (widgetClass, XmTEMPLATE_BOX_BIT); */
530
531     return ;
532 }
533
534
535 \f
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
549 static void ClassInitialize(
550     void)
551 {
552   XmRepTypeId checkId;
553
554     /* First check to see if these have already been registered */
555      checkId = XmRepTypeGetId(DtRDtScrollBarPolicy);
556
557
558     if (checkId == XmREP_TYPE_INVALID)
559       {
560         /* Register the help representation types here */
561    
562         XmRepTypeRegister(DtRDtHelpType, HelpTypeNames, NULL,
563                                       NUM_NAMES(HelpTypeNames)) ;
564         XmRepTypeRegister(DtRDtScrollBarPolicy, ScrollBarValueNames, NULL,
565                                       NUM_NAMES(ScrollBarValueNames)) ;
566         XmRepTypeRegister(DtRDtExecutionPolicy, ExecutionValueNames, NULL,
567                                       NUM_NAMES(ExecutionValueNames)) ;
568         XmRepTypeRegister(DtRDtPaperSize, _DtHelpPaperSizeNames, NULL,
569                                       _DtHelpPaperSizeNamesCnt) ;
570       }
571
572     return ;
573 }
574
575  
576 \f
577 /*****************************************************************************
578  * Function:        static void VariableInitialize()
579  *                      
580  *
581  * Return Value:    Void.
582  *
583  *
584  * Purpose:         This routine initializes all global variables to valid
585  *                  starting values.
586  *
587  *****************************************************************************/
588 static void VariableInitialize(
589 DtHelpQuickDialogWidget nw)
590 {
591
592   DtHelpQuickDialogWidget qw = (DtHelpQuickDialogWidget) nw ;
593
594   /* Set our current topic variables to initial values */
595   _DtHelpCommonHelpInit(&qw->qhelp_dialog.help);
596
597   /* set inherited values */
598   qw->bulletin_board.auto_unmanage  = FALSE;
599   qw->bulletin_board.resize_policy  = XmRESIZE_NONE;
600
601   /* Set display values */
602   /* Make local copies of all resource strings assigned by the user */
603   if (qw->qhelp_dialog.display.locationId != NULL)
604     qw->qhelp_dialog.display.locationId = XtNewString(qw->qhelp_dialog.display.locationId);
605   if (qw->qhelp_dialog.display.helpVolume != NULL)
606      qw->qhelp_dialog.display.helpVolume =
607                           XtNewString(qw->qhelp_dialog.display.helpVolume);
608   if (qw->qhelp_dialog.display.manPage != NULL)
609     qw->qhelp_dialog.display.manPage = XtNewString(qw->qhelp_dialog.display.manPage);
610   if (qw->qhelp_dialog.display.stringData != NULL)
611     qw->qhelp_dialog.display.stringData = XtNewString(qw->qhelp_dialog.display.stringData);
612   if (qw->qhelp_dialog.display.helpFile != NULL)
613     qw->qhelp_dialog.display.helpFile = XtNewString(qw->qhelp_dialog.display.helpFile);
614
615   /* Initialize the topic title variables. */
616   qw->qhelp_dialog.display.topicTitleLbl = NULL;
617   if (qw->qhelp_dialog.display.topicTitleStr != NULL)
618     qw->qhelp_dialog.display.topicTitleLbl = XmStringCreateLocalized(
619                                         qw->qhelp_dialog.display.topicTitleStr);
620
621   /* Set our volume handle to an NULL initial value */
622   qw->qhelp_dialog.display.volumeHandle = NULL;
623
624   /* setup print stuff */
625   _DtHelpInitPrintStuff(&qw->qhelp_dialog.print);
626
627
628  /* Set our map flag: true after we hit our popup callback, 
629    * false otherwise
630    */
631   qw->qhelp_dialog.display.firstTimePopupFlag = FALSE;
632
633
634   /* Set our jump list display stuff to initial values */
635   qw->qhelp_dialog.backtr.pJumpListHead     = NULL;
636   qw->qhelp_dialog.backtr.pJumpListTale     = NULL;
637   qw->qhelp_dialog.backtr.totalJumpNodes    = 0;
638   qw->qhelp_dialog.backtr.scrollPosition    = -1;
639  
640   /* Set our help dialog widgets to NULL starting values */
641   qw->qhelp_dialog.qhelp.separator          = NULL;
642   qw->qhelp_dialog.qhelp.displayAreaFrame   = NULL;
643   qw->qhelp_dialog.qhelp.closeButton        = NULL;
644   qw->qhelp_dialog.qhelp.helpButton         = NULL;
645   qw->qhelp_dialog.qhelp.printButton        = NULL;
646   qw->qhelp_dialog.qhelp.moreButton         = NULL;
647   qw->qhelp_dialog.qhelp.backButton         = NULL;
648   qw->qhelp_dialog.qhelp.definitionBox      = NULL;
649 }
650
651 \f
652 /*****************************************************************************
653  * Function:        FilterExecCmdCB
654  *
655  *  clientData:     The quick help dialog widget
656  *  cmdStr:         cmd string to filter
657  *  ret_filteredCmdStr:  string after filtering.  NULL if exec denied
658  *
659  * Return Value:    0: ok, < 0: error
660  *
661  * Purpose:         filter an execution command using executionPolicy rsrc
662  *
663  * Memory:
664  *   The caller must free memory allocated for the ret_filteredCmdStr
665  *****************************************************************************/
666 static int FilterExecCmdCB(
667     void *   clientData,
668     const char *   cmdStr,
669     char * * ret_filteredCmdStr)
670 {
671      DtHelpQuickDialogWidget qw;
672      char    *hv_path;
673
674      qw = (DtHelpQuickDialogWidget) _DtHelpDisplayAreaData(clientData);
675
676      hv_path = _DtHelpFileLocate(DtHelpVOLUME_TYPE,
677                                  qw->qhelp_dialog.display.helpVolume,
678                                  _DtHelpFileSuffixList, False, R_OK);
679      return _DtHelpFilterExecCmd((Widget) qw, cmdStr, 
680                   qw->qhelp_dialog.display.executionPolicy, 
681                   True, &qw->qhelp_dialog.help, ret_filteredCmdStr, hv_path);
682 }
683
684
685 \f
686 /*****************************************************************************
687  * Function:        static void Initialize (
688  *                      WidgetClass widgetClass)
689  *
690  * Parameters:      WidgetClass      
691  *
692  *
693  * Return Value:    Void.
694  *
695  * Purpose:         This is the Help Dialog widget initialize routine. This
696  *                  routine is responsible for the following:
697  *                      1) Validate all resources the user passed in.
698  *                      2) Over ride any invalid resources.
699  *                      3) Build the internal UI component for the Help Dialog.
700  *                      4) Add any internal callbacks for the UI components.
701  *
702  *****************************************************************************/
703 static void Initialize(
704     Widget rw,
705     Widget nw,
706     ArgList args_init,
707     Cardinal *num_args )
708 {
709
710   Arg           args[10];       /*  arg list            */
711   int           n;              /*  arg count           */
712   XmFontList  defaultList;
713   DtHelpQuickDialogWidget qw = (DtHelpQuickDialogWidget) nw ;
714   DtHelpListStruct *pHelpInfo;
715
716   /* Local variables */
717   XmString          labelStr;
718
719   /* Initialize all global variables */
720   VariableInitialize(qw);
721
722   /* Setup a frame to hold our display area */
723    n = 0;
724    XtSetArg(args[n], XmNshadowThickness, 0);            ++n;
725    qw->qhelp_dialog.qhelp.displayAreaFrame = 
726              XmCreateFrame ((Widget)qw, "displayAreaFrame", args, n);
727    XtManageChild (qw->qhelp_dialog.qhelp.displayAreaFrame);
728    
729
730   /*  Create a separator between the buttons  */
731   n = 0;
732   qw->qhelp_dialog.qhelp.separator = 
733            XmCreateSeparatorGadget ((Widget)qw, "separator", args, n);
734   XtManageChild (qw->qhelp_dialog.qhelp.separator);
735
736
737   /* Setup the control buttons along the bottom */
738
739   /* Close button */
740
741   if (qw->qhelp_dialog.qhelp.closeLabelString != NULL)
742     labelStr = XmStringCopy(qw->qhelp_dialog.qhelp.closeLabelString);
743   else
744     labelStr = XmStringCreateLocalized(
745            (char *)_DTGETMESSAGE(HQSET,1,"Close"));
746
747   n=0;
748   XtSetArg(args[n], XmNlabelString, labelStr);                  ++n;
749   qw->qhelp_dialog.qhelp.closeButton = 
750              XmCreatePushButtonGadget((Widget)qw, "closeButton", args, n);
751   XtManageChild (qw->qhelp_dialog.qhelp.closeButton);
752   XtAddCallback(qw->qhelp_dialog.qhelp.closeButton,XmNactivateCallback, 
753                  CloseQuickCB, (XtPointer) qw); 
754   XmStringFree(labelStr);
755
756   /* set the cancel button (for KCancel) */
757   qw->bulletin_board.cancel_button= qw->qhelp_dialog.qhelp.closeButton;
758   
759   /* Set the close button as the default button */
760   XtSetArg (args[0], XmNdefaultButton, qw->qhelp_dialog.qhelp.closeButton);
761   XtSetValues ((Widget)qw, args, 1);
762
763
764   /* More button: We do not manage this button, the user must do that */
765
766   if (qw->qhelp_dialog.qhelp.moreLabelString != NULL)
767     labelStr = XmStringCopy(qw->qhelp_dialog.qhelp.moreLabelString);
768   else
769     labelStr = XmStringCreateLocalized(
770            (char *)_DTGETMESSAGE(HQSET,2,"More ..."));
771
772   n=0;
773   XtSetArg(args[n], XmNlabelString, labelStr);                  ++n;
774   qw->qhelp_dialog.qhelp.moreButton = 
775              XmCreatePushButtonGadget((Widget)qw, "moreButton", args, n);
776   XmStringFree(labelStr);
777
778
779   /* Back button */
780
781   if (qw->qhelp_dialog.qhelp.backLabelString != NULL)
782     labelStr = XmStringCopy(qw->qhelp_dialog.qhelp.backLabelString);
783   else
784     labelStr = XmStringCreateLocalized(
785            (char *)_DTGETMESSAGE(HQSET,3,"Backtrack"));
786
787   n=0;
788   XtSetArg(args[n], XmNlabelString, labelStr);                  ++n;
789   qw->qhelp_dialog.qhelp.backButton = 
790              XmCreatePushButtonGadget((Widget)qw, "backButton", args, n);
791   XtManageChild (qw->qhelp_dialog.qhelp.backButton);
792   XtAddCallback(qw->qhelp_dialog.qhelp.backButton,XmNactivateCallback, 
793                  ProcessBackCB, (XtPointer) qw); 
794   XmStringFree(labelStr);
795
796   XtSetSensitive(qw->qhelp_dialog.qhelp.backButton, FALSE);
797
798
799
800   /* Print button */
801   if (qw->qhelp_dialog.qhelp.printLabelString != NULL)
802     labelStr = XmStringCopy(qw->qhelp_dialog.qhelp.printLabelString);
803   else
804     labelStr = XmStringCreateLocalized(
805            (char *)_DTGETMESSAGE(HQSET,4,"Print ..."));  
806
807   n=0;
808   XtSetArg(args[n], XmNlabelString, labelStr);                  ++n;
809   qw->qhelp_dialog.qhelp.printButton = 
810              XmCreatePushButtonGadget((Widget)qw, "printButton", args, n);
811   XtManageChild (qw->qhelp_dialog.qhelp.printButton);
812   
813   XtAddCallback(qw->qhelp_dialog.qhelp.printButton,XmNactivateCallback, 
814                 PrintQuickHelpCB, (XtPointer) qw); 
815   XmStringFree(labelStr); 
816   
817
818   /* Help Button */
819
820   if (qw->qhelp_dialog.qhelp.helpLabelString != NULL)
821     labelStr = XmStringCopy(qw->qhelp_dialog.qhelp.helpLabelString);
822   else
823     labelStr = XmStringCreateLocalized(
824            (char *)_DTGETMESSAGE(HQSET,5,"Help ..."));
825
826   n=0;
827   XtSetArg(args[n], XmNlabelString, labelStr);          ++n;
828   qw->qhelp_dialog.qhelp.helpButton = 
829         XmCreatePushButtonGadget((Widget)qw,"helpButton", args, n);
830   XtManageChild(qw->qhelp_dialog.qhelp.helpButton);
831   /* Now remove BulletinBoard Unmanage callback from apply and help buttons. */
832   XtRemoveAllCallbacks( qw->qhelp_dialog.qhelp.helpButton, XmNactivateCallback) ;
833   /* and add ours */
834
835   pHelpInfo = _DtHelpListAdd(DtHELP_quickHelpBtn_STR,
836                         (Widget) qw, &qw->qhelp_dialog.help,
837                         &qw->qhelp_dialog.help.pHelpListHead);
838   XtAddCallback( qw->qhelp_dialog.qhelp.helpButton, XmNactivateCallback,
839                  _DtHelpCB, (XtPointer) pHelpInfo);
840   XmStringFree(labelStr);
841
842   /* Shell help */
843   pHelpInfo = _DtHelpListAdd(DtHELP_quickHelpShell_STR,
844                         (Widget) qw, &qw->qhelp_dialog.help,
845                         &qw->qhelp_dialog.help.pHelpListHead);
846   XtAddCallback((Widget) qw, XmNhelpCallback,
847                  _DtHelpCB, (XtPointer) pHelpInfo);
848
849   /* Get our current fontlist value */
850   n = 0;
851   XtSetArg (args[n], XmNfontList, &(defaultList));  ++n;
852   XtGetValues (qw->qhelp_dialog.qhelp.closeButton, args, n);
853
854
855   /* Build the Display Area */
856   qw->qhelp_dialog.help.pDisplayArea = _DtHelpCreateDisplayArea
857                                    ((Widget)qw->qhelp_dialog.qhelp.displayAreaFrame,
858                                    "DisplayArea",
859                                    ((short) qw->qhelp_dialog.display.scrollBarPolicy),
860                                    ((short) qw->qhelp_dialog.display.scrollBarPolicy),
861                                    False,
862                                    ((int) qw->qhelp_dialog.display.textRows),
863                                    ((int) qw->qhelp_dialog.display.textColumns),
864                                    _DtHelpQuickDialogHypertextCB,
865                                    ResizeQuickDialogCB,
866                                    FilterExecCmdCB,
867                                    (XtPointer) qw,
868                                    defaultList);
869
870   
871   /* Now Validate our incoming help requests topics */
872   SetupDisplayType((Widget)qw ,DtJUMP_UPDATE);
873
874   /* Just for fun, lets make sure our sizes are correct */
875   XtAddCallback (XtParent(qw), XmNpopupCallback, (XtCallbackProc)
876                  InitialPopupCB, (XtPointer) qw);
877
878
879  
880   return;
881 }
882
883
884
885 \f
886
887 /****************************************************************************
888  * Function:        static XtCallbackProc InitialPopupCB
889  *                   
890  *                            
891  *
892  * Parameters:  
893  *
894  * Return Value:    Void.
895  *
896  * Purpose:         We do some last minute sizing of our dialog on its first
897  *                  mapping, then we remove the callback.
898  *
899  ****************************************************************************/
900 static void InitialPopupCB(
901     Widget w,
902     XtPointer clientData,
903     XtPointer callData)
904 {
905    DtHelpQuickDialogWidget qw = (DtHelpQuickDialogWidget) clientData ;
906    
907  
908    /* set our firstTimePopupFlag to TRUE because we map it right 
909       after this call */
910    qw->qhelp_dialog.display.firstTimePopupFlag = TRUE;
911
912   _DtHelpResizeDisplayArea (XtParent(qw),
913                              qw->qhelp_dialog.help.pDisplayArea, 
914                              qw->qhelp_dialog.display.textRows,
915                              qw->qhelp_dialog.display.textColumns);
916
917   XtRemoveCallback (XtParent(qw), XmNpopupCallback, (XtCallbackProc)
918                   InitialPopupCB, (XtPointer) qw);
919
920 }
921
922
923
924
925 \f
926 /*****************************************************************************
927  * Function:        static Boolean SetValues(
928  *                             Widget cw,
929  *                             Widget rw,
930  *                             Widget nw,
931  *                             ArgList args,
932  *                             Cardinal *num_args )
933  *
934  * Parameters:      cw       Specifies the current working widget.
935  *                  rw       Specifies the replacement working widget.
936  *                  nw       Specifies the new widget.
937  *                  args     Specifies the arguments to be applied to the
938  *                           New widget.
939  *                  numArgs  Number of argument/value pars in args.
940  *
941  * Return Value:    
942  *
943  * Purpose:         Set the attributes of the Help Dialog widget.
944
945  *
946  *****************************************************************************/
947 static Boolean SetValues(
948     Widget cw,
949     Widget rw,
950     Widget nw,
951     ArgList args,
952     Cardinal *numArgs)
953 {
954  
955   DtHelpQuickDialogWidget qw = (DtHelpQuickDialogWidget) nw ;
956   DtHelpQuickDialogWidget current = (DtHelpQuickDialogWidget) cw ;
957   Boolean updateRequest=FALSE;
958
959   /* Setup some initial argument values we know we need on the B-board */
960   qw->bulletin_board.auto_unmanage  = FALSE;
961   qw->bulletin_board.resize_policy  = XmRESIZE_NONE;
962  
963   /* Check DtNcolumns & or DtNrows  resource for change */
964   if ((current->qhelp_dialog.display.textRows != qw->qhelp_dialog.display.textRows) ||
965       (current->qhelp_dialog.display.textColumns != qw->qhelp_dialog.display.textColumns))
966     {
967       /* Perform a resize on our display area */
968       _DtHelpResizeDisplayArea (XtParent(qw),
969                              qw->qhelp_dialog.help.pDisplayArea, 
970                              qw->qhelp_dialog.display.textRows,
971                              qw->qhelp_dialog.display.textColumns);
972
973     }
974
975   /* Check DtNhelpVolume resource for change */
976   if (current->qhelp_dialog.display.helpVolume != qw->qhelp_dialog.display.helpVolume) 
977     {
978       qw->qhelp_dialog.display.helpVolume = XtNewString(qw->qhelp_dialog.display.helpVolume);
979       XtFree(current->qhelp_dialog.display.helpVolume);
980       updateRequest = TRUE;
981     }
982
983
984   /* Check DtNlocationId resource for change */
985   if (current->qhelp_dialog.display.locationId != qw->qhelp_dialog.display.locationId) 
986     {
987       qw->qhelp_dialog.display.locationId = XtNewString(qw->qhelp_dialog.display.locationId);
988       XtFree(current->qhelp_dialog.display.locationId);
989       updateRequest = TRUE;
990     }
991
992    /* set the printing resources */
993    _DtHelpPrintSetValues(&current->qhelp_dialog.print,&qw->qhelp_dialog.print,
994              &qw->qhelp_dialog.display,&qw->qhelp_dialog.help);
995
996   /* Check DtNmanPage resource for change */
997   if (current->qhelp_dialog.display.manPage != qw->qhelp_dialog.display.manPage) 
998     {
999       qw->qhelp_dialog.display.manPage = XtNewString(qw->qhelp_dialog.display.manPage);
1000       XtFree(current->qhelp_dialog.display.manPage);
1001       updateRequest = TRUE;
1002     }
1003
1004   /* Check DtNstringData resource for change */
1005   if (current->qhelp_dialog.display.stringData != qw->qhelp_dialog.display.stringData) 
1006     {
1007       qw->qhelp_dialog.display.stringData = XtNewString(qw->qhelp_dialog.display.stringData);
1008       XtFree(current->qhelp_dialog.display.stringData);
1009       updateRequest = TRUE;
1010     }
1011
1012
1013   /* Check DtNhelpFile resource for change */
1014   if (current->qhelp_dialog.display.helpFile != qw->qhelp_dialog.display.helpFile) 
1015     {
1016       qw->qhelp_dialog.display.helpFile = XtNewString(qw->qhelp_dialog.display.helpFile);
1017       XtFree(current->qhelp_dialog.display.helpFile);
1018       updateRequest = TRUE;
1019     }
1020
1021    
1022     /* Check and modify if required any of the push button labels */
1023
1024     /* Check DtNcloseLabelString resource for change */
1025     if (current->qhelp_dialog.qhelp.closeLabelString != 
1026                                   qw->qhelp_dialog.qhelp.closeLabelString) 
1027       {
1028         qw->qhelp_dialog.qhelp.closeLabelString =
1029                     XmStringCopy(qw->qhelp_dialog.qhelp.closeLabelString);
1030         XmStringFree(current->qhelp_dialog.qhelp.closeLabelString);
1031         
1032         XtSetArg(args[0], XmNlabelString, qw->qhelp_dialog.qhelp.closeLabelString); 
1033         XtSetValues(qw->qhelp_dialog.qhelp.closeButton, args, 1);
1034       }
1035
1036     /* Check DtNhelpLabelString resource for change */
1037     if (current->qhelp_dialog.qhelp.helpLabelString != 
1038                                   qw->qhelp_dialog.qhelp.helpLabelString) 
1039       {
1040         qw->qhelp_dialog.qhelp.helpLabelString =
1041                     XmStringCopy(qw->qhelp_dialog.qhelp.helpLabelString);
1042         XmStringFree(current->qhelp_dialog.qhelp.helpLabelString);
1043         
1044         XtSetArg(args[0], XmNlabelString, qw->qhelp_dialog.qhelp.helpLabelString); 
1045         XtSetValues(qw->qhelp_dialog.qhelp.helpButton, args, 1);
1046       }
1047
1048     /* Check DtNmoreLabelString resource for change */
1049     if (current->qhelp_dialog.qhelp.moreLabelString != 
1050                                   qw->qhelp_dialog.qhelp.moreLabelString) 
1051       {
1052         qw->qhelp_dialog.qhelp.moreLabelString =
1053                     XmStringCopy(qw->qhelp_dialog.qhelp.moreLabelString);
1054         XmStringFree(current->qhelp_dialog.qhelp.moreLabelString);
1055         
1056         XtSetArg(args[0], XmNlabelString, qw->qhelp_dialog.qhelp.moreLabelString); 
1057         XtSetValues(qw->qhelp_dialog.qhelp.moreButton, args, 1);
1058       }
1059
1060     /* Check DtNbackLabelString resource for change */
1061     if (current->qhelp_dialog.qhelp.backLabelString != 
1062                                   qw->qhelp_dialog.qhelp.backLabelString) 
1063       {
1064         qw->qhelp_dialog.qhelp.backLabelString =
1065                     XmStringCopy(qw->qhelp_dialog.qhelp.backLabelString);
1066         XmStringFree(current->qhelp_dialog.qhelp.backLabelString);
1067         
1068         XtSetArg(args[0], XmNlabelString, qw->qhelp_dialog.qhelp.backLabelString); 
1069         XtSetValues(qw->qhelp_dialog.qhelp.backButton, args, 1);
1070       }
1071
1072     /* Check DtNprintLabelString resource for change */
1073     if (current->qhelp_dialog.qhelp.printLabelString != 
1074                                   qw->qhelp_dialog.qhelp.printLabelString) 
1075       {
1076         qw->qhelp_dialog.qhelp.printLabelString =
1077                     XmStringCopy(qw->qhelp_dialog.qhelp.printLabelString);
1078         XmStringFree(current->qhelp_dialog.qhelp.printLabelString);
1079         
1080         XtSetArg(args[0], XmNlabelString, qw->qhelp_dialog.qhelp.printLabelString); 
1081         XtSetValues(qw->qhelp_dialog.qhelp.printButton, args, 1);
1082       }
1083
1084
1085  
1086   /* Check the help type for change */
1087   if ((current->qhelp_dialog.display.helpType != qw->qhelp_dialog.display.helpType) ||
1088      (updateRequest))
1089     {
1090       /* Setup and display our new topic */
1091       SetupDisplayType((Widget)qw, DtJUMP_UPDATE);
1092     }
1093
1094
1095
1096   return(FALSE);
1097 }
1098
1099
1100
1101
1102
1103
1104 \f
1105 /*****************************************************************************
1106  * Function:        static void Destroy(Widget w );
1107  *
1108  * Parameters:      w       Specifies the widget to be  destroyed.
1109  *
1110  * Return Value:    
1111  *
1112  * Purpose:         Destroy any internally malloced memory.
1113  *
1114  *****************************************************************************/
1115 static void Destroy(
1116     Widget w)
1117 {
1118    DtHelpQuickDialogWidget qw = (DtHelpQuickDialogWidget) w;
1119
1120      /* This routine will clean up all malloc'ed stuff in our instance 
1121       * structure.  It does not remove any callbacks or delete any of the
1122       * widgets created in this instance of the help dialog.
1123       *
1124       * If destroy is being called, then the Display Area destroy has
1125       * already been called and the canvas has been freed. Therefore
1126       * pass in NULL for canvas type.
1127       */
1128
1129      FreeQuickHelpInfo((Widget)qw, DtCLEAN_FOR_DESTROY);
1130  
1131      /* Remove any of the callbacks added to the help dialog ??? */
1132
1133
1134 }
1135
1136 /*****************************************************************************
1137  * Function:        static void SeparatorFix( 
1138  *                            XmGeoMatrix geoSpec,
1139  *                            int action,
1140  *                            XmGeoRowLayout layoutPtr,
1141  *                            XmKidGeometry rowPtr)
1142  *                            
1143  *                         
1144  *
1145  * Parameters:   
1146  *
1147  * Return Value:    
1148  *
1149  * Purpose:       This routine is a fixup routine which can be used for rows 
1150  *                which consist of a single separator widget.  The effect of
1151  *                this routine is to have the separator ignore the margin
1152  *                width.
1153  *
1154  *****************************************************************************/
1155 /*ARGSUSED*/
1156 static void 
1157 SeparatorFix(
1158         XmGeoMatrix geoSpec,
1159         int action,
1160         XmGeoMajorLayout layoutPtr, /* unused */
1161         XmKidGeometry rowPtr )
1162 {
1163     Dimension       marginW ;
1164     Dimension       twoMarginW ;
1165
1166     marginW = geoSpec->margin_w ;
1167     twoMarginW = (marginW << 1) ;
1168
1169     switch(    action    )
1170     {   
1171         case XmGEO_PRE_SET:
1172         {   rowPtr->box.x -= marginW ;
1173             rowPtr->box.width += twoMarginW ;
1174             break ;
1175             } 
1176         default:
1177         {   if(    rowPtr->box.width > twoMarginW    )
1178             {   
1179                 /* Avoid subtracting a margin from box width which would
1180                 *   result in underflow.
1181                 */
1182                 rowPtr->box.x += marginW ;
1183                 rowPtr->box.width -= twoMarginW ;
1184                 } 
1185             if(    action == XmGET_PREFERRED_SIZE    )
1186             {   
1187                 /* Set width to some small value so it does not 
1188                 *   effect total width of matrix.
1189                 */
1190                 rowPtr->box.width = 1 ;
1191                 } 
1192             break ;
1193             } 
1194         } 
1195     return ;
1196
1197 \f
1198 /*****************************************************************************
1199  * Function:         XmGeoMatrix _DtHelpQuickDialogWidgeGeoMatrixCreate(
1200  *                           Widget wid,
1201  *                           Widget instigator,
1202  *                           XtWidgetGeometry *desired) 
1203  *
1204  * Parameters:   
1205  *
1206  * Return Value:    
1207  *
1208  * Purpose:       This routine is responsible for all the positioning of the
1209  *                the internal Help Dialog widgets.
1210  *
1211  *****************************************************************************/
1212 XmGeoMatrix _DtHelpQuickDialogWidgetGeoMatrixCreate(
1213     Widget wid,
1214     Widget instigator,
1215     XtWidgetGeometry *desired )
1216 {
1217  
1218
1219              DtHelpQuickDialogWidget qw = (DtHelpQuickDialogWidget) wid ;
1220              XmGeoMatrix     geoSpec ;
1221     XmGeoRowLayout  layoutPtr ;
1222     XmKidGeometry   boxPtr ;
1223              XmKidGeometry   firstButtonBox ;
1224
1225     /* Replace the value "10" for the marginWidth resource when avail */
1226
1227     geoSpec = _XmGeoMatrixAlloc( TB_MAX_WIDGETS_VERT, TB_MAX_NUM_WIDGETS, 0) ;
1228     geoSpec->composite = (Widget) qw ;
1229     geoSpec->instigator = (Widget) instigator ;
1230     if(    desired    )
1231     {   geoSpec->instig_request = *desired ;
1232         } 
1233     geoSpec->margin_w = 10 + qw->manager.shadow_thickness ;
1234     geoSpec->margin_h = 10 + qw->manager.shadow_thickness ;
1235     geoSpec->no_geo_request = _DtHelpQuickDialogWidgetNoGeoRequest ;
1236
1237     layoutPtr = (XmGeoRowLayout)geoSpec->layouts ;
1238     boxPtr = geoSpec->boxes ;
1239
1240      
1241     /* Display area setup stuff */
1242     if( _XmGeoSetupKid(boxPtr, qw->qhelp_dialog.qhelp.displayAreaFrame))
1243     {   
1244         layoutPtr->space_above = 5;
1245         layoutPtr->stretch_height = TRUE ;
1246         layoutPtr->min_height = 100 ;
1247         boxPtr += 2 ;       /* For new row, add 2. */
1248         ++layoutPtr ;       /* For new row. */
1249         } 
1250
1251
1252     /* Separator area setup stuff */
1253     if(    _XmGeoSetupKid(boxPtr, qw->qhelp_dialog.qhelp.separator))
1254     {   layoutPtr->fix_up = SeparatorFix ;
1255         layoutPtr->space_above = 10;
1256         boxPtr += 2 ;       /* For new row, add 2. */
1257         ++layoutPtr ;       /* For new row. */
1258         } 
1259     firstButtonBox = boxPtr ;
1260     if(    _XmGeoSetupKid( boxPtr, qw->qhelp_dialog.qhelp.closeButton)    )
1261     {   ++boxPtr ;
1262         } 
1263    if(    _XmGeoSetupKid( boxPtr, qw->qhelp_dialog.qhelp.moreButton)    )
1264     {   ++boxPtr ;
1265         } 
1266    if(    _XmGeoSetupKid( boxPtr, qw->qhelp_dialog.qhelp.backButton)    )
1267     {   ++boxPtr ;
1268         } 
1269     if(    _XmGeoSetupKid( boxPtr, qw->qhelp_dialog.qhelp.printButton)    )
1270     {   ++boxPtr ;
1271         } 
1272     if(    _XmGeoSetupKid( boxPtr, qw->qhelp_dialog.qhelp.helpButton)    )
1273     {   ++boxPtr ;
1274         } 
1275    
1276     if(    boxPtr != firstButtonBox    )
1277     {   /* Had at least one button.
1278         */
1279         layoutPtr->fill_mode = XmGEO_CENTER ;
1280         layoutPtr->fit_mode = XmGEO_WRAP ;
1281         layoutPtr->space_above = 10;
1282         if(    !(qw->qhelp_dialog.qhelp.minimize_buttons)    )
1283         {   layoutPtr->even_width = 1 ;
1284             } 
1285         layoutPtr->even_height = 1 ;
1286         ++layoutPtr ;
1287         } 
1288     layoutPtr->space_above = 10 ;
1289     layoutPtr->end = TRUE ;        /* Mark the last row. */
1290     return( geoSpec) ;
1291 }
1292
1293
1294
1295 \f
1296 /*****************************************************************************
1297  * Function:         Boolean _DtHelpQuickDialogWidgetNoGeoRequest(geoSpec)
1298  *                          XmGeoMatrix geoSpec)
1299  *
1300  *
1301  * Parameters:   
1302  *
1303  * Return Value:    
1304  *
1305  * Purpose:       
1306  *
1307  ****************************************************************************/
1308 Boolean _DtHelpQuickDialogWidgetNoGeoRequest(XmGeoMatrix geoSpec)
1309 {
1310
1311   if(    BB_InSetValues( geoSpec->composite)
1312       && (XtClass( geoSpec->composite) == dtHelpQuickDialogWidgetClass)    )
1313     {   
1314       return( TRUE) ;
1315     } 
1316   return( FALSE) ;
1317 }
1318
1319
1320
1321 \f
1322 /*****************************************************************************
1323  * Function:        Widget DtCreateHelpQuickDialog(Widget parent,
1324  *                                             String name,
1325  *                                             ArgList arglist,
1326  *                                             Cardinal argcount);
1327  *
1328  * Parameters:      parent      Specifies the parent widget ID.
1329  *                  name        Specifies the name of the created BB widget.
1330  *                  arglis      Specifies the argument list.
1331  *                  argcount    Specifies the number of attribute/value pairs
1332  *                              in the argument list (arglist).
1333  *
1334  * Return Value:    Returns a Bulletin Board widget ID, that correlates to
1335  *                  the top level child in the help dialog.
1336  *
1337  * Purpose:         Create an instance of a Help Dialog.
1338  *
1339  *****************************************************************************/
1340 Widget DtCreateHelpQuickDialog(
1341     Widget parent,
1342     char *name,
1343     ArgList al,
1344     Cardinal ac)
1345 {
1346     Widget w;
1347     _DtHelpWidgetToAppContext(parent);
1348     
1349     _DtHelpAppLock(app);
1350     w = XmeCreateClassDialog (dtHelpQuickDialogWidgetClass, parent, 
1351                               name, al, ac);
1352
1353     /* Add the CatchClose here so we catch the window manager close requests */
1354     CatchClose(w);
1355
1356     _DtHelpAppUnlock(app);
1357     return w;
1358 }
1359
1360
1361
1362 \f
1363 /*****************************************************************************
1364  * Function:        Widget DtHelpQuickDialogGetChild(Widget parent,
1365  *                                                unsigned char child);
1366  *
1367  * Parameters:      parent      Specifies the parent widget ID.
1368  *                  child       Specifies the child widget to return.
1369  *
1370  * Return Value:    Returns the requested widet id.
1371  *
1372  * Purpose:         Gives developers access to the quick help dialogs
1373  *                  children.
1374  *
1375  *****************************************************************************/
1376 Widget DtHelpQuickDialogGetChild(
1377         Widget widget,
1378         unsigned char child )
1379 {
1380     DtHelpQuickDialogWidget  w = (DtHelpQuickDialogWidget)widget;
1381     Widget result = NULL;
1382
1383     _DtHelpWidgetToAppContext(widget);
1384
1385     _DtHelpAppLock(app);
1386     switch (child) 
1387       {
1388       case DtHELP_QUICK_PRINT_BUTTON:
1389           result = (w->qhelp_dialog.qhelp.printButton);
1390           break;
1391           
1392         case DtHELP_QUICK_MORE_BUTTON: 
1393           result = (w->qhelp_dialog.qhelp.moreButton);
1394           break;
1395    
1396         case DtHELP_QUICK_BACK_BUTTON: 
1397           result = (w->qhelp_dialog.qhelp.backButton);
1398           break;
1399   
1400         case DtHELP_QUICK_CLOSE_BUTTON: 
1401           result = (w->qhelp_dialog.qhelp.closeButton);
1402           break;
1403            
1404         case DtHELP_QUICK_HELP_BUTTON:
1405           result = (w->qhelp_dialog.qhelp.helpButton);
1406           break;
1407          
1408         case DtHELP_QUICK_SEPARATOR:  
1409           result = (w->qhelp_dialog.qhelp.separator);
1410           break;
1411
1412         default: 
1413           XmeWarning( (Widget) w, (char*)QHDMessage1); 
1414           break;
1415        }  /* End of switch statement */
1416
1417     _DtHelpAppUnlock(app);
1418     return result;
1419 }
1420
1421
1422
1423 \f
1424 /*****************************************************************************
1425  * Function:        void _DtHelpQuickDialogHypertextCB(
1426  *                              DtHelpDispAreaStruct *pDisplayAreaStruct,
1427  *                              XtPointer clientData, 
1428  *                              DtHelpHyperTextStruct *hyperData.) 
1429  *
1430  * Parameters:      pDisplayAreaStruct  Specifies the curretn display are info.
1431  *
1432  *                  clientData          Specifies the client data passed into
1433  *                                      the hypertext callback. 
1434  *
1435  *                  hyperData           Specifies the current hypertext info
1436  *                                      structure.
1437  *
1438  * Return Value:    Void.
1439  *
1440  * Purpose:         Process all hypertext requests in a given Help Dialogs
1441  *                  display area.
1442  *
1443  ****************************************************************************/
1444 void _DtHelpQuickDialogHypertextCB (
1445     XtPointer pDisplayAreaStruct,
1446     XtPointer clientData,
1447     DtHelpHyperTextStruct *hyperData)
1448 {
1449   DtHelpDialogCallbackStruct callData;
1450   DtHelpQuickDialogWidget qw = (DtHelpQuickDialogWidget) clientData ;
1451   char         *pTempAccessPath;
1452   char         *pTempLocationId;  
1453   char         *tmpErrorMsg;
1454   
1455
1456   /* We allow users to force a new window and override the jump-reuse
1457    * hyper type and force a new window to be used
1458    */
1459    if (   (   ButtonRelease == hyperData->event->type 
1460            && hyperData->event->xbutton.state & (ControlMask|ShiftMask))
1461        || (   KeyPress == hyperData->event->type 
1462            && hyperData->event->xkey.state & (ControlMask|ShiftMask)))
1463      hyperData->window_hint = _DtCvWindowHint_NewWindow;
1464
1465
1466
1467 switch (hyperData->hyper_type)
1468     {
1469
1470       case _DtCvLinkType_SameVolume:
1471       case _DtCvLinkType_CrossLink:
1472
1473
1474          switch (hyperData->window_hint)
1475            {
1476
1477              case _DtCvWindowHint_CurrentWindow:
1478                ProcessJumpReuse((Widget)qw, hyperData);
1479              break;
1480
1481              case _DtCvWindowHint_NewWindow:
1482         
1483                _DtHelpTurnOnHourGlass(XtParent(qw));
1484   
1485                if (qw->qhelp_dialog.display.hyperLinkCallback != NULL)
1486                  {
1487                     pTempAccessPath = 
1488                       _DtHelpParseAccessFile(hyperData->specification);
1489          
1490                     if (pTempAccessPath != NULL)       /* Use the New one */
1491                       callData.helpVolume = pTempAccessPath;
1492                     else                               /* Use the old one */
1493                       callData.helpVolume =
1494                                 XtNewString(qw->qhelp_dialog.display.helpVolume);
1495
1496
1497                     callData.reason        = DtCR_HELP_LINK_ACTIVATE;
1498                     callData.event         = hyperData->event;
1499                     callData.locationId    = _DtHelpParseIdString
1500                                                 (hyperData->specification);
1501                     callData.specification = NULL;
1502                     callData.hyperType     = DtHELP_LINK_TOPIC;
1503                     callData.windowHint    = DtHELP_NEW_WINDOW;
1504
1505                     XtCallCallbackList(
1506                      (Widget)qw,qw->qhelp_dialog.display.hyperLinkCallback,&callData);
1507                  }
1508                else
1509                  {  /* The application did not register a hypertext callback so
1510                      *  we must generate the proper warning message and 
1511                      *  continue!
1512                      */
1513                     XmeWarning((Widget)qw, (char*) QHDMessage1); 
1514
1515                     /* Call jump-reuse procedure for default */
1516                     ProcessJumpReuse((Widget)qw, hyperData);
1517                   }
1518               
1519                _DtHelpTurnOffHourGlass(XtParent(qw));       
1520  
1521              break;
1522
1523              case _DtCvWindowHint_PopupWindow:
1524
1525                _DtHelpTurnOnHourGlass(XtParent(qw));
1526
1527                pTempAccessPath = 
1528                          _DtHelpParseAccessFile(hyperData->specification);
1529          
1530                if (pTempAccessPath == NULL)  /* Use the old one */  
1531                  pTempAccessPath = XtNewString(qw->qhelp_dialog.display.helpVolume);
1532
1533                pTempLocationId = _DtHelpParseIdString(hyperData->specification);
1534
1535                _DtHelpDisplayDefinitionBox((Widget)qw,
1536                                  (Widget **)&(qw->qhelp_dialog.qhelp.definitionBox),
1537                                  pTempAccessPath, pTempLocationId);
1538
1539                XtFree(pTempLocationId);
1540                XtFree(pTempAccessPath);
1541
1542                _DtHelpTurnOffHourGlass(XtParent(qw));       
1543
1544              break;
1545
1546              default:  
1547
1548                /* Non valid window hint generage the proper
1549                 *  error message.
1550                 */
1551              
1552                 /* ERROR-MESSAGE */
1553               break;
1554
1555
1556             }  /* End Window_hint Switch Statement */
1557
1558         break;
1559
1560
1561
1562       case _DtCvLinkType_Execute:
1563           _DtHelpExecFilteredCmd((Widget) qw,
1564                     hyperData->specification, DtHELP_ExecutionPolicy_STR,
1565                     &qw->qhelp_dialog.display, &qw->qhelp_dialog.help);
1566         break;
1567
1568
1569       case _DtCvLinkType_ManPage:
1570       case _DtCvLinkType_AppDefine:     
1571       case _DtCvLinkType_TextFile:
1572                
1573         /* Process Application Man page link or App Defined link types */
1574         _DtHelpTurnOnHourGlass(XtParent(qw));
1575
1576         /* If the application registered a hypertext callback use it! */
1577         if (qw->qhelp_dialog.display.hyperLinkCallback != NULL)
1578           {
1579   
1580             /* Setup the DtHyperProcStructer to pass back to the 
1581              * client as callData. 
1582              */
1583              callData.reason         = DtCR_HELP_LINK_ACTIVATE;
1584              callData.event          = hyperData->event;
1585              callData.locationId     = NULL;
1586              callData.helpVolume     = NULL;
1587              if (_DtCvLinkType_AppDefine == hyperData->hyper_type)
1588                {
1589                  callData.locationId =
1590                                 _DtHelpParseIdString(hyperData->specification);
1591                  callData.helpVolume =
1592                                XtNewString(qw->qhelp_dialog.display.helpVolume);
1593                }
1594              callData.specification  = hyperData->specification;
1595              callData.hyperType      = hyperData->hyper_type;
1596              callData.windowHint     = hyperData->window_hint;
1597
1598              XtCallCallbackList ((Widget) qw,
1599                              qw->qhelp_dialog.display.hyperLinkCallback, &callData);
1600           }
1601         else
1602           { 
1603              /* The application did not register a hypertext 
1604               * callback so we must generate the proper error 
1605               * message and continue!
1606               */
1607               XmeWarning((Widget)qw, (char*) QHDMessage1); 
1608
1609               if (hyperData->hyper_type == DtHELP_LINK_APP_DEFINE)
1610                 {
1611                   tmpErrorMsg = XtNewString((char *)_DTGETMESSAGE(2, 56,
1612                       "The selected Hypertext link is not supported within this application."));
1613                   _DtHelpErrorDialog(XtParent(qw),tmpErrorMsg);
1614                 }
1615               else
1616                 {
1617                   tmpErrorMsg = XtNewString((char *)_DTGETMESSAGE(2, 57,
1618                       "Links to Man Pages are not supported by this application."));
1619                   _DtHelpErrorDialog(XtParent(qw),tmpErrorMsg);
1620
1621                 }
1622               XtFree(tmpErrorMsg);
1623              
1624            }
1625
1626         _DtHelpTurnOffHourGlass(XtParent(qw));  
1627         break;
1628
1629         default:  /* This catches bogus link types */
1630
1631             /* Non valid link type so we are dropping it and are generating
1632              * the  proper error message.
1633              */
1634              
1635              /* ERROR-MESSAGE */
1636              XmeWarning((Widget)qw, (char*) QHDMessage2);
1637              break;
1638
1639
1640     }  /* End Switch Statement */
1641
1642
1643 }  /* End _DtHelpQuickDialogHypertextCB */
1644
1645
1646 \f
1647 /*****************************************************************************
1648  * Function:        void ResizeQuickDialogCB()
1649  *
1650  *
1651  * Return Value:    Void.
1652  *
1653  * Purpose:         Adjust the widget instance values for rows and columns.
1654  *
1655  ****************************************************************************/
1656 static void ResizeQuickDialogCB (
1657     XtPointer clientData)
1658 {
1659   DtHelpQuickDialogWidget qw = (DtHelpQuickDialogWidget) clientData ;
1660     
1661
1662
1663   /* Re-Set our rows and colums values */
1664   if ((qw->qhelp_dialog.help.pDisplayArea != NULL) &&
1665        qw->qhelp_dialog.display.firstTimePopupFlag == TRUE)
1666     _DtHelpDisplayAreaDimensionsReturn (qw->qhelp_dialog.help.pDisplayArea,
1667                                   &(qw->qhelp_dialog.display.textRows),
1668                                   &(qw->qhelp_dialog.display.textColumns));
1669 }
1670
1671
1672 \f
1673 /*****************************************************************************
1674  * Function:        static void  ProcessJumpReuse(nw, hyperData)
1675  *                                  Widget nw;
1676  *                                  DtHelpHyperTextStruct *hyperData;
1677  *
1678  * Parameters:      nw    Specifies the widget ID of the current help dialog
1679  *                        widget.
1680  * 
1681  *                  hyperData Specifies the hypertext data callback struct.
1682  *
1683  * Return Value:    Void.
1684  *
1685  * Purpose:         Process the jump-reuse hypertext link data.
1686  *
1687  *****************************************************************************/
1688 static void  ProcessJumpReuse(
1689     Widget nw,
1690     DtHelpHyperTextStruct *hyperData)
1691
1692 {
1693
1694   DtHelpQuickDialogWidget qw = (DtHelpQuickDialogWidget) nw;
1695   char         *pTempAccessPath;
1696   char         *pTempLocationId;  
1697
1698   
1699   /* Parse our specification into the proper fields in our instance 
1700    * record.  
1701    */
1702
1703    pTempAccessPath = _DtHelpParseAccessFile(hyperData->specification);
1704          
1705    if (pTempAccessPath != NULL) 
1706      {
1707        /* Free the old one and assign the new path */
1708        XtFree(qw->qhelp_dialog.display.helpVolume);
1709        qw->qhelp_dialog.display.helpVolume = pTempAccessPath;
1710        
1711      }
1712  
1713     /* Free old copy first ??? */
1714     pTempLocationId = _DtHelpParseIdString(hyperData->specification);
1715     XtFree(qw->qhelp_dialog.display.locationId);
1716     qw->qhelp_dialog.display.locationId = pTempLocationId;
1717    
1718     SetupDisplayType((Widget)qw, DtJUMP_UPDATE);
1719             
1720 }
1721
1722
1723
1724
1725
1726 \f
1727 /*****************************************************************************
1728  * Function:        void SetupDisplayType(Widget nw, int updateKind);
1729  *
1730  *
1731  * Parameters:      nw          Specifies the current help dialog widget.
1732  *
1733  * Return Value:    Void.
1734  *
1735  * Purpose:         Determins the type of topic the user want's to display
1736  *                  in the current Quick help dialog and sets it up for display.
1737  *
1738  *****************************************************************************/
1739 static void SetupDisplayType(
1740      Widget nw,
1741      int updateKind)
1742 {
1743    XtPointer          topicHandle;
1744    DtHelpQuickDialogWidget qw = (DtHelpQuickDialogWidget) nw ;
1745    int                status=VALID_STATUS;
1746    char               *tmpError;
1747    DtTopicListStruct  *tmpPtr;
1748
1749
1750    /* Here we need to store away our current scroll position as the currentlly
1751     * displayed item is about replaced w/a new item.
1752     * We already have placed this item in the jump stack, and now are just adding
1753     * the proper value for our scrollPosition.
1754     */
1755
1756    if (qw->qhelp_dialog.backtr.pJumpListHead != NULL)
1757      {
1758        tmpPtr = qw->qhelp_dialog.backtr.pJumpListHead;
1759        tmpPtr->scrollPosition = 
1760                      _DtHelpGetScrollbarValue(qw->qhelp_dialog.help.pDisplayArea);
1761      }
1762
1763
1764    switch (qw->qhelp_dialog.display.helpType)
1765     {
1766       case DtHELP_TYPE_TOPIC:
1767
1768         SetupTopic((Widget)qw, updateKind);
1769         break;
1770
1771       case DtHELP_TYPE_STRING:
1772      
1773         /* Set the string to the current help dialog */
1774         status = _DtHelpFormatAsciiString(qw->qhelp_dialog.help.pDisplayArea,
1775                                         qw->qhelp_dialog.display.stringData, 
1776                                        &topicHandle);
1777         if (status >= VALID_STATUS)
1778           {
1779             _DtHelpDisplayAreaSetList (qw->qhelp_dialog.help.pDisplayArea,
1780                                     topicHandle, FALSE,
1781                                     qw->qhelp_dialog.backtr.scrollPosition);
1782
1783             if (updateKind == DtJUMP_UPDATE)
1784               UpdateJumpList(qw->qhelp_dialog.display.stringData,
1785                              DtHELP_TYPE_STRING, (Widget) qw);
1786
1787           }
1788         else
1789           {
1790             tmpError = XtNewString((char *)_DTGETMESSAGE(2, 50,
1791               "String data could not be formatted."));
1792
1793             _DtHelpDisplayFormatError(qw->qhelp_dialog.help.pDisplayArea, (Widget)qw,
1794               tmpError, (char*)QHDMessage3);
1795          
1796              qw->qhelp_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
1797              qw->qhelp_dialog.display.stringData = XtNewString(tmpError);
1798
1799             if (updateKind == DtJUMP_UPDATE)
1800                UpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING, 
1801                               (Widget) qw);
1802             XtFree(tmpError);
1803           }
1804
1805         break;
1806
1807       case DtHELP_TYPE_DYNAMIC_STRING:
1808      
1809         /* Set the string to the current help dialog */
1810         status = _DtHelpFormatAsciiStringDynamic(
1811                                         qw->qhelp_dialog.help.pDisplayArea,
1812                                         qw->qhelp_dialog.display.stringData,
1813                                               &topicHandle);
1814         if (status >= VALID_STATUS)
1815           {
1816             _DtHelpDisplayAreaSetList (qw->qhelp_dialog.help.pDisplayArea,
1817                                     topicHandle, FALSE, 
1818                                     qw->qhelp_dialog.backtr.scrollPosition);
1819             if (updateKind == DtJUMP_UPDATE) 
1820               UpdateJumpList(qw->qhelp_dialog.display.stringData,
1821                              DtHELP_TYPE_DYNAMIC_STRING, (Widget) qw);
1822         
1823           }
1824         else
1825           {
1826             tmpError = XtNewString((char *)_DTGETMESSAGE(2, 51,
1827                              "Dynamic string data could not be formatted."));
1828             _DtHelpDisplayFormatError(qw->qhelp_dialog.help.pDisplayArea, (Widget)qw,
1829                                    tmpError, (char*)QHDMessage4);
1830
1831             qw->qhelp_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
1832             qw->qhelp_dialog.display.stringData = XtNewString(tmpError);
1833
1834             if (updateKind == DtJUMP_UPDATE)
1835                UpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING, 
1836                               (Widget) qw);
1837              XtFree(tmpError);
1838
1839           }
1840
1841         break;
1842
1843
1844       case DtHELP_TYPE_MAN_PAGE:
1845          status = _DtHelpFormatManPage(qw->qhelp_dialog.help.pDisplayArea,
1846                                 qw->qhelp_dialog.display.manPage, &topicHandle);
1847          if (status >= VALID_STATUS)
1848            {
1849              _DtHelpDisplayAreaSetList (qw->qhelp_dialog.help.pDisplayArea,
1850                                     topicHandle, FALSE, 
1851                                     qw->qhelp_dialog.backtr.scrollPosition);  
1852             if (updateKind == DtJUMP_UPDATE)
1853                UpdateJumpList(qw->qhelp_dialog.display.manPage,
1854                               DtHELP_TYPE_MAN_PAGE, (Widget) qw);
1855
1856            }
1857          else
1858            {
1859              tmpError = XtNewString((char *)_DTGETMESSAGE(2, 52,
1860                                     "Man Page could not be formatted. The requested Man Page is either not present, or corrupt."));
1861
1862              _DtHelpDisplayFormatError(qw->qhelp_dialog.help.pDisplayArea,(Widget)qw,
1863                 tmpError, (char*)QHDMessage5);
1864  
1865              qw->qhelp_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
1866              qw->qhelp_dialog.display.stringData = XtNewString(tmpError);
1867
1868              if (updateKind == DtJUMP_UPDATE)
1869                UpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING, 
1870                               (Widget) qw);
1871              XtFree(tmpError);
1872
1873            }
1874          break;
1875
1876       case DtHELP_TYPE_FILE:
1877       
1878         /* Set the string to the current help dialog */
1879         status = _DtHelpFormatAsciiFile(qw->qhelp_dialog.help.pDisplayArea,
1880                                         qw->qhelp_dialog.display.helpFile,
1881                                      &topicHandle);
1882         if (status >= VALID_STATUS)
1883            {
1884              _DtHelpDisplayAreaSetList (qw->qhelp_dialog.help.pDisplayArea,
1885                                     topicHandle, FALSE, 
1886                                     qw->qhelp_dialog.backtr.scrollPosition);
1887   
1888              if (updateKind == DtJUMP_UPDATE)
1889                 UpdateJumpList(qw->qhelp_dialog.display.helpFile,
1890                                DtHELP_TYPE_FILE, (Widget) qw);
1891  
1892            }
1893          else
1894            {
1895              tmpError = XtNewString((char *)_DTGETMESSAGE(2, 53,
1896                 "Text file data could not be formatted. The requested text file is either not present, or corrupt."));
1897
1898              _DtHelpDisplayFormatError(qw->qhelp_dialog.help.pDisplayArea,(Widget)qw,
1899                 tmpError, (char*)QHDMessage6);
1900  
1901              qw->qhelp_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
1902              qw->qhelp_dialog.display.stringData = XtNewString(tmpError);
1903
1904              if (updateKind == DtJUMP_UPDATE)
1905                UpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING, 
1906                               (Widget) qw);
1907              XtFree(tmpError);
1908
1909            }
1910
1911          break;
1912
1913
1914       default:  
1915
1916         /* ERROR-MESSAGE */
1917         /* This means the user used the wrong help type */
1918         tmpError = XtNewString((char *)_DTGETMESSAGE(2, 80,
1919                            "The specified help type is invalid."));
1920
1921         _DtHelpDisplayFormatError(qw->qhelp_dialog.help.pDisplayArea,(Widget)qw,
1922            tmpError, (char*)QHDMessage7);
1923  
1924         qw->qhelp_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
1925         qw->qhelp_dialog.display.stringData = XtNewString(tmpError);
1926
1927         if (updateKind == DtJUMP_UPDATE)
1928           UpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING, 
1929                          (Widget) qw);
1930         XtFree(tmpError);
1931
1932         break;
1933
1934     }  /* End Switch Statement */
1935
1936     /* Update the print dialog */
1937     _DtHelpUpdatePrintDialog(&qw->qhelp_dialog.print,
1938                 &qw->qhelp_dialog.display,&qw->qhelp_dialog.help,False);
1939
1940 }
1941
1942
1943
1944 \f
1945 /*****************************************************************************
1946  * Function:        void SetupTopic(Widget nw, int updateKind)
1947  *
1948  * Parameters:      nw      Specifies the widget ID of the quick help dialog 
1949  *                           you to setup the topic in.
1950  *                  updateKind   Specifies weather to update the jump list or
1951  *                               not if an error message occures.
1952  *
1953  * Return Value:    Void.
1954  *
1955  * Purpose:         Display a new help topic in an existing quick help dialog.
1956  *
1957  *****************************************************************************/
1958 static void SetupTopic(
1959     Widget nw,
1960     int updateKind)
1961 {
1962   Boolean validTopic = FALSE;
1963   Boolean validPath  = FALSE;
1964   XtPointer     topicHandle;
1965   int           status=NON_VALID_STATUS;
1966   char          *userErrorStr=NULL;
1967   char          *sysErrorStr=NULL;
1968   char          *tmpMsg=NULL;
1969   char          *tmpError;
1970   char          *locTitle;
1971   char          *volumeTitle;
1972
1973
1974
1975   DtHelpQuickDialogWidget qw = (DtHelpQuickDialogWidget) nw;
1976
1977   _DtHelpTurnOnHourGlass(XtParent(qw));
1978     
1979   /* Locate our HelpVolume file */
1980    if (qw->qhelp_dialog.display.helpVolume != NULL)
1981      {
1982        validPath = _DtHelpExpandHelpVolume((Widget)qw,
1983                                 &qw->qhelp_dialog.display,
1984                                 &qw->qhelp_dialog.help,
1985                                 &qw->qhelp_dialog.print);
1986      }
1987      
1988   if (validPath)
1989     {
1990       validTopic = False;  /* default */
1991       if (qw->qhelp_dialog.display.locationId != NULL)
1992         {
1993            XmUpdateDisplay((Widget)qw);
1994
1995            /* format the initial locationId info to display */
1996            status = _DtHelpFormatTopic (
1997                      qw->qhelp_dialog.help.pDisplayArea,
1998                      qw->qhelp_dialog.display.volumeHandle, 
1999                      qw->qhelp_dialog.display.locationId,
2000                      True,
2001                      &topicHandle);
2002             
2003             /* unless locationId not found, the topic is valid */
2004             if (status != -2) 
2005                validTopic = True;
2006             
2007             if (status == 0)  /* success */
2008             {
2009                 _DtHelpDisplayAreaSetList (qw->qhelp_dialog.help.pDisplayArea, 
2010                                         topicHandle, FALSE, 
2011                                         qw->qhelp_dialog.backtr.scrollPosition);
2012
2013                 if (updateKind == DtJUMP_UPDATE)
2014                    UpdateJumpList(qw->qhelp_dialog.display.locationId,
2015                                      DtHELP_TYPE_TOPIC, (Widget) qw);
2016             }
2017         }
2018     }
2019
2020
2021   /* Setup and display the proper error message if we have any problems
2022    * with displaying the proper topic.
2023    */
2024    if (!validPath)
2025      {
2026        if (qw->qhelp_dialog.display.helpVolume == NULL)
2027          {
2028
2029            tmpError = XtNewString((char *)_DTGETMESSAGE(2, 60,
2030                                   "No help volume specified."));
2031
2032            _DtHelpDisplayFormatError(qw->qhelp_dialog.help.pDisplayArea, (Widget)qw,
2033                                   tmpError, NULL);
2034            
2035            if (updateKind == DtJUMP_UPDATE)
2036                UpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING,
2037                               (Widget) qw);
2038
2039            qw->qhelp_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
2040            qw->qhelp_dialog.display.stringData = XtNewString(tmpError);
2041
2042            XtFree(tmpError);
2043
2044
2045          }
2046        else
2047          {
2048          
2049             /* We cannot find our HelpVolume so display the proper error
2050              * message in the help dialog and continue.
2051              */
2052             tmpMsg = XtNewString((char *)_DTGETMESSAGE(2, 58,
2053                              "The requested online help is either not installed or not in the proper help search path.  For information on installing online help, consult the documentation for the product.\n"));
2054             locTitle = XtNewString((char *)_DTGETMESSAGE(2, 62,
2055                                   "Location ID:"));
2056             volumeTitle = XtNewString((char *)_DTGETMESSAGE(2, 61,
2057                                        "Help Volume:"));
2058             tmpError = XtMalloc(strlen(tmpMsg) +
2059                                 strlen(locTitle) +
2060                                 strlen(volumeTitle) + 
2061                                 strlen(qw->qhelp_dialog.display.locationId) +
2062                                 strlen(qw->qhelp_dialog.display.helpVolume) + 4);
2063
2064             (void) strcpy(tmpError, tmpMsg);
2065             (void) strcat(tmpError, volumeTitle);
2066             (void) strcat(tmpError, " ");
2067             (void) strcat(tmpError, qw->qhelp_dialog.display.helpVolume);
2068             (void) strcat(tmpError,"\n");
2069             (void) strcat(tmpError, locTitle);
2070             (void) strcat(tmpError, " ");
2071             (void) strcat(tmpError, qw->qhelp_dialog.display.locationId);
2072
2073
2074            _DtHelpDisplayFormatError(qw->qhelp_dialog.help.pDisplayArea, (Widget)qw,
2075                     tmpError, NULL);
2076  
2077           
2078            UpdateJumpList((char *)tmpError,
2079                                DtHELP_TYPE_DYNAMIC_STRING, (Widget) qw);
2080            qw->qhelp_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
2081            qw->qhelp_dialog.display.stringData = XtNewString(tmpError);
2082
2083
2084            XtFree(tmpError);
2085            XtFree(tmpMsg);
2086            XtFree(locTitle);
2087            XtFree(volumeTitle);
2088
2089          }
2090
2091      }
2092    else if  (!validTopic)
2093      {
2094        if (qw->qhelp_dialog.display.locationId == NULL)
2095          {
2096             tmpMsg =_DTGETMESSAGE(2, 59,"No location ID specified.");
2097             userErrorStr = XtNewString(tmpMsg);
2098          }
2099        else
2100         {
2101            tmpMsg = _DTGETMESSAGE(2, 55,
2102                                  "Nonexistent location ID:");
2103            userErrorStr = XtMalloc(strlen(tmpMsg) + 
2104                                    strlen(qw->qhelp_dialog.display.locationId)+ 2);
2105            (void) strcpy(userErrorStr, tmpMsg);
2106            (void) strcat(userErrorStr, " ");
2107            (void) strcat(userErrorStr, qw->qhelp_dialog.display.locationId);
2108            sysErrorStr = (char*)QHDMessage9;
2109         }
2110         _DtHelpDisplayFormatError(qw->qhelp_dialog.help.pDisplayArea, (Widget)qw,
2111                     userErrorStr, sysErrorStr);
2112
2113         qw->qhelp_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
2114         qw->qhelp_dialog.display.stringData = XtNewString(userErrorStr);
2115
2116
2117         if (updateKind == DtJUMP_UPDATE)
2118                UpdateJumpList((char *)userErrorStr,
2119                              DtHELP_TYPE_DYNAMIC_STRING, (Widget) qw);
2120
2121      
2122         XtFree(userErrorStr);
2123
2124      }
2125    else if (status <= NON_VALID_STATUS) 
2126      {
2127        tmpError = XtNewString((char *)_DTGETMESSAGE(2, 54,
2128                     "Help topic could not be formatted."));
2129
2130        _DtHelpDisplayFormatError(qw->qhelp_dialog.help.pDisplayArea,(Widget)qw,
2131                     tmpError, (char*)QHDMessage10);
2132       
2133        if (updateKind == DtJUMP_UPDATE)
2134                UpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING,
2135                               (Widget) qw);
2136
2137        XtFree(tmpError);
2138
2139      }   
2140
2141     _DtHelpTurnOffHourGlass(XtParent(qw));          
2142
2143 }
2144
2145
2146
2147
2148 \f
2149 /*****************************************************************************
2150  * Function:        void FreeQuickHelpInfo();  
2151  *
2152  *
2153  * Parameters:      nw  Specifies the current help dialog widget.
2154  *                  
2155  *
2156  * Return Value:    Void.
2157  *
2158  * Purpose:         This function will re-initializes a Help Dialog Widget to 
2159  *                  known good starting values or clean up in prepretion for 
2160  *                  an impending destroy.
2161  *
2162  *****************************************************************************/
2163 static void FreeQuickHelpInfo(
2164     Widget nw,
2165     int cleanUpKind)
2166 {
2167   DtHelpQuickDialogWidget qw = (DtHelpQuickDialogWidget) nw;
2168
2169   /* Free our jump list display stuff */
2170   _DtHelpTopicListFree(qw->qhelp_dialog.backtr.pJumpListHead);
2171   qw->qhelp_dialog.backtr.pJumpListHead     = NULL;
2172   qw->qhelp_dialog.backtr.pJumpListTale     = NULL;
2173   qw->qhelp_dialog.backtr.totalJumpNodes    = 0;
2174
2175   /* Close our current help volume */
2176   if (qw->qhelp_dialog.display.volumeHandle != NULL)
2177     {
2178       _DtHelpCloseVolume(qw->qhelp_dialog.display.volumeHandle);
2179       qw->qhelp_dialog.display.volumeHandle = NULL;
2180     }
2181
2182
2183   if (cleanUpKind == DtCLEAN_FOR_DESTROY)
2184     {
2185
2186       /* Free any remaining char * values we malloc'ed in our help dialog */
2187       XtFree(qw->qhelp_dialog.help.currentHelpFile);  
2188       XtFree(qw->qhelp_dialog.display.locationId);
2189       XtFree(qw->qhelp_dialog.display.helpVolume); 
2190       XtFree(qw->qhelp_dialog.display.manPage);
2191       XtFree(qw->qhelp_dialog.display.stringData);
2192       XtFree(qw->qhelp_dialog.display.helpFile);
2193       if (qw->qhelp_dialog.display.topicTitleLbl != NULL)
2194           XmStringFree(qw->qhelp_dialog.display.topicTitleLbl);
2195      
2196       /* close print dialog, free all memory */
2197       _DtHelpFreePrintStuff(&qw->qhelp_dialog.print,DtCLEAN_FOR_DESTROY);
2198
2199       /* Free all the info we saved for our help callbacks */
2200       _DtHelpListFree(&qw->qhelp_dialog.help.pHelpListHead);
2201
2202     }
2203   else
2204     {
2205       /* Set our display area to a null starting vlaues */
2206       _DtHelpDisplayAreaClean(qw->qhelp_dialog.help.pDisplayArea);
2207
2208       /* Set the back button to false */
2209       XtSetSensitive(qw->qhelp_dialog.qhelp.backButton, FALSE);
2210
2211       /* close print dialog, free unused memory */
2212       _DtHelpFreePrintStuff(&qw->qhelp_dialog.print,DtCLEAN_FOR_REUSE);
2213
2214     }
2215
2216
2217 }
2218
2219
2220 \f
2221 /*****************************************************************************
2222  * Function:        void UpdateJumpList(char *topicInfo,
2223  *                                 int topicType,
2224  *                                 DtHelpDialogWidget nw);  
2225  *
2226  *
2227  * Parameters:      topicInfo   Specifies the 
2228  *                  int         Specifies the topicInfo type.
2229  *
2230  *                  nw          Specifies the current help dialog widget.
2231  *
2232  * Return Value:    Void.
2233  *
2234  * Purpose:         Updates the Jump List with the new topic.
2235  *
2236  *****************************************************************************/
2237 static void UpdateJumpList(
2238     char *topicInfo,
2239     int topicType,
2240     Widget nw)
2241 {
2242   DtHelpQuickDialogWidget qw = (DtHelpQuickDialogWidget) nw ;
2243   
2244   /* Add the new topic to the top of the jump list */
2245   /* We add a -1 for the scrollbar position value, and will replace it with the
2246    * actual value just prior to changing the window to the new topic.
2247    */
2248   _DtHelpTopicListAddToHead(topicInfo, NULL, topicType, 999,
2249                         qw->qhelp_dialog.display.helpVolume,
2250                         &qw->qhelp_dialog.backtr.pJumpListHead,
2251                         &qw->qhelp_dialog.backtr.pJumpListTale,
2252                         &qw->qhelp_dialog.backtr.totalJumpNodes,
2253                          -1);
2254
2255   if (qw->qhelp_dialog.backtr.totalJumpNodes <= 1) 
2256     XtSetSensitive(qw->qhelp_dialog.qhelp.backButton, FALSE);
2257   else
2258     XtSetSensitive(qw->qhelp_dialog.qhelp.backButton, TRUE);
2259  
2260 }
2261
2262
2263 \f
2264 /*****************************************************************************
2265  * Function:       static void ProcessBackCB(
2266  *                            Widget w,   
2267  *                            XtPointer client_data,
2268  *                            XtPointer call_data);
2269  *       
2270  * Parameters:   
2271  *
2272  * Return Value:    
2273  *
2274  * Purpose:        This routine will cause the top element in the jump
2275  *                 stack to be displayed.
2276  *
2277  ****************************************************************************/
2278 static void  ProcessBackCB(
2279     Widget w,
2280     XtPointer clientData,
2281     XtPointer callData )
2282 {
2283
2284
2285  
2286   DtHelpQuickDialogWidget qw = (DtHelpQuickDialogWidget)  clientData;
2287   DtTopicListStruct *pTemp= NULL;
2288
2289   _DtHelpTurnOnHourGlass(XtParent(qw));
2290
2291
2292   /* Pop the top element off our jump list and display the new top element */
2293   _DtHelpTopicListDeleteHead(&qw->qhelp_dialog.backtr.pJumpListHead,
2294                           &qw->qhelp_dialog.backtr.pJumpListTale,
2295                           &qw->qhelp_dialog.backtr.totalJumpNodes);
2296
2297
2298   /* Assign pTemp to the current head pointer for or jump list */
2299   pTemp = qw->qhelp_dialog.backtr.pJumpListHead;
2300
2301   if (qw->qhelp_dialog.backtr.totalJumpNodes <= 1)
2302     {
2303       XtSetSensitive(qw->qhelp_dialog.qhelp.backButton, FALSE);
2304  
2305       /* Also make sure the default button is set properly */
2306       XmProcessTraversal(qw->qhelp_dialog.qhelp.closeButton, XmTRAVERSE_HOME);
2307     }
2308   else
2309     XtSetSensitive(qw->qhelp_dialog.qhelp.backButton, TRUE);
2310
2311
2312   /* Assign the jump values to or instance structure variables */
2313   XtFree(qw->qhelp_dialog.display.helpVolume);
2314   qw->qhelp_dialog.display.helpVolume  = XtNewString(pTemp->helpVolume);
2315   qw->qhelp_dialog.display.helpType = pTemp->topicType;
2316
2317   /* Set our help volume flag so we open the proper volume */
2318   /*  qw->help_dialog.ghelp.volumeFlag         = FALSE; */
2319  
2320
2321   /* Assign our scrollbar value to our instance structure  so we jump to the
2322    * proper location 
2323    */
2324  
2325   qw->qhelp_dialog.backtr.scrollPosition = pTemp->scrollPosition;
2326
2327
2328   switch (pTemp->topicType)
2329     {
2330       case DtHELP_TYPE_TOPIC:
2331
2332         /* Update our help dialog with top jump element */
2333         XtFree(qw->qhelp_dialog.display.locationId);
2334         qw->qhelp_dialog.display.locationId = XtNewString(pTemp->locationId);
2335         
2336         SetupDisplayType((Widget)qw, DtNO_JUMP_UPDATE);
2337       
2338         break;
2339
2340       case DtHELP_TYPE_STRING:
2341       case DtHELP_TYPE_DYNAMIC_STRING:
2342         XtFree(qw->qhelp_dialog.display.stringData);
2343         qw->qhelp_dialog.display.stringData = XtNewString(pTemp->locationId);
2344         
2345         SetupDisplayType((Widget)qw, DtNO_JUMP_UPDATE);
2346      
2347         break;
2348
2349       case DtHELP_TYPE_MAN_PAGE:
2350         XtFree(qw->qhelp_dialog.display.manPage);
2351         qw->qhelp_dialog.display.manPage = XtNewString(pTemp->locationId);
2352         
2353         SetupDisplayType((Widget)qw, DtNO_JUMP_UPDATE);
2354      
2355         break;
2356
2357       case DtHELP_TYPE_FILE:
2358         XtFree(qw->qhelp_dialog.display.helpFile);
2359         qw->qhelp_dialog.display.helpFile = XtNewString(pTemp->locationId);
2360         
2361         SetupDisplayType((Widget)qw, DtNO_JUMP_UPDATE);
2362      
2363         break;
2364
2365
2366       default:  
2367
2368         /* ERROR-MESSAGE */
2369         /* This means the user used the worng help type */
2370         XmeWarning((Widget)qw, (char*) QHDMessage7);
2371
2372         break;
2373
2374     }  /* End Switch Statement */
2375
2376
2377     /* reset our scrollPosition back to its default here so in any other case,
2378      * we jump to the top of the topic 
2379      */
2380     qw->qhelp_dialog.backtr.scrollPosition = -1;
2381
2382
2383    _DtHelpTurnOffHourGlass(XtParent(qw)); 
2384     
2385 }
2386
2387
2388 \f
2389 /****************************************************************************
2390  * Function:         CatchClose( Widget w);
2391  *                          
2392  * Parameters:      
2393  *
2394  * Return Value:    Void.
2395  *
2396  * Purpose:         Catches the window manager close requests and assigns our
2397  *                  CloseQuickCB to handel them.
2398  *
2399  ***************************************************************************/
2400 static void CatchClose (
2401     Widget widget)
2402 {
2403
2404   Atom      wm_delete_window;
2405   Arg       args[2];
2406
2407   /* Grab the window mgr close */
2408   wm_delete_window = XmInternAtom(XtDisplay(XtParent(widget)),
2409                                             "WM_DELETE_WINDOW", FALSE);
2410   XtSetArg(args[0], XmNdeleteResponse, XmDO_NOTHING);
2411
2412   /* Current Help Dialog Window */
2413   XmAddWMProtocolCallback(XtParent(widget),wm_delete_window,
2414                           CloseQuickCB, (XtPointer)widget);
2415   XtSetValues(XtParent(widget), args, 1);
2416   
2417
2418
2419
2420
2421 \f
2422 /************************************************************************
2423  * Function: CloseQuickCB()
2424  *
2425  *      Close the Help Dialog Window
2426  *
2427  ************************************************************************/
2428 static void CloseQuickCB (
2429     Widget w,
2430     XtPointer clientData,
2431     XtPointer callData)
2432 {
2433   DtHelpDialogCallbackStruct callDataInfo;
2434   DtHelpQuickDialogWidget qw = (DtHelpQuickDialogWidget) clientData;
2435   XmPushButtonCallbackStruct *callbackStruct = 
2436                                (XmPushButtonCallbackStruct*) callData; 
2437
2438     /*
2439      * Check to see if a selection is in process.
2440      * If so, cancel the selection and don't close the dialog
2441      */
2442     if (_DtHelpCancelSelection(qw->qhelp_dialog.help.pDisplayArea) == True)
2443         return;
2444
2445   /* No selection in progress. Close the dialog.
2446    *
2447    * ??? By definition, when a user closes a Help Dialog if it is 
2448    * used again by the application the state will be new. So we should 
2449    * flush out any info currently in the help, history, and search dialogs.
2450    *
2451    * We are just cleaning the canvas and the destroy routine for the
2452    * Display Area *has not been called*. Therefore canvas is still valid.
2453    */
2454  
2455   FreeQuickHelpInfo((Widget)qw, DtCLEAN_FOR_REUSE);
2456  
2457   /* Look to see if they registered their own close callback */
2458   if (qw->qhelp_dialog.qhelp.closeCallback != NULL)
2459     {
2460        callDataInfo.reason = DtCR_HELP_CLOSE;
2461        callDataInfo.event = callbackStruct->event;
2462        callDataInfo.locationId = NULL;
2463        callDataInfo.helpVolume = NULL;
2464        callDataInfo.specification = NULL;
2465        callDataInfo.hyperType = 0;
2466           
2467        /* All we do is envoke the applications close callback */
2468        XtCallCallbackList((Widget)qw,qw->qhelp_dialog.qhelp.closeCallback,
2469                           &callDataInfo);
2470     }
2471   else
2472     XtUnmanageChild((Widget)qw);
2473 }
2474
2475
2476
2477 #if 0  /* no longer needed, now that the Help button is hardwired
2478           to the _DtHelpCB function. */
2479 \f
2480 /************************************************************************
2481  * Function: HelpButtonCB()
2482  *
2483  *      Arrange to call the help callback on the widget 
2484  *
2485  ************************************************************************/
2486 static void HelpButtonCB (
2487     Widget w,
2488     XtPointer clientData,
2489     XtPointer callData)
2490 {
2491
2492   DtHelpQuickDialogWidget qw = (DtHelpQuickDialogWidget) clientData;
2493   XmAnyCallbackStruct   *callback = (XmAnyCallbackStruct *) callData;
2494
2495
2496
2497   /* Invoke the help system. */
2498   _XmManagerHelp((Widget)qw, callback->event, NULL, NULL);
2499
2500
2501 }
2502 #endif
2503
2504
2505
2506 \f
2507 /************************************************************************
2508  * Function: PrintQuickHelpCB()
2509  *
2510  *      Print the current help topic
2511  *
2512  ************************************************************************/
2513 static void PrintQuickHelpCB (
2514     Widget w,
2515     XtPointer clientData,
2516     XtPointer callData)
2517 {
2518   DtHelpQuickDialogWidget qw = (DtHelpQuickDialogWidget) clientData;
2519
2520   XmUpdateDisplay((Widget) qw);
2521   _DtHelpTurnOnHourGlass(XtParent(qw));
2522
2523   /* display the print dialog */
2524   _DtHelpDisplayPrintDialog((Widget) qw,&qw->qhelp_dialog.print,
2525                 &qw->qhelp_dialog.display,&qw->qhelp_dialog.help);
2526
2527   _DtHelpTurnOffHourGlass(XtParent(qw));
2528 }
2529
2530