• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Drawing an NSAttributedString into an NSRect
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Drawing an NSAttributedString into an NSRect (From: Graham <email@hidden>)

  • Prev by Date: Re: Re: Drawing an NSAttributedString into an NSRect
  • Next by Date: How to use NSTextAttachments and get word wrap around images?
  • Previous by thread: Re: Drawing an NSAttributedString into an NSRect
  • Next by thread: Re: Re: Drawing an NSAttributedString into an NSRect
  • Index(es):
    • Date
    • Thread