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 librararies 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 "StringFuncsI.h"
69 #include "HelpDialogI.h"
70 #include "HelpDialogP.h"
71 #include "HelpUtilI.h"
72 #include "PathAreaI.h"
74 #include "XUICreateI.h"
82 /*****************************************************************************
83 * Function: void _DtHelpBuildPathArea(Widget parent,
84 * DtHelpDialogWidget nw);
87 * Parameters: parent Specifies the widget ID of the help dialog you
88 * want to set the topic in.
89 * nw Specifies the current help dialog widget.
93 * Purpose: Creates/updates the Path Display area on top of the help
96 *****************************************************************************/
97 void _DtHelpBuildPathArea(
99 DtHelpDialogWidget nw)
104 Widget pathForm, pathLabel, btnBox, tocFrame;
106 XmString labelString;
107 XmFontList defaultList;
108 DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
110 Dimension button1, button2, button3, button4;
111 Dimension maxBtnWidth;
114 /* Create a form to hold the topic map stuff */
116 XtSetArg (args[n], XmNmarginWidth, 1); n++;
117 XtSetArg (args[n], XmNmarginHeight, 1); n++;
118 XtSetArg (args[n], XmNshadowType, XmSHADOW_OUT); n++;
119 XtSetArg (args[n], XmNautoUnmanage, False); n++;
120 pathForm = XmCreateForm (parent, "pathForm", args, n);
123 XtSetArg (args[n], XmNmarginWidth, 1); n++;
124 XtSetArg (args[n], XmNmarginHeight, 1); n++;
125 XtSetArg (args[n], XmNshadowType, XmSHADOW_OUT); n++;
126 XtSetArg (args[n], XmNautoUnmanage, False); n++;
127 _pathForm = XmCreateForm (pathForm, "_pathForm", args, n);
129 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE
132 XtSetArg (args[n], XmNlabelString, labelString); n++;
133 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
134 XtSetArg (args[n], XmNleftOffset, 0); n++;
135 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
136 XtSetArg (args[n], XmNtopOffset, 0); n++;
137 XtSetArg (args[n], XmNtraversalOn, FALSE); n++;
139 XmCreateLabelGadget (_pathForm, "pathLabel", args, n);
140 XtManageChild (pathLabel);
141 XmStringFree (labelString);
144 /* Create a label for our volume title. We fill it out later
145 * bacause at this point we may not have yet opened the volume.
149 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
150 XtSetArg (args[n], XmNleftWidget, pathLabel); n++;
151 XtSetArg (args[n], XmNleftOffset, 1); n++;
152 XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
153 XtSetArg (args[n], XmNtopOffset, 0); n++;
154 XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
155 hw->help_dialog.browser.volumeLabel =
156 XmCreateLabelGadget (_pathForm, "volumeLabel", args, n);
157 XtManageChild (hw->help_dialog.browser.volumeLabel);
160 /* Build a container for our toc to sit in. We do this because we cannot
161 * set form constraints on our toc, but can on the container.
165 XtSetArg(args[n], XmNshadowThickness, 0); n++;
166 XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
167 XtSetArg (args[n], XmNleftOffset, 0); n++;
168 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
169 XtSetArg (args[n], XmNbottomOffset, 0); n++;
170 XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
171 XtSetArg (args[n], XmNtopOffset, 0); n++;
172 XtSetArg (args[n], XmNtopWidget, _pathForm);n++;
173 tocFrame = XmCreateFrame (pathForm, "tocFrame", args, n);
174 XtManageChild (tocFrame);
177 /* Build our button box rowcol widget container */
179 XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
180 XtSetArg (args[n], XmNleftOffset,3); n++;
181 XtSetArg (args[n], XmNleftWidget, tocFrame); n++;
182 XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
183 XtSetArg (args[n], XmNbottomOffset, 2); n++;
184 XtSetArg (args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
185 XtSetArg (args[n], XmNtopOffset, 2); n++;
186 XtSetArg (args[n], XmNtopWidget, tocFrame); n++;
187 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
188 XtSetArg (args[n], XmNrightOffset, 1); n++;
189 XtSetArg (args[n], XmNspacing, 5); n++;
190 XtSetArg (args[n], XmNentryVerticalAlignment, XmALIGNMENT_CENTER); n++;
191 XtSetArg (args[n], XmNpacking, XmPACK_COLUMN); n++;
192 XtSetArg (args[n], XmNorientation, XmVERTICAL); n++;
193 btnBox = XmCreateRowColumn (pathForm, "BtnBox", args, n);
194 XtManageChild (btnBox);
197 /* Backtrack button */
198 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(9, 2,"Backtrack")));
200 XtSetArg(args[n], XmNlabelString, labelString); n++;
201 hw->help_dialog.browser.btnBoxBackBtn = XmCreatePushButtonGadget(btnBox,
202 "btnBoxBackBtn", args, n);
203 XtManageChild (hw->help_dialog.browser.btnBoxBackBtn);
204 XmStringFree(labelString);
205 XtAddCallback(hw->help_dialog.browser.btnBoxBackBtn,XmNactivateCallback,
206 _DtHelpDisplayBackCB, (XtPointer) hw);
207 XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, FALSE);
211 labelString = XmStringCreateLocalized(((char *)_DTGETMESSAGE(9, 3,"History...")));
213 XtSetArg(args[n], XmNlabelString, labelString); n++;
214 hw->help_dialog.browser.btnBoxHistoryBtn = XmCreatePushButtonGadget(btnBox,
215 "btnBoxHistoryBtn",args, n);
216 XtManageChild (hw->help_dialog.browser.btnBoxHistoryBtn);
217 XmStringFree(labelString);
218 XtAddCallback(hw->help_dialog.browser.btnBoxHistoryBtn,XmNactivateCallback,
219 _DtHelpDisplayHistoryCB, (XtPointer) hw);
224 XmStringCreateLocalized(((char *)_DTGETMESSAGE(9, 4,"Index...")));
226 XtSetArg(args[n], XmNlabelString, labelString); n++;
227 hw->help_dialog.browser.btnBoxIndexBtn = XmCreatePushButtonGadget(btnBox,
228 "btnBoxIndexBtn",args, n);
229 XtManageChild (hw->help_dialog.browser.btnBoxIndexBtn);
230 XmStringFree(labelString);
231 XtAddCallback(hw->help_dialog.browser.btnBoxIndexBtn,XmNactivateCallback,
232 _DtHelpDisplayIndexCB, (XtPointer) hw);
235 /* Top Level Browser Button */
237 if (hw->help_dialog.browser.showTopLevelBtn == TRUE)
240 XmStringCreateLocalized(((char *)_DTGETMESSAGE(9, 5,"Top Level")));
242 XtSetArg(args[n], XmNlabelString, labelString); n++;
243 hw->help_dialog.browser.btnBoxTopLevelBtn = XmCreatePushButtonGadget(btnBox,
244 "btnBoxTopLevelBtn",args, n);
245 XtManageChild (hw->help_dialog.browser.btnBoxTopLevelBtn);
246 XmStringFree(labelString);
247 XtAddCallback(hw->help_dialog.browser.btnBoxTopLevelBtn,XmNactivateCallback,
248 _DtHelpDisplayBrowserHomeCB, (XtPointer) hw);
252 /* Get our current fontlist value */
254 XtSetArg (args[n], XmNfontList, &(defaultList)); ++n;
255 XtGetValues (hw->help_dialog.menu.topBtn, args, n);
258 /* Build the Display Area */
260 hw->help_dialog.browser.pTocArea = _DtHelpCreateDisplayArea(tocFrame,
262 ((short) hw->help_dialog.display.scrollBarPolicy),
263 ((short) hw->help_dialog.display.scrollBarPolicy),
265 ((int) hw->help_dialog.browser.visiblePathCount),
267 _DtHelpDialogHypertextCB,
268 NULL /*ResizeHelpDialogCB*/,
269 _DtHelpFilterExecCmdCB,
274 /* We build a blank toc at first, it gets filled in later when
275 * updatePathArea gets called.
279 XtManageChild(_pathForm);
280 XtManageChild(pathForm);
283 /* Perform some sizing stuff here to ensure that we layout our UI
284 * per the current fonts.
287 /* Get the size of each button */
289 XtSetArg(args[n], XmNwidth, &button1); ++n;
290 XtGetValues(hw->help_dialog.browser.btnBoxBackBtn, args, n);
292 XtSetArg(args[n], XmNwidth, &button2); ++n;
293 XtGetValues(hw->help_dialog.browser.btnBoxHistoryBtn, args, n);
296 XtSetArg(args[n], XmNwidth, &button3); ++n;
297 XtGetValues(hw->help_dialog.browser.btnBoxIndexBtn, args, n);
299 if (hw->help_dialog.browser.showTopLevelBtn == True)
302 XtSetArg(args[n], XmNwidth, &button4); ++n;
303 XtGetValues(hw->help_dialog.browser.btnBoxTopLevelBtn, args, n);
308 if (button1 >= button2)
309 maxBtnWidth = button1;
311 maxBtnWidth = button2;
313 if (button3 >= maxBtnWidth)
314 maxBtnWidth = button3;
316 if (hw->help_dialog.browser.showTopLevelBtn == True)
317 if (button4 >= maxBtnWidth)
318 maxBtnWidth = button4;
320 /* Set our toc right hand attachments */
322 XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
323 XtSetArg (args[n], XmNrightOffset, maxBtnWidth +10); n++;
324 XtSetValues (tocFrame, args, n);
331 /*****************************************************************************
332 * Function: void _DtHelpUpdatePathArea(char *locationId,
333 * DtHelpDialogWidget nw);
336 * Parameters: locationId Specifies the ID string for the new topic we
337 * are going to display in the HelpDialog widget.
339 * helpDialogWidget Specifies the current help dialog widget.
341 * Return Value: Void.
343 * Purpose: Updates the Path Display area on top of the help
346 *****************************************************************************/
347 void _DtHelpUpdatePathArea(
349 DtHelpDialogWidget nw)
351 DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
355 if (locationId != NULL)
357 retState = _DtHelpUpdatePath (hw->help_dialog.browser.pTocArea,
358 hw->help_dialog.display.volumeHandle,
364 /* Some error occured while processing the new toc,
365 * error out or something ???
369 else if (locationId == NULL)
371 /* We have most likely entered an error state and must set our path
372 * area to NULL values while we display and error message in the
375 _DtHelpDisplayAreaClean(hw->help_dialog.browser.pTocArea);
377 /* We set our volumeFlag back to false so we are sure to create a new
378 * toc next time we enter this function (i.e. recovering from our
381 hw->help_dialog.ghelp.volumeFlag = FALSE;