diff options
| author | Pietro Gagliardi <[email protected]> | 2015-04-16 13:51:46 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-04-16 13:51:46 -0400 |
| commit | 89931668a56b0b12edcf4e77423313f5917e6bb0 (patch) | |
| tree | 3d55fb168021d4f4d72b81921939946d2dae692b | |
| parent | bb00796956f5ca0f91904b74e27eee523b416306 (diff) | |
Migrated darwin/checkbox.m.
| -rw-r--r-- | new/darwin/checkbox.m | 79 |
1 files changed, 44 insertions, 35 deletions
diff --git a/new/darwin/checkbox.m b/new/darwin/checkbox.m index ca52389..42ea833 100644 --- a/new/darwin/checkbox.m +++ b/new/darwin/checkbox.m @@ -2,8 +2,8 @@ #import "uipriv_darwin.h" @interface uiCheckboxNSButton : NSButton -@property uiControl *uiC; -@property void (*uiOnToggled)(uiControl *, void *); +@property uiCheckbox *uiC; +@property void (*uiOnToggled)(uiCheckbox *, void *); @property void *uiOnToggledData; @end @@ -25,74 +25,83 @@ @end -static void defaultOnToggled(uiControl *c, void *data) +static void defaultOnToggled(uiCheckbox *c, void *data) { // do nothing } -uiControl *uiNewCheckbox(const char *text) +static char *checkboxText(uiCheckbox *c) { - 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); + cc = (uiCheckboxNSButton *) uiControlHandle(uiControl(c)); return uiDarwinNSStringToText([cc title]); } -void uiCheckboxSetText(uiControl *c, const char *text) +static void checkboxSetText(uiCheckbox *c, const char *text) { uiCheckboxNSButton *cc; - cc = (uiCheckboxNSButton *) uiControlHandle(c); + cc = (uiCheckboxNSButton *) uiControlHandle(uiControl(c)); [cc setTitle:toNSString(text)]; } -void uiCheckboxOnToggled(uiControl *c, void (*f)(uiControl *, void *), void *data) +static void checkboxOnToggled(uiCheckbox *c, void (*f)(uiCheckbox *, void *), void *data) { uiCheckboxNSButton *cc; - cc = (uiCheckboxNSButton *) uiControlHandle(c); + cc = (uiCheckboxNSButton *) uiControlHandle(uiCheckbox(c)); cc.uiOnToggled = f; cc.uiOnToggledData = data; } -int uiCheckboxChecked(uiControl *c) +static int checkboxChecked(uiCheckbox *c) { uiCheckboxNSButton *cc; - cc = (uiCheckboxNSButton *) uiControlHandle(c); + cc = (uiCheckboxNSButton *) uiControlHandle(uiControl(c)); return [cc state] == NSOnState; } -void uiCheckboxSetChecked(uiControl *c, int checked) +static void checkboxSetChecked(uiCheckbox *c, int checked) { uiCheckboxNSButton *cc; NSInteger state; - cc = (uiCheckboxNSButton *) uiControlHandle(c); + 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(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; +} |
