File: types.c

package info (click to toggle)
x11iraf 1.2-4
  • links: PTS
  • area: contrib
  • in suites: woody
  • size: 13,168 kB
  • ctags: 14,531
  • sloc: ansic: 143,143; makefile: 964; perl: 549; csh: 249; yacc: 247; fortran: 238; tcl: 199; lex: 125; lisp: 88; sh: 23; sed: 6
file content (78 lines) | stat: -rw-r--r-- 2,153 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * types.c : Converters for SearchType and SortType, and an improved
 *	converter for Widget that allows "NULL" to be specified.
 *
 * George Ferguson, ferguson@cs.rochester.edu, 12 Sep 1991.
 *
 */

#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xmu/CharSet.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Cardinals.h>
#include "types.h"
extern void XmuConvertStringToWidget();		/* original converter */

/*
 * Functions defined here:
 */
void initConverters();

void cvtStringToWidget();

/* Straight from the Xt manual... */
#define done(VALUE,TYPE)\
{							\
    if (toVal->addr != NULL) {				\
	if (toVal->size < sizeof(TYPE)) {		\
	    toVal->size = sizeof(TYPE);			\
	    return(False);				\
	}						\
	*(TYPE *)(toVal->addr) = (VALUE);		\
    } else {						\
	static TYPE static_val;				\
	static_val = (VALUE);				\
	toVal->addr = (XtPointer)&static_val;		\
    }							\
    toVal->size = sizeof(TYPE);				\
    return(True);					\
}
							
void
initConverters(appContext)
XtAppContext appContext;
{
    static XtConvertArgRec parentCvtArgs[] = {
        {XtBaseOffset, (caddr_t)XtOffset(Widget, core.parent), sizeof(Widget)}
    };

    /* Have to initialize Form class first or our converter will be	*/
    /* overidden by the class initialization function.			*/
    /* Use the old style here on purpose since that what the default is.*/
    XtInitializeWidgetClass(formWidgetClass);
    XtAppAddConverter(appContext,XtRString,XtRWidget,cvtStringToWidget,
					parentCvtArgs,XtNumber(parentCvtArgs));
}

/*
 * cvtStringToWidget() : Allows us to specify "NULL" as a widget name in
 *	a resource file to override compiled-in defaults for composite
 *	widget layouts. Simply calls the regular converter if the string
 *	is not "NULL". Note that this must be registered *after* the
 *	Form class is initialized.
 */
void
cvtStringToWidget(args,num_args,fromVal,toVal)
XrmValuePtr args;
Cardinal *num_args;
XrmValuePtr fromVal;
XrmValuePtr toVal;
{
    if (XmuCompareISOLatin1(fromVal->addr,"NULL") == 0) {
	toVal->addr = NULL;
	toVal->size = 0;
    } else {
	XmuCvtStringToWidget(args,num_args,fromVal,toVal);
    }
}