[comp.windows.x] HP Form Widget Woes

rosenbl@cis.ohio-state.edu (Robert Rosenblum) (07/18/89)

Hi.  I'm having a problem with the HP form widget and resizing widgets within
the form widget.

I've got one main form widget called 'big', and some more form widgets called 
'one', 'two', and 'three', which are placed inside 'big'.  'one' is supposed to
be at the top, 'two' is just below 'one', and 'three' is just below 'two'.

Both 'one' and 'two' are supposed to span the width of the window, even after
resizing the window.  But when I make a small modification to the program, 
'one' will no longer resize itself.  From my understanding, the change I made
shouldn't affect 'one's ability to resize to the new window width.

Below is the code with the modification pointed out in the comments:



#include <X11/StringDefs.h>
#include <X11/Intrinsic.h>
#include <Xw/Xw.h>
#include <Xw/Form.h>				  /* form widget */

Widget top, big, one, two, three, four;
Arg arglist[20];
Cardinal i;

main(argc, argv)
int argc;
char *argv[];
{
  top = XtInitialize("toplevel", "TOplevel", NULL, NULL, &argc, argv);


						  /* the main form widget */
  big = XtCreateManagedWidget(NULL, XwformWidgetClass, top, NULL, 0);

  i = 0;
  XtSetArg(arglist[i], XtNxRefWidget, (XtArgVal) big); i++;
  XtSetArg(arglist[i], XtNyRefWidget, (XtArgVal) big); i++;
  XtSetArg(arglist[i], XtNxResizable, (XtArgVal) TRUE); i++;
  XtSetArg(arglist[i], XtNxAttachRight, (XtArgVal) TRUE); i++;
  one = XtCreateManagedWidget("one", XwformWidgetClass, big, arglist, i);

  /*** widget one goes at the top of the window and spans the width of the */
  /*** window */



  i = 0;
  XtSetArg(arglist[i], XtNxRefWidget, (XtArgVal) big); i++;
  XtSetArg(arglist[i], XtNyRefWidget, (XtArgVal) one); i++;
  XtSetArg(arglist[i], XtNxResizable, (XtArgVal) TRUE); i++;
  XtSetArg(arglist[i], XtNxAttachRight, (XtArgVal) TRUE); i++;

  XtSetArg(arglist[i], XtNyAddHeight, (XtArgVal) TRUE); i++;


  two = XtCreateManagedWidget("two", XwformWidgetClass, big, arglist, i);

  /*** widget two goes just below widget one and also spans the width of the */
  /*** window */



  /*************************************************************************/
  /******* HERE IS WHERE THE PROBLEM IS.  If I change 'big' to 'one' in the */
  /******* XtNxRefWidget set below, widget one will no longer resize itself */
  /******* to span the width of the window.                                 */
  /**************************************************************************/
  i = 0;
  XtSetArg(arglist[i], XtNxRefWidget, (XtArgVal) big); i++; /* <--- here */
						 /* change 'big' */
						 /* to 'one' and */
						 /* 'one' won't resize*/


  XtSetArg(arglist[i], XtNyRefWidget, (XtArgVal) two); i++;
  XtSetArg(arglist[i], XtNyAddHeight, (XtArgVal) TRUE); i++;

  XtSetArg(arglist[i], XtNyAttachBottom, (XtArgVal) TRUE); i++;
  XtSetArg(arglist[i], XtNyResizable, (XtArgVal) TRUE); i++;

  three = XtCreateManagedWidget("three", XwformWidgetClass, big, arglist, i);


  XtRealizeWidget(top);
  XtMainLoop();
}



Am I doing something wrong?  I'm running on an HP 9000/370 under HP-UX 6.2
and X11-R2 (I'm pretty sure it's R2).

Thanks in advance!


      Rob