Path: utzoo!attcan!uunet!husc6!bloom-beacon!CS.WISC.EDU!hagens From: hagens@CS.WISC.EDU Newsgroups: comp.windows.x Subject: simple widget question Message-ID: <8812122212.AA15668@janeb.cs.wisc.edu> Date: 12 Dec 88 22:12:27 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 93 I want to duplicate something that Xmh does: create a Viewport widget, create a Box widget inside the Viewport, and then create Command widgets inside the Box widget. When I run the sample program below, I get a box with 3 buttons in it (if 3 is passed as an argument). When I click on a button, my callback is invoked, but I do not get a scroll bar formed by the viewport. If I manually resize the whole thing, then I do get a scroll bar. However, if I then add more buttons, the scroll bar does not change accordingly and I can not access the new command buttons. Any help would be appreciated. Please excuse the sloppyness of the example. Environment: X11R2 on IBM PC/RT, AOS Release 2, AED, APC card ps. my example is based upon xboxes.c in the examples directory ================ cut here to see sloppy example ============================= #ifndef lint static char rcsid[] = "$Header: xboxes.c,v 1.12 88/02/14 15:08:38 rws Exp $"; #endif lint #include #include #include #include #include #include #include #include static Widget toplevel; Widget viewp; Widget viewp_inner; void poof(widget,closure,callData) Widget widget; caddr_t closure; caddr_t callData; { Widget w; (void) fprintf(stderr,"poof callback\n"); w = XtCreateManagedWidget("NEW", commandWidgetClass, viewp_inner, NULL, (Cardinal)0); XtRealizeWidget(w); } void main(argc, argv) unsigned int argc; char **argv; { static Arg viewArgs[] = { {XtNheight, 400}, {XtNwidth, 80}, {XtNallowVert, True}, }; static Arg boxArgs[] = { {XtNheight, 400}, {XtNwidth, 80}, }; static XtCallbackRec callbacks[] = { {poof, NULL}, {NULL, NULL}, }; static Arg butArgs[] = { {XtNcallback, (XtArgVal)callbacks}, }; int i; Widget xyzzy; toplevel = XtInitialize( NULL, "Xb", NULL, 0, &argc, argv); viewp = XtCreateManagedWidget(NULL, viewportWidgetClass, toplevel, viewArgs, XtNumber(viewArgs)); viewp_inner = XtCreateManagedWidget(NULL, boxWidgetClass, viewp, NULL, (Cardinal)0); for (i=0; i