[comp.windows.x] How do I tell parent widget to resize after explicit child resize?

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

Using Motif I have a drawingArea widget that is a child of a selectionBox
widget. In my application I want to explicitly change the size of the
drawingArea widget and then have the selectionBox widget resize itself to
accomadate the new size of the drawingArea widget. I realize that there is
no guarentee that the parent widget will allow a resize on one of its
children but is there a way to make this happen most of the time. This is
all happening after managing and realizing the widgets. I have tried calling
XtResizeWidget on the drawingArea widget and its size appears to have
changed. Now all I need is something like Remanage to call on the
selectionBox widget.

Mike Burbidge
mike@bach.cs.byu.edu

kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (06/15/90)

> Using Motif I have a drawingArea widget that is a child of a selectionBox
> widget.  In my application I want to explicitly change the size of the
> drawingArea widget and then have the selectionBox widget resize itself to
> accomadate the new size of the drawingArea widget. I realize that there is
> no guarentee that the parent widget will allow a resize on one of its
> children but is there a way to make this happen most of the time. This is
> all happening after managing and realizing the widgets. I have tried calling
> XtResizeWidget on the drawingArea widget and its size appears to have
> changed. Now all I need is something like Remanage to call on the
> selectionBox widget.

This is one of the reasons that the drawing area widget is a bad idea.  People
use it instead of subclassing a new widget.  A new widget would know what size
it wanted to be, and could make an XtMakeResizeRequest() call to its parent.  It
would then be informed of what actually happened, and could properly deal with
the results.  When an application programmer tries to do this without the
facilites that Xt Provide for geometry management to widget writers, they
usually end of losing.  

The proper solution to this problem is to create a new widget, and then when
your "drawing" changes to a new size, make a resize request of your parent to
see if it will allow you to be big enought to contain the new drawing.  

No application should ever call XtResizeWidget, and no widget should ever call
XtResizeWidget on itself.  XtResize widget is only to be used by parent widgets
to change the size of their managed children.

The ONLY accepted method for application to ask a widget to change its size is
to make an XtSetValues() call on the XtNheight and XtNwidth resources.  The only
way to see if this has succeeded is to make a GetValues query to see if the
results have change to the new values or not.


						Chris D. Peterson     
						MIT X Consortium 

Net:	 kit@expo.lcs.mit.edu
Phone:   (617) 253 - 9608	
Address: MIT - Room NE43-213

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

XtResizeWidget called from the application is almost always a bad
thing.  Only the widget hears about the resize; the parent is NOT
notified.

You should be using SetValues of width and height.

---

Ben