2014-08-02 21:35:58 -05:00
|
|
|
// +build !windows,!darwin
|
|
|
|
|
|
|
|
// 7 july 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
// #include "gtk_unix.h"
|
|
|
|
// extern void buttonClicked(GtkButton *, gpointer);
|
|
|
|
// extern void checkboxToggled(GtkToggleButton *, gpointer);
|
|
|
|
import "C"
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
type textfield struct {
|
2014-08-03 15:28:21 -05:00
|
|
|
_widget *C.GtkWidget
|
2014-08-02 21:35:58 -05:00
|
|
|
entry *C.GtkEntry
|
|
|
|
}
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func startNewTextField() *textfield {
|
2014-08-03 15:28:21 -05:00
|
|
|
widget := C.gtk_entry_new()
|
2014-08-05 16:46:42 -05:00
|
|
|
return &textfield{
|
2014-08-03 15:28:21 -05:00
|
|
|
_widget: widget,
|
|
|
|
entry: (*C.GtkEntry)(unsafe.Pointer(widget)),
|
2014-08-02 21:35:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func newTextField() *textfield {
|
2014-08-02 21:35:58 -05:00
|
|
|
return startNewTextField()
|
|
|
|
}
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func newPasswordField() *textfield {
|
2014-08-02 21:35:58 -05:00
|
|
|
t := startNewTextField()
|
|
|
|
C.gtk_entry_set_visibility(t.entry, C.FALSE)
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func (t *textfield) Text() string {
|
2014-08-02 21:35:58 -05:00
|
|
|
return fromgstr(C.gtk_entry_get_text(t.entry))
|
|
|
|
}
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func (t *textfield) SetText(text string) {
|
2014-08-02 21:35:58 -05:00
|
|
|
ctext := togstr(text)
|
|
|
|
defer freegstr(ctext)
|
|
|
|
C.gtk_entry_set_text(t.entry, ctext)
|
|
|
|
}
|
2014-08-03 15:28:21 -05:00
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func (t *textfield) widget() *C.GtkWidget {
|
2014-08-03 15:28:21 -05:00
|
|
|
return t._widget
|
|
|
|
}
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func (t *textfield) setParent(p *controlParent) {
|
2014-08-03 15:28:21 -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 15:28:21 -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 15:28:21 -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 15:28:21 -05:00
|
|
|
basecommitResize(t, a, d)
|
|
|
|
}
|
|
|
|
|
2014-08-05 16:46:42 -05:00
|
|
|
func (t *textfield) getAuxResizeInfo(d *sizing) {
|
2014-08-03 19:33:19 -05:00
|
|
|
basegetAuxResizeInfo(t, d)
|
2014-08-03 15:28:21 -05:00
|
|
|
}
|