summaryrefslogtreecommitdiff
path: root/test/files/pos/gui.scala
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2008-06-10 10:27:45 +0000
committermichelou <michelou@epfl.ch>2008-06-10 10:27:45 +0000
commit0dabdc7b17a02f1d36a99cd21acfdc0b2498f951 (patch)
tree05e7999dc39a0faf11ca743d7314b178a9823026 /test/files/pos/gui.scala
parent943f6dda3b32057a3d9e91c68baac8971d94e567 (diff)
downloadscala-0dabdc7b17a02f1d36a99cd21acfdc0b2498f951.tar.gz
scala-0dabdc7b17a02f1d36a99cd21acfdc0b2498f951.tar.bz2
scala-0dabdc7b17a02f1d36a99cd21acfdc0b2498f951.zip
int -> Int, etc..
Diffstat (limited to 'test/files/pos/gui.scala')
-rw-r--r--test/files/pos/gui.scala64
1 files changed, 33 insertions, 31 deletions
diff --git a/test/files/pos/gui.scala b/test/files/pos/gui.scala
index 54ecbfa719..9d87d1b869 100644
--- a/test/files/pos/gui.scala
+++ b/test/files/pos/gui.scala
@@ -1,29 +1,31 @@
object Geom {
- trait Shape;
- case class Point(x: int, y: int) extends Shape;
+ trait Shape
+ case class Point(x: Int, y: Int) extends Shape
case class Rectangle(ll: Point, ur: Point) extends Shape {
- def inset(delta: int) =
+ 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;
+ 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;
+ 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 =
- Console.println("draw " + r + " with " + c);
- def fillRect(r: Geom.Rectangle, c: Color): unit =
- Console.println("fill " + r + " with " + c);
+ def drawRect(r: Geom.Rectangle, c: Color) {
+ Console.println("draw " + r + " with " + c)
+ }
+ def fillRect(r: Geom.Rectangle, c: Color) {
+ Console.println("fill " + r + " with " + c)
+ }
}
object GUI {
@@ -33,33 +35,33 @@ object GUI {
}
trait Glyph {
- def getRect: Geom.Rectangle;
- def setLoc(p: Geom.Point): unit;
- def draw() = Console.println("draw " + this);
+ def getRect: Geom.Rectangle
+ def setLoc(p: Geom.Point): Unit
+ def draw() { Console.println("draw " + this) }
}
class Label(scr: Screen, p: Geom.Point, name: String) extends Glyph {
- private var origin = p;
+ 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;
+ def getGlyph: Glyph
+ def enable(b: Boolean): this.type
}
trait MouseCtl extends Ctl {
- def mouseDown(p: Geom.Point): unit;
+ 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);
+ var enabled: Boolean = false
+ val label = new Label(scr, p, name)
/* Glyph methods */
- override def draw(): unit = {
+ override def draw() {
if (enabled) scr.drawRect(getRect, Color.black)
else scr.fillRect(getRect, Color.grey);
label.draw();
@@ -68,28 +70,28 @@ object GUI {
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 =
+ def enable(b: Boolean): this.type = { enabled = b; draw(); this }
+ def getGlyph = label
+ final def mouseDown(p: Geom.Point) {
if (enabled) doit() else Console.println("button is disabled");
-
+ }
/* deferred method to be specified by client */
- def doit(): unit;
+ def doit(): Unit
}
}
object GUIClient {
class Application {
- def quit() = Console.println("application exited");
+ def quit() { Console.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 doit() { a.quit() }
}
- def main(args: Array[String]) = {
+ def main(args: Array[String]) {
val b = new QuitButton(
DummyScreen, Geom.Point(1, 1), "quit", new Application);
b.draw();