Commits

Anonymous committed e5aefa9

add method to retrieve the TWL instance

  • Participants
  • Parent commits 84cbd59

Comments (0)

Files changed (1)

src/de/matthiasmann/twlscala/TWL.scala

     implicit def size2dimension(s:Size) = new TWLDimension(s.width, s.height)
     implicit def list2listmodel[T](xs:Seq[T]) = new ListModel(xs)
 
+    def getTWL(w:TWLWidget):TWL = w match {
+        case x:RootWidget => x.getTWL
+        case _            => getTWL(w.getParent)
+    }
+
     private[twlscala] val emptyActions = scala.collection.immutable.Map.empty[Action,Boolean]
+
+    private[twlscala] class RootWidget(twl:TWL) extends Widget {
+        override def layout { twl.doRootLayout }
+        theme = ""
+        def getTWL = twl
+    }
 }
 
-class TWL {
+class TWL { twl =>
     import de.matthiasmann.twl.{GUI, PopupWindow}
     import de.matthiasmann.twl.theme.ThemeManager
 
     val renderer = new de.matthiasmann.twl.renderer.lwjgl.LWJGLRenderer
-    val root = new Widget {
-        override def layout { doRootLayout }
-        theme = ""
-    }
+    val root = new TWL.RootWidget(twl)
     val gui = new GUI(root, renderer)
 
     private var themeManager : ThemeManager = null