[comp.sys.mac.programmer] The 'styl' resource

Ken.Knight@f421.n109.z1.fidonet.org (Ken Knight) (02/28/91)

I think this has been asked before here, but I haven't seen a real
answer myself. There is, in ResEdit 2.x a resource called 'styl'
defined. It appears to be a resource that lets you store/retrieve
styled TextEdit (text, style runs, and so on) data. Are there any calls
like GetStylResource/PutStyleResource that can retrieve and write out
these 'styl' resources? Just what is the format of a 'styl' resource?
 
  ** Ken **


--  

        Ken Knight, Ken.Knight@f421.n109.z1.fidonet.org
      via The Black Cat's Shack's FidoNet<->Usenet Gateway
          blkcat.fidonet.org   and   Fidonet 1:109/401

jwwalker@opusc.csd.scarolina.edu (Jim Walker) (03/01/91)

The format of the 'styl' resource is the same as the 'styl' scrap type.
See Inside Macintosh pages 267, 268.  For instance you use TEStylInsert to
insert styled text.
-- 
  -- Jim Walker 76367.2271@compuserve.com  walker@math.scarolina.edu

mxmora@unix.SRI.COM (Matt Mora) (03/02/91)

In article <3732.27CD8EBC@blkcat.fidonet.org> Ken.Knight@f421.n109.z1.fidonet.org (Ken Knight) writes:
>I think this has been asked before here, but I haven't seen a real
>answer myself. There is, in ResEdit 2.x a resource called 'styl'
>defined. It appears to be a resource that lets you store/retrieve
>styled TextEdit (text, style runs, and so on) data. Are there any calls
>like GetStylResource/PutStyleResource that can retrieve and write out
>these 'styl' resources? Just what is the format of a 'styl' resource?


Below are some calls to the new textedit routines described in IM Vol5.
starting on page 259.

TEGetStyle(offset, style, lineHeight, fontAscent, te); 
TEGetHeight(endLine, startLine, te);
TEStylPaste(te);
TESetStyle(mode, style, redraw, te);
TEStylNew(destRect, viewRect);
TEReplaceStyle(mode, oldStyle, newStyle, redraw, te);
GetStylHandle(te);
GetStylScrap(te);
SetStylHandle(h, te);
TEStylInsert(text, length, h, te);
TEGetPoint(offset, te);
TEGetHeight(endLine, startLine, te);


-- 
___________________________________________________________
Matthew Mora                |   my Mac  Matt_Mora@sri.com
SRI International           |  my unix  mxmora@unix.sri.com
___________________________________________________________

mxmora@unix.SRI.COM (Matt Mora) (03/02/91)

In article <3732.27CD8EBC@blkcat.fidonet.org> Ken.Knight@f421.n109.z1.fidonet.org (Ken Knight) writes:

In a previos post I forgot to anwser your last question.

>these 'styl' resources? Just what is the format of a 'styl' resource?

So here it goes: (this off the top of my head :-))


    TEStyleHandle = ^TEStylePtr;
    TEStylePtr = ^TEStyleRec;
    TEStyleRec = RECORD
        nRuns: INTEGER;     {number of style runs}
        nStyles: INTEGER;   {size of style table}
        styleTab: STHandle; {handle to style table}
        lhTab: LHHandle;    {handle to line-height table}
        teRefCon: LONGINT;  {reserved for application use}
        nullStyle: nullSTH  = ^LHTable;
    LHTable = ARRAY [0..0] OF LHElement;
    LHElement   = RECORD
        lhHeight: INTEGER;  {maximum height in line}
        lhAscent: INTEGER   {maximum ascent in line}
      END;

    NullSTHandle = ^NullSTPtr;
    NullSTPtr = ^NullSTRec;
    NullSTRec = RECORD
        TEReserved: LONGINT;        {reserved for future expansion}
        nullScrap:  STScrpHandle    {handle to scrap style table}
      END;

    TextStyle   = RECORD
        tsFont: INTEGER;    {font (family) number}
        tsFace: Style;      {character style}
        tsSize: INTEGER;    {size in points}
        tsColor: RGBColor   {absolute (RGB) color}
      END;

    StScrpHandle = ^StScrpPtr;
    StScrpPtr = ^StScrpRec;
    StScrpRec = RECORD
        scrpNStyles: INTEGER;   {number of distinct styles in scrap}
        scrpStyleTab: ScrpSTTable   {table of styles for scrap}
      END;

    ScrpSTTable = ARRAY [0..0] OF scrpSTElement;
    ScrpSTElement   = RECORD
        scrpStartChar: LONGINT; {offset to start of style}
        scrpHeight: INTEGER;    {line height}
        scrpAscent: INTEGER;    {font ascent}
        scrpFont: INTEGER;      {font (family) number}
        scrpFace: Style;        {character style}
        scrpSize: INTEGER;      {size in points}
        scrpColor: RGBColor;    {absolute (RGB) color}
      END;

Pheew...

Matt


-- 
___________________________________________________________
Matthew Mora                |   my Mac  Matt_Mora@sri.com
SRI International           |  my unix  mxmora@unix.sri.com
___________________________________________________________