• 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: horizontal sizeToFit of NSTextView or NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: horizontal sizeToFit of NSTextView or NSTextField


  • Subject: Re: horizontal sizeToFit of NSTextView or NSTextField
  • From: Jack Repenning <email@hidden>
  • Date: Mon, 21 Apr 2008 08:41:41 -0700

On Apr 20, 2008, at 11:37 AM, Manfred Schwind wrote:

Getting the height of a text for a given width is easy and I've done that countless times.
Also getting the width of a string (layed out in one line if it has no newlines) is no problem.


But I have a different problem. I try to give an easier explanation of my problem:

I have a text view that has a height that can hold three lines of text. Now I have one long string (without newlines). When putting this string into the text view, the text is automatically wrapped around. But maybe - for the initial width of the view - it will need four (or more) lines instead of just three. Now I want to calculate the optimal (minimum) width of the text view, to that the string is wrapped around in just three (or less) lines.


Either I'm misunderstanding your question, or you're misunderstanding the Geometries code. I think you want -widthForHeight:attributes:, with the height specified for three lines (could just take it from what IB sets for you, or first get a heightForWidth:reallyBig, then triple that). The demo program has a -heightForWidth:attributes: case, just flip it around. This code _does_ work for a multi-line height, and does allow for correct wrapping, font changes in mid fly, multibyte characters, and all the rest.

-==-
Jack Repenning
email@hidden
Project Owner
SCPlugin
http://scplugin.tigris.org
"Subversion for the rest of OS X"


_______________________________________________

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


  • Follow-Ups:
    • Re: horizontal sizeToFit of NSTextView or NSTextField
      • From: Manfred Schwind <email@hidden>
References: 
 >horizontal sizeToFit of NSTextView or NSTextField (From: Manfred Schwind <email@hidden>)
 >Re: horizontal sizeToFit of NSTextView or NSTextField (From: Jack Repenning <email@hidden>)
 >Re: horizontal sizeToFit of NSTextView or NSTextField (From: Manfred Schwind <email@hidden>)

  • Prev by Date: Re: Premature notification from NSApplication - workaround?
  • Next by Date: Cannot find an icon
  • Previous by thread: Re: horizontal sizeToFit of NSTextView or NSTextField
  • Next by thread: Re: horizontal sizeToFit of NSTextView or NSTextField
  • Index(es):
    • Date
    • Thread