From 4d67e716e5a2b1b50d5eb09db4f19fd7c1ba04ae Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Fri, 19 Mar 2010 21:35:39 +0000 Subject: [Author: thomasvl] Add a fudge factor for buttons (radios, checkboxes) that have forced wordwraps. R=dmaclach DELTA=11 (11 added, 0 deleted, 0 changed) --- AppKit/GTMUILocalizerAndLayoutTweaker.m | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'AppKit') diff --git a/AppKit/GTMUILocalizerAndLayoutTweaker.m b/AppKit/GTMUILocalizerAndLayoutTweaker.m index ab61d8e..a7149a6 100644 --- a/AppKit/GTMUILocalizerAndLayoutTweaker.m +++ b/AppKit/GTMUILocalizerAndLayoutTweaker.m @@ -578,6 +578,17 @@ static NSSize SizeToFit(NSView *view, NSPoint offset) { if (NSWidth(newFrame) < kMinButtonWidth) { newFrame.size.width = kMinButtonWidth; } + } else { + // NSButton likes to lie when the title has forced word wraps (like + // wrapButtonTitleForWidth does). When it actually draws, it comes up + // with slightly different metrics which causes unintended wrapping so + // pad the size by 0.5 to help cover this (odds are there is a + // NSIntegralRect call used along the way that triggers the bug). + NSString *title = [button title]; + NSString * const kForcedWrapString = @"\xA"; + if ([title rangeOfString:kForcedWrapString].location != NSNotFound) { + newFrame.size.width += 0.5; + } } } } -- cgit v1.2.3