3 * Rob Zimmermann. All rights reserved.
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
12 #include <sys/cdefs.h>
15 static const char sccsid
[] = "Id: m_util.c,v 8.12 2003/11/05 17:10:00 skimo Exp (Berkeley) Date: 2003/11/05 17:10:00 ";
18 __RCSID("$NetBSD: m_util.c,v 1.2 2014/01/26 21:43:45 christos Exp $");
21 #include <sys/types.h>
22 #include <sys/queue.h>
24 #include <X11/Intrinsic.h>
25 #include <X11/StringDefs.h>
26 #include <X11/Shell.h>
27 #include <X11/Xatom.h>
29 #include <bitstring.h>
34 #include "../common/common.h"
35 #include "../ipc/ip.h"
39 /* Widget hierarchy routines
41 * void XutShowWidgetTree( FILE *fp, Widget root, int indent )
42 * prints the widgets and sub-widgets beneath the named root widget
46 void XutShowWidgetTree( FILE *fp
, Widget root
, int indent
)
48 void XutShowWidgetTree( fp
, root
, indent
)
54 #if ! defined(DECWINDOWS)
58 /* print where we are right now */
60 "%*.*swidget => 0x%x name => \"%s\"\n\r",
67 /* get the correct widget values */
68 XtVaGetValues( root
, XtNchildren
, &l
, 0 );
69 XtVaGetValues( root
, XtNchildren
, &l2
, 0 );
70 XtVaGetValues( root
, XtNnumChildren
, &count
, 0 );
72 /* print the sub-widgets */
73 for ( i
=0; i
<count
; i
++ ) {
74 XutShowWidgetTree( fp
, l
[i
], indent
+4 );
77 /* tidy up if this thing contained children */
79 /* we may or may not have to free the children */
82 XtFree( (char *) l2
);
90 /* Utilities for converting X resources...
92 * __XutConvertResources( Widget, String root, XutResource *, int count )
93 * The resource block is loaded with converted values
94 * If the X resource does not exist, no change is made to the value
95 * 'root' should be the application name.
97 * PUBLIC: void __XutConvertResources __P((Widget, String, XutResource *, int));
99 void __XutConvertResources(Widget wid
, String root
, XutResource
*resources
, int count
)
104 Boolean success
= True
;
106 /* for each resource */
107 for (i
=0; i
<count
; i
++) {
109 /* is there a value in the database? */
110 from
.addr
= XGetDefault( XtDisplay(wid
), root
, resources
[i
].name
);
111 if ( from
.addr
== NULL
|| *from
.addr
== '\0' )
114 /* load common parameters */
115 from
.size
= strlen( from
.addr
);
116 to
.addr
= resources
[i
].value
;
118 /* load type-specific parameters */
119 switch ( resources
[i
].kind
) {
121 to
.size
= sizeof(int);
126 /* String to Boolean */
127 to
.size
= sizeof(Boolean
);
132 /* String to Font structure */
133 to
.size
= sizeof(XFontStruct
*);
134 kind
= XtRFontStruct
;
137 case XutRKpixelBackup
:
138 /* String to Pixel backup algorithm */
139 if ( success
) continue;
143 /* String to Pixel */
144 to
.size
= sizeof(Pixel
);
149 /* String to Cursor */
150 to
.size
= sizeof(int);
158 /* call the converter */
159 success
= XtConvertAndStore( wid
, XtRString
, &from
, kind
, &to
);