From: kshomper@harp.cis.ohio-state.edu (keith shomper)
Subject: Need Help Resizing Form Widget and Children
Summary: What **REALLY** is happening whan a widget is resized?
Keywords: resizing
Organization: The Ohio State University Dept. of Computer and Info. Science
Distribution: usa
Date: Thu, 15 Oct 1992 12:39:50 GMT

     I'm trying to resize a Form widget by setting the new height and width via
the XtSetValues procedure (setting XmNwidth and XmNheight with XtSetArg).  This
gives me a Form window that`s the right size, but the children of the Form,
in this case a Label and a Scrolled_Window, are not resizing; although, I have
them attached to the Form.

     Currently, to get the resizing I want I am resizing the Scrolled_Window,
and the Form grows (or shrinks) to accomodate the change to its child.
Although this works, I'd rather learn how to resize the form directly.  Any
suggestions about why the Form's children will not resize when I resize the 
Form are appreciated.  One other note:  I thought that the children might
resize if I called the change_managed method directly from my application
(at least I wanted to see what would happen), this didn't work, rather 
than the children resizing to accomodate the Form, the Form resized to 
enclose the children according to the given attachments.

For those that care, here is the code that creates the Form, its children, and
my attempt to resize them....


	/* create a form to contain the scrolling window and title widgets */

	cnt = 0;
	XtSetArg(args[cnt], XmNborderWidth,  FORMBORDERWIDTH); cnt++;
	XtSetArg(args[cnt], XmNmarginWidth,  FUNCTIONMARGINWIDTH); cnt++;
	XtSetArg(args[cnt], XmNmarginHeight, FUNCTIONMARGINWIDTH); cnt++;

	form = XtCreateManagedWidget("form", xmFormWidgetClass, parent, args, cnt);

	/* create a title for this form */

	cnt = 0;
	XtSetArg(args[cnt], XmNlabelString,
			 XmStringCreate(title_name,      XmSTRING_DEFAULT_CHARSET)); cnt++;
	XtSetArg(args[cnt], XmNborderWidth,      TITLEBORDERWIDTH); cnt++;
	XtSetArg(args[cnt], XmNtopAttachment,    XmATTACH_FORM); cnt++;
	XtSetArg(args[cnt], XmNrightAttachment,  XmATTACH_FORM); cnt++;
	XtSetArg(args[cnt], XmNleftAttachment,   XmATTACH_FORM); cnt++;

	title = XtCreateManagedWidget("title", xmLabelWidgetClass, form, args, cnt);

	/* create a scrolling window widget to view the drawing area */

	cnt = 0;
	XtSetArg(args[cnt], XmNborderWidth,      SCROLLEDWINDOWBORDERWIDTH); cnt++;
	XtSetArg(args[cnt], XmNscrollingPolicy,  XmAUTOMATIC); cnt++;
	XtSetArg(args[cnt], XmNtopAttachment,    XmATTACH_WIDGET); cnt++;
	XtSetArg(args[cnt], XmNtopWidget,        function->title); cnt++;
	XtSetArg(args[cnt], XmNrightAttachment,  XmATTACH_FORM); cnt++;
	XtSetArg(args[cnt], XmNleftAttachment,   XmATTACH_FORM); cnt++;
	XtSetArg(args[cnt], XmNbottomAttachment, XmATTACH_FORM); cnt++;
  	XtSetArg(args[cnt], XmNwidth,            SCROLLEDWINDOWWIDTH); cnt++;
  	XtSetArg(args[cnt], XmNheight,           SCROLLEDWINDOWHEIGHT); cnt++;

	swin = XtCreateManagedWidget("swin", xmScrolledWindowWidgetClass, form,
								  args, cnt);
								   
								   .
								   .
					other widgets are created
								   .
								   .


  /* determine how to resize scrolled window so that the form window matches
   * the size I really want -- THIS WORKS, BUT REQUIRES ME TO KNOW ALL ABOUT
   * THE FORM'S CHILDREN AND HOW THEY HELP DETERMINE THE FORM'S FINAL SIZE */

   scrolled_window_width  = formwidth - 
						    2 * (FUNCTIONMARGINWIDTH+SCROLLEDWINDOWBORDERWIDTH);
  
   scrolled_window_height = formheight - 
						    (2 * (FUNCTIONMARGINWIDTH+SCROLLEDWINDOWBORDERWIDTH+
								  TITLEBORDERWIDTH) + titleheight);

  /* set the scrolled window to these new sizes */

  cnt = 0;
  XtSetArg(args[cnt], XmNwidth, scrolled_window_width); cnt++;
  XtSetArg(args[cnt], XmNheight, scrolled_window_height); cnt++;
  XtSetValues(swin, args, cnt);
  
  /* what I'd like is to just resize the form like so -- THIS DOES NOT WORK 
   * THE FORM RESIZES, BUT THE CHILDREN DO NOT, AND IF I CALL change_managed
   * FROM MY APPLICATION, THEN THE FORM REVERTS TO ITS ORIGINAL SIZE */

  cnt = 0;
  XtSetArg(args[cnt], XmNwidth, form_window_width); cnt++;
  XtSetArg(args[cnt], XmNheight, form_window_height); cnt++;
  XtSetValues(form, args, cnt);