aboutsummaryrefslogtreecommitdiff
path: root/AppKit
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-04-06 18:06:35 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-04-06 18:06:35 +0000
commitedb9eb2865f530d6b12f4401d86f4dcae01a0ff9 (patch)
tree9f75f41bcc858ce34ff9c93be0168d9a0c4693b0 /AppKit
parente9f65ca2fef0d51eccee34ab3640536a71b5c2de (diff)
[Author: thomasvl]
Add a radar number for the sizeToFit padding issue. Reorder two functions in the impl to match the header. R=dmaclach DELTA=55 (28 added, 27 deleted, 0 changed)
Diffstat (limited to 'AppKit')
-rw-r--r--AppKit/GTMUILocalizerAndLayoutTweaker.m59
1 files changed, 30 insertions, 29 deletions
diff --git a/AppKit/GTMUILocalizerAndLayoutTweaker.m b/AppKit/GTMUILocalizerAndLayoutTweaker.m
index 4aa93c0..5e19cd0 100644
--- a/AppKit/GTMUILocalizerAndLayoutTweaker.m
+++ b/AppKit/GTMUILocalizerAndLayoutTweaker.m
@@ -44,6 +44,7 @@ NSString * const kForcedWrapString = @"\xA";
// gets as wide, resulting in a clipped control. This fudge factor is what is
// added to try and avoid these by giving the size calls just enough slop to
// handle the differences.
+// radar://7831901 different wrapping between sizeToFit and drawing
static const CGFloat kWrapperStringSlop = 0.9;
#if GTM_USE_TYPESETTER
@@ -247,33 +248,6 @@ static const CGFloat kWrapperStringSlop = 0.9;
return newSize.height - NSHeight(initialFrame);
}
-+ (void)wrapButtonTitleForWidth:(NSButton *)button {
- NSCell *cell = [button cell];
- NSRect frame = [button frame];
-
- NSRect titleFrame = [cell titleRectForBounds:frame];
-
- NSString* newTitle = [self wrapString:[button title]
- width:NSWidth(titleFrame)
- font:[button font]];
- [button setTitle:newTitle];
-}
-
-+ (void)wrapRadioGroupForWidth:(NSMatrix *)radioGroup {
- NSSize cellSize = [radioGroup cellSize];
- NSRect tmpRect = NSMakeRect(0, 0, cellSize.width, cellSize.height);
- NSFont *font = [radioGroup font];
-
- NSCell *cell;
- GTM_FOREACH_OBJECT(cell, [radioGroup cells]) {
- NSRect titleFrame = [cell titleRectForBounds:tmpRect];
- NSString* newTitle = [self wrapString:[cell title]
- width:NSWidth(titleFrame)
- font:font];
- [cell setTitle:newTitle];
- }
-}
-
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+ (CGFloat)sizeToFitFixedHeightTextField:(NSTextField *)textField {
@@ -349,6 +323,33 @@ static const CGFloat kWrapperStringSlop = 0.9;
#endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
++ (void)wrapButtonTitleForWidth:(NSButton *)button {
+ NSCell *cell = [button cell];
+ NSRect frame = [button frame];
+
+ NSRect titleFrame = [cell titleRectForBounds:frame];
+
+ NSString* newTitle = [self wrapString:[button title]
+ width:NSWidth(titleFrame)
+ font:[button font]];
+ [button setTitle:newTitle];
+}
+
++ (void)wrapRadioGroupForWidth:(NSMatrix *)radioGroup {
+ NSSize cellSize = [radioGroup cellSize];
+ NSRect tmpRect = NSMakeRect(0, 0, cellSize.width, cellSize.height);
+ NSFont *font = [radioGroup font];
+
+ NSCell *cell;
+ GTM_FOREACH_OBJECT(cell, [radioGroup cells]) {
+ NSRect titleFrame = [cell titleRectForBounds:tmpRect];
+ NSString* newTitle = [self wrapString:[cell title]
+ width:NSWidth(titleFrame)
+ font:font];
+ [cell setTitle:newTitle];
+ }
+}
+
+ (void)resizeWindowWithoutAutoResizingSubViews:(NSWindow*)window
delta:(NSSize)delta {
NSView *contentView = [window contentView];
@@ -568,7 +569,7 @@ static NSSize SizeToFit(NSView *view, NSPoint offset) {
[view performSelector:@selector(sizeToFit)];
fitFrame = [view frame];
newFrame = fitFrame;
-
+
if ([view isKindOfClass:[NSMatrix class]]) {
NSMatrix *matrix = (NSMatrix *)view;
// See note on kWrapperStringSlop for why this is done.
@@ -581,7 +582,7 @@ static NSSize SizeToFit(NSView *view, NSPoint offset) {
}
}
}
-
+
}
if ([view isKindOfClass:[NSButton class]]) {