[comp.windows.x] getting a widget's name

dheller@cory.Berkeley.EDU (Dan Heller) (04/15/89)

In article <4249@stiatl.UUCP> meo@stiatl.UUCP (Miles O'Neal) writes:
>In article <4010@ece-csc.UUCP> hwa@ece-csc.UUCP (Russ Cook) writes:
>|  I need to know the name
>| of the widget that called the callback.  How can I do this?

>(String) W->core.name

Isn't the whole point of the intrinsics to be "object oriented" --that is,
you don't access data struct fields directly at all?  This is the whole
purpose of the WidgetP.h (private) private include files.  Assuming this
statement is true, the real answer to the above question is:

    You *don't* get the widget's name because you break the rules of
    the toolkit intrinsics.
(Corollary: your code is not guaranteed to work in future releases.)

The intrinsics utilize a good idea in that you should be able to access
all [necessary] information about the widget (object) in an opaque manner.
That is, you should not know anything about a widget's internals at all.

The real problem seems to be that the intrinsics don't provide quite enough
functionality to access everything you need.  That is, you can get the
background color of a widget by the following call:

    Pixel background;
    WidgetGet(widget, XtNbackground, &background, NULL);

Yet, you can't get the widget's name using the same method.  The thing
to do is enhance the toolkit and include files to allow the XtGetValues
function to be able to access *all* the fields of the core widget.

Properly written widgets by toolkit implementors should be aware of the
same issues.  That is, try to provide a XtN<whatever> define for all pertinent
fields in your widget's data structure.  Also, while you're at it, be sure
to include all of the XtN strings in your public .h file and *comment*
the type, class and default value of the argument that the widget will
initialize that field to if the user doesn't set it himself when he creates
the widget.


Dan Heller	<island!argv@sun.com>

asente@decwrl.dec.com (Paul Asente) (04/16/89)

In article <12460@pasteur.Berkeley.EDU> dheller@cory.Berkeley.EDU.UUCP (Dan Heller) writes:
> [Why can't you get a widget's name?]

A known problem; in the next release of the intrinsics there will be an
XtName(widget) call.  Sorry we missed it before.

	-paul asente
	    asente@decwrl.dec.com	decwrl!asente