2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
23 /* $XConsortium: PathArea.c /main/7 1996/08/28 16:47:42 drk $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 ** Project: Cache Creek (Rivers) Project
31 ** Description: Routines to create & process the Path area portion of our
35 ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
37 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
38 ** (c) Copyright 1993, 1994 International Business Machines Corp.
39 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
40 ** (c) Copyright 1993, 1994 Novell, Inc.
42 ****************************************************************************
43 ************************************<+>*************************************/
44 #include <sys/param.h>
50 #include <Xm/ScrolledW.h>
53 #include <Xm/LabelG.h>
55 #include <Xm/RowColumn.h>
56 #include <Xm/PushBG.h>
58 #include <X11/Intrinsic.h>
59 #include <X11/Shell.h>
66 #include "DisplayAreaI.h"
67 #include "DisplayAreaP.h"
68 #include "StringFuncsI.h"
70 #include "HelpDialogI.h"
71 #include "HelpDialogP.h"
72 #include "HelpUtilI.h"
73 #include "PathAreaI.h"
76 #include "XUICreateI.h"
84 /*****************************************************************************
85 * Function: void _DtHelpBuildPathArea(Widget parent,
86 * DtHelpDialogWidget nw);
89 * Parameters: parent Specifies the widget ID of the help dialog you
90 * want to set the topic in.
91 * nw Specifies the current help dialog widget.
95 * Purpose: Creates/updates the Path Display area on top of the help
98 *****************************************************************************/
99 void _DtHelpBuildPathArea(
101 DtHelpDialogWidget nw)
106 Widget pathForm, pathLabel, btnBox, tocFrame;
108 XmString labelString;
109 XmFontList defaultList;
110 DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
112 Dimension button1, button2, button3, button4;
113 Dimension maxBtnWidth;
116 /* Create a form to hold the topic map stuff */
118 XtSetArg (args[n], XmNmarginWidth, 1); n++;
119 XtSetArg (args[n], XmNmarginHeight, 1); n++;
120 XtSetArg (args[n], XmNshadowType, XmSHADOW_OUT); n++;
121 XtSetArg (args[n], XmNautoUnmanage, False); n++;
122 pathForm = XmCreateForm (parent, "pathForm", args, n);
125 XtSetArg (args[n], XmNmarginWidth, 1); n++;
126 XtSetArg (args[n], XmNmarginHeight, 1); n++;
127 XtSetArg (args[n], XmNshadowType, XmSHADOW_OUT); n++;
128 XtSetArg (args[n], XmNautoUnmanage, False); n++;
129 _pathForm = XmCreateForm (pathForm, "_pathForm", args, n);
131 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
134 XtSetArg (args[n], XmNlabelString, labelString); n++;
135 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
136 XtSetArg (args[n], XmNleftOffset, 0); n++;
137 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
138 XtSetArg (args[n], XmNtopOffset, 0); n++;
139 XtSetArg (args[n], XmNtraversalOn, FALSE); n++;
141 XmCreateLabelGadget (_pathForm, "pathLabel", args, n);
142 XtManageChild (pathLabel);
143 XmStringFree (labelString);
146 /* Create a label for our volume title. We fill it out later
147 * bacause at this point we may not have yet opened the volume.
151 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
152 XtSetArg (args[n], XmNleftWidget, pathLabel); n++;
153 XtSetArg (args[n], XmNleftOffset, 1); n++;
154 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
155 XtSetArg (args[n], XmNtopOffset, 0); n++;
156 XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
157 hw->help_dialog.browser.volumeLabel =
158 XmCreateLabelGadget (_pathForm, "volumeLabel", args, n);
159 XtManageChild (hw->help_dialog.browser.volumeLabel);
162 /* Build a container for our toc to sit in. We do this because we cannot
163 * set form constraints on our toc, but can on the container.
167 XtSetArg(args[n], XmNshadowThickness, 0); n++;
168 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
169 XtSetArg (args[n], XmNleftOffset, 0); n++;
170 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
171 XtSetArg (args[n], XmNbottomOffset, 0); n++;
172 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
173 XtSetArg (args[n], XmNtopOffset, 0); n++;
174 XtSetArg (args[n], XmNtopWidget, _pathForm);n++;
175 tocFrame = XmCreateFrame (pathForm, "tocFrame", args, n);
176 XtManageChild (tocFrame);
179 /* Build our button box rowcol widget container */
181 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
182 XtSetArg (args[n], XmNleftOffset,3); n++;
183 XtSetArg (args[n], XmNleftWidget, tocFrame); n++;
184 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
185 XtSetArg (args[n], XmNbottomOffset, 2); n++;
186 XtSetArg (args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
187 XtSetArg (args[n], XmNtopOffset, 2); n++;
188 XtSetArg (args[n], XmNtopWidget, tocFrame); n++;
189 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
190 XtSetArg (args[n], XmNrightOffset, 1); n++;
191 XtSetArg (args[n], XmNspacing, 5); n++;
192 XtSetArg (args[n], XmNentryVerticalAlignment, XmALIGNMENT_CENTER); n++;
193 XtSetArg (args[n], XmNpacking, XmPACK_COLUMN); n++;
194 XtSetArg (args[n], XmNorientation, XmVERTICAL); n++;
195 btnBox = XmCreateRowColumn (pathForm, "BtnBox", args, n);
196 XtManageChild (btnBox);
199 /* Backtrack button */
200 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(9, 2,"Backtrack")));
202 XtSetArg(args[n], XmNlabelString, labelString); n++;
203 hw->help_dialog.browser.btnBoxBackBtn = XmCreatePushButtonGadget(btnBox,
204 "btnBoxBackBtn", args, n);
205 XtManageChild (hw->help_dialog.browser.btnBoxBackBtn);
206 XmStringFree(labelString);
207 XtAddCallback(hw->help_dialog.browser.btnBoxBackBtn,XmNactivateCallback,
208 _DtHelpDisplayBackCB, (XtPointer) hw);
209 XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, FALSE);
213 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(9, 3,"History...")));
215 XtSetArg(args[n], XmNlabelString, labelString); n++;
216 hw->help_dialog.browser.btnBoxHistoryBtn = XmCreatePushButtonGadget(btnBox,
217 "btnBoxHistoryBtn",args, n);
218 XtManageChild (hw->help_dialog.browser.btnBoxHistoryBtn);
219 XmStringFree(labelString);
220 XtAddCallback(hw->help_dialog.browser.btnBoxHistoryBtn,XmNactivateCallback,
221 _DtHelpDisplayHistoryCB, (XtPointer) hw);
226 XmStringCreateLocalized(((char *)_DTGETMESSAGE(9, 4,"Index...")));
228 XtSetArg(args[n], XmNlabelString, labelString); n++;
229 hw->help_dialog.browser.btnBoxIndexBtn = XmCreatePushButtonGadget(btnBox,
230 "btnBoxIndexBtn",args, n);
231 XtManageChild (hw->help_dialog.browser.btnBoxIndexBtn);
232 XmStringFree(labelString);
233 XtAddCallback(hw->help_dialog.browser.btnBoxIndexBtn,XmNactivateCallback,
234 _DtHelpDisplayIndexCB, (XtPointer) hw);
237 /* Top Level Browser Button */
239 if (hw->help_dialog.browser.showTopLevelBtn == TRUE)
242 XmStringCreateLocalized(((char *)_DTGETMESSAGE(9, 5,"Top Level")));
244 XtSetArg(args[n], XmNlabelString, labelString); n++;
245 hw->help_dialog.browser.btnBoxTopLevelBtn = XmCreatePushButtonGadget(btnBox,
246 "btnBoxTopLevelBtn",args, n);
247 XtManageChild (hw->help_dialog.browser.btnBoxTopLevelBtn);
248 XmStringFree(labelString);
249 XtAddCallback(hw->help_dialog.browser.btnBoxTopLevelBtn,XmNactivateCallback,
250 _DtHelpDisplayBrowserHomeCB, (XtPointer) hw);
254 /* Get our current fontlist value */
256 XtSetArg (args[n], XmNfontList, &(defaultList)); ++n;
257 XtGetValues (hw->help_dialog.menu.topBtn, args, n);
260 /* Build the Display Area */
262 hw->help_dialog.browser.pTocArea = _DtHelpCreateDisplayArea(tocFrame,
264 ((short) hw->help_dialog.display.scrollBarPolicy),
265 ((short) hw->help_dialog.display.scrollBarPolicy),
267 ((int) hw->help_dialog.browser.visiblePathCount),
269 _DtHelpDialogHypertextCB,
270 NULL /*ResizeHelpDialogCB*/,
271 _DtHelpFilterExecCmdCB,
276 /* We build a blank toc at first, it gets filled in later when
277 * updatePathArea gets called.
281 XtManageChild(_pathForm);
282 XtManageChild(pathForm);
285 /* Perform some sizing stuff here to ensure that we layout our UI
286 * per the current fonts.
289 /* Get the size of each button */
291 XtSetArg(args[n], XmNwidth, &button1); ++n;
292 XtGetValues(hw->help_dialog.browser.btnBoxBackBtn, args, n);
294 XtSetArg(args[n], XmNwidth, &button2); ++n;
295 XtGetValues(hw->help_dialog.browser.btnBoxHistoryBtn, args, n);
298 XtSetArg(args[n], XmNwidth, &button3); ++n;
299 XtGetValues(hw->help_dialog.browser.btnBoxIndexBtn, args, n);
301 if (hw->help_dialog.browser.showTopLevelBtn == True)
304 XtSetArg(args[n], XmNwidth, &button4); ++n;
305 XtGetValues(hw->help_dialog.browser.btnBoxTopLevelBtn, args, n);
310 if (button1 >= button2)
311 maxBtnWidth = button1;
313 maxBtnWidth = button2;
315 if (button3 >= maxBtnWidth)
316 maxBtnWidth = button3;
318 if (hw->help_dialog.browser.showTopLevelBtn == True)
319 if (button4 >= maxBtnWidth)
320 maxBtnWidth = button4;
322 /* Set our toc right hand attachments */
324 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
325 XtSetArg (args[n], XmNrightOffset, maxBtnWidth +10); n++;
326 XtSetValues (tocFrame, args, n);
333 /*****************************************************************************
334 * Function: void _DtHelpUpdatePathArea(char *locationId,
335 * DtHelpDialogWidget nw);
338 * Parameters: locationId Specifies the ID string for the new topic we
339 * are going to display in the HelpDialog widget.
341 * helpDialogWidget Specifies the current help dialog widget.
343 * Return Value: Void.
345 * Purpose: Updates the Path Display area on top of the help
348 *****************************************************************************/
349 void _DtHelpUpdatePathArea(
351 DtHelpDialogWidget nw)
353 DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
357 if (locationId != NULL)
359 retState = _DtHelpUpdatePath (hw->help_dialog.browser.pTocArea,
360 hw->help_dialog.display.volumeHandle,
366 /* Some error occurred while processing the new toc,
367 * error out or something ???
371 else if (locationId == NULL)
373 /* We have most likely entered an error state and must set our path
374 * area to NULL values while we display and error message in the
377 _DtHelpDisplayAreaClean(hw->help_dialog.browser.pTocArea);
379 /* We set our volumeFlag back to false so we are sure to create a new
380 * toc next time we enter this function (i.e. recovering from our
383 hw->help_dialog.ghelp.volumeFlag = FALSE;