summaryrefslogtreecommitdiff
path: root/checkbox_windows.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-10-18 17:03:07 -0400
committerPietro Gagliardi <[email protected]>2014-10-18 17:03:07 -0400
commit62048303a34f6cac733798651adb53b640e2114a (patch)
treeb03994dfe1d5cfbc94be65075f3345a45166bbef /checkbox_windows.go
parent8c8b642adbed274133b6e9d975c7ca8786300d2c (diff)
Merged new container/sizing stuff.
Diffstat (limited to 'checkbox_windows.go')
-rw-r--r--checkbox_windows.go52
1 files changed, 12 insertions, 40 deletions
diff --git a/checkbox_windows.go b/checkbox_windows.go
index 7f8ce85..4ccd5e2 100644
--- a/checkbox_windows.go
+++ b/checkbox_windows.go
@@ -10,8 +10,7 @@ import (
import "C"
type checkbox struct {
- _hwnd C.HWND
- _textlen C.LONG
+ *controlSingleHWNDWithText
toggled *event
}
@@ -22,12 +21,13 @@ func newCheckbox(text string) *checkbox {
C.BS_CHECKBOX|C.WS_TABSTOP,
0)
c := &checkbox{
- _hwnd: hwnd,
+ controlSingleHWNDWithText: newControlSingleHWNDWithText(hwnd),
toggled: newEvent(),
}
+ c.fpreferredSize = c.xpreferredSize
c.SetText(text)
- C.controlSetControlFont(c._hwnd)
- C.setCheckboxSubclass(c._hwnd, unsafe.Pointer(c))
+ C.controlSetControlFont(c.hwnd)
+ C.setCheckboxSubclass(c.hwnd, unsafe.Pointer(c))
return c
}
@@ -36,23 +36,23 @@ func (c *checkbox) OnToggled(e func()) {
}
func (c *checkbox) Text() string {
- return baseText(c)
+ return c.text()
}
func (c *checkbox) SetText(text string) {
- baseSetText(c, text)
+ c.setText(text)
}
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) {
if checked {
- C.checkboxSetChecked(c._hwnd, C.TRUE)
+ C.checkboxSetChecked(c.hwnd, C.TRUE)
return
}
- C.checkboxSetChecked(c._hwnd, C.FALSE)
+ C.checkboxSetChecked(c.hwnd, C.FALSE)
}
//export checkboxToggled
@@ -61,26 +61,6 @@ func checkboxToggled(data unsafe.Pointer) {
c.toggled.fire()
}
-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) {
- basesetParent(c, p)
-}
-
-func (c *checkbox) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
- return baseallocate(c, x, y, width, height, d)
-}
-
const (
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
checkboxHeight = 10
@@ -88,15 +68,7 @@ const (
checkboxXFromLeftOfBoxToLeftOfLabel = 12
)
-func (c *checkbox) preferredSize(d *sizing) (width, height int) {
- return fromdlgunitsX(checkboxXFromLeftOfBoxToLeftOfLabel, d) + int(c._textlen),
+func (c *checkbox) xpreferredSize(d *sizing) (width, height int) {
+ return fromdlgunitsX(checkboxXFromLeftOfBoxToLeftOfLabel, d) + int(c.textlen),
fromdlgunitsY(checkboxHeight, d)
}
-
-func (c *checkbox) commitResize(a *allocation, d *sizing) {
- basecommitResize(c, a, d)
-}
-
-func (c *checkbox) getAuxResizeInfo(d *sizing) {
- basegetAuxResizeInfo(c, d)
-}