[comp.windows.x] widget resizing problem

kquick@dcs.simpact.com (Kevin Quick, Simpact Assoc., Inc.) (06/19/91)

I am writing an widget which displays various things in its primary window.
The selection of what's displayed is controlled by a popup menu from mouse
button 3.  The problem is when I'm trying to resize the widget's window to
accomodate the user's requested information.  The following code excerpts
show the basic operation of my code:

update_rtn(widget)
{
  (calculate the preferred height and width of the window to hold the
   selected information)
  result = XtMakeResizeRequest( XtParent(widget), preferred.., allowed.. );
  if( result == XtGeometryAlmost)
      XtMakeResizeRequest( XtParent(widget), allowed.., NULL, NULL );
  XtResizeWidget( widget, allowed.. )
}

Initialize(...)		<-- widget initialize callback
{
  ...
  update_rtn(w);
  ...
}

SetValues(...)		<-- widget set values callback
{
  ...
  update_rtn(w);
  ...
}

Btn3_callback(...)	<-- button 3 menu selection callback
{
  XtSetValues(w, ...);
}

The callback is correctly invoked and performs an XtSetValues request to
change booleans specifying whether certain things are to be displayed or
not.  The SetValues widget routine, like the widget's Initialize routine,
calls update_rtn to recalculate the desired window size based on the new
display.  The update_rtn first makes a geometry request to the widget's
parent to change the window size, then attempts to change its own size to
match the window.

This is where the confusion starts.  According to the XtSetValues routine
description, it "determines if a geometry request is needed by comparing
by comparing the current widget to the new widget. ... calls the widget's
resize procedure."

According to this, instead of using XtResizeWidget above, I should just
set the core.height and core.width values of the widget to my desired
values and the XtSetValues routine will detect this and effect a resize.
This does not work.

I have had more success invoking the resize myself with the XtResizeWidget
routine shown, but (a) I shouldn't have to do this according to the above,
and (b) this also does not work if the user changes the display and then
returns to the original display; update_rtn always reports that the initial
core.height and core.width of the widget are the same as they were on startup;
if the user returns to the startup display, XtResizeWidget thinks that nothing
has changed and returns immediately without calling the widget's resize rtn.

On further investigation, I find that, on exiting the update_rtn the core
height and width values I've set via the XtResizeWidget request are being
used, but on entry to the SetValues routine, all THREE widgets (current,
request, and new) have the widgets ORIGINAL height and width, regardless of
the last setting.  This seems like a bug to me.

I have not been able to determine my error, and would appreciate any help
that could be given in this respect.  Please email me directly and I will
post a summary to the net.  Thanks in advance!

--
	-- Kevin Quick,  Simpact Associates, Inc.,  San Diego, CA.
	   UUCP: kquick@simpact.com  (or simpact!kquick@crash.cts.com)