2014-08-02 21:35:58 -05:00
|
|
|
// 16 july 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
// #include "objc_darwin.h"
|
|
|
|
import "C"
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
type textfield struct {
|
2014-08-03 19:08:25 -05:00
|
|
|
_id C.id
|
2014-08-02 21:35:58 -05:00
|
|
|
}
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func newTextField() *textfield {
|
|
|
|
return &textfield{
|
2014-08-03 19:08:25 -05:00
|
|
|
_id: C.newTextField(),
|
2014-08-02 21:35:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func newPasswordField() *textfield {
|
|
|
|
return &textfield{
|
2014-08-03 19:08:25 -05:00
|
|
|
_id: C.newPasswordField(),
|
|
|
|
}
|
2014-08-02 21:35:58 -05:00
|
|
|
}
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func (t *textfield) Text() string {
|
2014-08-03 19:08:25 -05:00
|
|
|
return C.GoString(C.textFieldText(t._id))
|
2014-08-02 21:35:58 -05:00
|
|
|
}
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func (t *textfield) SetText(text string) {
|
2014-08-02 21:35:58 -05:00
|
|
|
ctext := C.CString(text)
|
|
|
|
defer C.free(unsafe.Pointer(ctext))
|
2014-08-03 19:08:25 -05:00
|
|
|
C.textFieldSetText(t._id, ctext)
|
|
|
|
}
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func (t *textfield) id() C.id {
|
2014-08-03 19:08:25 -05:00
|
|
|
return t._id
|
|
|
|
}
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func (t *textfield) setParent(p *controlParent) {
|
2014-08-03 19:08:25 -05:00
|
|
|
basesetParent(t, p)
|
|
|
|
}
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func (t *textfield) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
|
2014-08-03 19:08:25 -05:00
|
|
|
return baseallocate(t, x, y, width, height, d)
|
|
|
|
}
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func (t *textfield) preferredSize(d *sizing) (width, height int) {
|
2014-08-03 19:08:25 -05:00
|
|
|
return basepreferredSize(t, d)
|
|
|
|
}
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func (t *textfield) commitResize(a *allocation, d *sizing) {
|
2014-08-03 19:08:25 -05:00
|
|
|
basecommitResize(t, a, d)
|
|
|
|
}
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func (t *textfield) getAuxResizeInfo(d *sizing) {
|
2014-08-03 19:08:25 -05:00
|
|
|
basegetAuxResizeInfo(t, d)
|
2014-08-02 21:35:58 -05:00
|
|
|
}
|