nazgul@alphalpha.com (Kee Hinckley) (07/18/90)
Let's get serious here. I cannot believe that there is not someone out there who knows the answer to this question - or at least knows that there isn't an answer to this question. I mean, I'm pretty certain that at least one of the people reading this message implemented this stuff! I'm using Motif, 1.0A. I'll be using 1.1 as soon as it's released, so answers involving that are fine. I'd also be happy to take any other widget that I can incorporate into Motif and use that in the solution. I'll also take a solution that requires subclassing existing widgets. For curiousity's sake I'll even take XView solutions. There are two minor variations on the problem. They may require separate solutions. Case 1: I have an XmScrolledWindow. It needs to contain a single column of N readonly XmText widgets, each of which has data inserted in it by the program. There are two possible configurations, I'll take either, although both would be nice. a. They are XmScrolledText widgets, and they are contained in an XmPanedWindow so that the user can resize them. b. In the other they are just straight XmText, and they are always as big as the text they contain. I would like the following conditions to be true. o The text widgets are always at least as wide and tall as the viewport of the scrolled window. o The scrollbars (on either the scrolled window or the individual widgets) don't show up unless they are needed. Case 2: Same as Case 1, save that the text widgets are not readonly and start out with or without initial data. I would like the following conditions to be true. o The conditions above AND o So long as the user can type in a text region without going off the edge of the ScrolledWindow, the Text area they are in grows. When they hit the edge, it sprouts scrollbars OR the ScrolledWindow scrolls. Minor note. I have limited this to Text widgets, however I actually have other widgets in the region as well (graphics displays, etc..) So, what are the problems? One issue is that XmText widgets don't seem to pay a lot of attention to the size you give to them if you give it at runtime. If you tell them at create time things usually work okay, but if I, for instance, tell them a new size and then give them some text, all bets are off. And the problem above requires that the sizing be dynamic. When I create the widgets I don't know the size of the text I'm putting in them. This raises an interesting question though. Why on earth do I have to tell the text widget how big to make itself when I'm putting text in it? Shouldn't notice the size of the text and do something about it? Here is what I've tried: o ScrolledWindow -> PanedWindow -> Text Text widgets come out around 1 line by 40 columns. I can grow the top ones some (until I hit the bottom). I can't grow the bottom one at all, and in any case, the some total size is way too small. o ScrolledWindow -> RowColumn -> Text If I tell the Text widget how big to make the text, this usually works to some extent. However I can't ensure that the size always fits the viewport, and it doesn't meet the conditions for Case 2. o ScrolledExpWindow -> RowColumn -> Text ScrolledExpWindow is a subclass I made of ScrolledWindow. It attempts (not completely correctly, unfortunately) to force the child to be the size of the viewport. In this particular case it fails miserably since RowColumn things that XtGeometryAlmost is the same as XtGeometryNo. I have also tried using the Table widget and XmForm. I have tried all of these with Scrolled and unScrolled Text widgets. By now I've forgotten all the variations, but none of them seemed to work correctly in all cases. The best luck I've had is with using a RowColumn and nonscrolling Text. That works okay for the readonly case, modulo that I have to calculate the text size (which I can't do very well, since "XmNcolumns" sets it in "M"s, which is usually too large) and it doesn't always fill the viewport. However it does not meet the conditions for editable text, and nothing I have tried yet works for that at all. So. What's your solution? -kee Alphalpha Software, Inc. | motif-request@alphalpha.com nazgul@alphalpha.com |----------------------------------- 617/646-7703 (voice/fax) | Proline BBS: 617/641-3722 I'm not sure which upsets me more; that people are so unwilling to accept responsibility for their own actions, or that they are so eager to regulate everyone else's. -------