diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-03 20:08:25 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-03 20:08:25 -0400 |
| commit | 8c4cd789ca4dc69a56bf3327ff7ebbb5b88314be (patch) | |
| tree | fe52b1a8a55552d2ebcea3480442f5953374afd3 /redo/button_darwin.go | |
| parent | b6d07237b423b690570e105e5f0810d35693b0d0 (diff) | |
Migrated the Mac OS X backend to the new Control setup.
Diffstat (limited to 'redo/button_darwin.go')
| -rw-r--r-- | redo/button_darwin.go | 60 |
1 files changed, 44 insertions, 16 deletions
diff --git a/redo/button_darwin.go b/redo/button_darwin.go index e5a7f5b..1e6cf33 100644 --- a/redo/button_darwin.go +++ b/redo/button_darwin.go @@ -10,30 +10,36 @@ import ( import "C" type button struct { - *controlbase - clicked *event + _id C.id + clicked *event } -func finishNewButton(id C.id, text string) *button { +func newButton(text string) *button { ctext := C.CString(text) defer C.free(unsafe.Pointer(ctext)) b := &button{ - controlbase: newControl(id), + _id: C.newButton(), clicked: newEvent(), } - C.buttonSetText(b.id, ctext) - C.buttonSetDelegate(b.id, unsafe.Pointer(b)) + C.buttonSetText(b._id, ctext) + C.buttonSetDelegate(b._id, unsafe.Pointer(b)) return b } -func newButton(text string) *button { - return finishNewButton(C.newButton(), text) -} - func (b *button) OnClicked(e func()) { b.clicked.set(e) } +func (b *button) Text() string { + return C.GoString(C.buttonText(b._id)) +} + +func (b *button) SetText(text string) { + ctext := C.CString(text) + defer C.free(unsafe.Pointer(ctext)) + C.buttonSetText(b._id, ctext) +} + //export buttonClicked func buttonClicked(xb unsafe.Pointer) { b := (*button)(unsafe.Pointer(xb)) @@ -41,12 +47,34 @@ func buttonClicked(xb unsafe.Pointer) { println("button clicked") } -func (b *button) Text() string { - return C.GoString(C.buttonText(b.id)) +func (b *button) id() C.id { + return b._id } -func (b *button) SetText(text string) { - ctext := C.CString(text) - defer C.free(unsafe.Pointer(ctext)) - C.buttonSetText(b.id, ctext) +func (b *button) setParent(p *controlParent) { + basesetParent(b, p) +} + +func (b *button) containerShow() { + basecontainerShow(b) +} + +func (b *button) containerHide() { + basecontainerHide(b) +} + +func (b *button) allocate(x int, y int, width int, height int, d *sizing) []*allocation { + return baseallocate(b, x, y, width, height, d) +} + +func (b *button) preferredSize(d *sizing) (width, height int) { + return basepreferredSize(b, d) +} + +func (b *button) commitResize(a *allocation, d *sizing) { + basecommitResize(b, a, d) +} + +func (b *button) getAuxResizeInfo(d *sizing) { + basegetAuxResizeInfo(b, d) } |
