Correctly convert NSButtons set as checkboxs and radiogroups to CPCheckBoxes and CPRadios.

Closes #365.
This commit is contained in:
Ross Boucher
2010-02-12 20:05:34 -08:00
parent 24ecf31bd3
commit 0b22b1d022
+40 -4
View File
@@ -46,12 +46,11 @@ _CPButtonBezelStyleHeights[CPHUDBezelStyle] = 20;
{
var cell = [aCoder decodeObjectForKey:@"NSCell"];
_controlSize = CPRegularControlSize;
_title = [cell title];
if (![self NS_isCheckBox] && ![self NS_isRadio])
{
_controlSize = CPRegularControlSize;
_title = [cell title];
[self setBordered:[cell isBordered]];
_bezelStyle = [cell bezelStyle];
@@ -101,7 +100,18 @@ _CPButtonBezelStyleHeights[CPHUDBezelStyle] = 20;
}
}
else
{
if (![self isKindOfClass:CPCheckBox] && ![self isKindOfClass:CPRadio])
{
if ([self NS_isCheckBox])
return [[CPCheckBox alloc] NS_initWithCoder:aCoder];
else
return [[CPRadio alloc] NS_initWithCoder:aCoder];
}
[self setBordered:YES];
self._title = [cell title];
}
}
return self;
@@ -119,6 +129,32 @@ _CPButtonBezelStyleHeights[CPHUDBezelStyle] = 20;
@end
@implementation CPRadio (NS)
- (BOOL)NS_isRadio
{
return YES;
}
- (id)NS_initWithCoder:(CPCoder)aCoder
{
if (self = [super NS_initWithCoder:aCoder])
_radioGroup = [CPRadioGroup new];
return self;
}
@end
@implementation CPCheckBox (NS)
- (BOOL)NS_isCheckBox
{
return YES;
}
@end
@implementation NSButton : CPButton
{
BOOL _isCheckBox @accessors(readonly, getter=NS_isCheckBox);