[comp.windows.x] Instrinsics resource question

clyne@redcloud.ucar.edu (John Clyne) (02/28/89)

Hello, Can someone tell me why the following code fragment won't return
the font used by the label widget? 

thanks in advance - jc



	Widget	label;
	int	n;
	XFontStruct	font;

		|
		|
		|

	n = 0;
	XtSetArg(args[n], XtNlabel, "label"); n++;
	label =  XtCreateManagedWidget( "label", labelWidgetClass, panel,
			   args, n );
	/*
	 *	get font
	 */ 
	n = 0; 
	XtSetArg(args[n], XtNfont, &font); n++;
	XtGetValues(comm, args, n);

	/*
	 *	length of string in pixels
	 */
	width = XTextWidth(&font, "string", strlen("string");







	John Clyne 	(clyne@bierstadt.ucar.edu)
	c/o
	National Center for Atmospheric Research
	P.O. Box 3000
	Boulder, Colorado 80307
	(303) 497-1236

	
		%%% Its a small world. But I wouldn't want to paint it %%%
						S. Wright
		%%%						       %%%

yong@metasoft.UUCP (Yongdeng Chen) (03/01/89)

In article <1489@ncar.ucar.edu>, clyne@redcloud.ucar.edu (John Clyne) writes:
> 
> Hello, Can someone tell me why the following code fragment won't return
> the font used by the label widget? 
> 
> 	n = 0;
> 	XtSetArg(args[n], XtNlabel, "label"); n++;
> 	label =  XtCreateManagedWidget( "label", labelWidgetClass, panel,
> 			   args, n );
> 	/*
> 	 *	get font
> 	 */ 
> 	n = 0; 
> 	XtSetArg(args[n], XtNfont, &font); n++;
> 	XtGetValues(comm, args, n);
> 

I had similar problem with  	XtGetValues(comm, args, n);
It seems to me that XtGetValues is not doing anything.

For example:
	int x;
	x = 200;
	n = 0;
 	XtSetArg(args[n], XtNx, &x); n++;
  	XtGetValues(comm, args, n);
you will have x == 200 here.

Am I missing something also?

____________________________________________________________
yong%metasoft@bbn.com
Yongdeng Chen
Meta Software Corporation
150 Cambridge Park Drive
Cambridge, MA 02140
(617)576-6920

jmberkley@watnext.waterloo.edu (J. Michael Berkley) (03/06/89)

In article <1489@ncar.ucar.edu> clyne@redcloud.ucar.edu.UUCP () writes:
>
>Hello, Can someone tell me why the following code fragment won't return
>the font used by the label widget? 
>
>	/*
>	 *	get font
>	 */ 
>	n = 0; 
>	XtSetArg(args[n], XtNfont, &font); n++;
>	XtGetValues(comm, args, n);
>
>	/*
>	 *	length of string in pixels
>	 */
>	width = XTextWidth(&font, "string", strlen("string");

I've been having trouble with this too.  Using XtGetValues() didn't
work for finding the font, so I started poking around in the public
and private structures for the Text Sink.  It turns out that the font
element is ALWAYS NULL in the public sink struct, but is set correctly
in the private sink struct.  XtGetValues() must be looking at the
public struct.

******************************************
* Mike Berkley, University of Waterloo   *
* PAMI Lab                               *
* jmberkley@watnext.waterloo.edu         *
* jmberkley@watnext.UWaterloo.CA         *
* {utai,uunet}!watmath!watnext!jmberkley *
******************************************