[comp.windows.x] Athena Form-ed woes

richards@eng.AUburn.EDU (Eric J. Richards) (08/09/90)

Hello out there!  I'll be brief:  I'm using an Athena Form widget and
I've ran into a layout problem.  It's not doing what I wanted... say
I want to put the following Command widgets in a form, like this:

 +-----------------------------+   The outer box is a form widget.
 |                             |   A1..A3, B1..B3 are command widgets.
 | +-------+         +-------+ |
 | |       |         |       | |   The arrows represent XtNfromVert
 | |  A 1  |  <--    |  B 1  | |   and XtNfromHoriz relationships.
 | |       |         |       | |
 | +-------+         +-------+ |   The A column is made first.
 |     ^                       |
 |     |                       |   When realized, the form collapses
 | +-------+         +-------+ |   the B column into one spot:  to
 | |       |         |       | |   the right of A1, as if all the
 | |  A 2  |  <--    |  B 2  | |   B column widgets were referencing
 | |       |         |       | |   A1 instead of the desired
 | +-------+         +-------+ |   relationship.
 |     ^                       |
 |     |                       |
 | +-------+         +-------+ |   System:
 | |       |         |       | |       Sparc's under 4.0.3
 | |  A 3  |  <--    |  B 3  | |       X11R4
 | |       |         |       | |       Patch level at least 10
 | +-------+         +-------+ |       Sun cc compiler
 |                             |           -g -sun4 flags used.
 +-----------------------------+

All I can guess is that the fromVert / fromHoriz constraint resources
are intrepted like a graph, with all paths leading towards A1.  I've
checked my big program to make sure that I'm setting the right
relationships for the B column.  XtGetValues() also confirms that I've
set the correct A widget to be positioned near.

So, is it a Form problem, or am I missing something?  To help you decide
this burning question, I've included a small, worthless program that
demonstrates the same problem.  All of the B column, instead of pacing
the A column, collapses into B1's space.

I'll summarize any non-posted solutions / suggestions ;-}  Thanks!

_________________________________________________________________
\ Eric Richards, Auburn University    "Money can't buy happiness.\
 \   InterNet:                         Then again, happiness can't\
\\\       richards@eng.auburn.edu      buy government insured CD's"\
 \\\ BitNet:                                                        \
  \\\     erichard@ducvax.auburn.edu         -- David Addison        \
   \\\________________________________________________________________\
    \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\


==== Code bits:  linked with -lXaw -lXmu -lXt -lX11 -lm
|
==== C U T    H E R E   ===============================================

/*=== Xproblem.c -- a worthless program that demonstrates
|*                  a problem I'm having with the Athena
|*                  form widget.
\*/

#include <stdio.h>
#include <X11/StringDefs.h>
#include <X11/Intrinsic.h>
#include <X11/Xaw/Box.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Label.h>
#include <X11/Xaw/Command.h>

void my_quit()
{
exit(0);
}

main ( argc, argv)
	int	argc;
	char	**argv;
{
Widget	topW, formW,
	a1, a2, a3,
	b1, b2, b3;
Arg	args[8];
int	n;

printf( "Xproblem:  demonstrates a problem I'm having with\n");
printf( "           setting widget layouts using the Athena\n");
printf( "           Form widget.\n\n");
printf( "Click on A1 to exit.\n");

topW  = XtInitialize( argv[0], "Xproblem", NULL, 0, &argc, argv);
formW = XtCreateManagedWidget( "Buttons", formWidgetClass,
				topW, NULL, 0);

n = 0;
XtSetArg( args[n], XtNlabel, "A1    ");		n++;

a1    = XtCreateManagedWidget( "a1", commandWidgetClass, formW, args, n);

n = 0;
XtSetArg( args[n], XtNlabel, "  A2  ");		n++;
XtSetArg( args[n], XtNfromVert, a1);		n++;

a2    = XtCreateManagedWidget( "a2", commandWidgetClass, formW, args, n);

n = 0;
XtSetArg( args[n], XtNlabel, "    A3");		n++;
XtSetArg( args[n], XtNfromVert, a2);		n++;

a3    = XtCreateManagedWidget( "a3", commandWidgetClass, formW, args, n);

n = 0;
XtSetArg( args[n], XtNlabel, "B1");		n++;
XtSetArg( args[n], XtNfromHoriz, a1);		n++;

b1 = XtCreateManagedWidget( "b1", commandWidgetClass, formW, args, n);

n = 0;
XtSetArg( args[n], XtNlabel, "  B2");		n++;
XtSetArg( args[n], XtNfromHoriz, a2);		n++;

b2 = XtCreateManagedWidget( "b2", commandWidgetClass, formW, args, n);

n = 0;
XtSetArg( args[n], XtNlabel, "    B3");		n++;
XtSetArg( args[n], XtNfromHoriz, a3);		n++;

b3 = XtCreateManagedWidget( "b3", commandWidgetClass, formW, args, n);


XtAddCallback( a1, XtNcallback, my_quit, (XtPointer) NULL);
XtRealizeWidget( topW);
XtMainLoop();
}


/*-- eof --*/