Re: [MacPerl-Toolbox] Re: TESetStyle problem

[email protected] (Alan Fry) Sun, 20 May 2001 19:14:44 +0100
Newsgroups perl.macperl.toolbox
Message-ID <p05010400b72db307b047@[158.152.146.73]>
At 5:42 am +0200 14/05/01, Matthias Neeracher wrote:

>In article <p05010400b722c60468b0@[158.152.146.73]>, Alan Fry 
><[email protected]> writes:
>
>>  I think there is definitely something wrong with the TextEdit.xs in
>>  relation to TextStyle. Specifically if a 'style field' is invoked
>>  with:
>
>>  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
>
>0 can sometimes stand for the default Application font size, which could very
>well be 12.

Oh -- I had no idea. It certainly was the default font so that's no 
doubt what's going on.

>  > 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);
>
>Well, that is one limitation of my struct approach: The RGBColor returned by
>tsColor is a copy, so to set it, you'd need to call:
>
>$text_color = $text_style->tsColor;
>$text_color->red(65535);
>$text_style->tsColor($text_color);

Yes of course -- I should have thought of that. It works perfectly.

>Your code is equivalent to inly the first two of these lines.
>
>>	TESetStyle(doAll, $text_style, 1, $hte);
>
>>  using the value of $text_style from TEGetStyle() fails returning 'undef'.
>
>Hmm. Can you file a bug on that? I'll need to investigate further.

I had delayed doing so until there was a chance to get the latest 
version of MacPerl built and redo the experiment on the grounds its 
probably better to concentrate resources on that than the older 5.2.1 
version. However that has been defeated by a more serious bug with 
Windows, about which I will file a report.

Also I am now pretty certain there is nothing wrong with 
TESetStyle(). Used properly it works fine. IM is quite heavy going 
when it comes to styled text and I got it wrong. The fact that 
TEGetStyle() returns 'undef' is really neither here nor there -- it 
would do, would it not, because nothing is returned by the XS?

>  > 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?
>
>No, this is typical XS jargon for a parameter passed in by value 
>which needs to
>passed further by reference.

Understood.

Many thanks for your most helpful explanations and apologies for my 
delay in responding. There was little spare time last week 
unfortunately.

Alan Fry