Re: lineFragmentRectForProposedRect question ?
Re: lineFragmentRectForProposedRect question ?
- Subject: Re: lineFragmentRectForProposedRect question ?
- From: RFM <email@hidden>
- Date: Wed, 10 Apr 2002 14:40:32 -0400
- Organization: RFM & Associates
Hi Douglas,
Thanks for the quick response. To be more specific, imagine a grid of
paper-sized rectangles n * n in dimension, next take a mountain text and
place it on top of the grid, now it is possible that some words in the text
may be split by the vertical lines in the grid as well as some lines of text
split by the horizontal lines of the grid. (split meaning the grid line
actually intersects the text of the word or the line of text, sort of like a
strike through) I want to be able to detect those conditions and adjust the
layout so that no grid intersections of the text occur effectively creating
clean page breaks. I'm not using NSTextView for numerous architectural
reasons primarily because the view may encompass many items. It could be a
report with 1000 pages of stuff in it, or 1000 or more separate items
including text, images, gif animations, movies etc. There is likely to be a
number of different areas in the content of the report containing text of
varying attributes. Text rendering is modeled somewhat after the 'Sketch'
application from the Developer examples, which avoids using NSView subclasses
for performance reasons. Any info on advanced usage NSLayoutManager,
NSTextContainer, NSTextStorage, glyph handling, etc. would be immensely
appreciated.
Regards,
Bob
Douglas Davidson wrote:
>
On Wednesday, April 10, 2002, at 06:43 AM, RFM wrote:
>
>
> Does anyone know if there is an example available on how to use the
>
> NSTextContainer method lineFragmentRectForProposedRect: ? That is how to
>
> calculate an actual line fragment rectangle for a particular word or
>
> line in text ? I've had no luck subclassing this to do some special
>
> operations that I would like to implement such as clean page breaking on
>
> both horizontal and vertical page boundaries for words and lines that
>
> are split across these boundaries ? Is that even possible using this
>
> method ? is there some other way to achieve this ?
>
>
The point of NSTextContainer is to model the geometry of a region in
>
which text is to be laid out. A given layout manager will have a list
>
of such regions, representing such things as the columns on a page, or
>
the pages in a document, and will lay the text out into them
>
sequentially. To see a simple example, run TextEdit and put it in "wrap
>
to page" mode. The pages you will see are individual text containers.
>
>
Most text containers are simple rectangles, and that is the behavior
>
provided by the basic NSTextContainer class. Usually you would subclass
>
NSTextContainer if you wanted to model some other type of region,
>
especially a non-rectangular one. In that case, the way it works is
>
that the typesetter will propose a particular line rectangle, and the
>
text container will be asked to approve, modify, or reject it. For
>
example, if your text container were a rectangle with holes, you would
>
decide whether the proposed line intersected any of the holes, and if so
>
truncate it into a piece to the left of the hole, plus a remainder to
>
the right of the hole.
>
>
I'm not sure what you mean by "words and lines that are split across
>
these boundaries", but perhaps you could supply some examples, and then
>
maybe we could better advise you.
>
>
Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.