Commits

Hector Miuler Malpica Gallegos  committed 0799cdb

primer ejemplo

  • Participants

Comments (0)

Files changed (8)

+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/scala"/>
+	<classpathentry kind="src" path="src/test/scala"/>
+	<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+	<classpathentry kind="lib" path="/usr/share/java/gtk.jar"/>
+	<classpathentry kind="output" path="target"/>
+</classpath>
+target
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>blacknote</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.scala-ide.sdt.core.scalabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.scala-ide.sdt.core.scalanature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

File .settings/org.eclipse.jdt.core.prefs

+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7

File .settings/org.scala-ide.sdt.core.prefs

+eclipse.preferences.version=1
+organizeimports.expandcollapse=expand
+organizeimports.groups=java$scala$org$com
+organizeimports.wildcards=scalaz$scalaz.Scalaz
+name := "BlackNote"
+
+version := "1.0"
+
+

File src/main/scala/com/miuler/blacknote/BackNote.scala

+package com.miuler.blacknote
+
+import org.gnome.gtk.Window
+import org.gnome.gtk.Gtk
+import org.gnome.gtk.Widget
+import org.gnome.gtk.Window.DeleteEvent
+import org.gnome.gdk.Event
+
+import Events.newMethodEventsToWindow
+import org.gnome.gtk.Button
+
+class WindowConnect(window: Window) {
+
+  def connect2 (eventType: AnyRef, function: (Widget, Event)=>Boolean) {
+    
+    val deleteEvent = classOf[Window.DeleteEvent]
+    
+    eventType match {
+      case deleteEvent => {
+        window.connect(new Window.DeleteEvent() {
+          def onDeleteEvent(source: Widget, event: Event) = function(source, event)
+        })
+      }
+    }
+
+  }
+}
+
+object Events {
+  implicit def newMethodEventsToWindow(window: Window) : WindowConnect = new WindowConnect(window)
+}
+
+
+
+
+object BackNote {
+
+  def main(args: Array[String]) {
+    val prueba = new Prueba1
+    prueba.init(args)
+  }
+
+}
+
+
+class Prueba1 {
+  
+  val self = this
+  var window:Window = null
+
+  def init(args: Array[String]) {
+    Gtk init (args)
+    initWindow ()
+    Gtk main ()
+  }
+  
+  def initWindow() {
+    window = new Window()
+    
+    val button = new Button("clickeame")
+    window.add(button)
+
+    window.connect2(classOf[Window.DeleteEvent], onDeleteEvent)
+    window showAll ()
+  }
+  
+  def onDeleteEvent (source: Widget, event: Event) = {
+    println("Saliendo")
+    Gtk.mainQuit
+    false
+  }
+  
+}

File src/test/scala/com/miuler/backnote/NoteTest.scala

+package com.miuler.backnote
+
+object NoteTest {
+  
+  val age = 32
+  
+  def main(args: Array[String]) = {
+    
+    val p = new Prueba {
+      def test(name: String) = testMethod(name)
+    }
+    
+    p.test("Miuler")
+    
+    println("Hola Mundo")
+  }
+  
+  def testMethod (name: String) = {
+    println("Hola " + name + ", tienes " + this.age + "años")
+  }
+
+}
+
+
+abstract class Prueba {
+  
+  def test(name: String)
+
+}