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/tab_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/tab_windows.go')
| -rw-r--r-- | redo/tab_windows.go | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/redo/tab_windows.go b/redo/tab_windows.go index da97c2c..20e1ee0 100644 --- a/redo/tab_windows.go +++ b/redo/tab_windows.go @@ -18,19 +18,20 @@ TODO */ type tab struct { - *controlbase - tabs []*sizer + _hwnd C.HWND + tabs []*sizer + parent C.HWND } func newTab() Tab { - c := newControl(C.xWC_TABCONTROL, + hwnd := C.newControl(C.xWC_TABCONTROL, C.TCS_TOOLTIPS | C.WS_TABSTOP, 0) t := &tab{ - controlbase: c, + _hwnd: hwnd, } - C.controlSetControlFont(t.hwnd) - C.setTabSubclass(t.hwnd, unsafe.Pointer(t)) + C.controlSetControlFont(t._hwnd) + C.setTabSubclass(t._hwnd, unsafe.Pointer(t)) return t } @@ -45,7 +46,7 @@ func (t *tab) Append(name string, control Control) { if len(t.tabs) != 1 { s.child.containerHide() } - C.tabAppend(t.hwnd, toUTF16(name)) + C.tabAppend(t._hwnd, toUTF16(name)) } //export tabChanging @@ -60,21 +61,26 @@ func tabChanged(data unsafe.Pointer, new C.LRESULT) { t.tabs[int(new)].child.containerShow() } +func (t *tab) hwnd() C.HWND { + return t._hwnd +} + func (t *tab) setParent(p *controlParent) { - basesetParent(t.controlbase, p) + basesetParent(t, p) for _, c := range t.tabs { c.child.setParent(p) } + t.parent = p.hwnd } // TODO actually write this func (t *tab) containerShow() { - basecontainerShow(t.controlbase) + basecontainerShow(t) } // TODO actually write this func (t *tab) containerHide() { - basecontainerHide(t.controlbase) + basecontainerHide(t) } 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 } } - return width, height + int(C.tabGetTabHeight(t.hwnd)) + return width, height + int(C.tabGetTabHeight(t._hwnd)) } // 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.right = C.LONG(c.x + c.width) r.bottom = C.LONG(c.y + c.height) - C.tabGetContentRect(t.hwnd, &r) + C.tabGetContentRect(t._hwnd, &r) // and resize tabs // don't resize just the current tab; resize all 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)) } // and now resize the tab control itself - basecommitResize(t.controlbase, c, d) + basecommitResize(t, c, d) } func (t *tab) getAuxResizeInfo(d *sizing) { |
