Top Document: Motif FAQ (Part 9 of 9) Previous Document: 327) Can I write a multi-threaded Motif application? Next Document: 329) How do I get the events for gadgets? Or the name of the gadget? See reader questions & answers on this topic! - Help others by sharing your knowledge the hierarchy? [Last modified: July 97] Answer: Jeremy Jameson (jameson@drmail.dr.att.com) posted this code to c.w.x.m in 5/95. [Note: this code does not consider popup children, which are not listed in the XmNchildren array. To find those, you have to peek at the popup_list in core widget record. - K.Lee 7/97] /******************************************************************************* * dumpWidgetTree( Widget w ) * * This function will recursively descend throught the Widget tree * and print the children and their pointer addresses. * * Jeremy Jameson 5/17/95 * *******************************************************************************/ static void dumpWidgetTree( Widget w ) { WidgetList list = NULL; Cardinal num_children = 0; int i; static int n = 0; Widget child; static char* indent = "-----------------------------------------------------------------------------"; char tmp[256]; *tmp = ' '; if ( n >= strlen( indent ) +1 ) { printf( "ERROR:Widget tree is too deep, not enough indent string ( < %d )!\n", n ); n = 0; return; } strncpy( tmp, indent, n ); tmp[n] = ' '; printf( "%s> Dumping widget tree of %s - %#x \n", tmp, XtName( w ), w ); if ( ! XtIsComposite( w ) ) { printf( "%s> %s is not a subclass of Composite and therefore has no children\n", tmp, XtName( w ) ); return; } XtVaGetValues( w, XmNchildren, &list, XmNnumChildren, &num_children, NULL ); printf( "%s> %s has %d %s\n", tmp, XtName( w ), num_children, num_children == 1 ? "child" : "children" ); for ( i = 1; i <= num_children; i++ ) { child = list[i-1]; printf( "%s> child %2d %20s \t (%#x)\n", tmp, i, XtName( child ), child ); } printf( "\n" ); for ( i = 1; i <= num_children; i++ ) { child = list[i-1]; n += 3; dumpWidgetTree( child ); n -= 3; } printf( "\n" ); } User Contributions:Top Document: Motif FAQ (Part 9 of 9) Previous Document: 327) Can I write a multi-threaded Motif application? Next Document: 329) How do I get the events for gadgets? Or the name of the gadget? Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Part8 - Part9 - Single Page [ Usenet FAQs | Web FAQs | Documents | RFC Index ] Send corrections/additions to the FAQ Maintainer: kenton@rahul.net (Ken Lee)
Last Update March 27 2014 @ 02:11 PM
|
Comment about this article, ask questions, or add new information about this topic: