drapeau@jessica.Stanford.EDU (George D. Drapeau) (02/25/90)
I have a question about the behavior of the Viewport widget in the R4 Athena Widget Set. I've included a sample program that should illustrate my problem, but let try to explain in English first. The problem is that if I create a Viewport widget using XtCreateManagedWidget (assuming that the Viewport's parent has already been realized), then I get the following error: Error: Widget clip has zero width and/or height If you look at the following code, though, I had already specified both a width and height for the Viewport, but it doesn't seem to take unless the Viewport has a child before it's realized. In other words, if I were just to make a Viewport then call "XtRealizeWidget", I'll get the error. But if I make a Viewport then insert a child into the Viewport, *then* call "XtRealizeWidget", things will work fine. I can't find anything in the "Athena Widget Set - C Language Interface" doc that mentions anything about this constraint. So is this a problem with the Viewport, or did I miss something in the documentation that says a Viewport will only have dimensions if a child is inserted? One more thing about the sample program: if you move the call to "XtRealizeWidget" after "myList" is created, the program should run just fine. As the program is included here, the program should produce the error I described. Help and/or clarification would be much appreciated. Working around this is fine, but I want to get the conceptual model correct (and see where I failed to read). Thanks in advance, George Here's the sample program to illustrate my problem: ------------- cut here ------------- #include <X11/Intrinsic.h> #include <X11/StringDefs.h> #include <X11/Xaw/Viewport.h> #include <X11/Xaw/List.h> #define HELPSIZE 2 char *listStrings[HELPSIZE] = { "First List Item", "Second List Item" }; void main(argc,argv) int argc; char **argv; { Widget topLevelShell,myList,myViewport; static Arg listArgs[] = { {XtNlist,(XtArgVal)listStrings}, {XtNnumberStrings,(XtArgVal)HELPSIZE}, {XtNverticalList,(XtArgVal)True} }; static Arg viewportArgs[] = { {XtNwidth,300}, {XtNheight,400}, {XtNallowVert,(XtArgVal)True} }; topLevelShell = XtInitialize("widgetTest","TestApp",NULL,0,&argc,argv); myViewport = XtCreateManagedWidget("myViewport", viewportWidgetClass, topLevelShell, viewportArgs,XtNumber(viewportArgs)); XtRealizeWidget(topLevelShell); myList = XtCreateManagedWidget("myList", listWidgetClass, myViewport, listArgs,XtNumber(listArgs)); XtMainLoop(); } ______________________________________________________________________________ George D. Drapeau Internet: drapeau@jessica.stanford.edu Academic Information Resources Stanford University
kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (03/01/90)
> The problem is that if I create a Viewport widget using > XtCreateManagedWidget (assuming that the Viewport's parent has already > been realized), then I get the following error: > Error: Widget clip has zero width and/or height The current Athena Viewport does not allow you to realize it when it has no managed children. This is a bug. I don't have fix yet, however. Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213