home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!bnr.co.uk!uknet!mcsun!news.funet.fi!ajk.tele.fi!funic!nntp.hut.fi!cs.hut.fi!aleskine
- From: aleskine@cs.hut.fi (Arto Leskinen)
- Newsgroups: comp.sys.mac.programmer
- Subject: StyledLineBreak
- Message-ID: <ALESKINE.92Dec26002756@cardhu.cs.hut.fi>
- Date: 25 Dec 92 22:27:58 GMT
- Sender: usenet@nntp.hut.fi (Usenet pseudouser id)
- Distribution: comp.sys.mac.programmer
- Organization: Helsinki University of Technology, Finland
- Lines: 45
- Nntp-Posting-Host: cardhu.cs.hut.fi
-
- I have tried to use SryledLineBreak function in my program. I know how to do
- this with NFindWord, but I thought that StyledLineBreak would be faster.
- But I can not make it to work. Here is my function:
-
- long lineLength(mTextSHand mTRecH, long chars, long line,
- mLineStyleRec *lineStyles, short styleCount)
- {
- unsigned char *cPtr, **cHand;
- unsigned short i, width = 0, offset = 1;
- long start;
- FormatOrder order[kMaxLineStyles];
- StyledLineBreakCode sLBCode = smBreakOverflow;
-
- for ( i=0; order[i][0] = i++; );
- start = (*(*mTRecH)->lineStarts)[line];
- cHand = capCpyStr((**mTRecH).currText, start, chars);
- width = (**mTRecH).destRect.right - (**mTRecH).destRect.left;
- if ( cHand && **cHand)
- {
- cPtr = *cHand;
- styleCount = setLineStyles(mTRecH, line, lineStyles);
- GetFormatOrder(order, 0, styleCount, (Boolean)GetSysJust(),
- mTRLDirProc, (Ptr) lineStyles);
- for (i = 0; lineStyles[order[i][0]].tStyleH &&
- (sLBCode == smBreakOverflow); i++)
- {
- setTextStyle(lineStyles[order[i][0]].tStyleH);
- sLBCode = StyledLineBreak(cPtr, chars,
- lineStyles[order[i][0]].start,
- lineStyles[order[i][0]+1].start-1, 0L, &width,
- &offset);
- }
- return (offset ? offset : chars);
- }
- }
- the offset will be always 0, I have thought that it will be set to byte count
- for line break position. Linestyles in an array of structs where there is
- handle to stylerec and start(long). When line wrap happends, return value
- is right, but offset is 0. Any Ideas?
-
- I would like to loop through styles and return number of chars that will go
- into line.
-
- Arto Leskinen
- aleskine@cs.hut.fi
-