Renamed textField to textfield; this is just for the private implementation.
This commit is contained in:
parent
c460c11b65
commit
1badd53681
|
@ -42,7 +42,6 @@ func NewCheckbox(text string) Checkbox {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextField is a Control in which the user can enter a single line of text.
|
// TextField is a Control in which the user can enter a single line of text.
|
||||||
// TODO rename private implementations from textField to textfield
|
|
||||||
type TextField interface {
|
type TextField interface {
|
||||||
Control
|
Control
|
||||||
|
|
||||||
|
|
|
@ -9,52 +9,52 @@ import (
|
||||||
// #include "objc_darwin.h"
|
// #include "objc_darwin.h"
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
type textField struct {
|
type textfield struct {
|
||||||
_id C.id
|
_id C.id
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTextField() *textField {
|
func newTextField() *textfield {
|
||||||
return &textField{
|
return &textfield{
|
||||||
_id: C.newTextField(),
|
_id: C.newTextField(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPasswordField() *textField {
|
func newPasswordField() *textfield {
|
||||||
return &textField{
|
return &textfield{
|
||||||
_id: C.newPasswordField(),
|
_id: C.newPasswordField(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) Text() string {
|
func (t *textfield) Text() string {
|
||||||
return C.GoString(C.textFieldText(t._id))
|
return C.GoString(C.textFieldText(t._id))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) SetText(text string) {
|
func (t *textfield) SetText(text string) {
|
||||||
ctext := C.CString(text)
|
ctext := C.CString(text)
|
||||||
defer C.free(unsafe.Pointer(ctext))
|
defer C.free(unsafe.Pointer(ctext))
|
||||||
C.textFieldSetText(t._id, ctext)
|
C.textFieldSetText(t._id, ctext)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) id() C.id {
|
func (t *textfield) id() C.id {
|
||||||
return t._id
|
return t._id
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) setParent(p *controlParent) {
|
func (t *textfield) setParent(p *controlParent) {
|
||||||
basesetParent(t, p)
|
basesetParent(t, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
|
func (t *textfield) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
|
||||||
return baseallocate(t, x, y, width, height, d)
|
return baseallocate(t, x, y, width, height, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) preferredSize(d *sizing) (width, height int) {
|
func (t *textfield) preferredSize(d *sizing) (width, height int) {
|
||||||
return basepreferredSize(t, d)
|
return basepreferredSize(t, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) commitResize(a *allocation, d *sizing) {
|
func (t *textfield) commitResize(a *allocation, d *sizing) {
|
||||||
basecommitResize(t, a, d)
|
basecommitResize(t, a, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) getAuxResizeInfo(d *sizing) {
|
func (t *textfield) getAuxResizeInfo(d *sizing) {
|
||||||
basegetAuxResizeInfo(t, d)
|
basegetAuxResizeInfo(t, d)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,59 +13,59 @@ import (
|
||||||
// extern void checkboxToggled(GtkToggleButton *, gpointer);
|
// extern void checkboxToggled(GtkToggleButton *, gpointer);
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
type textField struct {
|
type textfield struct {
|
||||||
_widget *C.GtkWidget
|
_widget *C.GtkWidget
|
||||||
entry *C.GtkEntry
|
entry *C.GtkEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
func startNewTextField() *textField {
|
func startNewTextField() *textfield {
|
||||||
widget := C.gtk_entry_new()
|
widget := C.gtk_entry_new()
|
||||||
return &textField{
|
return &textfield{
|
||||||
_widget: widget,
|
_widget: widget,
|
||||||
entry: (*C.GtkEntry)(unsafe.Pointer(widget)),
|
entry: (*C.GtkEntry)(unsafe.Pointer(widget)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTextField() *textField {
|
func newTextField() *textfield {
|
||||||
return startNewTextField()
|
return startNewTextField()
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPasswordField() *textField {
|
func newPasswordField() *textfield {
|
||||||
t := startNewTextField()
|
t := startNewTextField()
|
||||||
C.gtk_entry_set_visibility(t.entry, C.FALSE)
|
C.gtk_entry_set_visibility(t.entry, C.FALSE)
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) Text() string {
|
func (t *textfield) Text() string {
|
||||||
return fromgstr(C.gtk_entry_get_text(t.entry))
|
return fromgstr(C.gtk_entry_get_text(t.entry))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) SetText(text string) {
|
func (t *textfield) SetText(text string) {
|
||||||
ctext := togstr(text)
|
ctext := togstr(text)
|
||||||
defer freegstr(ctext)
|
defer freegstr(ctext)
|
||||||
C.gtk_entry_set_text(t.entry, ctext)
|
C.gtk_entry_set_text(t.entry, ctext)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) widget() *C.GtkWidget {
|
func (t *textfield) widget() *C.GtkWidget {
|
||||||
return t._widget
|
return t._widget
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) setParent(p *controlParent) {
|
func (t *textfield) setParent(p *controlParent) {
|
||||||
basesetParent(t, p)
|
basesetParent(t, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
|
func (t *textfield) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
|
||||||
return baseallocate(t, x, y, width, height, d)
|
return baseallocate(t, x, y, width, height, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) preferredSize(d *sizing) (width, height int) {
|
func (t *textfield) preferredSize(d *sizing) (width, height int) {
|
||||||
return basepreferredSize(t, d)
|
return basepreferredSize(t, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) commitResize(a *allocation, d *sizing) {
|
func (t *textfield) commitResize(a *allocation, d *sizing) {
|
||||||
basecommitResize(t, a, d)
|
basecommitResize(t, a, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) getAuxResizeInfo(d *sizing) {
|
func (t *textfield) getAuxResizeInfo(d *sizing) {
|
||||||
basegetAuxResizeInfo(t, d)
|
basegetAuxResizeInfo(t, d)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,57 +5,57 @@ package ui
|
||||||
// #include "winapi_windows.h"
|
// #include "winapi_windows.h"
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
type textField struct {
|
type textfield struct {
|
||||||
_hwnd C.HWND
|
_hwnd C.HWND
|
||||||
_textlen C.LONG
|
_textlen C.LONG
|
||||||
}
|
}
|
||||||
|
|
||||||
var editclass = toUTF16("EDIT")
|
var editclass = toUTF16("EDIT")
|
||||||
|
|
||||||
func startNewTextField(style C.DWORD) *textField {
|
func startNewTextField(style C.DWORD) *textfield {
|
||||||
hwnd := C.newControl(editclass,
|
hwnd := C.newControl(editclass,
|
||||||
style | C.ES_AUTOHSCROLL | C.ES_LEFT | C.ES_NOHIDESEL | C.WS_TABSTOP,
|
style | C.ES_AUTOHSCROLL | C.ES_LEFT | C.ES_NOHIDESEL | C.WS_TABSTOP,
|
||||||
C.WS_EX_CLIENTEDGE) // WS_EX_CLIENTEDGE without WS_BORDER will show the canonical visual styles border (thanks to MindChild in irc.efnet.net/#winprog)
|
C.WS_EX_CLIENTEDGE) // WS_EX_CLIENTEDGE without WS_BORDER will show the canonical visual styles border (thanks to MindChild in irc.efnet.net/#winprog)
|
||||||
t := &textField{
|
t := &textfield{
|
||||||
_hwnd: hwnd,
|
_hwnd: hwnd,
|
||||||
}
|
}
|
||||||
C.controlSetControlFont(t._hwnd)
|
C.controlSetControlFont(t._hwnd)
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTextField() *textField {
|
func newTextField() *textfield {
|
||||||
return startNewTextField(0)
|
return startNewTextField(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPasswordField() *textField {
|
func newPasswordField() *textfield {
|
||||||
return startNewTextField(C.ES_PASSWORD)
|
return startNewTextField(C.ES_PASSWORD)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) Text() string {
|
func (t *textfield) Text() string {
|
||||||
return baseText(t)
|
return baseText(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) SetText(text string) {
|
func (t *textfield) SetText(text string) {
|
||||||
baseSetText(t, text)
|
baseSetText(t, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) hwnd() C.HWND {
|
func (t *textfield) hwnd() C.HWND {
|
||||||
return t._hwnd
|
return t._hwnd
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) textlen() C.LONG {
|
func (t *textfield) textlen() C.LONG {
|
||||||
return t._textlen
|
return t._textlen
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) settextlen(len C.LONG) {
|
func (t *textfield) settextlen(len C.LONG) {
|
||||||
t._textlen = len
|
t._textlen = len
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) setParent(p *controlParent) {
|
func (t *textfield) setParent(p *controlParent) {
|
||||||
basesetParent(t, p)
|
basesetParent(t, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
|
func (t *textfield) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
|
||||||
return baseallocate(t, x, y, width, height, d)
|
return baseallocate(t, x, y, width, height, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,14 +65,14 @@ const (
|
||||||
textfieldHeight = 14
|
textfieldHeight = 14
|
||||||
)
|
)
|
||||||
|
|
||||||
func (t *textField) preferredSize(d *sizing) (width, height int) {
|
func (t *textfield) preferredSize(d *sizing) (width, height int) {
|
||||||
return fromdlgunitsX(textfieldWidth, d), fromdlgunitsY(textfieldHeight, d)
|
return fromdlgunitsX(textfieldWidth, d), fromdlgunitsY(textfieldHeight, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) commitResize(a *allocation, d *sizing) {
|
func (t *textfield) commitResize(a *allocation, d *sizing) {
|
||||||
basecommitResize(t, a, d)
|
basecommitResize(t, a, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textField) getAuxResizeInfo(d *sizing) {
|
func (t *textfield) getAuxResizeInfo(d *sizing) {
|
||||||
basegetAuxResizeInfo(t, d)
|
basegetAuxResizeInfo(t, d)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue