Path: utzoo!attcan!uunet!cs.utexas.edu!csd4.csd.uwm.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!ATHENA.MIT.EDU!swick
From: swick@ATHENA.MIT.EDU (Ralph R. Swick)
Newsgroups: comp.windows.x
Subject: Re: need help creating a widget with a Widget field
Message-ID: <8908181251.AA02122@LYRE.MIT.EDU>
Date: 18 Aug 89 12:51:41 GMT
References: <30925@lll-winken.LLNL.GOV>
Sender: daemon@bloom-beacon.MIT.EDU
Organization: DEC/MIT Project Athena
Lines: 28


> static void Realize( w, valueMask, attributes )
>      Widget w;
>      Mask *valueMask;
>      XSetWindowAttributes *attributes;
> {
> 	TestWidget c = (TestWidget)w;
> 	XtRealizeWidget(c->test.label);
> }


The realize procedure has to actually create the window for
the widget.  In this case, it also has to make sure to create
the window _before_ attempting to realize the child (since the
child will be a subwindow).  The most-frequently-correct action
is to call your superclass realize from within your own
realize;

	TestWidget c = (TestWidget)w;
	*(testWidgetClass->core_class.superclass->
	    core_class.realize) ( w, valueMask, attributes )
	XtRealizeWidget(c->test.label);

[Note that you can't use XtSuperclass(w), as things will get
fouled up if someone ever tries to subclass TestWidget.  I have
gotten into the habit of defining a macro, "superclass", for
thisWidgetClass->core_class.superclass so that the 3 or 4
typical references in the widget.c file are uniform.]