ricks@shambhala.Berkeley.EDU (Rick L Spickelmier) (11/24/88)
Can a composite widget manage children that were not created
at the time the composite widget was realized?
Here are 2 senarios:
1.
- create a box widget
- create two buttons in the box (unmanaged)
- manage one of the buttons (button0)
- in the call back routine for button0, unmanage button0
and manage button1
2.
- create a box widget
- create one button in the box (unmanaged)
- manage button0
- in the call back routine for button0, unmanage button0,
and create and manage button1.
Senario 1 works as expected, senario 2 gives an XError in
'XtManageChild' (trying to Map a window with an invalid ID).
Below is an example of this (senario 2, senario 1 can
be realized by moving the button1 creation from the call back
routine to the main routine).
Rick Spickelmier
UC Berkeley
ricks@berkeley.edu
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Command.h>
#include <X11/Box.h>
Widget topLevel;
Widget ModeButtonBox;
Widget Buttons[2];
static void
bob(w, c1, c2)
Widget w;
caddr_t c1, c2;
{
static Arg args1[] = {
{XtNlabel, (XtArgVal) "button 1"},
};
XtUnmanageChild(Buttons[0]);
Buttons[1] = XtCreateWidget("command", commandWidgetClass,
ModeButtonBox,
args1, XtNumber(args1));
XtManageChild(Buttons[1]);
}
main(argc, argv)
int argc;
char **argv;
{
static Arg frameArgs[] = {
{XtNx, (XtArgVal) 100},
{XtNy, (XtArgVal) 100},
};
static Arg boxArgs[] = {
{XtNallowResize, (XtArgVal) False},
};
static XtCallbackRec callbacks[] = {
{bob, NULL},
{NULL, NULL}
};
static Arg args0[] = {
{XtNlabel, (XtArgVal) "button 0"},
{XtNcallback, (XtArgVal) callbacks},
};
topLevel = XtInitialize("main", "test", 0, 0, &argc, argv);
ModeButtonBox = XtCreateManagedWidget("box", boxWidgetClass, topLevel,
boxArgs, XtNumber(boxArgs));
Buttons[0] = XtCreateWidget("command", commandWidgetClass,
ModeButtonBox,
args0, XtNumber(args0));
XtManageChild(Buttons[0]);
XtRealizeWidget(topLevel);
XtMainLoop();
exit(0);
}