diaz@venice.SEDD.TRW.COM (Phillip Diaz) (05/10/91)
Wcl users, A question to you Wcl users. I would like to read multiple resource files while in one application loop. Considering my first run through the code would look like this: ____________________________________________________________ /* -- Initialize Toolkit creating the application shell */ topShell = XtInitialize (appName, appClass, /* app name and class */ NULL, 0, /* description of cmd line options */ &argc, argv); app_context = XtWidgetToApplicationContext (topShell); /* -- Register all application specific callbacks and widget classes */ RegisterApplicationCallbacks (app_context); /* -- Register all Motif classes and constructors */ XmpRegisterAll ( app_context ); /* -- Create widget tree below toplevel shell using Xrm database */ WcWidgetCreation (topShell); /* -- Realize the widget tree and enter the main application loop */ XtRealizeWidget (topShell); /* -- Enter my own main application loop */ Main_Loop_ACT (display, app_context); ______________________________________________________________________ How do I go about reading in other resource file while the current display is up at running? I've tried this, but maybe I'm just grasping at potential problems, any help? ______________________________________________________________________ /* -- Create the Application Shell */ appShell = XtAppCreateShell(appName, appClass, applicationShellWidgetClass, display, NULL, 0); resfile = (char *) malloc (strlen(window_file) + 1); strcpy (resfile, window_file); WcLoadResourceFileCB (appShell, resfile, NULL); /* -- Create widget tree below toplevel shell using Xrm database */ WcWidgetCreation (appShell); /* -- Realize the widget tree and enter the main application loop */ XtRealizeWidget (appShell); ________________________________ I'm getting the following error: ________________________________ Warning; WcWidgetCreation (xxxxxx) - Failed Problem: No children defined in Xrm database. Possible: resource file not found (XENIRONEMENT not set?), Possible: top level widget in resource file not name xxxxxx Error: Shell widget xxxxxx has zero width and/or height ___________________________________________________ What do I need to include in the callback source ? Let's assume I want a new window when I click on a pushbutton. How about this? ____________________________________________________ /* -- open display, build Xrdb, add to app context */ dpy = XtOpenDisplay(app, clean, appName, appClass, NULL, 0, &largc, largv ); THANKS FOR ANY HELP*$&(@#&$(@$^ Phil Diaz P.S. Waiting impatiently
marbru@auto-trol.com (Martin Brunecky) (05/10/91)
In article <1086@venice.SEDD.TRW.COM> diaz@venice.sedd.trw.com (Phillip Diaz) writes: >A question to you Wcl users. I would like to read multiple >resource files while in one application loop. Considering my >first run through the code would look like this: .... >______________________________________________________________________ > >How do I go about reading in other resource file while the current >display is up at running? I've tried this, but maybe I'm just grasping >at potential problems, any help? >______________________________________________________________________ > > appShell = XtAppCreateShell(appName, appClass, > applicationShellWidgetClass, > display, > NULL, 0); > > resfile = (char *) malloc (strlen(window_file) + 1); > strcpy (resfile, window_file); > WcLoadResourceFileCB (appShell, resfile, NULL); > > /* -- Create widget tree below toplevel shell using Xrm database */ > WcWidgetCreation (appShell); Sounds like your "window_file" does not use the proper shell widget name, i.e. if appName here is "foo", the file must define "foo.wcChildren: ...". Also, if you don't want to get confused by the resources from the previous/initial "loop", you may consider the following: After the app initialization, make a copy of the Xrm databse containing all the resources gained through the Xt search pattern. In each loop, destroy the current dpy->dp and replace it with a copy of the "initial one", then load the new resource file(s). This will prevent your Xrm databse from growing (it won't grow if you constantly overwrite the same resources, but is this the case?). The Wcl code can be used as a guide ... -- =*= Opinions presented here are solely of my own and not those of Auto-trol =*= Martin Brunecky marbru%auto-trol@sunpeaks.central.sun.com (303) 252-2499 (better avoid: marbru@auto-trol.COM ) Auto-trol Technology Corp. 12500 North Washington St., Denver, CO 80241-2404
randy@erik.UUCP (Randy Brown) (05/11/91)
> From: uunet!venice.sedd.trw.com!diaz (Phillip Diaz) > appShell = XtAppCreateShell(appName, appClass, > applicationShellWidgetClass, > display, > NULL, 0); > Warning; WcWidgetCreation (xxxxxx) - Failed > Problem: No children defined in Xrm database. > Possible: resource file not found (XENIRONEMENT not set?), > Possible: top level widget in resource file not name xxxxxx > > Error: Shell widget xxxxxx has zero width and/or height This may be too simplistic (since I've never tried to do this, I don't know all the possible errors that can occur), but it's sufficient-- your XtAppCreateShell creates a new root for a widget hierarchy, the appShell widget. Its name is *appName. Suppose that *appName is "newTop". Do you have a line in your new resource file like newTop.wcChildren: larry, moe, joe because if you don't, wcl will not be able to get the subresources of the shell widget to know what children to create. (In theory I think you can use *appClass as well, but I'm not positive.) Even if you think the line's there, check again. The worst problem with the resource database is that there is little error checking; two of us once spent a long time looking for various problems which turned out to be caused by wcChildern in place of wcChildren.