[comp.windows.x] Motif DrawingArea widget seems to ignore XmNresizePolicy widget?

mike@BACH.CS.BYU.EDU (Mike Burbidge) (06/01/90)

The motif DrawingArea widget has a resource named XmNresizePolicy. The
documentation claims that it can be assigned three values: XmRESIZE_NONE,
XmRESIZE_ANY, XmRESIZE_GROW. I created a SelectionBox widget whose working
area widget is a DrawingArea widget with width and height 500 and
XmNresizePolicy set to XmRESIZE_NONE. The manual puts (fixed size) next to
XmRESIZE_NONE. I assume this means that the drawing area widget will ignore
resize requests from its parents. Either I have misunderstood the short two
word explaination for XmRESIZE_NONE, or else there is a bug somewhere. In
either event the SelectionBox widget resizes the DrawingArea widget to
20x20. Below a short example program.

----------------------------------------------------------------------
#include <stdio.h>
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <X11/Shell.h>
#include <Xm/DialogS.h>
#include <Xm/Frame.h>
#include <Xm/SelectioB.h>
#include <Xm/DrawingA.h>
  
main (int argc, char *argv[])
{
  Display *display;
  Widget appl_shell, dialog, selection, draw;
  XtAppContext context;
  Arg args[10];
  int n;
  
  /* Initialize X11 and the Motif widget environment. */
  
  XtToolkitInitialize ();
  context = XtCreateApplicationContext ();
  display = XtOpenDisplay (context, NULL, argv[0], "try", 
			   NULL, 0, &argc, argv);
  appl_shell = XtAppCreateShell (argv[0], "Root try",
				 applicationShellWidgetClass, 
				 display, NULL, 0);
  XtResizeWidget (appl_shell, 5, 5, 1);

  n = 0;
  dialog = XmCreateDialogShell (appl_shell, "dialog", args, n);

  n = 0;
  XtSetArg (args[n], XmNdialogType, XmDIALOG_PROMPT), n++;
  selection = XtCreateWidget ("selection", xmSelectionBoxWidgetClass,
			      dialog, args, n);

  n = 0;
  XtSetArg (args[n], XmNheight, 500), n++;
  XtSetArg (args[n], XmNwidth, 500), n++;
  XtSetArg (args[n], XmNresizePolicy, XmRESIZE_NONE), n++;
  draw = XmCreateDrawingArea (selection, "draw", args, n);
  XtManageChild (draw);

  XtManageChild (XmSelectionBoxGetChild (selection, XmDIALOG_APPLY_BUTTON));
  XtUnmanageChild (XmSelectionBoxGetChild (selection, XmDIALOG_TEXT));
  XtUnmanageChild (XmSelectionBoxGetChild (selection, 
					   XmDIALOG_SELECTION_LABEL));
  XtUnmanageChild (XmSelectionBoxGetChild (selection, XmDIALOG_HELP_BUTTON));

  XtManageChild (selection);
  XtManageChild (dialog);

  XtRealizeWidget (dialog);
  
  XtAppMainLoop (context);
}
------------------------------------------------------------------

Could someone help me fix this program or give me an alternative so that the
DrawingArea widget does not get resized!

Mike Burbidge
mike@bach.cs.byu.edu

jordan@morgan.COM (Jordan Hayes) (06/04/90)

Mike Burbidge <mike@bach.cs.byu.edu> writes:

	The Motif DrawingArea widget has a resource named
	XmNresizePolicy. The documentation claims that it can be
	assigned three values: XmRESIZE_NONE, XmRESIZE_ANY,
	XmRESIZE_GROW.  I assume this means that the drawing area
	widget will ignore resize requests from its parents.

You assumed incorrectly ;-)

The only way i've been able to make this work is to fix the whole
window, via an XSetWMNormalHints() call to the top.  I do this with
dialog boxes so people don't monkey with them.  The source seems to be
okay (1.0A) but I bet there's something in the R3 Intrinsics that
prevents this from working.

/jordan

ben@hpcvlx.cv.hp.com (Benjamin Ellsworth) (06/06/90)

> ...[setting resize policy to XmRESIZE_NONE]... I assume this means
> that the drawing area widget will ignore resize requests from its
> parents. Either I have misunderstood the short two word explaination
> for XmRESIZE_NONE, or else there is a bug somewhere. ...

You have misunderstood.  It is absolutely against The Rules(tm) for a
widget to ignore resize requests from its parent.  Keep this in mind
when trying to unravel the gordian knot of geometry management.

Resize policy controls whether or not the drawing area (or other
sub-class of BulletinBoard) will respond to changes in its children
with geometry requests of its parent.  If resize policy is none, the
widget never makes a request due to changes in its children.  If the 
policy is grow, the widget only makes a request if changes in its 
children cause the drawing area to grow.  If the policy is any, the
drawing area will make a geometry request any time changes in its
children cause the drawing area to have a new optimum size.

-----------------------------------------------------------------------
Benjamin Ellsworth      | ben@cv.hp.com                | INTERNET
Hewlett-Packard Company | {backbone}!hplabs!hp-pcd!ben | UUCP
1000 N.E. Circle        | (USA) (503) 750-4980         | FAX
Corvallis, OR 97330     | (USA) (503) 757-2000         | VOICE
-----------------------------------------------------------------------
                     All relevant disclaimers apply.
-----------------------------------------------------------------------