1 /**
2 *
3 * $Header: /cvsroot/lesstif/lesstif/test/common/XdbPrintTree.c,v 1.5 2002/05/01 16:01:26 amai Exp $
4 *
5 * Copyright (C) 1995 Free Software Foundation, Inc.
6 * Copyright (C) 1996-2002 LessTif Development Team
7 *
8 * This file is part of the GNU LessTif Library.
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details.
19 *
20 * You should have received a copy of the GNU Library General Public
21 * License along with this library; if not, write to the Free
22 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 **/
25
26
27 #include "LTTconfig.h"
28
29 #include <stdio.h>
30 #include <stdlib.h>
31
32 #include <X11/Xos.h>
33 #include <X11/Intrinsic.h>
34 #include <X11/IntrinsicP.h>
35 #include <X11/Xresource.h>
36
37 #include <Xm/XmP.h>
38 #include <Xm/GadgetP.h>
39 #include <Xm/VendorSEP.h>
40
41 #define LIB_LTTEST
42 #include "Test.h"
43
44
_XdbPrintTree(Widget w,int level)45 static void _XdbPrintTree(Widget w, int level)
46 {
47 int i;
48 CompositeWidget cw = (CompositeWidget)w;
49
50 if (w == NULL)
51 return;
52
53 for (i=0; i<level; i++)
54 fprintf(stderr, "\t");
55 #ifdef PRINT_ADDRESS
56 fprintf(stderr, "%s : %p/%ld", XtName(w), w, XtWindow(w));
57 #endif
58 #ifndef PRINT_APPSHELL_NAME
59 if(!XtIsApplicationShell(w))
60 #endif
61 fprintf(stderr, "%s", XtName(w));
62 fprintf(stderr, "(%s) geo %d %d %d %d",
63 w->core.widget_class->core_class.class_name,
64 XtX(w), XtY(w), XtWidth(w), XtHeight(w));
65 #ifdef PRINT_STATE
66 fprintf(stderr, " state: %s %s",
67 _XdbState(w), w->core.mapped_when_managed ? "mwm": "");
68 #endif
69 fprintf(stderr, "\n");
70 if (XtIsSubclass(w, compositeWidgetClass))
71 for (i=0; i<(int)cw->composite.num_children; i++)
72 _XdbPrintTree(cw->composite.children[i], level+1);
73
74 for (i=0; i<(int)cw->core.num_popups; i++)
75 _XdbPrintTree(cw->core.popup_list[i], level+1);
76 }
77
78
XdbPrintTree(Widget w)79 void XdbPrintTree(Widget w)
80 {
81 _XdbPrintTree(w, 0);
82 }
83
84
XdbPrintCompleteTree(Widget w)85 void XdbPrintCompleteTree(Widget w)
86 {
87 Widget ww = w;
88
89 while (ww) {
90 w = ww;
91 ww = XtParent(w);
92 }
93
94 _XdbPrintTree(w, 0);
95 }
96
97
XdbPrintTreeCB(Widget w,XtPointer client,XtPointer call)98 void XdbPrintTreeCB(Widget w, XtPointer client, XtPointer call)
99 {
100 XdbPrintTree((Widget)client);
101 }
102