[comp.soft-sys.andrew] Parents, just don't understand.

hassan@INFORMATICS.WUSTL.EDU (Scott Hassan) (07/26/90)

How can a view object find who is its parent is in the view tree?
Really important, really simple, but I cannot find it in the 
documentation(hah!)

				Scott
				hassan@informatics.wustl.edu
				Medical Informatics
				Department of Internal Medicine
				Washington University
				St. Louis, MO   63130
				(314) 362-3422

gk5g+@ANDREW.CMU.EDU (Gary Keim) (07/26/90)

Well, it is strange that there doesn't exist at least at view-class
macromethod along these lines:

class view  {

  macromethods:
	Parent()		((self)->parent)

};

I don't know what the reasoning is behind this because you just need to
get your parent sometimes -- mostly when posting menus and keystates.

Use this macro for any subclasses of view:

#define Parent(self)  ((self)->header.view.parent)

This macro is also useful:

#define  ViewLinked(self)  (view_IsAncestor(self,self_GetIM(self)))

Gary Keim
ATK Group

gk5g+@ANDREW.CMU.EDU (Gary Keim) (07/26/90)

Of course, I made a typo:

#define  ViewLinked(self)  (view_IsAncestor(self,view_GetIM(self)))

Gary Keim
ATK Group

nsb@THUMPER.BELLCORE.COM (Nathaniel Borenstein) (07/27/90)

For any subclass of view, you should be able to do:

((struct view *) self)->parent

Of course, there should be a method (macromethod) for this, so that you
could instead do

fooview_GetParent(self)

but in the absence of that method, the hack above should work.  -- NB

nsb@THUMPER.BELLCORE.COM (Nathaniel Borenstein) (07/27/90)

Excerpts from internet.info-andrew: 26-Jul-90 Re: Parents, just don't
und.. Gary Keim@andrew.cmu.edu (520+0)

> Well, it is strange that there doesn't exist at least at view-class
> macromethod along these lines:

> class view  {

>   macromethods:
> 	Parent()		((self)->parent)

> };

> I don't know what the reasoning is behind this because you just need to
> get your parent sometimes -- mostly when posting menus and keystates.

> Use this macro for any subclasses of view:

> #define Parent(self)  ((self)->header.view.parent)


Well, why not add "Parent" as a macromethod to the view class in the
next patch, rather than tell everyone to define their own macro and
leave it at that?