summaryrefslogtreecommitdiff
path: root/window.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-02-12 10:29:56 -0500
committerPietro Gagliardi <[email protected]>2014-02-12 10:29:56 -0500
commite9e2c0f269aac1157a3ea6a6021a86869fdd6888 (patch)
tree7edd6ae853fd47ea09972833bd74b3239674fcfa /window.go
parent0f373195de316b1b20a05ebff1463fb8a56b1f1b (diff)
Set up restrictions tracking. Added a restriction that a window and its controls are fixed to the window once it has been open. Started accounting for parent windows in controls.
Diffstat (limited to 'window.go')
-rw-r--r--window.go22
1 files changed, 8 insertions, 14 deletions
diff --git a/window.go b/window.go
index 8fb7ff8..50d4dbb 100644
--- a/window.go
+++ b/window.go
@@ -32,23 +32,17 @@ func NewWindow(title string) *Window {
}
}
-// SetControl sets the window's central control to control.
+// SetControl sets the window's central control to control. This function cannot be called once the window has been opened.
func (w *Window) SetControl(control Control) (err error) {
w.lock.Lock()
defer w.lock.Unlock()
- w.control = control
- err = w.control.unapply()
- if err != nil {
- return err
- }
- w.control.setParent(w)
if w.created {
- err = w.control.apply()
- if err != nil {
- return err
- }
+ panic("cannot set window control after window has been opened")
}
+ w.control = control
+ w.control.setParent(w)
+ w.control.setParentWindow(w)
return nil
}
@@ -85,9 +79,9 @@ func (w *Window) Close() (err error) {
func (w *Window) apply() error {
panic("Window.apply() should never be called")
}
-func (w *Window) unapply() error {
- panic("Window.unapply() should never be called")
-}
func (w *Window) setParent(c Control) {
panic("Window.setParent() should never be called")
}
+func (w *Window) setParentWindow(w *Window) {
+ panic("Window.setParent() should never be called")
+}