Re: macperl-toolbox Digest 9 May 2001 19:59:42 -0000 Issue 12

[email protected] (Peter Hartmann) Wed, 9 May 2001 23:49:53 +0200
Newsgroups perl.macperl.toolbox
Message-ID <a05100301b71f6726afd0@[213.7.142.170]>
At 19:59 Uhr +0000 09.05.2001, [email protected] wrote:

Didn't try it and don't know if that really helps, but for a starter, 
to get rid of all the question marks and "presumablys" I'd suggest 
you get yourself the Universal Headers from Apple and search them 
using BBedit or the like to get the *real* definitions for the 
records. Every defined datatype can be mapped down to simple C or 
Pascal style data types. E.g.:

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

Then look for struct TextStyle

struct TextStyle {
	short				tsFont;			/*font (family) number*/
	StyleField			tsFace;			/*character Style*/
	short				tsSize;			/*size in point*/
	RGBColor			tsColor;			/*absolute (RGB) color*/
};

And after that lookup struct StyleField and struct RGBColor

	StyleField			Style when used as a field (historical 
68K convention)

	Note:  The original Macintosh toolbox in 68K Pascal defined 
Style as a SET. 
		Both Style and CHAR occupy 8-bits in packed records or 16-bits when
		used as fields in non-packed records or as parameters.
	StyleField		/*StyleField occupies 16-bits, but only 
first 8-bits are used*/

struct RGBColor {
	unsigned short		red;			/*magnitude of red component*/
	unsigned short		green;			/*magnitude of green component*/
	unsigned short		blue;			/*magnitude of blue component*/
};

 From what I can see, there is no special meaning implied for 
"absolute RGBColor", it's just a simple RGB Color.

Hope this helps somehow.

>IM leads me to believe that to set a text style in TextEdit you call
>TESetStyle(TESetStyle MODE, NEWSTYLE, FREDRAW, HTE).
>
>'NEWSTYLE', it seems, should be a 'record':
>
>          short	   tsFont	(font ID)
>	short (?)  tsFace	(font face, 'bold' etc. -- presumably a short?)
>	short	   tsSize	(font size in points)
>          ????	   RGB		(absolute RGB color)
>
>Now what, for starters, is meant by "_absolute_ RGB Color"?
>
>I have tried this in a hopeful sort of a way...
>
>          my $col = RGBColor->new(0xFFFF, 0, 0);
>
>	my $ts  = { tsFont   =>  20,
>                      tsFace   =>   1,
>                      tsSize   =>  24,
>                     tsColor   =>  $col };
>
>          my $text_style = bless $ts, "TextStyle";
>
>          TESetStyle(doAll, $text_style, 1, $hte);
>
>...to no effect at all. As far as I can see it does absolutely nothing.
>
>Anyone any ideas?
>
>Alan Fry

-- 

___ Peter Hartmann ________

mailto:[email protected]