diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-03 21:52:21 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-03 21:52:21 -0400 |
| commit | 2c107d7057fec9d8c6fc1b694e28cea824668a3d (patch) | |
| tree | 9b7cd1f2d0d7df1f7af8f179fc23f9ab21b8db8e /redo/checkbox_windows.go | |
| parent | 0fb45ba84d7a948508b30e0b140910ae906b4d9d (diff) | |
Converted the new Windows Control code to use interfaces instead of controlbase, just like the GTK+ and Mac OS X backends do now.
Diffstat (limited to 'redo/checkbox_windows.go')
| -rw-r--r-- | redo/checkbox_windows.go | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/redo/checkbox_windows.go b/redo/checkbox_windows.go index 5ffce28..88c82ef 100644 --- a/redo/checkbox_windows.go +++ b/redo/checkbox_windows.go @@ -10,23 +10,24 @@ import ( import "C" type checkbox struct { - *controlbase - toggled *event + _hwnd C.HWND + _textlen C.LONG + toggled *event } 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) // 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, 0) - cc.setText(text) - C.controlSetControlFont(cc.hwnd) c := &checkbox{ - controlbase: cc, + _hwnd: hwnd, 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 } @@ -35,23 +36,23 @@ func (c *checkbox) OnToggled(e func()) { } func (c *checkbox) Text() string { - return c.text() + return baseText(c) } func (c *checkbox) SetText(text string) { - c.setText(text) + baseSetText(c, 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,16 +62,28 @@ func checkboxToggled(data unsafe.Pointer) { 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) { - basesetParent(c.controlbase, p) + basesetParent(c, p) } func (c *checkbox) containerShow() { - basecontainerShow(c.controlbase) + basecontainerShow(c) } func (c *checkbox) containerHide() { - basecontainerHide(c.controlbase) + basecontainerHide(c) } 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) { - return fromdlgunitsX(checkboxXFromLeftOfBoxToLeftOfLabel, d) + int(c.textlen), + return fromdlgunitsX(checkboxXFromLeftOfBoxToLeftOfLabel, d) + int(c._textlen), fromdlgunitsY(checkboxHeight, d) } func (c *checkbox) commitResize(a *allocation, d *sizing) { - basecommitResize(c.controlbase, a, d) + basecommitResize(c, a, d) } func (c *checkbox) getAuxResizeInfo(d *sizing) { |
