[comp.windows.x] How can I find the name of an HP widget?

garyo@THINK.COM (Gary Oberbrunner) (07/29/89)

I tried XtNname with no luck, and I even printed out the entire resource
list of the widget, but the name isn't there!  How can that be?  I even
looked in the source, but all I can find are private fields like xrm_name
that I can't get at.  So how do I get the widget name?

					Thanks,

					Gary O

-----------------------------------------------------------------------------
Remember,		      Truth is not beauty;	    Gary  Oberbrunner
Information is not knowledge; Beauty is not love;  {ames,harvard}!think!garyo
Knowledge is not wisdom;      Love is not music;	      garyo@think.com
Wisdom is not truth;	      Music is the best. - FZ	  (617) 876-1111 x265

kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (07/31/89)

> I tried XtNname with no luck, and I even printed out the entire resource
> list of the widget, but the name isn't there!  How can that be?  I even
> looked in the source, but all I can find are private fields like xrm_name
> that I can't get at.  So how do I get the widget name?

This is a hole in the R3 specification.  There is no portable way to do this.
We are busily working on the R4 specification and it will include a public
function that will support a portable interface for retreiving the the name
of a widget.  

Until then the only way to get the name of a widget is to include IntrinsicP.h
and read the core.name field.  Here is some example source code.


char *
GetWidgetName(w)
Widget w;
{
# include <X11/IntrinsicP.h>
  
  return(w->core.name);
}
	

						Chris D. Peterson     
						MIT X Consortium 

Net:	 kit@expo.lcs.mit.edu
Phone:   (617) 253 - 9608	
Address: MIT - Room NE43-213

diamant@hpfclp.SDE.HP.COM (John Diamant) (08/01/89)

> I tried XtNname with no luck, and I even printed out the entire resource
> list of the widget, but the name isn't there!  How can that be?  I even
> looked in the source, but all I can find are private fields like xrm_name
> that I can't get at.  So how do I get the widget name?

Unfortunately, the Xt Intrinsics (R2 at least) don't provide a public
way to get a widget's name.  The easiest way to get it is to cheat,
and pull it out of the private part of the widget data structure
(break the object oriented data hiding) by writing a function that
reads the name field out of the core part of the widget structure.
The way to do that is to include <X11/CoreP.h> in your file and then
reference the private fields directly.  Since this isn't a good idea in
general, you might just want to place your function in it's own source
file, so only that function has access to the private structures.


John Diamant
Software Engineering Systems Division
Hewlett-Packard Co.		Internet: diamant@hpfclp.sde.hp.com
Fort Collins, CO		    UUCP: {hplabs,hpfcla}!hpfclp!diamant