Renamed textField to textfield; this is just for the private implementation.

This commit is contained in:
Pietro Gagliardi 2014-08-05 17:46:42 -04:00
parent c460c11b65
commit 1badd53681
4 changed files with 41 additions and 42 deletions

View File

@ -42,7 +42,6 @@ func NewCheckbox(text string) Checkbox {
}
// 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 {
Control

View File

@ -9,52 +9,52 @@ import (
// #include "objc_darwin.h"
import "C"
type textField struct {
type textfield struct {
_id C.id
}
func newTextField() *textField {
return &textField{
func newTextField() *textfield {
return &textfield{
_id: C.newTextField(),
}
}
func newPasswordField() *textField {
return &textField{
func newPasswordField() *textfield {
return &textfield{
_id: C.newPasswordField(),
}
}
func (t *textField) Text() string {
func (t *textfield) Text() string {
return C.GoString(C.textFieldText(t._id))
}
func (t *textField) SetText(text string) {
func (t *textfield) SetText(text string) {
ctext := C.CString(text)
defer C.free(unsafe.Pointer(ctext))
C.textFieldSetText(t._id, ctext)
}
func (t *textField) id() C.id {
func (t *textfield) id() C.id {
return t._id
}
func (t *textField) setParent(p *controlParent) {
func (t *textfield) setParent(p *controlParent) {
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)
}
func (t *textField) preferredSize(d *sizing) (width, height int) {
func (t *textfield) preferredSize(d *sizing) (width, height int) {
return basepreferredSize(t, d)
}
func (t *textField) commitResize(a *allocation, d *sizing) {
func (t *textfield) commitResize(a *allocation, d *sizing) {
basecommitResize(t, a, d)
}
func (t *textField) getAuxResizeInfo(d *sizing) {
func (t *textfield) getAuxResizeInfo(d *sizing) {
basegetAuxResizeInfo(t, d)
}

View File

@ -13,59 +13,59 @@ import (
// extern void checkboxToggled(GtkToggleButton *, gpointer);
import "C"
type textField struct {
type textfield struct {
_widget *C.GtkWidget
entry *C.GtkEntry
}
func startNewTextField() *textField {
func startNewTextField() *textfield {
widget := C.gtk_entry_new()
return &textField{
return &textfield{
_widget: widget,
entry: (*C.GtkEntry)(unsafe.Pointer(widget)),
}
}
func newTextField() *textField {
func newTextField() *textfield {
return startNewTextField()
}
func newPasswordField() *textField {
func newPasswordField() *textfield {
t := startNewTextField()
C.gtk_entry_set_visibility(t.entry, C.FALSE)
return t
}
func (t *textField) Text() string {
func (t *textfield) Text() string {
return fromgstr(C.gtk_entry_get_text(t.entry))
}
func (t *textField) SetText(text string) {
func (t *textfield) SetText(text string) {
ctext := togstr(text)
defer freegstr(ctext)
C.gtk_entry_set_text(t.entry, ctext)
}
func (t *textField) widget() *C.GtkWidget {
func (t *textfield) widget() *C.GtkWidget {
return t._widget
}
func (t *textField) setParent(p *controlParent) {
func (t *textfield) setParent(p *controlParent) {
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)
}
func (t *textField) preferredSize(d *sizing) (width, height int) {
func (t *textfield) preferredSize(d *sizing) (width, height int) {
return basepreferredSize(t, d)
}
func (t *textField) commitResize(a *allocation, d *sizing) {
func (t *textfield) commitResize(a *allocation, d *sizing) {
basecommitResize(t, a, d)
}
func (t *textField) getAuxResizeInfo(d *sizing) {
func (t *textfield) getAuxResizeInfo(d *sizing) {
basegetAuxResizeInfo(t, d)
}

View File

@ -5,57 +5,57 @@ package ui
// #include "winapi_windows.h"
import "C"
type textField struct {
type textfield struct {
_hwnd C.HWND
_textlen C.LONG
}
var editclass = toUTF16("EDIT")
func startNewTextField(style C.DWORD) *textField {
func startNewTextField(style C.DWORD) *textfield {
hwnd := C.newControl(editclass,
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)
t := &textField{
t := &textfield{
_hwnd: hwnd,
}
C.controlSetControlFont(t._hwnd)
return t
}
func newTextField() *textField {
func newTextField() *textfield {
return startNewTextField(0)
}
func newPasswordField() *textField {
func newPasswordField() *textfield {
return startNewTextField(C.ES_PASSWORD)
}
func (t *textField) Text() string {
func (t *textfield) Text() string {
return baseText(t)
}
func (t *textField) SetText(text string) {
func (t *textfield) SetText(text string) {
baseSetText(t, text)
}
func (t *textField) hwnd() C.HWND {
func (t *textfield) hwnd() C.HWND {
return t._hwnd
}
func (t *textField) textlen() C.LONG {
func (t *textfield) textlen() C.LONG {
return t._textlen
}
func (t *textField) settextlen(len C.LONG) {
func (t *textfield) settextlen(len C.LONG) {
t._textlen = len
}
func (t *textField) setParent(p *controlParent) {
func (t *textfield) setParent(p *controlParent) {
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)
}
@ -65,14 +65,14 @@ const (
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)
}
func (t *textField) commitResize(a *allocation, d *sizing) {
func (t *textfield) commitResize(a *allocation, d *sizing) {
basecommitResize(t, a, d)
}
func (t *textField) getAuxResizeInfo(d *sizing) {
func (t *textfield) getAuxResizeInfo(d *sizing) {
basegetAuxResizeInfo(t, d)
}