Skip to content

Commit

Permalink
Switch from #ifdef NEW_RADIO to OLD_RADIO for #6
Browse files Browse the repository at this point in the history
It's good enough to be the default considering how miserable the old
radio behaviour was. Now we have groups that work and buttons that don't
spit out invalid surface error messages on the console.

It's not completely fixed until I have images with a little white dot
in the blue circle.
  • Loading branch information
Cecil committed Mar 24, 2015
1 parent 0802135 commit 59124b5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 36 deletions.
2 changes: 1 addition & 1 deletion shoes/native/cocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}
@end

#ifdef NEW_RADIO
#ifndef OLD_RADIO
@interface ShoesRadioButton : NSButton
{
VALUE object;
Expand Down
53 changes: 18 additions & 35 deletions shoes/native/cocoa.m
Original file line number Diff line number Diff line change
Expand Up @@ -349,23 +349,24 @@ -(IBAction)handleClick: (id)sender
}
@end

#ifdef NEW_RADIO
#ifndef OLD_RADIO
@implementation ShoesRadioButton
- (id)initWithType: (NSButtonType)t andObject: (VALUE)o
{
if ((self = [super init]))
{
object = o;
[self setButtonType: NSSwitchButton]; // checkbox for now
[self setBezelStyle: NSRoundedBezelStyle];
[self setButtonType: NSPushOnPushOffButton]; // checkbox for now
[self setImagePosition: NSImageOnly];
[self setBezelStyle: NSCircularBezelStyle];
[self setTarget: self];
[self setAction: @selector(handleClick:)];
}
return self;
}
-(IBAction)handleClick: (id)sender
{
NSLog(@"radio button handler called on %lx", object);
//NSLog(@"radio button handler called on %lx", object);
shoes_button_send_click(object);
}
@end
Expand Down Expand Up @@ -1417,54 +1418,36 @@ void shoes_cairo_destroy(shoes_canvas *canvas)
VALUE
shoes_native_check_get(SHOES_CONTROL_REF ref)
{
#ifdef NEW_RADIO
if ([ref isKindOfClass:[NSMatrix class]])
{
NSCell *contents = [ref cellAtRow:(NSInteger) 0
column:(NSInteger) 0];
int state = [contents state];
NSLog(@"matrix get %i", state);
return state == NSOnState ? Qtrue : Qfalse;
}
#endif
return [(ShoesButton *)ref state] == NSOnState ? Qtrue : Qfalse;
}

void
shoes_native_check_set(SHOES_CONTROL_REF ref, int on)
{
NSLog(@"matrix set to %i", on != 0);
#ifdef NEW_RADIO
if ([ref isKindOfClass:[NSMatrix class]])
{
[ref setState:(NSInteger) on != 0
atRow:(NSInteger)0
column:(NSInteger)0 ];
return;
}
#endif
COCOA_DO([(ShoesButton *)ref setState: on ? NSOnState : NSOffState]);
}

SHOES_CONTROL_REF
shoes_native_radio(VALUE self, shoes_canvas *canvas, shoes_place *place, VALUE attr, VALUE group)
{
INIT;
#ifdef NEW_RADIO
NSLog(@"shoes_native_radio self: %i, %lx", TYPE(self), self);
if (NIL_P(group))
NSLog(@"group: NIL");
else
NSLog(@"group: %lx", group);
ShoesRadioButton *button = [[ShoesRadioButton alloc] initWithType: NSSwitchButton
andObject: self];
RELEASE;
return (NSControl *)button;
#else
#ifdef OLD_RADIO
ShoesButton *button = [[ShoesButton alloc] initWithType: NSRadioButton
andObject: self];
RELEASE;
return (NSControl *)button;
#else
/*
NSLog(@"shoes_native_radio self: %i, %lx", TYPE(self), self);
if (NIL_P(group))
NSLog(@"group: NIL");
else
NSLog(@"group: %lx", group);
*/
ShoesRadioButton *button = [[ShoesRadioButton alloc] initWithType: NSSwitchButton
andObject: self];
RELEASE;
return (NSControl *)button;
#endif
}

Expand Down

0 comments on commit 59124b5

Please sign in to comment.