From e989c953fa683c56d9214e24c9f1fd22027afa9c Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 22 Jul 2014 00:07:41 -0400 Subject: [PATCH] Moved Window.SetControl() into window.go pending addition of fake resize events. --- redo/window.go | 14 ++++++++++++++ redo/window_darwin.go | 9 --------- redo/window_unix.go | 9 --------- redo/window_windows.go | 9 --------- 4 files changed, 14 insertions(+), 27 deletions(-) diff --git a/redo/window.go b/redo/window.go index 2bb3784..143a875 100644 --- a/redo/window.go +++ b/redo/window.go @@ -34,3 +34,17 @@ type Window interface { func NewWindow(title string, width int, height int) Window { return newWindow(title, width, height) } + +// everything below is kept here because they're the same on all platforms +// TODO move event stuff here and make windowbase + +func (w *window) SetControl(control Control) { + if w.child != nil { // unparent existing control + w.child.unparent() + } + control.unparent() + control.parent(w) + w.child = control + // TODO trigger a resize to let the new control actually be shown + // TODO do the same with control's old parent, if any +} diff --git a/redo/window_darwin.go b/redo/window_darwin.go index 9d70b1d..859c79a 100644 --- a/redo/window_darwin.go +++ b/redo/window_darwin.go @@ -33,15 +33,6 @@ func newWindow(title string, width int, height int) *window { return w } -func (w *window) SetControl(control Control) { - if w.child != nil { // unparent existing control - w.child.unparent() - } - control.unparent() - control.parent(w) - w.child = control -} - func (w *window) Title() string { return C.GoString(C.windowTitle(w.id)) } diff --git a/redo/window_unix.go b/redo/window_unix.go index 4b2d0d2..26675e7 100644 --- a/redo/window_unix.go +++ b/redo/window_unix.go @@ -66,15 +66,6 @@ func newWindow(title string, width int, height int) *window { return w } -func (w *window) SetControl(control Control) { - if w.child != nil { // unparent existing control - w.child.unparent() - } - control.unparent() - control.parent(w) - w.child = control -} - func (w *window) Title() string { return fromgstr(C.gtk_window_get_title(w.window)) } diff --git a/redo/window_windows.go b/redo/window_windows.go index e2a0973..01bc751 100644 --- a/redo/window_windows.go +++ b/redo/window_windows.go @@ -47,15 +47,6 @@ func newWindow(title string, width int, height int) *window { return w } -func (w *window) SetControl(control Control) { - if w.child != nil { // unparent existing control - w.child.unparent() - } - control.unparent() - control.parent(w) - w.child = control -} - func (w *window) Title() string { return getWindowText(w.hwnd) }