summaryrefslogtreecommitdiff
path: root/redo/control_windows.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-08-03 09:18:35 -0400
committerPietro Gagliardi <[email protected]>2014-08-03 09:18:35 -0400
commit1aea308645585f2fbc6c8b170381c811d562cc99 (patch)
tree1db721a972133a1ed0d9808eafabfbed66f6892f /redo/control_windows.go
parent585f5f5b62da3170d4398b39670d16811013d078 (diff)
Set up the Control restructure and migrated the Windows implementation over. Lots of repetition, but hopefully more correct and maintainable!
Diffstat (limited to 'redo/control_windows.go')
-rw-r--r--redo/control_windows.go44
1 files changed, 24 insertions, 20 deletions
diff --git a/redo/control_windows.go b/redo/control_windows.go
index b2af110..fd0ccaa 100644
--- a/redo/control_windows.go
+++ b/redo/control_windows.go
@@ -6,7 +6,6 @@ package ui
import "C"
type controlbase struct {
- *controldefs
hwnd C.HWND
parent C.HWND // for Tab and Group
textlen C.LONG
@@ -18,29 +17,34 @@ type controlParent struct {
func newControl(class C.LPWSTR, style C.DWORD, extstyle C.DWORD) *controlbase {
c := new(controlbase)
+ // TODO rename to newWidget
c.hwnd = C.newWidget(class, style, extstyle)
- c.controldefs = new(controldefs)
- c.fsetParent = func(p *controlParent) {
- C.controlSetParent(c.hwnd, p.hwnd)
- c.parent = p.hwnd
- }
- c.fcontainerShow = func() {
- C.ShowWindow(c.hwnd, C.SW_SHOW)
- }
- c.fcontainerHide = func() {
- C.ShowWindow(c.hwnd, C.SW_HIDE)
- }
- c.fallocate = baseallocate(c)
- // don't specify c.fpreferredSize; it is custom on ALL controls
- c.fcommitResize = func(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.fgetAuxResizeInfo = func(d *sizing) {
- // do nothing
- }
return c
}
+func basesetParent(c *controlbase, p *controlParent) {
+ C.controlSetParent(c.hwnd, p.hwnd)
+ c.parent = p.hwnd
+}
+
+func basecontainerShow(c *controlbase) {
+ C.ShowWindow(c.hwnd, C.SW_SHOW)
+}
+
+func basecontainerHide(c *controlbase) {
+ C.ShowWindow(c.hwnd, C.SW_HIDE)
+}
+
+// don't specify basepreferredSize; it is custom on ALL controls
+
+func basecommitResize(c *controlbase, a *allocation, d *sizing) {
+ C.moveWindow(c.hwnd, C.int(a.x), C.int(a.y), C.int(a.width), C.int(a.height))
+}
+
+func basegetAuxResizeInfo(d *sizing) {
+ // do nothing
+}
+
// these are provided for convenience
func (c *controlbase) text() string {