From 6d93fce5b5eb26b78d003fc79cd0592f697d75e3 Mon Sep 17 00:00:00 2001
From: Pietro Gagliardi <pietro10@mac.com>
Date: Thu, 9 Apr 2015 13:01:23 -0400
Subject: [PATCH] Implemented uiCheckbox(Set)Checked() on Mac OS X.

---
 new/checkbox_darwin.m | 20 ++++++++++++++++++++
 new/test.c            |  2 +-
 new/ui.h              |  2 +-
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/new/checkbox_darwin.m b/new/checkbox_darwin.m
index a1fd61c..a07a4d0 100644
--- a/new/checkbox_darwin.m
+++ b/new/checkbox_darwin.m
@@ -76,3 +76,23 @@ void uiCheckboxOnToggled(uiControl *c, void (*f)(uiControl *, void *), void *dat
 	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];
+}
diff --git a/new/test.c b/new/test.c
index a09e459..e4579b7 100644
--- a/new/test.c
+++ b/new/test.c
@@ -71,7 +71,7 @@ uiControl *spaced;
 static void setSpaced(uiControl *c, void *data)
 {
 	// TODO
-	printf("toggled %d\n", uiCheckboxCheked(spaced));
+	printf("toggled %d\n", uiCheckboxChecked(spaced));
 }
 
 // these will also be used to test if setting checks will trigger events
diff --git a/new/ui.h b/new/ui.h
index ee2c121..d6b9891 100644
--- a/new/ui.h
+++ b/new/ui.h
@@ -51,6 +51,6 @@ void uiCheckboxSetText(uiControl *, const char *);
 void uiCheckboxOnToggled(uiControl *, void (*)(uiControl *, void *), void *);
 int uiCheckboxChecked(uiControl *);
 // TODO should this trigger an event?
-void uiChekboxSetChecked(uiControl *, int);
+void uiCheckboxSetChecked(uiControl *, int);
 
 #endif