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: NewCvt.c /main/5 1996/03/26 19:53:53 drk $
25 * (c) Copyright 1996 Digital Equipment Corporation.
26 * (c) Copyright 1990,1996 Hewlett-Packard Company.
27 * (c) Copyright 1996 International Business Machines Corp.
28 * (c) Copyright 1996 Sun Microsystems, Inc.
29 * (c) Copyright 1996 Novell, Inc.
30 * (c) Copyright 1996 FUJITSU LIMITED.
31 * (c) Copyright 1996 Hitachi.
34 /**---------------------------------------------------------------------
38 *** project: Motif Widgets
40 *** description: Source code for new MotifPlus resource converters.
42 ***-------------------------------------------------------------------*/
45 /*-------------------------------------------------------------
49 #include <Dt/DialogBox.h>
51 #include <Dt/TitleBox.h>
52 #include "DtWidgetI.h"
56 extern void _DtRegisterNewConverters( void ) ;
58 /******** Static Function Declarations ********/
60 static Boolean _StringsAreEqual(
63 static void _DtCvtStringToBehavior(
68 static void _DtCvtStringToChildType(
73 static void _DtCvtStringToFillMode(
78 static void _DtCvtStringToPixmapPosition(
83 static void _DtCvtStringToStringPosition(
88 static void _DtCvtStringToTitlePosition(
94 /******** End Static Function Declarations ********/
97 /*-------------------------------------------------------------
98 ** _DtRegisterNewConverters
99 ** Convert MotifPlus resource converters.
102 _DtRegisterNewConverters( void )
104 static Boolean new_converters_registered = False;
106 if (!new_converters_registered)
109 if (!new_converters_registered)
111 /* Register new converters. */
112 XtAddConverter (XmRString, XmRBehavior,
113 _DtCvtStringToBehavior, NULL, 0);
115 XtAddConverter (XmRString, XmRChildType,
116 _DtCvtStringToChildType, NULL, 0);
118 XtAddConverter (XmRString, XmRFillMode,
119 _DtCvtStringToFillMode, NULL, 0);
121 XtAddConverter (XmRString, XmRPixmapPosition,
122 _DtCvtStringToPixmapPosition, NULL, 0);
124 XtAddConverter (XmRString, XmRStringPosition,
125 _DtCvtStringToStringPosition, NULL, 0);
127 XtAddConverter (XmRString, XmRTitlePosition,
128 _DtCvtStringToTitlePosition, NULL, 0);
130 new_converters_registered = True;
138 /*-------------------------------------------------------------
140 ** Compare possibly mixed case string with lowercase string.
156 if (i != j) return (False);
157 if (i == 0) return (True);
166 /*-------------------------------------------------------------
167 ** _DtCvtStringToBehavior
168 ** Convert XmRString to XmRBehavior.
171 _DtCvtStringToBehavior(
177 String string = (String) from_val->addr;
178 static unsigned char value;
180 to_val->size = sizeof (unsigned char);
181 to_val->addr = (XtPointer) &value;
183 if (_StringsAreEqual (string, STR_ICON_LABEL))
184 value = XmICON_LABEL;
185 else if (_StringsAreEqual (string, STR_ICON_BUTTON))
186 value = XmICON_BUTTON;
187 else if (_StringsAreEqual (string, STR_ICON_TOGGLE))
188 value = XmICON_TOGGLE;
189 else if (_StringsAreEqual (string, STR_ICON_DRAG))
195 XtStringConversionWarning ((String) from_val->addr,
202 /*-------------------------------------------------------------
203 ** _DtCvtStringToChildType
204 ** Convert XmRString to XmRChildType.
207 _DtCvtStringToChildType(
213 String string = (String) from_val->addr;
214 static unsigned char value;
216 to_val->size = sizeof (unsigned char);
217 to_val->addr = (XtPointer) &value;
219 if (_StringsAreEqual (string, STR_WORK_AREA))
221 else if (_StringsAreEqual (string, STR_TITLE_AREA))
222 value = XmTITLE_AREA;
223 else if (_StringsAreEqual (string, STR_SEPARATOR))
225 else if (_StringsAreEqual (string, STR_BUTTON))
231 XtStringConversionWarning ((String) from_val->addr,
238 /*-------------------------------------------------------------
239 ** _DtCvtStringToFillMode
240 ** Convert XmRString to XmRFillMode.
243 _DtCvtStringToFillMode(
249 String string = (String) from_val->addr;
250 static unsigned char value;
252 to_val->size = sizeof (unsigned char);
253 to_val->addr = (XtPointer) &value;
255 if (_StringsAreEqual (string, STR_FILL_NONE))
257 else if (_StringsAreEqual (string, STR_FILL_PARENT))
258 value = XmFILL_PARENT;
259 else if (_StringsAreEqual (string, STR_FILL_SELF))
261 else if (_StringsAreEqual (string, STR_FILL_TRANSPARENT))
262 value = XmFILL_TRANSPARENT;
267 XtStringConversionWarning ((String) from_val->addr,
274 /*-------------------------------------------------------------
275 ** _DtCvtStringToPixmapPosition
276 ** Convert string to pixmap position.
279 _DtCvtStringToPixmapPosition(
285 String string = (String) from_val->addr;
286 static unsigned char value;
288 to_val->size = sizeof (unsigned char);
289 to_val->addr = (XtPointer) &value;
291 if (_StringsAreEqual (string, STR_PIXMAP_TOP))
292 value = XmPIXMAP_TOP;
293 else if (_StringsAreEqual (string, STR_PIXMAP_BOTTOM))
294 value = XmPIXMAP_BOTTOM;
295 else if (_StringsAreEqual (string, STR_PIXMAP_LEFT))
296 value = XmPIXMAP_LEFT;
297 else if (_StringsAreEqual (string, STR_PIXMAP_RIGHT))
298 value = XmPIXMAP_RIGHT;
299 else if (_StringsAreEqual (string, "pixmap_middle"))
300 value = XmPIXMAP_MIDDLE;
305 XtStringConversionWarning ((String) from_val->addr,
312 /*-------------------------------------------------------------
313 ** _DtCvtStringToStringPosition
314 ** Convert XmRString to XmRStringPosition.
317 _DtCvtStringToStringPosition(
323 String string = (String) from_val->addr;
324 static unsigned char value;
326 to_val->size = sizeof (unsigned char);
327 to_val->addr = (XtPointer) &value;
329 if (_StringsAreEqual (string, STR_STRING_TOP))
330 value = XmSTRING_TOP;
331 else if (_StringsAreEqual (string, STR_STRING_BOTTOM))
332 value = XmSTRING_BOTTOM;
333 else if (_StringsAreEqual (string, STR_STRING_LEFT))
334 value = XmSTRING_LEFT;
335 else if (_StringsAreEqual (string, STR_STRING_RIGHT))
336 value = XmSTRING_RIGHT;
341 XtStringConversionWarning ((String) from_val->addr,
348 /*-------------------------------------------------------------
349 ** _DtCvtStringToTitlePosition
350 ** Convert XmRString to XmRTitlePosition.
353 _DtCvtStringToTitlePosition(
359 String string = (String) from_val->addr;
360 static unsigned char value;
362 to_val->size = sizeof (unsigned char);
363 to_val->addr = (XtPointer) &value;
365 if (_StringsAreEqual (string, STR_TITLE_TOP))
367 else if (_StringsAreEqual (string, STR_TITLE_BOTTOM))
368 value = XmTITLE_BOTTOM;
373 XtStringConversionWarning ((String) from_val->addr,