summaryrefslogtreecommitdiff
path: root/test/files/pos/gui.scala
diff options
context:
space:
mode:
authorGilles Dubochet <gilles.dubochet@epfl.ch>2005-12-16 18:20:15 +0000
committerGilles Dubochet <gilles.dubochet@epfl.ch>2005-12-16 18:20:15 +0000
commit17e2b1c2a6f69ba74e79c30d1e44195fe732e3e3 (patch)
treebb804b4038eb6d0dee58b77cea8bd2dcc6f42dc4 /test/files/pos/gui.scala
parente70a1a24ef7a7b596a92e1853fd44e96f36ad245 (diff)
downloadscala-17e2b1c2a6f69ba74e79c30d1e44195fe732e3e3.tar.gz
scala-17e2b1c2a6f69ba74e79c30d1e44195fe732e3e3.tar.bz2
scala-17e2b1c2a6f69ba74e79c30d1e44195fe732e3e3.zip
Removed old scala tests from new Scala core mod...
Removed old scala tests from new Scala core module.
Diffstat (limited to 'test/files/pos/gui.scala')
-rw-r--r--test/files/pos/gui.scala99
1 files changed, 0 insertions, 99 deletions
diff --git a/test/files/pos/gui.scala b/test/files/pos/gui.scala
deleted file mode 100644
index 27863f7368..0000000000
--- a/test/files/pos/gui.scala
+++ /dev/null
@@ -1,99 +0,0 @@
-object Geom {
- trait Shape;
- case class Point(x: int, y: int) extends Shape;
- case class Rectangle(ll: Point, ur: Point) extends Shape {
- def inset(delta: int) =
- Rectangle(Point(ll.x - delta, ll.y - delta), Point(ur.x + delta, ur.y + delta));
- }
-}
-
-object Color {
- type Color = int;
- val black = 0x000000;
- val grey = 0x808080;
-}
-
-trait Screen {
- type Color = int;
- def drawRect(r: Geom.Rectangle, c: Color): unit;
- def fillRect(r: Geom.Rectangle, c: Color): unit;
-}
-
-object DummyScreen extends Screen {
- def drawRect(r: Geom.Rectangle, c: Color): unit =
- System.out.println("draw " + r + " with " + c);
- def fillRect(r: Geom.Rectangle, c: Color): unit =
- System.out.println("fill " + r + " with " + c);
-}
-
-object GUI {
-
- object Controller {
- def addMouseCtl(c: MouseCtl) = ()
- }
-
- trait Glyph {
- def getRect: Geom.Rectangle;
- def setLoc(p: Geom.Point): unit;
- def draw() = System.out.println("draw " + this);
- }
-
- class Label(scr: Screen, p: Geom.Point, name: String) extends Glyph {
- private var origin = p;
- def getRect = Geom.Rectangle(origin, origin).inset(10);
- def setLoc(p: Geom.Point) = { origin = p }
- }
-
- trait Ctl {
- def getGlyph: Glyph;
- def enable(b: Boolean): this.type;
- }
-
- trait MouseCtl with Ctl {
- def mouseDown(p: Geom.Point): unit;
- }
-
- abstract class Button(scr: Screen, p: Geom.Point, name: String)
- extends Glyph with MouseCtl {
- var enabled: boolean = false;
- val label = new Label(scr, p, name);
-
- /* Glyph methods */
- override def draw(): unit = {
- if (enabled) scr.drawRect(getRect, Color.black)
- else scr.fillRect(getRect, Color.grey);
- label.draw();
- }
- def setLoc(p: Geom.Point) = label.setLoc(p);
- def getRect = label.getRect.inset(-2);
-
- /* Ctl methods */
- def enable(b: boolean): this.type = { enabled = b; draw(); this }
- def getGlyph = label;
- final def mouseDown(p: Geom.Point): unit =
- if (enabled) doit() else System.out.println("button is disabled");
-
- /* deferred method to be specified by client */
- def doit(): unit;
- }
-}
-
-object GUIClient {
-
- class Application {
- def quit() = System.out.println("application exited");
- }
-
- class QuitButton (scr: Screen, p: Geom.Point, name: String, a: Application)
- extends GUI.Button(scr, p, name) {
- def doit(): unit = a.quit();
- }
-
- def main(args: Array[String]) = {
- val b = new QuitButton(
- DummyScreen, Geom.Point(1, 1), "quit", new Application);
- b.draw();
- b.enable(true).mouseDown(Geom.Point(1, 2));
- }
-}
-