Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!caen!sol.ctr.columbia.edu!emory!att!bellcore!jello!aw From: aw@jello.bae.bellcore.com (Andrew Wason) Newsgroups: comp.windows.x Subject: Re: Querying the resource database for a child's "requested" resources? Message-ID: <1991Apr13.045455.13893@bellcore.bellcore.com> Date: 13 Apr 91 04:54:55 GMT References: Sender: usenet@bellcore.bellcore.com (Poster of News) Reply-To: aw@bae.bellcore.com Organization: Bell Communications Research Lines: 83 In article , gnb@bby.oz.au (Gregory N. Bond) writes: > Consider a subclass of a constraint widget that has three children > that are created in the parent widget initialize routine. The three > children are all the same class, but for one of them I want a > different default value for a constraint resource. (i.e. I want > children 1 and 2 to have "dislpayed: true" and child three to have > "displayed: false" as the default, where displayed is a constraint > resource). > > I also want the resource database to be able to override the default, > as you would expect. > > The default value for the displayed resource is true, so I don't need > anr args to the create call and children 1 and 2 work as expected - > they are normally displayed but the user can turn them off. How can I > specify the different default constraint resource for the third child? > If I specify it as an arg to the XtCreateManagedWidget() call, it > overrides the resource database and the user cannot change the > setting. I think you can do this by using XtGetSubresources for the display resource on widget three. Create a struct to hold the value of the XtNdisplay resource. Create a new XtResourceList with one entry for your XtNdisplay resource, but with default_addr set to False (instead of the normal default of True). (assume widgets 1,2,3 are of class "Display", class pointer displayWidgetClass). typedef struct { Boolean display; } ThreeDisplayStruct; ThreeDisplayStruct threeDisplay; XtResource displayResource[] = { { XtNdisplay, XtCDisplay, XtRBoolean, sizeof(Boolean), XtOffsetOf(ThreeDisplayStruct, display), XtRImmediate, (XtPointer)False } }; Now call XtGetSubresources to fetch this resource for your widget (parent is the constraint parent). XtGetSubresources(parent, (caddr_t)&threeDisplay, "three", "Display", displayResource, XtNumber(displayResource), NULL, 0); Now create your widget using the XtNdisplay resource you just fetched. three = XtVaCreateManagedWidget("three", displayWidgetClass, parent, XtNdisplay, threeDisplay.display, NULL); This would be even simpler if XtNdisplay wasn't a constraint resource (call it XtNnewDisplay), you could create the widget first and then refetch the XtNnewDisplay resource directly into the widget instance record. three = XtCreateManagedWidget("three", displayWidgetClass, parent, NULL, 0); XtGetSubresources(three, (caddr_t)&three, NULL, NULL, &resources[5], 1, NULL, 0); Where resources[5] is the entry for XtNnewDisplay in widget threes resource list (don't try this for callback resources though). I haven't actually tried any of this, but I think it will work. Let me know if you try it. Andrew _______________________________________________________________________________ Andrew Wason Bell Communications Research aw@bae.bellcore.com Piscataway, NJ bellcore!bae!aw