Path: utzoo!censor!geac!jtsv16!uunet!ginosko!ctrsol!lll-winken!lll-crg.llnl.gov!uejio
From: uejio@lll-crg.llnl.gov (Jeremy Y. Uejio)
Newsgroups: comp.windows.x
Subject: need help creating a widget with a Widget field
Message-ID: <30925@lll-winken.LLNL.GOV>
Date: 18 Aug 89 00:23:12 GMT
Reply-To: uejio@lll-crg.llnl.gov (Jeremy Y. Uejio)
Distribution: usa
Organization: Lawrence Livermore National Laboratory
Lines: 64

I've just started creating my own widgets and was wondering if someone
could help me with the following problem creating a widget with a
Widget field.

Basically, I want a widget where one of the fields is a Label widget.
To do this I first created my .h and P.h by simply copying the
Template example.  I call my widget test so my TestP.h file looks
partly like:

typedef struct {
    /* resources */
	Widget label;
    /* private state */
} TestPart;

In my Test.c file I have an Initialize and a Realize function:

static void Initialize (request,new)
     Widget request;
     Widget new;
{
	Arg args[2];
	TestWidget test = (TestWidget)new;

	/* width and height are not initialized by core */
	if (test->core.width == 0)
	  test->core.width = 200;
	if (test->core.height <= 20)
	  test->core.height = 200;
	XtSetArg(args[0],XtNwidth,100);
	XtSetArg(args[1],XtNlabel,"Hello");
	test->test.label = XtCreateWidget("label",labelWidgetClass,
					  test,args,2);
}

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

I compile, link, and run with a simple main.c and get the following error:

X Protocol error:  not a valid window ID
  Major opcode of failed request:  1 (X_CreateWindow)
  Minor opcode of failed request:  0
  Resource id in failed request:  0x0
  Serial number of failed request:  22
  Current serial number in output stream:  24

What's the problem here?  What am I doing wrong?


				Thanks in advance,
				jeremy


Jeremy Uejio (pronounced 'oo-ay-joe')    uejio@lll-crg.llnl.gov
Jeremy Uejio (pronounced 'oo-ay-joe')    uejio@lll-crg.llnl.gov
uucp:  {gatech,pyramid,rutgers}!lll-crg!uejio
other things to try:  uejio%lll-crg.llnl.gov@relay.cs.net