diff options
| author | Pietro Gagliardi <[email protected]> | 2015-04-16 20:33:28 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-04-16 20:33:28 -0400 |
| commit | e34c561ed5bedeb180437ec165882b98d70d38c1 (patch) | |
| tree | d095e5db16d7a23e883526c8c1d3c524639c97cf /new/darwin/checkbox.m | |
| parent | de9d72299fb89a8b6cdc8963cd6b6ae708a81e80 (diff) | |
Split the rewrite into a new repository.
Diffstat (limited to 'new/darwin/checkbox.m')
| -rw-r--r-- | new/darwin/checkbox.m | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/new/darwin/checkbox.m b/new/darwin/checkbox.m deleted file mode 100644 index a7ccfb3..0000000 --- a/new/darwin/checkbox.m +++ /dev/null @@ -1,107 +0,0 @@ -// 7 april 2015 -#import "uipriv_darwin.h" - -@interface uiCheckboxNSButton : NSButton -@property uiCheckbox *uiC; -@property void (*uiOnToggled)(uiCheckbox *, void *); -@property void *uiOnToggledData; -@end - -@implementation uiCheckboxNSButton - -- (void)viewDidMoveToSuperview -{ - if (uiDarwinControlFreeWhenAppropriate(uiControl(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(uiCheckbox *c, void *data) -{ - // do nothing -} - -static char *checkboxText(uiCheckbox *c) -{ - uiCheckboxNSButton *cc; - - cc = (uiCheckboxNSButton *) uiControlHandle(uiControl(c)); - return uiDarwinNSStringToText([cc title]); -} - -static void checkboxSetText(uiCheckbox *c, const char *text) -{ - uiCheckboxNSButton *cc; - - cc = (uiCheckboxNSButton *) uiControlHandle(uiControl(c)); - [cc setTitle:toNSString(text)]; -} - -static void checkboxOnToggled(uiCheckbox *c, void (*f)(uiCheckbox *, void *), void *data) -{ - uiCheckboxNSButton *cc; - - cc = (uiCheckboxNSButton *) uiControlHandle(uiControl(c)); - cc.uiOnToggled = f; - cc.uiOnToggledData = data; -} - -static int checkboxChecked(uiCheckbox *c) -{ - uiCheckboxNSButton *cc; - - cc = (uiCheckboxNSButton *) uiControlHandle(uiControl(c)); - return [cc state] == NSOnState; -} - -static void checkboxSetChecked(uiCheckbox *c, int checked) -{ - uiCheckboxNSButton *cc; - NSInteger state; - - cc = (uiCheckboxNSButton *) uiControlHandle(uiControl(c)); - state = NSOnState; - if (!checked) - state = NSOffState; - [cc setState:state]; -} - -uiCheckbox *uiNewCheckbox(const char *text) -{ - uiCheckbox *c; - uiCheckboxNSButton *cc; - - c = uiNew(uiCheckbox); - - uiDarwinNewControl(uiControl(c), [uiCheckboxNSButton class], NO, NO); - cc = (uiCheckboxNSButton *) uiControlHandle(uiControl(c)); - - [cc setTitle:toNSString(text)]; - [cc setButtonType:NSSwitchButton]; - [cc setBordered:NO]; - setStandardControlFont((NSControl *) cc); - - [cc setTarget:cc]; - [cc setAction:@selector(uiCheckboxToggled:)]; - - cc.uiOnToggled = defaultOnToggled; - - uiCheckbox(c)->Text = checkboxText; - uiCheckbox(c)->SetText = checkboxSetText; - uiCheckbox(c)->OnToggled = checkboxOnToggled; - uiCheckbox(c)->Checked = checkboxChecked; - uiCheckbox(c)->SetChecked = checkboxSetChecked; - - cc.uiC = c; - - return cc.uiC; -} |
