Re: Drawing an NSAttributedString into an NSRect
Re: Drawing an NSAttributedString into an NSRect
- Subject: Re: Drawing an NSAttributedString into an NSRect
- From: Ricky Sharp <email@hidden>
- Date: Tue, 30 May 2006 19:39:00 -0500
On May 30, 2006, at 4:26 PM, Graham wrote:
In my custom cell's drawing method, I am drawing an
NSAttributedString into a rectangle because I need it to wrap the
text based upon a limiting cell width.
What I need to know is, given the width of the rectangle, how many
lines and thus how many pixels deep is the rectangle that it
actually draws into after wrapping?
Check out the TipWrapper example. Specifically look at the
NSTextView_Lines.h/.m. It provides a category on NSTextView where
you can obtain a line count. It works with the "golden ratio", but
it's easy to modify it to work with a particular width.
I use the logic there to figure out line count for custom help tags.
Basically I use the logic for the measuring of text only. The text
is ultimately drawn via NSAttributedString. Just make sure to set
the attributes identically between the text view and string.
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden