stung@iuvax.cs.indiana.edu (07/06/89)
The following is a program that does not display the scroll bar of a text widget properly. When running the program the X Toolkit gives this warning message: No type converter registered for 'String' to 'Orientation' conversion. However, if I use XtDefaultAppContext in stead of creating my own context the program runs properly. Do I miss somthing? Thanks in advance for any help!! Sho-Huan Tung (stung@iuvax.cs.indiana.edu) Department of Computer Science Indiana University ------------------------------------------------------------------ /* Includes for X Toolkits */ #include <stdio.h> #include <X11/Intrinsic.h> #include <X11/AsciiText.h> #include <X11/Text.h> #include <X11/StringDefs.h> #include <X11/Shell.h> #define MAXCHAR 60 /* This number need to be divideable by 2 and 3 */ char text_buf[MAXCHAR] = "> " ; int create_text_widget(w) int w; { int n; Arg Xargs[10]; Widget text_widget1; n = 0 ; XtSetArg(Xargs[n], XtNeditType, (XtArgVal) XttextEdit) ; n++; XtSetArg(Xargs[n], XtNlength, (XtArgVal)MAXCHAR) ; n++; XtSetArg(Xargs[n], XtNstring, text_buf); n++; XtSetArg(Xargs[n], XtNinsertPosition, 2); n++; text_widget1 = XtCreateManagedWidget("", asciiStringWidgetClass, (Widget)w, Xargs, n); n = 0; XtSetArg(Xargs[n], XtNtextOptions, (XtArgVal)scrollVertical) ; n++; printf("before XtSetValue\n"); XtSetValues(text_widget1, Xargs, n); printf("after XtSetValue\n"); return (int)text_widget1; } void main(argc, argv) unsigned int argc; char **argv; { Widget toplevel; XtAppContext SDefaultAppContext; Display *SDefaultDisplay; XEvent event; XtToolkitInitialize(); SDefaultAppContext = XtCreateApplicationContext(); /* * If I change SDefaultAppContext to NULL in the following call, and replace * SDefalutAppContext in XtAppNextEvent with _XtDefaultAppContext(), * then the scroll bar display properly. */ SDefaultDisplay = XtOpenDisplay(SDefaultAppContext, NULL, NULL, "Test1", NULL, 0, &argc, argv); /* need to make sure that SDefaultDisplay is not NULL */ toplevel = XtAppCreateShell(NULL, "Test1", applicationShellWidgetClass, SDefaultDisplay, NULL, 0); create_text_widget(toplevel); XtRealizeWidget(toplevel); for (;;) { XtAppNextEvent(SDefaultAppContext, &event); XtDispatchEvent(&event); } }
dcr0@GTE.COM (David Robbins) (07/06/89)
From article <33500010@iuvax>, by stung@iuvax.cs.indiana.edu: > The following is a program that does not display the scroll bar of a text > widget properly. When running the program the X Toolkit gives this warning > message: > No type converter registered for 'String' to 'Orientation' conversion. > However, if I use XtDefaultAppContext in stead of creating my own context > the program runs properly. > Do I miss somthing? > Thanks in advance for any help!! I've encountered exactly the same problem, and it seems that the only solution is to do as the above poster did: use XtDefaultAppContext. The problem is due to the fact that resource converters exist in a specific application context. When a resource conversion is needed, the Toolkit looks for the required coverter in the application context associated with the widget whose resource value needs conversion. When a new resource converter is registered, it is in one specific application context. BUT ... a number of the Athena widgets register their own resource converters when the class is initialized (i.e. when ClassInitialize or its equivalent is called). These converters are always registered in the default application context (i.e. that returned by _XtDefaultAppContext()), and there is no way visible to my eye that they can be registered in any other context. This is all well and good when your application has but a single application context, and then only if it has implicitly or explicitly used the default context. But -- if your application decides to create its own context, which would seem to be entirely appropriate to a programmer reading the X Toolkit Intrinsics manual, those resource converters registered by the widgets are no longer available to your application, because they are still in the default context, which your application is not using. How do you solve this problem? 1) If your application requires only a single context, make sure that you use the default context, which you can get by calling _XtDefaultAppContext() (which is, of course, intended strictly for internal use by the Toolkit). 2) If your application requires more than one context, you are out of luck unless you care to write the code to copy resource converters from the default context to each of the other contexts. The X Toolkit Intrinsics seem to make absolutely no provision for registering resource conversions in a way that avoids this problem. Clearly, it may actually make sense to have converters available in one context that are not available in another context -- that is presumably why they are associated with the application context rather than being global. But just as clearly, every context that uses a given widget set ought to have available the converters needed by that widget set, and there appears to be absolutely no mechanism by which that result can be achieved. Conclusion: If I understand the situation correctly, it never makes sense for me to define my own application context if I ever expect to use the resource conversions supplied by the Athena widgets, and I can never, ever make use of multiple application contexts in one application. Query: Is my understanding of this problem correct? Or have I missed an essential point that would show that resource converters can in fact be made accessible in all application contexts? Query: Would it not make a terrific amount of sense for application contexts to have a trivial way to share resource converters? Like maybe having something like nested contexts, where a context inherits all the converters defined in its ancestors? -- Dave Robbins GTE Laboratories Incorporated drobbins@gte.com 40 Sylvan Rd. ...!harvard!bunny!drobbins Waltham, MA 02254
kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (07/06/89)
[ stung@iuvax.cs.indiana.edu writes: ] > The following is a program that does not display the scroll bar of a text > widget properly. When running the program the X Toolkit gives this warning > message: You need to apply public patch #9. Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213
J.Crowcroft@ucl-cs.UUCP (07/12/89)
From: Jon Crowcroft <J.Crowcroft@uk.ac.ucl.cs> with respect to the new text widget spec - can it include a callback for text events please? it's useful to be notified of text input for a variety of reasons (none the least is the possibility of having one source with several sinks...handy for multiple views onto some text...) cheers jon