From c8101d481e70ca68e05328745a3ce5202c74d545 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Wed, 28 Jan 2009 17:20:29 -0800 Subject: [PATCH] Fix spacing issues in CPPopUpButton. Reviewed by me. --- AppKit/CPButton.j | 27 ++++++++++++++++++++++----- AppKit/CPControl.j | 4 ++++ AppKit/CPPopUpButton.j | 12 +++++++++--- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/AppKit/CPButton.j b/AppKit/CPButton.j index 1c247f3ae..b167301c8 100644 --- a/AppKit/CPButton.j +++ b/AppKit/CPButton.j @@ -527,19 +527,36 @@ var _CPButtonClassName = nil, [_imageAndTextView setFrameSize:size]; } -- (CGRect)contentRectForBounds:(CGRect)aRect +- (CGRect)contentRectForBounds:(CGRect)bounds { if (_isBordered) { if (_bezelStyle === CPHUDBezelStyle) - aRect.size.height -= 4.0; + { + bounds.origin.x += 5.0; + bounds.origin.y += 2.0; + bounds.size.width -= 5.0 * 2; + bounds.size.height -= 2.0 + 4.0; + } + else if (_bezelStyle === CPRoundRectBezelStyle) - aRect.size.height -= 2.0; + { + bounds.origin.x += 5.0; + bounds.origin.y += 1.0; + bounds.size.width -= 5.0 * 2; + bounds.size.height -= 1.0 + 2.0; + } + else if (_bezelStyle === CPTexturedRoundedBezelStyle) - aRect.size.height -= 2.0; + { + bounds.origin.x += 5.0; + bounds.origin.y += 2.0; + bounds.size.width -= 5.0 * 2; + bounds.size.height -= 2.0 + 3.0; + } } - return aRect; + return bounds; } - (void)drawRect:(CGRect)aRect diff --git a/AppKit/CPControl.j b/AppKit/CPControl.j index 4a09bab1e..23fbf5b1e 100644 --- a/AppKit/CPControl.j +++ b/AppKit/CPControl.j @@ -691,6 +691,7 @@ var CPControlBlackColor = [CPColor blackColor]; var CPControlValueKey = "CPControlValueKey", CPControlIsEnabledKey = "CPControlIsEnabledKey", CPControlAlignmentKey = "CPControlAlignmentKey", + CPControlVerticalAlignmentKey = @"CPControlVerticalAlignmentKey", CPControlFontKey = "CPControlFontKey", CPControlTextColorKey = "CPControlTextColorKey", CPControlTargetKey = "CPControlTargetKey", @@ -720,6 +721,7 @@ var __Deprecated__CPImageViewImageKey = @"CPImageViewImageKey"; [self setEnabled:[aCoder decodeBoolForKey:CPControlIsEnabledKey]]; [self setAlignment:[aCoder decodeIntForKey:CPControlAlignmentKey]]; + [self setVerticalAlignment:[aCoder decodeIntForKey:CPControlVerticalAlignmentKey]]; [self setFont:[aCoder decodeObjectForKey:CPControlFontKey]]; [self setTextColor:[aCoder decodeObjectForKey:CPControlTextColorKey]]; @@ -744,6 +746,8 @@ var __Deprecated__CPImageViewImageKey = @"CPImageViewImageKey"; [aCoder encodeBool:_isEnabled forKey:CPControlIsEnabledKey]; [aCoder encodeInt:_alignment forKey:CPControlAlignmentKey]; + [aCoder encodeInt:_verticalAlignment forKey:CPControlVerticalAlignmentKey]; + [aCoder encodeObject:_font forKey:CPControlFontKey]; [aCoder encodeObject:_textColor forKey:CPControlTextColorKey]; diff --git a/AppKit/CPPopUpButton.j b/AppKit/CPPopUpButton.j index 65c5edddb..d36c8a68d 100644 --- a/AppKit/CPPopUpButton.j +++ b/AppKit/CPPopUpButton.j @@ -706,10 +706,16 @@ var CPPopUpButtonArrowsImage = nil; - (CGRect)contentRectForBounds:(CGRect)bounds { - if ([self isBordered]) - return CGRectMake(3.0, 2.0, CGRectGetWidth(bounds) - 16.0, CGRectGetHeight(bounds) - 5.0); + var contentRect = [super contentRectForBounds:bounds]; - return bounds; + if ([self isBordered]) + { + contentRect.size.width -= 16.0; + + return contentRect; + } + + return contentRect; } @end