Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!huxley!glenn From: glenn@bitstream.com (Glenn P. Parker) Newsgroups: comp.windows.interviews Subject: Re: Interactor::GetAttribute() and .Xdefaults Message-ID: Date: 11 Jun 91 16:32:03 GMT References: Sender: glenn@huxley.UUCP Reply-To: (Glenn Parker) Distribution: comp Organization: Bitstream, Inc. Lines: 64 In-reply-to: jeff@meaddata.com's message of 11 Jun 91 11:49:34 GMT In article jeff@meaddata.com (Jeff French) writes: > What I can't figure out is how to specify 'helpFile' in my .Xdefaults. > The only thing that has worked so far is: > > *helpFile: file1.hlp This will also work: resource*helpFile: file1.hlp > Unfortunately, different classes will have different help files. I > have tried all of the following, but received nil back from > GetAttribute(): > > resource*base*derived*helpFile: file2.hlp > *base*derived*helpFile: file3.hlp > *derived*helpFile: file4.hlp 1. The GetAttribute function only recognizes the Interactor hierarchy, NOT the class hierarchy, so "base*derived" will not do what you expected (it implies a derived inside a base). 2. The GetAttribute ONLY recognizes the Interactor hierarchy during the Reconfig pass, so you can't use it willy-nilly whenever you want. 3. Outside of the Reconfig pass, GetAttribute still recognizes resources at the "top" level, like the one that worked and the one I suggested. To adapt to these restrictions, you would have to fetch the resource within your Reconfig function and save it for later (make a copy). Then your .Xdefaults file should look like: resource*derived.helpFile: file1.hlp If you can't adapt to these restrictions, you could try this: class derived : public base { public: derived(char *m) : base(m) {SetClassName("derived");} const char *get(); }; const char* derived::get() { const char* classname = GetClassName(); static const char suffix[] = "_helpfile"; char* attrname = new char[strlen(classname) + sizeof(suffix)]; strcpy(attrname, classname); strcat(attrname, suffix); const char* attrvalue = GetAttribute(attrname); delete attrname; return attrvalue; } Then put this in your .Xdefaults: resource*derived_helpfile: file1.hlp Not too pretty, I know. -- Glenn P. Parker glenn@bitstream.com Bitstream, Inc. uunet!huxley!glenn 215 First Street BIX: parker Cambridge, MA 02142-1270