[comp.windows.x] X Toolkit question/problem

rusty@velveeta.berkeley.edu (03/17/88)

Since, for the time being, popup widgets have to be manually placed
with the mouse (at least when uwm is running) I decided to try using
the same top level widget.  My code looks something like

top = XtInitialize("top", "XTools", ...)
main_form = XtCreateWidget("main", formWidgetClass, top, ...)
quit_button = XtCreateManagedWidget("quit", commandWidgetClass, main_form, ...)

(Notice that main_form is using XtCreateWidget, not XtCreateManagedWidget.)

quit_button has a callback which uses this confirm/cancel dialog box:

confirm_form = XtCreateWidget("confirmForm", formWidgetClass, top, ...)
yes_button = XtCreateManagedWidget("yep", commandWidgetClass, confirm_form, ...)
no_button = XtCreateManagedWidget("nope", commandWidgetClass, confirm_form, ...)

(Here again, notice that confirm_form is using XtCreateWidget, not
XtCreateManagedWidget.)

After the widgets are set up main() does:

XtManageChild(main_form);
XtRealizeWidget(top);

When the quit button is pressed the quit_button callback does:

XtUnmanageChild(main_form);
XtManageChild(confirm_form);

I was hoping that the top level shell would resize itself when the
main_form was "managed out" (XtUnmanageChild) and the confirm_form was
"managed in" (XtManageChild), but it just keeps the size of the first
widget that was managed, which in my case is too small.

Am I doing something wrong or is this a bug or is that just the way
it is?

--------------------------------------
	rusty c. wright
	rusty@cartan.berkeley.edu ucbvax!cartan!rusty

kwh@sei.cmu.edu (Kurt Hoyt) (03/17/88)

In article <7753@agate.BERKELEY.EDU>, rusty@velveeta.berkeley.edu writes:
> top = XtInitialize("top", "XTools", ...)
> main_form = XtCreateWidget("main", formWidgetClass, top, ...)

{stuff deleted}

> confirm_form = XtCreateWidget("confirmForm", formWidgetClass, top, ...)

{stuff deleted}

> When the quit button is pressed the quit_button callback does:
> 
> XtUnmanageChild(main_form);
> XtManageChild(confirm_form);
> 
> I was hoping that the top level shell would resize itself when the

{stuff deleted}

> Am I doing something wrong or is this a bug or is that just the way
> it is?

You are doing something wrong. The top widget must have its
allow_shell_resize attribute set to TRUE (it is FALSE by default). Add this
after your XtInitialize:

	XtSetArg(args[0], XtNallowShellResize, TRUE);
	XtSetValues (toplevel, args, 1);

This will allow the top level widget to resize itself when necessary. The
toolkit seems to default all resize attributes to FALSE. I ran into the same
thing with a label on a form -- when I changed the label text, the label did
not resize until I set its resizable attribute (see the Athena Widgets doc,
page 30) to TRUE.