Commits

Anonymous committed cb44cb8

better modal dialog support in PopupWindow

Comments (0)

Files changed (2)

src/de/matthiasmann/twlscala/PopupWindow.scala

     def closeOnEscape = isCloseOnEscape
     def closeOnEscape_= (b:Boolean) { setCloseOnEscape(b) }
     def owner = getOwner
+
+    def runModalDialog {
+        twl.waitForPopup(this)
+    }
+    def showModalDialog {
+        twl.showPopup(this)
+    }
+
+    private[this] def twl = TWL.getTWL(getOwner)
 }
+
+trait PopupWindowFractionalSize extends PopupWindow { this:PopupWindow =>
+    override def adjustSize {
+        def calc(v:Int, f:Float) = (v.toFloat*f).toInt max 1
+        setSize(
+            calc(parent.getWidth, fractionalWidth),
+            calc(parent.getHeight, fractionalHeight))
+    }
+    def fractionalWidth:Float
+    def fractionalHeight:Float
+}

src/de/matthiasmann/twlscala/twlinternal/ThemeSupport.scala

 import de.matthiasmann.twlscala._
 
 trait ThemeSupport extends TWLWidget { this:TWLWidget =>
+    def parent = getParent
     def theme = getTheme
     def theme_= (t:String) { setTheme(t) }
     def visible = isVisible