[comp.soft-sys.andrew] help needed with arb/createcon

bill@allegra.tempo.nj.att.com (Bill Schell) (03/23/90)

Hi there. Perhaps someone could help me out with a problem I'm having
using tree/treev objects with arb and createcon?  I can get trees
to display themselves using the procedure laid out in the first
chapter of Nathanial Borenstein's book, but can't get more than a blank
window when I try to do it using the code generated by createcon.

Here's what I do:

1) I fire up arb and create a new window with an lset object in it
2) I pick 'Add Object' from the Arbcon menu and type 'tree treev'
	to get a tree-treev inset which I paste into the lset object.
	I save everything.
3) I run createcon to get the files infuse.ch and infuse.c.
4) I edit infuse.c and after the call to FindSelf()
	in the infuse_go function, I add a call to the following routine:

draw_tree(self)
  struct infuse *self;
{	
	struct tree_node *node;

	self->tree = tree_New();
	self->treeView = treev_New();
	treev_SetDataObject(self->treeView, self->tree);
	node = tree_CreateRootNode(self->tree, "Root Node", 0);
	tree_CreateChildNode(self->tree, "Child 1", 1, node);
	tree_CreateChildNode(self->tree, "Child 2", 2, node);
}

However, after compiling and running this code, all I get is a blank window.
I know this code makes a proper tree, because if I put:
	{ struct im *im = im_Create(NULL); im_SetView(im, self->treeView); }
at the end, I get a second window with the tree in it. 

Can someone give me a clue as to what I'm doing wrong here and how to
set up proper view tree?  This is the first Andrew based application
I've written.  I'd like to use arb/createcon for my application instead of
writing the glue code myself, as the eventual user interface will have tree
views, text views, button views, etc. in it and is likely to change
fairly often in the beginning.

Thanks,
	Bill Schell
	AT&T Bell Labs, Murray Hill, NJ
	bill@allegra.att.com or allegra!bill

gk5g+@ANDREW.CMU.EDU (Gary Keim) (03/23/90)

Excerpts from misc: 22-Mar-90 help needed with arb/create.. Bill
Schell@allegra.temp (1841)

> However, after compiling and running this code, all I get is a blank window.
> I know this code makes a proper tree, because if I put:
> 	{ struct im *im = im_Create(NULL); im_SetView(im, self->treeView); }
> at the end, I get a second window with the tree in it. 


You've created the tree/treev correctly.  You've created the nodes
correctly.  Then you must link the treev into the viewTree.  Use
LinkTree to attach it to its parent view:

	treev_LinkTree(self->treeView,	 self /*?*/);

This version of the code should work:

draw_tree(self)
  struct infuse *self;
{	
	struct tree_node *node;

	self->tree = tree_New();
	self->treeView = treev_New();
	treev_SetDataObject(self->treeView, self->tree);
	node = tree_CreateRootNode(self->tree, "Root Node", 0);
	tree_CreateChildNode(self->tree, "Child 1", 1, node);
	tree_CreateChildNode(self->tree, "Child 2", 2, node);
	treev_LinkTree(self->treeView,self ) ;
}

Gary Keim
ATK Group