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: GenUtils.c /main/10 1996/05/09 03:42:28 drk $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 ** Project: CDEnext Info Access.
31 ** Description: This module contains non public routines used only by
32 ** CDE 1.0 dthelpgen. If any of these routines are
33 ** renamed or modified to remove or add parameters, the
34 ** original routine should be moved to Obsolete.c, a new
35 ** routine created (and named differently), and the old
36 ** routine should call the new routine.
38 ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
40 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
41 ** (c) Copyright 1993, 1994 International Business Machines Corp.
42 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
43 ** (c) Copyright 1993, 1994 Novell, Inc.
46 ****************************************************************************
47 ************************************<+>*************************************/
54 #include <X11/Xresource.h>
57 * Canvas Engine includes
60 #include "CanvasSegP.h"
65 #include "bufioI.h" /* for FormatUtilI.h */
66 #include "GenUtilsP.h"
67 #include "FontAttrI.h"
70 #include "AccessSDLP.h"
71 #include "AccessSDLI.h"
72 #include "AccessCCDFP.h"
73 #include "AccessCCDFI.h"
75 #include "FormatUtilI.h"
76 #include "FormatSDLI.h"
82 /******** Private Defines ********/
83 /******** Private Function Declarations ********/
84 static void DefCvsMetrics(
85 _DtCvPointer client_data,
86 _DtCvElemType elem_type,
87 _DtCvPointer ret_metrics);
88 /******** Private Macro Declarations ********/
90 /******************************************************************************
92 * Private variables used within this file.
94 *******************************************************************************/
95 static _DtCvVirtualInfo MyVirtInfo =
97 DefCvsMetrics, /* void (*_CEGet_DtCvMetrics)(); */
98 NULL, /* void (*_DtCvRenderElem)(); */
99 NULL, /* DefCvsStrWidth, _DtCvUnit (*_DtCvGetElemWidth)(); */
100 NULL, /* DefCvsFontMetrics, void (*_DtCvGetFontMetrics)(); */
101 NULL, /* VStatus (*_DtCvBuildSelection)(); */
104 static const _DtCvSpaceMetrics defLinkMetrics = { 0, 0, 0, 0 };
106 /******************************************************************************
110 ******************************************************************************/
111 /*****************************************************************************
112 * Function: void DefCvsMetrics ();
120 *****************************************************************************/
123 _DtCvPointer client_data,
124 _DtCvElemType elem_type,
125 _DtCvPointer ret_metrics)
127 _DtCvSpaceMetrics *retLink = (_DtCvSpaceMetrics *) ret_metrics;
129 if (_DtCvCANVAS_TYPE == elem_type)
131 _DtCvMetrics *retCanvas = (_DtCvMetrics *) ret_metrics;
133 retCanvas->width = 1;
134 retCanvas->height = 1;
135 retCanvas->top_margin = 0;
136 retCanvas->side_margin = 0;
137 retCanvas->line_height = 1;
138 retCanvas->horiz_pad_hint = 1;
140 else if (_DtCvLINK_TYPE == elem_type || _DtCvTRAVERSAL_TYPE == elem_type)
141 *retLink = defLinkMetrics;
144 /******************************************************************************
145 * Semi-Public Functions
146 ******************************************************************************/
147 /******************************************************************************
148 * Function: int _DtHelpCeGetVolumeTitle(_DtHelpVolume vol, char **retTitle);
150 * Parameters: vol Specifies the loaded volume.
151 * retTitle Returns the title of the volume. This string is
152 * owned by the caller and must be freed.
154 * Return Value: 0 if successful, -1 if a failure occurs
156 * Purpose: Get the title of a volume.
158 * Used by: dthelpgen 1.0
160 ******************************************************************************/
162 _DtHelpCeGetVolumeTitle (
167 _FrmtUiInfo myUiInfo;
168 _DtHelpVolume vol = (_DtHelpVolume)volume;
172 * set up my UI information
174 myUiInfo.load_graphic = NULL;
175 myUiInfo.resolve_spc = NULL;
176 myUiInfo.load_font = NULL;
177 myUiInfo.destroy_region = NULL;
178 myUiInfo.exec_filter = NULL;
179 myUiInfo.client_data = NULL;
180 /* since we're going for a string, set avg_char width to 1 */
181 myUiInfo.line_width = 0;
182 myUiInfo.line_height = 0;
183 myUiInfo.leading = 0;
184 myUiInfo.avg_char = 1;
185 myUiInfo.nl_to_space = 0;
188 * What type of volume is it?
190 _DtHelpProcessLock();
191 if (0 == _DtHelpCeGetVolumeFlag(volume))
193 result = _DtHelpCeGetCcdfVolumeTitle(vol, ret_title);
197 result = _DtHelpCeFrmtSDLVolTitleToAscii(volume, &myUiInfo, ret_title);
199 _DtHelpProcessUnlock();
202 /******************************************************************************
203 * Function: int _DtHelpCeGetAsciiVolumeAbstract (_DtHelpVolume vol, char **a
206 * Parameters: vol Specifies the loaded volume.
207 * abstract Returns the abstract of the volume. This string
208 * is owned by the caller and should be freed.
210 * Return Value: 0 if successful, -1 if a failure occurs
212 * Purpose: Get the abstract of a volume.
214 * Used by: dthelpgen 1.0
216 ******************************************************************************/
218 _DtHelpCeGetAsciiVolumeAbstract (
223 _DtHelpVolume vol = (_DtHelpVolume)volume;
227 * What type of volume is it?
229 _DtHelpProcessLock();
230 if (0 == _DtHelpCeGetVolumeFlag(volume))
232 result = _DtHelpCeGetCcdfVolumeAbstract(vol, retAbs);
233 _DtHelpProcessUnlock();
237 *retAbs = _DtHelpCeGetSdlVolumeAsciiAbstract(volume);
240 _DtHelpProcessUnlock();
244 _DtHelpProcessUnlock();
248 /*****************************************************************************
249 * Function: CanvasHandle _DtHelpCeCreateDefCanvas (void);
253 * Returns: A handle to the canvas or NULL if an error occurs.
255 * Purpose: Create a canvas and attach the appropriate virtual functions
257 *****************************************************************************/
259 _DtHelpCeCreateDefCanvas (void)
261 return (_DtCanvasCreate(MyVirtInfo, NULL));
263 } /* End _DtHelpCeCreateDefCanvas */
265 /******************************************************************************
266 * Function: char *_DtHelpCeGetNxtToken (char *str, char **retToken)
269 * Return Value: Returns the pointer to the next unparsed character in
270 * the input string. A NULL value indicates an error.
276 * Purpose: Parse tokens in resource string values.
278 *****************************************************************************/
280 _DtHelpCeGetNxtToken (
284 return (_DtHelpGetNxtToken(str, retToken));