spanki@color.ced.berkeley.edu (Frank Goodman) (02/13/90)
I have a widget of my own, that is a child of a viewport widget. My widget is essentially a raster editor. When the application starts up, the child widget defaults to 400x400. When I load an image, I resize my editor to the size of the image. I want to set my widget's size to be exactly the size of the image. Since this is happening inside my widgets .c file (ie. not in the application code), I'm unmanaging my widget, resizing it (XtMakeResizeRequest), and then managing it again. This way, I always get XtGeometryYes. However, occassionally my program wil dump core, and a trace shows it is dying in XawScrollbarSetThumb. It just occured to me, that this is probably a function of the asynchronous model of X, and the viewport (parent to my widget) is setting it's thumb while my child is unmanaged (the event hasn't gotten processed yet). Is this a logical explanation for my problem? I don't make any calls to a scrollbar widget anywhere in my code. The scrollbars of the viewport are all handled internally by the viewport. What is the "correct" way to set the size of a widget from within a widget's code? The widget needs to resize every time it loads a new image. However, I want it to size itself to the exact size of the image. When I was using XtResizeWidget, the the viewport(parent) wasn't doing the right thing (ie. adding or subtracting the scrollbars, as appropriate). When I use XtMakeGeometryRequest, then I have to unmanage, then manage my widget to be assured of the right geometry, thereby causing the above mentioned problem. Any pointers? Frank. --------------------------------------------------------------------------- Frank Goodman arpa: spanki@CED.Berkeley.EDU University of California, Berkeley or: spanki%CED@jade.Berkeley.EDU College of Environmental Design uucp: ...hplabs!ucbvax!ced!spanki S.I.S Research Laboratory phone: Novelty item, not necessary ---------------------------------------------------------------------------
kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (02/14/90)
> I'm unmanaging my widget, resizing it (XtMakeResizeRequest), > and then managing it again. I think the problem is that the Viewport doesn't like to be realized when it has no managed child. I consider this a bug in that widget, but until it is fixed you may have to work around it. > What is the "correct" way to set the size of a widget from within a widget's > code? XtMakeGeometryRequest should be the only interface used by widget writers to ASK their parent to change their size. Remember that this is a request. It is perfectly acceptable for the parent to say no, or almost. If you as an application writer don't like the results then you have to use a different parent for this widget. The parent always has the final say about widget geometry. > The widget needs to resize every time it loads a new image. However, > I want it to size itself to the exact size of the image. You can never count on this happening, since the user can always resize your application to be real small. You just have to do the best you can. > When I was using > XtResizeWidget, the the viewport(parent) wasn't doing the right thing > (ie. adding or subtracting the scrollbars, as appropriate). Don't do that. > When I use > XtMakeGeometryRequest, then I have to unmanage, then manage my widget to be > assured of the right geometry, thereby causing the above mentioned problem. Why? Do you get a XtGeometryNo? If this is the case then you just have to deal with it, remember that the parent has the final say. Or perhaps you want the Viewport to grow to the new size, even though scrollbars are active. This behavior is not supported by the Viewport, perhaps you need to create your own widget that supports the behavior that you desire. Why not just let the user resize the widow if he/she wants it to be bigger? I'm confusing myself, I'd better quit while I'm ahead. Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213