Splitting an NSAttributedString across different NSRects of a given size
Splitting an NSAttributedString across different NSRects of a given size
- Subject: Splitting an NSAttributedString across different NSRects of a given size
- From: Keith Blount <email@hidden>
- Date: Mon, 30 Jun 2008 13:19:57 -0700 (PDT)
Hi,
First of all, I think I'm being a bit brain-dead here as I just *know* I've had to do something similar to this in the past, or have seen something similar to it at least, elsewhere, but I'm obviously using the wrong search terms in Cocoabuilder and Cocoadev and my memory is obviously fading with age... So -
I am creating a view for printing index cards that basically takes an array of attributed strings and prints each one on a 5 x 3 card. However, if an attributed string is too long for one card, I want to wrap it across two cards or more (however many it takes). This is where my brain-deadness comes in. What's the best way of doing this? That is, what is the best way of seeing how many NSRects of a given size it takes to fit one attributed string, and the range of characters for each rect? The only thing that has come to mind is using an NSLayoutManager with multiple text containers, creating a new text container each time the layout manager finishes layout out a text container if layout is not complete (i.e. using the same method you would use for a multiple page view, a la TextEdit). I suppose I could use one text view, set at 5 x 3 inches, for the drawing, swapping in and out the text containers as necessary... But this seems a heavy-handed approach
for a view that is only for printing and that will never be used for editing. Is there a simpler method, something blindingly obvious that I'm overlooking?
Thanks for any input and all the best,
Keith
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden