diff options
| author | Pietro Gagliardi <[email protected]> | 2014-07-08 16:47:28 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-07-08 16:47:28 -0400 |
| commit | b4357db4be6688c67e522b637f100ceecc4a9680 (patch) | |
| tree | 4b631edcb1e1fed7e6287b41b63a6a08d5aa3a45 /redo/window_darwin.go | |
| parent | 60d0953fe9f16726958f709007402ea4c8b89fc6 (diff) | |
Added the beginning of the Mac OS X code.
Diffstat (limited to 'redo/window_darwin.go')
| -rw-r--r-- | redo/window_darwin.go | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/redo/window_darwin.go b/redo/window_darwin.go new file mode 100644 index 0000000..c6d9585 --- /dev/null +++ b/redo/window_darwin.go @@ -0,0 +1,118 @@ +// 8 july 2014 + +package ui + +import ( + "unsafe" +) + +// #include "objc_darwin.h" +import "C" + +type window struct { + id C.id + + closing *event +} + +func newWindow(title string, width int, height int) *Request { + c := make(chan interface{}) + return &Request{ + op: func() { + id := C.newWindow(C.intptr_t(width), C.intptr_t(height)) + ctitle := C.CString(title) + defer C.free(unsafe.Pointer(ctitle)) + C.windowSetTitle(id, ctitle) + C.windowSetAppDelegate(id) + c <- &window{ + id: id, + closing: newEvent(), + } + }, + resp: c, + } +} + +func (w *window) SetControl(control Control) *Request { + c := make(chan interface{}) + return &Request{ + op: func() { + // TODO unparent + // TODO reparent + c <- struct{}{} + }, + resp: c, + } +} + +func (w *window) Title() *Request { + c := make(chan interface{}) + return &Request{ + op: func() { + c <- C.GoString(C.windowTitle(w.id)) + }, + resp: c, + } +} + +func (w *window) SetTitle(title string) *Request { + c := make(chan interface{}) + return &Request{ + op: func() { + ctitle := C.CString(title) + defer C.free(unsafe.Pointer(ctitle)) + C.windowSetTitle(w.id, ctitle) + c <- struct{}{} + }, + resp: c, + } +} + +func (w *window) Show() *Request { + c := make(chan interface{}) + return &Request{ + op: func() { + C.windowShow(w.id) + c <- struct{}{} + }, + resp: c, + } +} + +func (w *window) Hide() *Request { + c := make(chan interface{}) + return &Request{ + op: func() { + C.windowHide(w.id) + c <- struct{}{} + }, + resp: c, + } +} + +func (w *window) Close() *Request { + c := make(chan interface{}) + return &Request{ + op: func() { + C.windowClose(w.id) + c <- struct{}{} + }, + resp: c, + } +} + +func (w *window) OnClosing(e func(c Doer) bool) *Request { + c := make(chan interface{}) + return &Request{ + op: func() { + w.closing.setbool(e) + c <- struct{}{} + }, + resp: c, + } +} + +// TODO windowClosing + +// TODO for testing +func newButton(string) *Request { return nil } |
