🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.interviews
Article #1454

Re: Interactor::GetAttribute() and .Xdefaults

#1454
From: Glenn P. Parker
Date: Tue, 11 Jun 1991 16:32
64 lines
2725 bytes
In article <JEFF.91Jun11074934@dude.meaddata.com> 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
Technical Details
Message-ID: <GLENN.91Jun11123203@huxley.huxley.bitstream.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!huxley!glenn
References: <JEFF.91Jun11074934@dude.meaddata.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <GLENN.91Jun11123203@huxley.huxley.bitstream.com>
Date: 11 Jun 91 16:32:03 GMT
References: <JEFF.91Jun11074934@dude.meaddata.com>
Sender: glenn@huxley.UUCP
Reply-To: <glenn@bitstream.com> (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