diff options
| -rw-r--r-- | redo/containers_darwin.go | 2 | ||||
| -rw-r--r-- | redo/containers_unix.go | 2 | ||||
| -rw-r--r-- | redo/containers_windows.go | 8 | ||||
| -rw-r--r-- | redo/controls.go | 4 | ||||
| -rw-r--r-- | redo/controls_darwin.go | 8 | ||||
| -rw-r--r-- | redo/controls_unix.go | 8 | ||||
| -rw-r--r-- | redo/controls_windows.go | 10 | ||||
| -rw-r--r-- | redo/window_darwin.go | 6 | ||||
| -rw-r--r-- | redo/window_unix.go | 6 | ||||
| -rw-r--r-- | redo/window_windows.go | 6 |
10 files changed, 30 insertions, 30 deletions
diff --git a/redo/containers_darwin.go b/redo/containers_darwin.go index be74096..0e0221a 100644 --- a/redo/containers_darwin.go +++ b/redo/containers_darwin.go @@ -30,7 +30,7 @@ func (t *tab) Append(name string, control Control) { defer C.free(unsafe.Pointer(cname)) tabview := C.tabAppend(t.id, cname) c.child = control - c.child.setParent(tabview) + c.child.setParent(&controlParent{tabview}) } func (t *tab) allocate(x int, y int, width int, height int, d *sizing) []*allocation { diff --git a/redo/containers_unix.go b/redo/containers_unix.go index a6fe832..36118fe 100644 --- a/redo/containers_unix.go +++ b/redo/containers_unix.go @@ -42,7 +42,7 @@ func (t *tab) Append(name string, control Control) { c := new(container) t.containers = append(t.containers, c) c.child = control - c.child.setParent((*C.GtkContainer)(unsafe.Pointer(layout))) + c.child.setParent(&controlParent{(*C.GtkContainer)(unsafe.Pointer(layout))}) g_signal_connect_after( C.gpointer(unsafe.Pointer(layout)), "size-allocate", diff --git a/redo/containers_windows.go b/redo/containers_windows.go index d0d8496..cc881e7 100644 --- a/redo/containers_windows.go +++ b/redo/containers_windows.go @@ -34,10 +34,10 @@ func newTab() Tab { return t } -func (t *tab) setParent(win C.HWND) { - t.widgetbase.setParent(win) +func (t *tab) setParent(p *controlParent) { + t.widgetbase.setParent(p) for _, c := range t.tabs { - c.child.setParent(win) + c.child.setParent(p) } } @@ -46,7 +46,7 @@ func (t *tab) Append(name string, control Control) { t.tabs = append(t.tabs, c) c.child = control if t.parent != nil { - c.child.setParent(t.parent) + c.child.setParent(&controlParent{t.parent}) } // initially hide tab 1..n controls; if we don't, they'll appear over other tabs, resulting in weird behavior if len(t.tabs) != 1 { diff --git a/redo/controls.go b/redo/controls.go index ef97ed1..cda67db 100644 --- a/redo/controls.go +++ b/redo/controls.go @@ -5,10 +5,10 @@ package ui // Control represents a control. // All Controls have event handlers that take a single argument (the Doer active during the event) and return nothing. type Control interface { - controlParent // platform-specific + setParent(p *controlParent) // controlParent defined per-platform // TODO enable/disable (public) // TODO show/hide (public) - containerShow() // for Windows, where all controls need ot belong to an overlapped window, not to a container control; these respect programmer settings + containerShow() // for Windows, where all controls need ot belong to an overlapped window, not to a container control; these respect programmer settings containerHide() controlSizing } diff --git a/redo/controls_darwin.go b/redo/controls_darwin.go index d6968fc..78e9138 100644 --- a/redo/controls_darwin.go +++ b/redo/controls_darwin.go @@ -21,9 +21,13 @@ func newWidget(id C.id) *widgetbase { // these few methods are embedded by all the various Controls since they all will do the same thing -func (w *widgetbase) setParent(parent C.id) { +type controlParent struct { + id C.id +} + +func (w *widgetbase) setParent(parent *controlParent) { // redrawing the new window handled by C.parent() - C.parent(w.id, parent) + C.parent(w.id, parent.id) } func (w *widgetbase) containerShow() { diff --git a/redo/controls_unix.go b/redo/controls_unix.go index 8e13767..67d844b 100644 --- a/redo/controls_unix.go +++ b/redo/controls_unix.go @@ -28,8 +28,12 @@ func newWidget(w *C.GtkWidget) *widgetbase { // these few methods are embedded by all the various Controls since they all will do the same thing -func (w *widgetbase) setParent(c *C.GtkContainer) { - C.gtk_container_add(c, w.widget) +type controlParent struct { + c *C.GtkContainer +} + +func (w *widgetbase) setParent(c *controlParent) { + C.gtk_container_add(c.c, w.widget) // make sure the new widget is shown C.gtk_widget_show_all(w.widget) } diff --git a/redo/controls_windows.go b/redo/controls_windows.go index b9c69ed..ecc1494 100644 --- a/redo/controls_windows.go +++ b/redo/controls_windows.go @@ -22,9 +22,13 @@ func newWidget(class C.LPCWSTR, style C.DWORD, extstyle C.DWORD) *widgetbase { // these few methods are embedded by all the various Controls since they all will do the same thing -func (w *widgetbase) setParent(win C.HWND) { - C.controlSetParent(w.hwnd, win) - w.parent = win +type controlParent struct { + hwnd C.HWND +} + +func (w *widgetbase) setParent(win *controlParent) { + C.controlSetParent(w.hwnd, win.hwnd) + w.parent = win.hwnd } func (w *widgetbase) containerShow() { diff --git a/redo/window_darwin.go b/redo/window_darwin.go index 40c3ddf..80d1a51 100644 --- a/redo/window_darwin.go +++ b/redo/window_darwin.go @@ -18,10 +18,6 @@ type window struct { *container } -type controlParent interface { - setParent(C.id) -} - func newWindow(title string, width int, height int, control Control) *window { id := C.newWindow(C.intptr_t(width), C.intptr_t(height)) ctitle := C.CString(title) @@ -34,7 +30,7 @@ func newWindow(title string, width int, height int, control Control) *window { } C.windowSetDelegate(id, unsafe.Pointer(w)) w.child = control - w.child.setParent(C.windowContentView(w.id)) + w.child.setParent(&controlParent{C.windowContentView(w.id)}) return w } diff --git a/redo/window_unix.go b/redo/window_unix.go index dc91cbe..6a510b8 100644 --- a/redo/window_unix.go +++ b/redo/window_unix.go @@ -29,10 +29,6 @@ type window struct { *container } -type controlParent interface { - setParent(*C.GtkContainer) -} - func newWindow(title string, width int, height int, control Control) *window { widget := C.gtk_window_new(C.GTK_WINDOW_TOPLEVEL) ctitle := togstr(title) @@ -67,7 +63,7 @@ func newWindow(title string, width int, height int, control Control) *window { C.gtk_window_resize(w.window, C.gint(width), C.gint(height)) C.gtk_container_add(w.wc, layoutw) w.child = control - w.child.setParent(w.layoutc) + w.child.setParent(&controlParent{w.layoutc}) return w } diff --git a/redo/window_windows.go b/redo/window_windows.go index 1a36c01..8c64858 100644 --- a/redo/window_windows.go +++ b/redo/window_windows.go @@ -33,10 +33,6 @@ func makeWindowWindowClass() error { return nil } -type controlParent interface { - setParent(C.HWND) -} - func newWindow(title string, width int, height int, control Control) *window { w := &window{ // hwnd set in WM_CREATE handler @@ -53,7 +49,7 @@ func newWindow(title string, width int, height int, control Control) *window { panic(fmt.Errorf("error setting tab background texture on Window; HRESULT: 0x%X", hresult)) } w.child = control - w.child.setParent(w.hwnd) + w.child.setParent(&controlParent{w.hwnd}) return w } |
