add size to fit for buttons. Closes #34.

This commit is contained in:
Ross Boucher committed 2009-05-05 22:10:00 -07:00
1 parent 81d23aafab
commit ae8fd0c2d4
2 files changed
+20 -2

No files matched your search

+14 -2
View File
@@ -125,8 +125,8 @@ var _CPButtonClassName = nil,
+ (id)themedAttributes
{
return [CPDictionary dictionaryWithObjects:[_CGInsetMakeZero(), _CGInsetMakeZero(), nil]
forKeys:[@"bezel-inset", @"content-inset", @"bezel-color"]];
return [CPDictionary dictionaryWithObjects:[_CGInsetMakeZero(), _CGInsetMakeZero(), nil, 24.0]
forKeys:[@"bezel-inset", @"content-inset", @"bezel-color", @"default-height"]];
}
- (id)initWithFrame:(CGRect)aFrame
@@ -374,6 +374,18 @@ var _CPButtonClassName = nil,
return bounds;
}
/*!
Adjust the size of the button to fit the title and surrounding button image.
*/
- (void)sizeToFit
{
var size = [([self title] || " ") sizeWithFont:[self font]],
contentInset = [self currentValueForThemedAttributeName:@"content-inset"],
defaultHeight = [self currentValueForThemedAttributeName:@"default-height"];
[self setFrameSize:CGSizeMake(size.width + contentInset.left + contentInset.right, defaultHeight)];
}
- (CGRect)rectForEphemeralSubviewNamed:(CPString)aName
{
if (aName === "bezel-view")
+6
View File
@@ -208,3 +208,9 @@ function CGPointFromEvent(anEvent)
{
return _CGPointMake(anEvent.clientX, anEvent.clientY);
}
function CPStringFromInset(anInset)
{
return anInset.top+" "+anInset.left+" "+anInset.bottom+" "+anInset.right;
}