diff options
-rw-r--r-- | AppKit/GTMUILocalizerAndLayoutTweaker.m | 3 | ||||
-rw-r--r-- | AppKit/GTMUILocalizerAndLayoutTweakerTest.m | 14 |
2 files changed, 17 insertions, 0 deletions
diff --git a/AppKit/GTMUILocalizerAndLayoutTweaker.m b/AppKit/GTMUILocalizerAndLayoutTweaker.m index 27a4649..d2ff80c 100644 --- a/AppKit/GTMUILocalizerAndLayoutTweaker.m +++ b/AppKit/GTMUILocalizerAndLayoutTweaker.m @@ -313,6 +313,9 @@ static const CGFloat kWrapperStringSlop = 0.9; if (minWidth > fixedSize.width) { finalSize.width = minWidth; } + // Make integral. + finalSize.width = ceil(fixedSize.width); + finalSize.height = ceil(fixedSize.height); if (!NSEqualSizes(fixedSize, finalSize)) { [textField setFrameSize:finalSize]; } diff --git a/AppKit/GTMUILocalizerAndLayoutTweakerTest.m b/AppKit/GTMUILocalizerAndLayoutTweakerTest.m index d5b111c..8905e82 100644 --- a/AppKit/GTMUILocalizerAndLayoutTweakerTest.m +++ b/AppKit/GTMUILocalizerAndLayoutTweakerTest.m @@ -212,6 +212,7 @@ static NSUInteger gTestPass = 0; } #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + - (void)testSizeToFitFixedHeightTextField { struct { const char *name; @@ -266,6 +267,19 @@ static NSUInteger gTestPass = 0; } } } + +- (void)testSizeToFitFixedHeightTextFieldIntegral { + NSTextField* textField = + [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 50)]; + [textField setBezeled:NO]; + [textField setStringValue:@"The quick brown fox jumps over the lazy dog."]; + [GTMUILocalizerAndLayoutTweaker sizeToFitFixedHeightTextField:textField]; + STAssertTrue( + NSEqualRects([textField bounds], NSIntegralRect([textField bounds])), + nil); + [textField release]; +} + #endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 @end |