From 518a5ddbf15d50a254c732a80d5907ef8878abe0 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Wed, 15 Apr 2015 18:49:45 -0400 Subject: Split all OS backends into their own folders. --- new/checkbox_darwin.m | 98 --------------------------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 new/checkbox_darwin.m (limited to 'new/checkbox_darwin.m') diff --git a/new/checkbox_darwin.m b/new/checkbox_darwin.m deleted file mode 100644 index ca52389..0000000 --- a/new/checkbox_darwin.m +++ /dev/null @@ -1,98 +0,0 @@ -// 7 april 2015 -#import "uipriv_darwin.h" - -@interface uiCheckboxNSButton : NSButton -@property uiControl *uiC; -@property void (*uiOnToggled)(uiControl *, void *); -@property void *uiOnToggledData; -@end - -@implementation uiCheckboxNSButton - -- (void)viewDidMoveToSuperview -{ - if (uiDarwinControlFreeWhenAppropriate(self.uiC, [self superview])) { - [self setTarget:nil]; - self.uiC = NULL; - } - [super viewDidMoveToSuperview]; -} - -- (IBAction)uiCheckboxToggled:(id)sender -{ - (*(self.uiOnToggled))(self.uiC, self.uiOnToggledData); -} - -@end - -static void defaultOnToggled(uiControl *c, void *data) -{ - // do nothing -} - -uiControl *uiNewCheckbox(const char *text) -{ - uiControl *c; - uiCheckboxNSButton *cc; - - c = uiDarwinNewControl([uiCheckboxNSButton class], NO, NO); - cc = (uiCheckboxNSButton *) uiControlHandle(c); - cc.uiC = c; - - [cc setTitle:toNSString(text)]; - [cc setButtonType:NSSwitchButton]; - [cc setBordered:NO]; - setStandardControlFont((NSControl *) cc); - - [cc setTarget:cc]; - [cc setAction:@selector(uiCheckboxToggled:)]; - - cc.uiOnToggled = defaultOnToggled; - - return cc.uiC; -} - -char *uiCheckboxText(uiControl *c) -{ - uiCheckboxNSButton *cc; - - cc = (uiCheckboxNSButton *) uiControlHandle(c); - return uiDarwinNSStringToText([cc title]); -} - -void uiCheckboxSetText(uiControl *c, const char *text) -{ - uiCheckboxNSButton *cc; - - cc = (uiCheckboxNSButton *) uiControlHandle(c); - [cc setTitle:toNSString(text)]; -} - -void uiCheckboxOnToggled(uiControl *c, void (*f)(uiControl *, void *), void *data) -{ - uiCheckboxNSButton *cc; - - cc = (uiCheckboxNSButton *) uiControlHandle(c); - cc.uiOnToggled = f; - cc.uiOnToggledData = data; -} - -int uiCheckboxChecked(uiControl *c) -{ - uiCheckboxNSButton *cc; - - cc = (uiCheckboxNSButton *) uiControlHandle(c); - return [cc state] == NSOnState; -} - -void uiCheckboxSetChecked(uiControl *c, int checked) -{ - uiCheckboxNSButton *cc; - NSInteger state; - - cc = (uiCheckboxNSButton *) uiControlHandle(c); - state = NSOnState; - if (!checked) - state = NSOffState; - [cc setState:state]; -} -- cgit v1.2.3