Re: lineFragmentRectForProposedRect question ?
Re: lineFragmentRectForProposedRect question ?
- Subject: Re: lineFragmentRectForProposedRect question ?
- From: RFM <email@hidden>
- Date: Wed, 10 Apr 2002 15:54:04 -0400
- Organization: RFM & Associates
Hmmm. I tried something like what you are describing to handle the case where
the horizontal line intersects the proposed rect and move it down as in the
returned rect value, except that there where cases where the proposed
rectangle passed in had a height of one (1) ? So I gave up on the approach.
What would case a proposed rect to have a height of 1 ?
Douglas Davidson wrote:
>
On Wednesday, April 10, 2002, at 11:40 AM, RFM wrote:
>
>
> 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.
>
>
Well, there are a variety of approaches to this. Let me consider one of
>
them: remember the example I used, of a text container that was a
>
rectangle with holes? Well, let's think of this grid as a rectangle
>
with holes in it, very thin holes that cover the lines of the grid.
>
>
When the text container is passed a proposed rect, it will check to see
>
whether it intersects a horizontal grid line; if so, it will move it
>
down. Then it will check to see if it intersects a vertical grid line
>
(which it usually will), and if so it will split it into the part before
>
the line, and a remainder after the line.
>
>
In terminology we distinguish between lines and line fragments; one line
>
may be made up of many line fragments, as in this case, where the line
>
fragments would be the bits of line in between the vertical grid lines.
>
>
I'll see if I can work up a sample implementation, or somebody may beat
>
me to it.
>
>
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.