urban@spp2.UUCP (Mike Urban) (10/12/88)
The following short toolkit program attempts to put a shallow viewport in a form. It does not work properly in this form; the viewport is sized to the same size as the Box widget that it contains. If the CreateManagedWidget call for the box widget is changed to a CreateWidget, and if ManageChild(box) is performed after RealizeWidget, the behavior is what one would expect. Is this behavior a bug or a feature? Is there some way to get the viewport to maintain its specified size without doing any work after RealizeWidget? Thanks. Mike Urban ...!trwrb!trwspp!spp2!urban "You're in a maze of twisty UUCP connections, all alike" #include <stdio.h> #include <X11/Xatom.h> #include <X11/Intrinsic.h> #include <X11/Atoms.h> #include <X11/Box.h> #include <X11/Label.h> #include <X11/Viewport.h> #include <X11/Form.h> main (argc, argv) char **argv; { Widget topshell, label, form, viewport, box; Arg arg[10]; int n; topshell = XtInitialize (NULL, "XTest", NULL, 0, &argc, argv); form = XtCreateManagedWidget ("form", formWidgetClass, topshell, NULL, 0); label = XtCreateManagedWidget ("Scrolled? :", labelWidgetClass, form, NULL, 0); n = 0; XtSetArg (arg[n], XtNfromHoriz, label); n++; XtSetArg (arg[n], XtNhorizDistance, 10); n++; XtSetArg (arg[n], XtNheight, 30); n++; XtSetArg (arg[n], XtNwidth, 200); n++; XtSetArg (arg[n], XtNresizable, False); n++; XtSetArg (arg[n], XtNallowVert, True); n++; viewport = XtCreateManagedWidget ("view", viewportWidgetClass, form, arg, n); /* This call must be changed to XtCreateWidget */ box = XtCreateManagedWidget ("box", boxWidgetClass, viewport, NULL, 0); XtSetArg (arg[0], XtNheight, 12); XtSetArg (arg[1], XtNwidth, 200); for (n = 0; n < 10; n++) { char label[10]; sprintf (label, "Label %d", n); (void) XtCreateManagedWidget (label, labelWidgetClass, box, arg, 2); } XtRealizeWidget (topshell); /* XtManageChild(box) is needed here for proper operation */ XtMainLoop(); } Mike Urban ...!trwrb!trwspp!spp2!urban "You're in a maze of twisty UUCP connections, all alike"
swick@ATHENA.MIT.EDU (Ralph R. Swick) (10/14/88)
> the viewport is sized to the same size as the Box widget that > it contains. In R2, before it is realized, Xaw/Viewport always assumes the dimensions of it's child regardless of any width and height resource the Viewport may have been assigned. In R3, it will respect it's own width and height resource if they are non-zero before it is realized.