Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!sun-barr!decwrl!shelby!portia!drapeau@jessica.Stanford.EDU From: drapeau@jessica.Stanford.EDU (George D. Drapeau) Newsgroups: comp.windows.x Subject: Question about Xaw Viewport widget Keywords: (long), width, height, clip widget Message-ID: <9518@portia.Stanford.EDU> Date: 25 Feb 90 00:07:10 GMT Sender: USENET News System Reply-To: drapeau@jessica.Stanford.EDU (George D. Drapeau) Organization: Stanford University Lines: 89 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 #include #include #include #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