3 * Rob Zimmermann. All rights reserved.
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
13 static const char sccsid
[] = "$Id: m_util.c,v 8.10 1996/12/18 10:25:38 bostic Exp $ (Berkeley) $Date: 1996/12/18 10:25:38 $";
16 #include <sys/types.h>
17 #include <sys/queue.h>
19 #include <X11/Intrinsic.h>
20 #include <X11/StringDefs.h>
21 #include <X11/Shell.h>
22 #include <X11/Xatom.h>
24 #include <bitstring.h>
28 #include "../common/common.h"
29 #include "../ipc/ip.h"
33 /* Widget hierarchy routines
35 * void XutShowWidgetTree( FILE *fp, Widget root, int indent )
36 * prints the widgets and sub-widgets beneath the named root widget
40 void XutShowWidgetTree( FILE *fp
, Widget root
, int indent
)
42 void XutShowWidgetTree( fp
, root
, indent
)
48 #if ! defined(DECWINDOWS)
52 /* print where we are right now */
54 "%*.*swidget => 0x%x name => \"%s\"\n\r",
61 /* get the correct widget values */
62 XtVaGetValues( root
, XtNchildren
, &l
, 0 );
63 XtVaGetValues( root
, XtNchildren
, &l2
, 0 );
64 XtVaGetValues( root
, XtNnumChildren
, &count
, 0 );
66 /* print the sub-widgets */
67 for ( i
=0; i
<count
; i
++ ) {
68 XutShowWidgetTree( fp
, l
[i
], indent
+4 );
71 /* tidy up if this thing contained children */
73 /* we may or may not have to free the children */
76 XtFree( (char *) l2
);
84 /* Utilities for converting X resources...
86 * __XutConvertResources( Widget, String root, XutResource *, int count )
87 * The resource block is loaded with converted values
88 * If the X resource does not exist, no change is made to the value
89 * 'root' should be the application name.
91 * PUBLIC: void __XutConvertResources __P((Widget, String, XutResource *, int));
93 void __XutConvertResources(wid
, root
, resources
, count
)
96 XutResource
*resources
;
102 Boolean success
= True
;
104 /* for each resource */
105 for (i
=0; i
<count
; i
++) {
107 /* is there a value in the database? */
108 from
.addr
= XGetDefault( XtDisplay(wid
), root
, resources
[i
].name
);
109 if ( from
.addr
== NULL
|| *from
.addr
== '\0' )
112 /* load common parameters */
113 from
.size
= strlen( from
.addr
);
114 to
.addr
= resources
[i
].value
;
116 /* load type-specific parameters */
117 switch ( resources
[i
].kind
) {
119 to
.size
= sizeof(int);
124 /* String to Boolean */
125 to
.size
= sizeof(Boolean
);
130 /* String to Font structure */
131 to
.size
= sizeof(XFontStruct
*);
132 kind
= XtRFontStruct
;
135 case XutRKpixelBackup
:
136 /* String to Pixel backup algorithm */
137 if ( success
) continue;
141 /* String to Pixel */
142 to
.size
= sizeof(Pixel
);
147 /* String to Cursor */
148 to
.size
= sizeof(int);
156 /* call the converter */
157 success
= XtConvertAndStore( wid
, XtRString
, &from
, kind
, &to
);