On Nov 11, 2009, at 12:40 PM, Shawn Erickson wrote:

> On Wed, Nov 11, 2009 at 9:28 AM, Bill Cheeseman <b...@cheeseman.name> wrote:
> 
>> What I'm trying to do is figure out how -boundingRectWithSize:option: works 
>> and what it's good for. If it did what I understood from the documentation, 
>> it could make some things easier. But you seem to be right: it was wishful 
>> thinking.
> 
> The utility of -boundingRectWithSize: has so far escaped me. It never
> has returned what I, possibly naively, expected based on the
> documentation and my needs. It always looked like something that could
> be used to do simple sizing of view with little code.
> 
> I would love to see it more useful... never did file defects about it
> since I always had the feeling I may be missing what its real utility
> is and/or how to use it.

Well, it is sometimes useful to be able to get the bounding rect that a string 
will have after it is laid out and wrapped to a specified constraint size, such 
as a fixed width but an open-ended height. For example, when I create a 
printing view I specify NSZeroRect for the initial frame, then in the printing 
view itself I reset the frame to the bounding rect every time the user changes 
print panel settings that affect the size. As Matt points out, I can do all 
that with text layout, but I'm looking for shortcuts.

I would like a method that truncated the string to the rect returned by this 
method when both width and height are constrained. But what I would like even 
more than that is to get the character index at which it was cut off based on 
the constraints. Then I could truncate the string myself, or do other things 
with the index. I would also like to be able to calculate the laid-out rect of 
successive page rects within the overall string, although this would have to be 
done in a way that didn't re-calculate the rect of all the preceding page rects.


--

Bill Cheeseman
b...@cheeseman.name

_______________________________________________

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 arch...@mail-archive.com

Reply via email to