Re: TESetStyle problem

[email protected] (Alan Fry) Sat, 12 May 2001 12:29:31 +0100
Newsgroups perl.macperl.toolbox
Message-ID <p05010400b722c60468b0@[158.152.146.73]>
I think there is definitely something wrong with the TextEdit.xs in 
relation to TextStyle. Specifically if a 'style field' is invoked 
with:

	$hte = TEStyleNew($destRect, $viewRect);

the following elements:

	print $hte->txFont, "\n";	returns 785	OK (probably)
	print $hte->txFace, "\n";	returns 743	OK (probably)
	print $hte->txSize, "\n";	returns -1	OK
	print $hte->lineHeight, "\n";	returns -1	OK
	print $hte->fontAscent, "\n";	returns -1	OK

txFont and txFace are used for the address of TextStyle and the other 
three should be -1. So the conclusion is that TEStyleNew() functions 
as it should.

However the paramenters returned by TEGetStyle() do not:

	($text_style, $height, $ascent) = TEGetStyle(0, $hte);

	print $text_style, "\n";	  returns TextStyle=SCALAR(0x3335a64)
	print $text_style->tsFont, "\n";  returns 1	OK
	print $text_style->tsFace, "\n";  returns 0	OK
	print $text_style->tsSize, "\n";  returns 0	not OK
	print $text_style->tsColor, "\n"; returns RGBColor=SCALAR(0x3335a70)

The value of tsSize is certainly wrong since the actual font size was 
12 Moreover RGBColor does not behave as expected since:

         print $text_style->tsColor->red, "\n"; returns 0  OK (text was black)
	$text_style->tsColor->red(65535);
         print $text_style->tsColor->red, "\n"; returns 0  not OK

But the clincher is that:

	TESetStyle(doAll, $text_style, 1, $hte);

using the value of $text_style from TEGetStyle() fails returning 'undef'.

The only thing I can see is that TextEdit.xs for TESetStyle() has:

void
TESetStyle(mode, newStyle, fRedraw, hTE)
	short		mode
	TextStyle	&newStyle
	Boolean		fRedraw
	TEHandle	hTE

whereas TextEdit.h defines it as:

TESetStyle(
   short              mode,
   const TextStyle *  newStyle,
   Boolean            fRedraw,
   TEHandle           hTE)

Is that significant? Anyone any ideas what to do?

Alan Fry