ssroy@phoenix.Princeton.EDU (Steve Scot Roy) (01/25/89)
I have another novice type question. I was trying to create two semi-independent widgets in the same application and I did what seemed to be the obvious thing -- I created two widgets under toplevel, one of type compositeWidgetClass and the other asciiStringWidgetClass -- and it didn't work. Every time the one which I declare first is the only one to appear, and it performs entirely as expected. Also, it is ignoring the XtNx and XtNy fields in the ArgLists. I know I can get these two windows as subwindows of a VPaned or some such, but I was hoping the have them independent. Do I need to do something special to do that? Thanks in advance. Here is the main of the routine if it helps. void main(argc, argv) unsigned int argc; char **argv; { Widget toplevel; static Arg typingArgList[] = { {XtNstring, (XtArgVal) default_value}, {XtNeditType, (XtArgVal) XttextEdit}, {XtNtextOptions, 0}, {XtNx, (XtArgVal)100}, {XtNy, (XtArgVal)200}, {XtNwidth, (XtArgVal)50}, {XtNheight, (XtArgVal)100}, }; static Arg drawingArgList[] = { {XtNx, (XtArgVal)100}, {XtNy, (XtArgVal)200}, {XtNwidth, (XtArgVal)50}, {XtNheight, (XtArgVal)100}, }; toplevel = XtInitialize("textTest", "Demo", table, XtNumber(table), &argc, argv); XtGetApplicationResources(toplevel, &app_resources, resources,XtNumber(resources), NULL, 0); /* set up the drawing widget. */ Drawing = XtCreateManagedWidget("drawing",compositeWidgetClass,toplevel, drawingArgList,XtNumber(drawingArgList)); /* Set up the typing widget. */ typingArgList[0].value = (XtArgVal) default_value; if (app_resources.word_wrap) typingArgList[2].value = wordBreak; Typing = XtCreateManagedWidget("typing",asciiStringWidgetClass,toplevel, typingArgList, XtNumber(typingArgList) ); XtRealizeWidget(toplevel); XtMainLoop(); }
kit@ATHENA.MIT.EDU (Chris D. Peterson) (01/27/89)
> I was trying to create two semi-independent widgets in the same application > and I did what seemed to be the obvious thing -- I created two widgets > under toplevel, one of type compositeWidgetClass and the other > asciiStringWidgetClass -- and it didn't work. All current shell widgets only know how to MANAGE one child. If you give them more than that they get confused and do the wrong thing. It is possible to have many children in a shell widget, but at most one can be managed. This means that the application must handle all other geometry management. This is usually more of a pain than it is worth though, and I suggest that you think twice before doing it, but it is possible. The other possibility is to have only one of your widgets managed at a time, so when you want the text widget visable then you unmanage the other composite widget and manage the text wiget. This assures that the shell widget has only one child to manage, and it knows how to do this. > Also, it is ignoring the XtNx and XtNy fields in the ArgLists. Remember that it is the parent who has the final decision where its children widgets will be placed, so that all parent widgets are allowed to ignore the XtNy and XtNx positions supplied by their children. > Thanks in advance. Your welcome :-) Chris D. Peterson MIT X Consortium / Project Athena Net: kit@athena.mit.edu Phone: (617) 253 - 1326 USMail: MIT - Room E40-321 77 Massachusetts Ave. Cambridge, MA 02139
bw@hpcvlx.HP.COM (Bill Wilhelmi) (01/27/89)
The toplevel shell manages one child widget. The child widget is typically a manager widget. Bill Wilhelmi Hewlett-Packard Company Corvallis, Oregon
diamant@hpfclp.SDE.HP.COM (John Diamant) (01/28/89)
> I know I can get these two windows as subwindows of a VPaned > or some such, but I was hoping the have them independent. > Do I need to do something special to do that? I assume by independent you mean that you want two toplevel windows (two windows that are children of the root window instead of being in the same child of the root window). The way to do that is to call XtCreateApplicationShell to create the second one. It will return a shell widget (just as XtInitialize does). In each, you can place one child widget. This description is based on the R2 toolkit. In R3, you should still be able to use the above, but XtInitialize is no longer the only way to intialize the toolkit and thus there are other variants (of which I'm not familiar as I'm pretty new to R3). John Diamant Software Engineering Systems Division Hewlett-Packard Co. ARPA Internet: diamant@hpfclp.sde.hp.com Fort Collins, CO UUCP: {hplabs,hpfcla}!hpfclp!diamant
RUSOFFMH@CTRVX1.VANDERBILT.EDU (T B A L) (01/31/89)
Would it