summaryrefslogtreecommitdiff
path: root/newctrl/checkbox_darwin.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-10-18 15:44:56 -0400
committerPietro Gagliardi <[email protected]>2014-10-18 15:44:56 -0400
commit0351cf27fefd59148eee3f5f98ecfbaef2b607ac (patch)
tree2302611a0c7e388b38bd6c000aa231aacfdfee02 /newctrl/checkbox_darwin.go
parentfd9e614faaae390a42f7dc39e63d0197ea9d7efa (diff)
Migrated the Mac OS X basic controls.
Diffstat (limited to 'newctrl/checkbox_darwin.go')
-rw-r--r--newctrl/checkbox_darwin.go55
1 files changed, 55 insertions, 0 deletions
diff --git a/newctrl/checkbox_darwin.go b/newctrl/checkbox_darwin.go
new file mode 100644
index 0000000..741b163
--- /dev/null
+++ b/newctrl/checkbox_darwin.go
@@ -0,0 +1,55 @@
+// 16 july 2014
+
+package ui
+
+import (
+ "unsafe"
+)
+
+// #include "objc_darwin.h"
+import "C"
+
+type checkbox struct {
+ *controlSingleObject
+ toggled *event
+}
+
+func newCheckbox(text string) *checkbox {
+ ctext := C.CString(text)
+ defer C.free(unsafe.Pointer(ctext))
+ c := &checkbox{
+ controlSingleObject: newControlSingleObject(C.newCheckbox()),
+ toggled: newEvent(),
+ }
+ C.buttonSetText(c._id, ctext)
+ C.checkboxSetDelegate(c._id, unsafe.Pointer(c))
+ return c
+}
+
+func (c *checkbox) OnToggled(e func()) {
+ c.toggled.set(e)
+}
+
+func (c *checkbox) Text() string {
+ return C.GoString(C.buttonText(c._id))
+}
+
+func (c *checkbox) SetText(text string) {
+ ctext := C.CString(text)
+ defer C.free(unsafe.Pointer(ctext))
+ C.buttonSetText(c._id, ctext)
+}
+
+func (c *checkbox) Checked() bool {
+ return fromBOOL(C.checkboxChecked(c._id))
+}
+
+func (c *checkbox) SetChecked(checked bool) {
+ C.checkboxSetChecked(c._id, toBOOL(checked))
+}
+
+//export checkboxToggled
+func checkboxToggled(xc unsafe.Pointer) {
+ c := (*checkbox)(unsafe.Pointer(xc))
+ c.toggled.fire()
+}