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 PROTECTED]
Project Owner
SCPlugin
http://scplugin.tigris.org
"Subversion for the rest of OS X"


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to