Converted the new Windows Control code to use interfaces instead of controlbase, just like the GTK+ and Mac OS X backends do now.

This commit is contained in:
Pietro Gagliardi 2014-08-03 21:52:21 -04:00
parent 0fb45ba84d
commit 2c107d7057
9 changed files with 165 additions and 112 deletions

View File

@ -3,7 +3,7 @@
#include "winapi_windows.h" #include "winapi_windows.h"
#include "_cgo_export.h" #include "_cgo_export.h"
HWND newWidget(LPWSTR class, DWORD style, DWORD extstyle) HWND newControl(LPWSTR class, DWORD style, DWORD extstyle)
{ {
HWND hwnd; HWND hwnd;

View File

@ -10,23 +10,24 @@ import (
import "C" import "C"
type button struct { type button struct {
*controlbase _hwnd C.HWND
clicked *event _textlen C.LONG
clicked *event
} }
var buttonclass = toUTF16("BUTTON") var buttonclass = toUTF16("BUTTON")
func newButton(text string) *button { func newButton(text string) *button {
c := newControl(buttonclass, hwnd := C.newControl(buttonclass,
C.BS_PUSHBUTTON | C.WS_TABSTOP, C.BS_PUSHBUTTON | C.WS_TABSTOP,
0) 0)
c.setText(text)
C.controlSetControlFont(c.hwnd)
b := &button{ b := &button{
controlbase: c, _hwnd: hwnd,
clicked: newEvent(), clicked: newEvent(),
} }
C.setButtonSubclass(b.hwnd, unsafe.Pointer(b)) b.SetText(text)
C.controlSetControlFont(b._hwnd)
C.setButtonSubclass(b._hwnd, unsafe.Pointer(b))
return b return b
} }
@ -35,11 +36,11 @@ func (b *button) OnClicked(e func()) {
} }
func (b *button) Text() string { func (b *button) Text() string {
return b.text() return baseText(b)
} }
func (b *button) SetText(text string) { func (b *button) SetText(text string) {
b.setText(text) baseSetText(b, text)
} }
//export buttonClicked //export buttonClicked
@ -49,16 +50,28 @@ func buttonClicked(data unsafe.Pointer) {
println("button clicked") println("button clicked")
} }
func (b *button) hwnd() C.HWND {
return b._hwnd
}
func (b *button) textlen() C.LONG {
return b._textlen
}
func (b *button) settextlen(len C.LONG) {
b._textlen = len
}
func (b *button) setParent(p *controlParent) { func (b *button) setParent(p *controlParent) {
basesetParent(b.controlbase, p) basesetParent(b, p)
} }
func (b *button) containerShow() { func (b *button) containerShow() {
basecontainerShow(b.controlbase) basecontainerShow(b)
} }
func (b *button) containerHide() { func (b *button) containerHide() {
basecontainerHide(b.controlbase) basecontainerHide(b)
} }
func (b *button) allocate(x int, y int, width int, height int, d *sizing) []*allocation { func (b *button) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
@ -76,18 +89,18 @@ func (b *button) preferredSize(d *sizing) (width, height int) {
size.cx = 0 // explicitly ask for ideal size size.cx = 0 // explicitly ask for ideal size
size.cy = 0 size.cy = 0
if C.SendMessageW(b.hwnd, C.BCM_GETIDEALSIZE, 0, C.LPARAM(uintptr(unsafe.Pointer(&size)))) != C.FALSE { if C.SendMessageW(b._hwnd, C.BCM_GETIDEALSIZE, 0, C.LPARAM(uintptr(unsafe.Pointer(&size)))) != C.FALSE {
return int(size.cx), int(size.cy) return int(size.cx), int(size.cy)
} }
// that failed, fall back // that failed, fall back
println("message failed; falling back") println("message failed; falling back")
// don't worry about the error return from GetSystemMetrics(); there's no way to tell (explicitly documented as such) // don't worry about the error return from GetSystemMetrics(); there's no way to tell (explicitly documented as such)
xmargins := 2 * int(C.GetSystemMetrics(C.SM_CXEDGE)) xmargins := 2 * int(C.GetSystemMetrics(C.SM_CXEDGE))
return xmargins + int(b.textlen), fromdlgunitsY(buttonHeight, d) return xmargins + int(b._textlen), fromdlgunitsY(buttonHeight, d)
} }
func (b *button) commitResize(a *allocation, d *sizing) { func (b *button) commitResize(a *allocation, d *sizing) {
basecommitResize(b.controlbase, a, d) basecommitResize(b, a, d)
} }
func (b *button) getAuxResizeInfo(d *sizing) { func (b *button) getAuxResizeInfo(d *sizing) {

View File

@ -10,23 +10,24 @@ import (
import "C" import "C"
type checkbox struct { type checkbox struct {
*controlbase _hwnd C.HWND
toggled *event _textlen C.LONG
toggled *event
} }
func newCheckbox(text string) *checkbox { func newCheckbox(text string) *checkbox {
// don't use BS_AUTOCHECKBOX here because it creates problems when refocusing (see http://blogs.msdn.com/b/oldnewthing/archive/2014/05/22/10527522.aspx) // don't use BS_AUTOCHECKBOX here because it creates problems when refocusing (see http://blogs.msdn.com/b/oldnewthing/archive/2014/05/22/10527522.aspx)
// we'll handle actually toggling the check state ourselves (see controls_windows.c) // we'll handle actually toggling the check state ourselves (see controls_windows.c)
cc := newControl(buttonclass, hwnd := C.newControl(buttonclass,
C.BS_CHECKBOX | C.WS_TABSTOP, C.BS_CHECKBOX | C.WS_TABSTOP,
0) 0)
cc.setText(text)
C.controlSetControlFont(cc.hwnd)
c := &checkbox{ c := &checkbox{
controlbase: cc, _hwnd: hwnd,
toggled: newEvent(), toggled: newEvent(),
} }
C.setCheckboxSubclass(c.hwnd, unsafe.Pointer(c)) c.SetText(text)
C.controlSetControlFont(c._hwnd)
C.setCheckboxSubclass(c._hwnd, unsafe.Pointer(c))
return c return c
} }
@ -35,23 +36,23 @@ func (c *checkbox) OnToggled(e func()) {
} }
func (c *checkbox) Text() string { func (c *checkbox) Text() string {
return c.text() return baseText(c)
} }
func (c *checkbox) SetText(text string) { func (c *checkbox) SetText(text string) {
c.setText(text) baseSetText(c, text)
} }
func (c *checkbox) Checked() bool { func (c *checkbox) Checked() bool {
return C.checkboxChecked(c.hwnd) != C.FALSE return C.checkboxChecked(c._hwnd) != C.FALSE
} }
func (c *checkbox) SetChecked(checked bool) { func (c *checkbox) SetChecked(checked bool) {
if checked { if checked {
C.checkboxSetChecked(c.hwnd, C.TRUE) C.checkboxSetChecked(c._hwnd, C.TRUE)
return return
} }
C.checkboxSetChecked(c.hwnd, C.FALSE) C.checkboxSetChecked(c._hwnd, C.FALSE)
} }
//export checkboxToggled //export checkboxToggled
@ -61,16 +62,28 @@ func checkboxToggled(data unsafe.Pointer) {
println("checkbox toggled") println("checkbox toggled")
} }
func (c *checkbox) hwnd() C.HWND {
return c._hwnd
}
func (c *checkbox) textlen() C.LONG {
return c._textlen
}
func (c *checkbox) settextlen(len C.LONG) {
c._textlen = len
}
func (c *checkbox) setParent(p *controlParent) { func (c *checkbox) setParent(p *controlParent) {
basesetParent(c.controlbase, p) basesetParent(c, p)
} }
func (c *checkbox) containerShow() { func (c *checkbox) containerShow() {
basecontainerShow(c.controlbase) basecontainerShow(c)
} }
func (c *checkbox) containerHide() { func (c *checkbox) containerHide() {
basecontainerHide(c.controlbase) basecontainerHide(c)
} }
func (c *checkbox) allocate(x int, y int, width int, height int, d *sizing) []*allocation { func (c *checkbox) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
@ -85,12 +98,12 @@ const (
) )
func (c *checkbox) preferredSize(d *sizing) (width, height int) { func (c *checkbox) preferredSize(d *sizing) (width, height int) {
return fromdlgunitsX(checkboxXFromLeftOfBoxToLeftOfLabel, d) + int(c.textlen), return fromdlgunitsX(checkboxXFromLeftOfBoxToLeftOfLabel, d) + int(c._textlen),
fromdlgunitsY(checkboxHeight, d) fromdlgunitsY(checkboxHeight, d)
} }
func (c *checkbox) commitResize(a *allocation, d *sizing) { func (c *checkbox) commitResize(a *allocation, d *sizing) {
basecommitResize(c.controlbase, a, d) basecommitResize(c, a, d)
} }
func (c *checkbox) getAuxResizeInfo(d *sizing) { func (c *checkbox) getAuxResizeInfo(d *sizing) {

View File

@ -6,46 +6,30 @@ package ui
import "C" import "C"
type controlPrivate interface { type controlPrivate interface {
// TODO hwnd() C.HWND
Control Control
} }
type controlbase struct {
hwnd C.HWND
parent C.HWND // for Tab and Group
textlen C.LONG
}
type controlParent struct { type controlParent struct {
hwnd C.HWND hwnd C.HWND
} }
func newControl(class C.LPWSTR, style C.DWORD, extstyle C.DWORD) *controlbase { func basesetParent(c controlPrivate, p *controlParent) {
c := new(controlbase) C.controlSetParent(c.hwnd(), p.hwnd)
// TODO rename to newWidget
c.hwnd = C.newWidget(class, style, extstyle)
return c
} }
// TODO for maximum correctness these shouldn't take controlbases... but then the amount of duplicated code would skyrocket func basecontainerShow(c controlPrivate) {
C.ShowWindow(c.hwnd(), C.SW_SHOW)
func basesetParent(c *controlbase, p *controlParent) {
C.controlSetParent(c.hwnd, p.hwnd)
c.parent = p.hwnd
} }
func basecontainerShow(c *controlbase) { func basecontainerHide(c controlPrivate) {
C.ShowWindow(c.hwnd, C.SW_SHOW) C.ShowWindow(c.hwnd(), C.SW_HIDE)
}
func basecontainerHide(c *controlbase) {
C.ShowWindow(c.hwnd, C.SW_HIDE)
} }
// don't specify basepreferredSize; it is custom on ALL controls // don't specify basepreferredSize; it is custom on ALL controls
func basecommitResize(c *controlbase, a *allocation, d *sizing) { func basecommitResize(c controlPrivate, a *allocation, d *sizing) {
C.moveWindow(c.hwnd, C.int(a.x), C.int(a.y), C.int(a.width), C.int(a.height)) C.moveWindow(c.hwnd(), C.int(a.x), C.int(a.y), C.int(a.width), C.int(a.height))
} }
func basegetAuxResizeInfo(c controlPrivate, d *sizing) { func basegetAuxResizeInfo(c controlPrivate, d *sizing) {
@ -54,12 +38,19 @@ func basegetAuxResizeInfo(c controlPrivate, d *sizing) {
// these are provided for convenience // these are provided for convenience
func (c *controlbase) text() string { type textableControl interface {
return getWindowText(c.hwnd) controlPrivate
textlen() C.LONG
settextlen(C.LONG)
} }
func (c *controlbase) setText(text string) { func baseText(c textableControl) string {
t := toUTF16(text) return getWindowText(c.hwnd())
C.setWindowText(c.hwnd, t) }
c.textlen = C.controlTextLength(c.hwnd, t)
func baseSetText(c textableControl, text string) {
hwnd := c.hwnd()
t := toUTF16(text)
C.setWindowText(hwnd, t)
c.settextlen(C.controlTextLength(hwnd, t))
} }

View File

@ -6,24 +6,25 @@ package ui
import "C" import "C"
type label struct { type label struct {
*controlbase _hwnd C.HWND
_textlen C.LONG
standalone bool standalone bool
} }
var labelclass = toUTF16("STATIC") var labelclass = toUTF16("STATIC")
func finishNewLabel(text string, standalone bool) *label { func finishNewLabel(text string, standalone bool) *label {
c := newControl(labelclass, hwnd := C.newControl(labelclass,
// SS_NOPREFIX avoids accelerator translation; SS_LEFTNOWORDWRAP clips text past the end // SS_NOPREFIX avoids accelerator translation; SS_LEFTNOWORDWRAP clips text past the end
// controls are vertically aligned to the top by default (thanks Xeek in irc.freenode.net/#winapi) // controls are vertically aligned to the top by default (thanks Xeek in irc.freenode.net/#winapi)
C.SS_NOPREFIX | C.SS_LEFTNOWORDWRAP, C.SS_NOPREFIX | C.SS_LEFTNOWORDWRAP,
0) 0)
c.setText(text)
C.controlSetControlFont(c.hwnd)
l := &label{ l := &label{
controlbase: c, _hwnd: hwnd,
standalone: standalone, standalone: standalone,
} }
l.SetText(text)
C.controlSetControlFont(l._hwnd)
return l return l
} }
@ -36,23 +37,35 @@ func newStandaloneLabel(text string) Label {
} }
func (l *label) Text() string { func (l *label) Text() string {
return l.text() return baseText(l)
} }
func (l *label) SetText(text string) { func (l *label) SetText(text string) {
l.setText(text) baseSetText(l, text)
}
func (l *label) hwnd() C.HWND {
return l._hwnd
}
func (l *label) textlen() C.LONG {
return l._textlen
}
func (l *label) settextlen(len C.LONG) {
l._textlen = len
} }
func (l *label) setParent(p *controlParent) { func (l *label) setParent(p *controlParent) {
basesetParent(l.controlbase, p) basesetParent(l, p)
} }
func (l *label) containerShow() { func (l *label) containerShow() {
basecontainerShow(l.controlbase) basecontainerShow(l)
} }
func (l *label) containerHide() { func (l *label) containerHide() {
basecontainerHide(l.controlbase) basecontainerHide(l)
} }
func (l *label) allocate(x int, y int, width int, height int, d *sizing) []*allocation { func (l *label) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
@ -67,7 +80,7 @@ const (
) )
func (l *label) preferredSize(d *sizing) (width, height int) { func (l *label) preferredSize(d *sizing) (width, height int) {
return int(l.textlen), fromdlgunitsY(labelHeight, d) return int(l._textlen), fromdlgunitsY(labelHeight, d)
} }
func (l *label) commitResize(c *allocation, d *sizing) { func (l *label) commitResize(c *allocation, d *sizing) {
@ -76,7 +89,7 @@ func (l *label) commitResize(c *allocation, d *sizing) {
c.y += yoff c.y += yoff
c.height -= yoff c.height -= yoff
} }
basecommitResize(l.controlbase, c, d) basecommitResize(l, c, d)
} }
func (l *label) getAuxResizeInfo(d *sizing) { func (l *label) getAuxResizeInfo(d *sizing) {

View File

@ -18,19 +18,20 @@ TODO
*/ */
type tab struct { type tab struct {
*controlbase _hwnd C.HWND
tabs []*sizer tabs []*sizer
parent C.HWND
} }
func newTab() Tab { func newTab() Tab {
c := newControl(C.xWC_TABCONTROL, hwnd := C.newControl(C.xWC_TABCONTROL,
C.TCS_TOOLTIPS | C.WS_TABSTOP, C.TCS_TOOLTIPS | C.WS_TABSTOP,
0) 0)
t := &tab{ t := &tab{
controlbase: c, _hwnd: hwnd,
} }
C.controlSetControlFont(t.hwnd) C.controlSetControlFont(t._hwnd)
C.setTabSubclass(t.hwnd, unsafe.Pointer(t)) C.setTabSubclass(t._hwnd, unsafe.Pointer(t))
return t return t
} }
@ -45,7 +46,7 @@ func (t *tab) Append(name string, control Control) {
if len(t.tabs) != 1 { if len(t.tabs) != 1 {
s.child.containerHide() s.child.containerHide()
} }
C.tabAppend(t.hwnd, toUTF16(name)) C.tabAppend(t._hwnd, toUTF16(name))
} }
//export tabChanging //export tabChanging
@ -60,21 +61,26 @@ func tabChanged(data unsafe.Pointer, new C.LRESULT) {
t.tabs[int(new)].child.containerShow() t.tabs[int(new)].child.containerShow()
} }
func (t *tab) hwnd() C.HWND {
return t._hwnd
}
func (t *tab) setParent(p *controlParent) { func (t *tab) setParent(p *controlParent) {
basesetParent(t.controlbase, p) basesetParent(t, p)
for _, c := range t.tabs { for _, c := range t.tabs {
c.child.setParent(p) c.child.setParent(p)
} }
t.parent = p.hwnd
} }
// TODO actually write this // TODO actually write this
func (t *tab) containerShow() { func (t *tab) containerShow() {
basecontainerShow(t.controlbase) basecontainerShow(t)
} }
// TODO actually write this // TODO actually write this
func (t *tab) containerHide() { func (t *tab) containerHide() {
basecontainerHide(t.controlbase) basecontainerHide(t)
} }
func (t *tab) allocate(x int, y int, width int, height int, d *sizing) []*allocation { func (t *tab) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
@ -92,7 +98,7 @@ func (t *tab) preferredSize(d *sizing) (width, height int) {
height = h height = h
} }
} }
return width, height + int(C.tabGetTabHeight(t.hwnd)) return width, height + int(C.tabGetTabHeight(t._hwnd))
} }
// a tab control contains other controls; size appropriately // a tab control contains other controls; size appropriately
@ -104,7 +110,7 @@ func (t *tab) commitResize(c *allocation, d *sizing) {
r.top = C.LONG(c.y) r.top = C.LONG(c.y)
r.right = C.LONG(c.x + c.width) r.right = C.LONG(c.x + c.width)
r.bottom = C.LONG(c.y + c.height) r.bottom = C.LONG(c.y + c.height)
C.tabGetContentRect(t.hwnd, &r) C.tabGetContentRect(t._hwnd, &r)
// and resize tabs // and resize tabs
// don't resize just the current tab; resize all tabs! // don't resize just the current tab; resize all tabs!
for _, s := range t.tabs { for _, s := range t.tabs {
@ -112,7 +118,7 @@ func (t *tab) commitResize(c *allocation, d *sizing) {
s.resize(int(r.left), int(r.top), int(r.right - r.left), int(r.bottom - r.top)) s.resize(int(r.left), int(r.top), int(r.right - r.left), int(r.bottom - r.top))
} }
// and now resize the tab control itself // and now resize the tab control itself
basecommitResize(t.controlbase, c, d) basecommitResize(t, c, d)
} }
func (t *tab) getAuxResizeInfo(d *sizing) { func (t *tab) getAuxResizeInfo(d *sizing) {

View File

@ -12,23 +12,23 @@ import (
import "C" import "C"
type table struct { type table struct {
*controlbase
*tablebase *tablebase
_hwnd C.HWND
} }
func finishNewTable(b *tablebase, ty reflect.Type) Table { func finishNewTable(b *tablebase, ty reflect.Type) Table {
t := &table{ t := &table{
controlbase: newControl(C.xWC_LISTVIEW, _hwnd: C.newControl(C.xWC_LISTVIEW,
C.LVS_REPORT | C.LVS_OWNERDATA | C.LVS_NOSORTHEADER | C.LVS_SHOWSELALWAYS | C.WS_HSCROLL | C.WS_VSCROLL, C.LVS_REPORT | C.LVS_OWNERDATA | C.LVS_NOSORTHEADER | C.LVS_SHOWSELALWAYS | C.WS_HSCROLL | C.WS_VSCROLL,
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)
tablebase: b, tablebase: b,
} }
C.setTableSubclass(t.hwnd, unsafe.Pointer(t)) C.setTableSubclass(t._hwnd, unsafe.Pointer(t))
// LVS_EX_FULLROWSELECT gives us selection across the whole row, not just the leftmost column; this makes the list view work like on other platforms // LVS_EX_FULLROWSELECT gives us selection across the whole row, not just the leftmost column; this makes the list view work like on other platforms
// LVS_EX_SUBITEMIMAGES gives us images in subitems, which will be important when both images and checkboxes are added // LVS_EX_SUBITEMIMAGES gives us images in subitems, which will be important when both images and checkboxes are added
C.tableAddExtendedStyles(t.hwnd, C.LVS_EX_FULLROWSELECT | C.LVS_EX_SUBITEMIMAGES) C.tableAddExtendedStyles(t._hwnd, C.LVS_EX_FULLROWSELECT | C.LVS_EX_SUBITEMIMAGES)
for i := 0; i < ty.NumField(); i++ { for i := 0; i < ty.NumField(); i++ {
C.tableAppendColumn(t.hwnd, C.int(i), toUTF16(ty.Field(i).Name)) C.tableAppendColumn(t._hwnd, C.int(i), toUTF16(ty.Field(i).Name))
} }
return t return t
} }
@ -39,7 +39,7 @@ func (t *table) Unlock() {
// I think there's a way to set the item count without causing a refetch of data that works around this... // I think there's a way to set the item count without causing a refetch of data that works around this...
t.RLock() t.RLock()
defer t.RUnlock() defer t.RUnlock()
C.tableUpdate(t.hwnd, C.int(reflect.Indirect(reflect.ValueOf(t.data)).Len())) C.tableUpdate(t._hwnd, C.int(reflect.Indirect(reflect.ValueOf(t.data)).Len()))
} }
//export tableGetCellText //export tableGetCellText
@ -53,16 +53,20 @@ func tableGetCellText(data unsafe.Pointer, row C.int, col C.int, str *C.LPWSTR)
*str = toUTF16(s) *str = toUTF16(s)
} }
func (t *table) hwnd() C.HWND {
return t._hwnd
}
func (t *table) setParent(p *controlParent) { func (t *table) setParent(p *controlParent) {
basesetParent(t.controlbase, p) basesetParent(t, p)
} }
func (t *table) containerShow() { func (t *table) containerShow() {
basecontainerShow(t.controlbase) basecontainerShow(t)
} }
func (t *table) containerHide() { func (t *table) containerHide() {
basecontainerHide(t.controlbase) basecontainerHide(t)
} }
func (t *table) allocate(x int, y int, width int, height int, d *sizing) []*allocation { func (t *table) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
@ -80,7 +84,7 @@ func (t *table) preferredSize(d *sizing) (width, height int) {
} }
func (t *table) commitResize(a *allocation, d *sizing) { func (t *table) commitResize(a *allocation, d *sizing) {
basecommitResize(t.controlbase, a, d) basecommitResize(t, a, d)
} }
func (t *table) getAuxResizeInfo(d *sizing) { func (t *table) getAuxResizeInfo(d *sizing) {

View File

@ -6,19 +6,20 @@ package ui
import "C" import "C"
type textField struct { type textField struct {
*controlbase _hwnd C.HWND
_textlen C.LONG
} }
var editclass = toUTF16("EDIT") var editclass = toUTF16("EDIT")
func startNewTextField(style C.DWORD) *textField { func startNewTextField(style C.DWORD) *textField {
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)
C.controlSetControlFont(c.hwnd)
t := &textField{ t := &textField{
controlbase: c, _hwnd: hwnd,
} }
C.controlSetControlFont(t._hwnd)
return t return t
} }
@ -31,23 +32,35 @@ func newPasswordField() *textField {
} }
func (t *textField) Text() string { func (t *textField) Text() string {
return t.text() return baseText(t)
} }
func (t *textField) SetText(text string) { func (t *textField) SetText(text string) {
t.setText(text) baseSetText(t, text)
}
func (t *textField) hwnd() C.HWND {
return t._hwnd
}
func (t *textField) textlen() C.LONG {
return t._textlen
}
func (t *textField) settextlen(len C.LONG) {
t._textlen = len
} }
func (t *textField) setParent(p *controlParent) { func (t *textField) setParent(p *controlParent) {
basesetParent(t.controlbase, p) basesetParent(t, p)
} }
func (t *textField) containerShow() { func (t *textField) containerShow() {
basecontainerShow(t.controlbase) basecontainerShow(t)
} }
func (t *textField) containerHide() { func (t *textField) containerHide() {
basecontainerHide(t.controlbase) basecontainerHide(t)
} }
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 {
@ -65,7 +78,7 @@ func (t *textField) preferredSize(d *sizing) (width, height int) {
} }
func (t *textField) commitResize(a *allocation, d *sizing) { func (t *textField) commitResize(a *allocation, d *sizing) {
basecommitResize(t.controlbase, a, d) basecommitResize(t, a, d)
} }
func (t *textField) getAuxResizeInfo(d *sizing) { func (t *textField) getAuxResizeInfo(d *sizing) {

View File

@ -41,8 +41,8 @@ extern BOOL (*WINAPI fv_SetWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR, DWORD_P
extern BOOL (*WINAPI fv_RemoveWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR); extern BOOL (*WINAPI fv_RemoveWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR);
extern LRESULT (*WINAPI fv_DefSubclassProc)(HWND, UINT, WPARAM, LPARAM); extern LRESULT (*WINAPI fv_DefSubclassProc)(HWND, UINT, WPARAM, LPARAM);
/* controls_windows.c */ /* [TODO rename] controls_windows.c */
extern HWND newWidget(LPWSTR, DWORD, DWORD); extern HWND newControl(LPWSTR, DWORD, DWORD);
extern void controlSetParent(HWND, HWND); extern void controlSetParent(HWND, HWND);
extern void controlSetControlFont(HWND); extern void controlSetControlFont(HWND);
extern LRESULT forwardCommand(HWND, UINT, WPARAM, LPARAM); extern LRESULT forwardCommand(HWND, UINT, WPARAM, LPARAM);