Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dynamic right-sizing of TextContainer



I am able to set the initial height/width of the NSTextContainer object of a NSTextView object in IB. However, I cannot find any method that will allow the programmatic re-sizing of the container when the text I'm adding exceeds this size.

Optimally, I'd like to utilize the setContainerSize with an NSSize object that just handles the amount of text that needs displaying (I'm leaving the scrolling behavior up to NSScrollView).

Currently, I'm just punting with the following in awakeFromNib:

[decimalStringView setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
[decimalStringView setVerticallyResizable:YES];
[[decimalStringView textContainer] setContainerSize:NSMakeSize([decimalStringView minSize].width, FLT_MAX)];


This guarantees that any string I will generate will fit in.

Where I am stuck is the height calculation for an NSSize object given a string of length N. For my purposes, the width will stay fixed. Since I know the font size (12 pt) and assuming the leading of the layout is fixed and measurable (~6px), I could calculate a new total pixel height if needed.

Is this the way to go, or should I just leave the height at the system max?

--
* Martin C. Stoufer              *
* ISS/IT                         *
* Lawrence Berkeley National Lab *
* 510-486-5306                   *
* MS 937-700                     *

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.