home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / mac / programm / 20322 < prev    next >
Encoding:
Internet Message Format  |  1992-12-25  |  2.0 KB

  1. Path: sparky!uunet!pipex!bnr.co.uk!uknet!mcsun!news.funet.fi!ajk.tele.fi!funic!nntp.hut.fi!cs.hut.fi!aleskine
  2. From: aleskine@cs.hut.fi (Arto Leskinen)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: StyledLineBreak
  5. Message-ID: <ALESKINE.92Dec26002756@cardhu.cs.hut.fi>
  6. Date: 25 Dec 92 22:27:58 GMT
  7. Sender: usenet@nntp.hut.fi (Usenet pseudouser id)
  8. Distribution: comp.sys.mac.programmer
  9. Organization: Helsinki University of Technology, Finland
  10. Lines: 45
  11. Nntp-Posting-Host: cardhu.cs.hut.fi
  12.  
  13. I have tried to use SryledLineBreak function in my program. I know how to do
  14. this with NFindWord, but I thought that StyledLineBreak would be faster.
  15. But I can not make it to work. Here is my function:
  16.  
  17. long lineLength(mTextSHand mTRecH, long chars, long line,
  18.         mLineStyleRec *lineStyles, short styleCount)
  19. {
  20.     unsigned char *cPtr, **cHand;
  21.     unsigned short i, width = 0, offset = 1;
  22.     long start;
  23.     FormatOrder order[kMaxLineStyles];
  24.     StyledLineBreakCode sLBCode = smBreakOverflow;
  25.     
  26.     for ( i=0; order[i][0] = i++; );
  27.     start = (*(*mTRecH)->lineStarts)[line];
  28.     cHand = capCpyStr((**mTRecH).currText, start, chars);
  29.     width = (**mTRecH).destRect.right - (**mTRecH).destRect.left;
  30.     if ( cHand && **cHand)
  31.     {
  32.         cPtr = *cHand;
  33.         styleCount = setLineStyles(mTRecH, line, lineStyles);
  34.         GetFormatOrder(order, 0, styleCount, (Boolean)GetSysJust(),
  35.                     mTRLDirProc, (Ptr) lineStyles);
  36.         for (i = 0; lineStyles[order[i][0]].tStyleH && 
  37.         (sLBCode == smBreakOverflow); i++)
  38.         {
  39.             setTextStyle(lineStyles[order[i][0]].tStyleH);
  40.             sLBCode = StyledLineBreak(cPtr, chars,
  41.                 lineStyles[order[i][0]].start,
  42.                 lineStyles[order[i][0]+1].start-1, 0L, &width,
  43.                 &offset);
  44.         }
  45.         return (offset ? offset : chars);
  46.     }
  47. }
  48. the offset will be always 0, I have thought that it will be set to byte count
  49. for line break position. Linestyles in an array of structs where there is 
  50. handle to stylerec and start(long). When line wrap happends, return value
  51. is right, but offset is 0. Any Ideas?
  52.  
  53. I would like to loop through styles and return number of chars that will go
  54. into line.
  55.  
  56. Arto Leskinen
  57. aleskine@cs.hut.fi
  58.