diff options
author | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2010-03-19 21:35:39 +0000 |
---|---|---|
committer | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2010-03-19 21:35:39 +0000 |
commit | 4d67e716e5a2b1b50d5eb09db4f19fd7c1ba04ae (patch) | |
tree | 59a644aa8560d9c5ef0e3ec4cb8eae0fadd9d98a /AppKit | |
parent | b52866b053b49238bb536324e8a1a1fce859e49e (diff) |
[Author: thomasvl]
Add a fudge factor for buttons (radios, checkboxes) that have forced wordwraps.
R=dmaclach
DELTA=11 (11 added, 0 deleted, 0 changed)
Diffstat (limited to 'AppKit')
-rw-r--r-- | AppKit/GTMUILocalizerAndLayoutTweaker.m | 11 |
1 files changed, 11 insertions, 0 deletions
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; + } } } } |