From f736aed5642b3c7f19533653e1ddfd4599f1ee7d Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Tue, 9 Mar 2010 20:36:55 +0000 Subject: [Author: thomasvl] Add an api for forcing a NSTextField to a fixed height but what ever width is needed. R=dmaclach DELTA=634 (631 added, 0 deleted, 3 changed) --- AppKit/GTMUILocalizerAndLayoutTweaker.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'AppKit/GTMUILocalizerAndLayoutTweaker.h') diff --git a/AppKit/GTMUILocalizerAndLayoutTweaker.h b/AppKit/GTMUILocalizerAndLayoutTweaker.h index edbfc25..4a9b666 100644 --- a/AppKit/GTMUILocalizerAndLayoutTweaker.h +++ b/AppKit/GTMUILocalizerAndLayoutTweaker.h @@ -56,11 +56,21 @@ // Returns the amount the field changed height. + (CGFloat)sizeToFitFixedWidthTextField:(NSTextField *)textField; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 +// If you call sizeToFit on a NSTextField it will try not to word wrap, so it +// can get really wide. This method will keep the height fixed, but figure out +// how wide the textfield needs to be to fit its text. +// Returns the amount the field changed width. ++ (CGFloat)sizeToFitFixedHeightTextField:(NSTextField *)textField; ++ (CGFloat)sizeToFitFixedHeightTextField:(NSTextField *)textField + minWidth:(NSUInteger)minWidth; +#endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + // Insert newlines into the title of the button (radio or checkbox) or all cells // in the radio group (NSMatrix) so they will word wrap to the item's current -// width. Then +sizeToFitView can be called to have then resize to the exact -// width and height needed. Note: any existing Opt-Return forced wraps are -// removed from the existing titles. +// width. Then +sizeToFitView can be called to then resize to the exact width +// and height needed. Note: any existing Opt-Return forced wraps are removed +// from the existing titles. + (void)wrapButtonTitleForWidth:(NSButton *)button; + (void)wrapRadioGroupForWidth:(NSMatrix *)radioGroup; -- cgit v1.2.3