tan@ektools.UUCP (Thomas A. Napoli) (11/13/89)
I am writing my first application using the Athena widgets X11R2; actually, its my first toolkit application under X. Hopefully, someone can tell me (or provide an example) how to use the TextWidget. I am using an asciiStringTextWidget and want to change the string when the user asks for new information. Changing XtNstring results in a X Toolkit error, because this feature is not supported. I thought that I might need to create a TextWidget instead, by supplying both the source and sink myself. Then, I could change the source, as needed. Unfortunately, the documentation is a bit sparse in this area. Any suggestions on how to create both sources and sinks or where I can find additional documentation on the Athena Widgets would be appreciated. Tom Napoli tan@aviary.kodak.com (or ...!rochester!kodak!aviary!tan)
kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (11/14/89)
> I am using an asciiStringTextWidget (sic) and want to change the string > when the user asks for new information. Changing XtNstring results in a > X Toolkit error, because this feature is not supported. The easiest way is the make sure you have an "editable" test string and use XtTextReplace() to just replace the entire string. Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213
xg00@GTE.COM (Xev Gittler) (02/17/90)
I have a text widget that I am trying to place text into. The text in question is a long line, and I would like to be able to insert it and have it wrap, as opposed to running off the edge of the widget. I have the text widget defined as follows: n = 0; XtSetArg (args[n], XtNfromVert, TitleDisplay); n++; XtSetArg (args[n], XtNeditType, XawtextEdit); n++; XtSetArg (args[n], XtNscrollVertical, XawtextScrollAlways); n++; XtSetArg (args[n], XtNwrap, XawtextWrapWord); n++; XtSetArg (args[n], XtNautoFill, True); n++; XtSetArg (args[n], XtNtype, XawAsciiString); n++; XtSetArg (args[n], XtNresize, XawtextResizeWidth); n++; XtSetArg (args[n], XtNstring, ""); n++; TextDisplay = XtCreateManagedWidget ("TextDisplay", asciiTextWidgetClass, ProjectForm, args, n); and I am adding the text with: n = 0; XtSetArg (args[n], XtNstring, ProjectText[List->list_index]); n++; XtSetValues (TextDisplay, args, n); though I also tried XawTextReplace, and that didn't work any better. Any pointers on how I could do this? -- Xev Gittler xev@gte.com
kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (02/22/90)
> I have a text widget that I am trying to place text into. The text in > question is a long line, and I would like to be able to insert it and > have it wrap, as opposed to running off the edge of the widget. It works like a champ for me. If you send me a short example program I will see what I can do. Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213
kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (02/23/90)
[ I am cc'ing this to xpert, because it may be of general interest. ] >> Xev > me me > > I have a text widget that I am trying to place text into. The text in > > question is a long line, and I would like to be able to insert it and > > have it wrap, as opposed to running off the edge of the widget. > It works like a champ for me. If you send me a short example > program I will see what I can do. > There are some interesting problems here. But there is nothing that is a show-stopper. The first is that word wrap does not get activated if you have XawtextResizeWidth set. This actually makes sense because if you are always resizing to a new width then you should never need to wrap. Of course, there are times when the resize request will be denied, and then you would like to wrap, unfortunatly the current code does not do the right thing in this case. The moral of the story is that you do no want to use a wrap wrap mode that is other than never with resize width, since the wrapping will never get invoked. The second problem is that the Text widget does not attempt a resize width when the text is changed with SetValues, or XtTextReplace(). This bug is known, but has not been fixed. If you click with one of the pointer buttons in the text widget after the new string has been added the text widget will then resize itself. The Xmh dialog boxes show the same bug. I hope this gives you enough information to work around your problems. I have include some example code fragments to help you understand how the words above would translate into your source code. Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213 ---------------------------------------------------------------- ProjectForm = XtCreateManagedWidget "form", formWidgetClass, parent, NULL, ZERO); n = 0; . . . #ifdef USE_WORD_WRAP XtSetArg (args[n], XtNwrap, XawtextWrapWord); n++; #else XtSetArg (args[n], XtNresize, XawtextResizeWidth); n++; XtSetArg (args[n], XtNresizable, TRUE); n++ /* a form constraint resource. */ #endif . . . TextDisplay = XtCreateManagedWidget ("TextDisplay", asciiTextWidgetClass, ProjectForm, args, n);