From: rmbult01@starbase.spd.louisville.edu (Robert M. Bultman)
Subject: Re: Problems positioning widgets in a Form widget
Date: Fri, 18 Dec 1992 04:51:32 GMT
Organization: University of Louisville

I had some difficulty mailing this, so I posted instead.  My apoligies
if the question has been answered. 

In comp.windows.x.intrinsics you write:

>Hi folks,

>I've a problem with Athena's Form widget (If this is a FAQ, please tell
>me!): I can't specify the position of any of the Children in a Form
>widget. They all appear in the upper left corner, overlaying each other.
>Can anybody help me? My code looks about like that:

>#includes...
>void main(int argc, char *argv[])
>{
>	Widget myform, mycommand1, mycommand2;
>	XtAppContext mycontext;
>	int num;
>	static Arg arglist[]={
>		{XtNwidth, 400},
>		{XtNheight, 560},
>	};
>	static Arg comarglist[]={
>		{XtNwidth, 30},
>		{XtNheight, 10},
>		{XtNx, 1},
>	};

>	myrootwid = XtAppInitialize(&mycontext, "first", NULL, 0, 
>		&argc, argv, NULL, NULL, 0);
>	myform = XtCreateManagedWidget("Form", formWidgetClass,
>		myrootwid, arglist, 2);
>	mycommand1 = XtCreateManagedWidget("End", commandWidgetClass, 
>		myform, comarglist, 3);
>	comarglist[3].value = 40;
>	mycommand2 = XtCreateManagedWidget("Click me!", 
>		commandWidgetClass, myform, comarglist, 3);
>	XtRealizeWidget(myrootwid);
>	XtAppMainLoop(mycontext);
>}

>Thanks in advance,

>Thomas

>P.S.: Please reply by mail...

Well, I use the varargs style of widget creation (XtVaCreateManagedWidget).
It is just easier for me to use and allows setting of resources for
widgets easily.  I will use the varargs style here.

The way to position children of form widgets is listed in the documentation
for the form widget.  There are 9 resources you can set to control the
placement of the children relative to the other children in the widget.
I have rewritten your commandWidget creation code below.  (Note that it
has not been tested, but should be at least good enough to get the idea
across.)

mycommand1 = XtVaCreateManagedWidget("End", commandWidgetClass,
	myform, 
	XtNwidth, 400, 
	XtNheight, 560,
	NULL);
mycommand2 = XtVaCreateManagedWidget("Click me!", commandWidgetClass,
	myform,
	XtNwidth, 150,
	XtNheight, 50,
	XtNfromVert, "End",
	XtNvertDistance, 10,
	NULL);

I didn't use the same width and length as you did, but that doesn't really 
matter.  In the argument list for the creation of mycommand2, you can
see how I have use the XtNfromVert and XtNvertDistance resources to 
position mycommand2 10 pixels below mycommand1.  The fromVert resources tells
the form widget (really, not the command widget) to position mycommand2
vertically from mycommand1.  vertDistance tells how many pixels to put
between then two.  You can combine these two resources with XtNfromHoriz and
XtNhorizDistance to place mycommand2 diagonally from mycommand1.  I don't
know if you can use negative distances or not, but generally, the first
widget create goes in the top left (unless you set XtNx and XtNy).  The 
next create widget can be referenced from the first, the third created
can be reference from either the first or second or both, etc.

This is where using resource files come in handy.  You can move the
buttons and such around using a resource file without recompiling, which
usually saves some time.  After you get it the way you want it, you
can hard-code the positions into the code.

By the way, all of this stuff is in the O'Reilly book, Vol. 5, X Toolkit
Intrinsics Reference Manual under the section on the form widget.

Good Luck,
Rob
-- 
Robert M. Bultman                              |
Speed Scientific School                        |
University of Louisville                       |
Internet: rmbult01@starbase.spd.louisville.edu |