~ubuntu-branches/ubuntu/intrepid/tcm/intrepid

« back to all changes in this revision

Viewing changes to src/ui/dumpwidgettree.c

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2003-07-03 20:08:21 UTC
  • Revision ID: james.westby@ubuntu.com-20030703200821-se4xtqx25e5miczi
Tags: upstream-2.20
ImportĀ upstreamĀ versionĀ 2.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
////////////////////////////////////////////////////////////////////////////////
 
2
//
 
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
 
4
// (c) copyright 1996, Vrije Universiteit Amsterdam.
 
5
// Author: Frank Dehne (frank@cs.vu.nl).
 
6
//
 
7
// TCM is free software; you can redistribute it and/or modify
 
8
// it under the terms of the GNU General Public License as published by
 
9
// the Free Software Foundation; either version 2 of the License, or 
 
10
// (at your option) any later version.
 
11
//
 
12
// TCM is distributed in the hope that it will be useful,
 
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
// GNU General Public License for more details.
 
16
//
 
17
// You should have received a copy of the GNU General Public License
 
18
// along with TCM; if not, write to the Free Software
 
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
20
// 02111-1307, USA.
 
21
////////////////////////////////////////////////////////////////////////////////
 
22
#include "dumpwidgettree.h"
 
23
#include <stdio.h>
 
24
#include <Xm/Xm.h>
 
25
#include <X11/IntrinsicP.h>
 
26
#include <X11/CoreP.h>
 
27
 
 
28
void DumpWidgetTree::Dump(Widget w) {
 
29
        WidgetList list = 0;
 
30
        Cardinal num_children = 0;
 
31
        unsigned i;
 
32
        static unsigned n = 0;
 
33
        Widget child;
 
34
        static const char *indent =
 
35
 "----------------------------------------------------------------------------";
 
36
        char tmp[256];
 
37
        *tmp = '\0';
 
38
        if ( n >= strlen(indent) +1) {
 
39
                printf("ERROR: Widget tree is too deep ( < %d )!\n", n);
 
40
                n = 0;
 
41
                return;
 
42
        }
 
43
        strncpy(tmp, indent, n);
 
44
        tmp[n] = '\0';
 
45
        printf("%s> widget tree of %s %s \n", tmp, 
 
46
                ((CoreClassPart *)XtClass(w))->class_name, XtName(w));
 
47
        if (!XtIsComposite(w)) {
 
48
                printf("%s> %s has no children\n", tmp, XtName(w));
 
49
                printf("\n");
 
50
                return;
 
51
        }
 
52
        XtVaGetValues(w,
 
53
                XmNchildren, &list,
 
54
                XmNnumChildren, &num_children, 0);
 
55
        printf("%s> %s has %d %s:\n", tmp,
 
56
                        XtName(w), num_children, 
 
57
                        num_children == 1 ? "child" : "children");
 
58
        for (i=1; i<=num_children; i++) {
 
59
                child = list[i-1];
 
60
                printf("%s>    child %2d: %20s\n",
 
61
                        tmp, i, XtName(child));
 
62
        }
 
63
        printf("\n");
 
64
        for (i=1; i <= num_children; i++) {
 
65
                child = list[i-1];
 
66
                n += 3;
 
67
                Dump(child);
 
68
                n -= 3;
 
69
        }
 
70
        printf("\n");
 
71
}