1.1 --- a/isac-java/src/java/isac/gui/mawen/editor/BoxUtil.scala Thu Sep 07 09:21:29 2017 +0200
1.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/BoxUtil.scala Thu Sep 07 09:27:43 2017 +0200
1.3 @@ -1,16 +1,16 @@
1.4 package isac.gui.mawen.editor
1.5
1.6 -import isac.gui.mawen.editor.Box._
1.7 +import java.awt.Graphics
1.8 +import java.awt.Color
1.9 +import javax.swing.JTextField
1.10 +import java.awt.Dimension
1.11 +import javax.swing.JButton
1.12 import isac.gui.mawen.syntax.Ast._
1.13 import isac.gui.mawen.syntax.Ast
1.14 +import java.awt.Font
1.15 +import isac.gui.mawen.editor.Box._
1.16 +import java.awt.Graphics2D
1.17 import isac.gui.mawen.syntax.XSyntax
1.18 -import java.awt.Graphics
1.19 -import java.awt.Color
1.20 -import java.awt.Dimension
1.21 -import java.awt.Font
1.22 -import java.awt.Graphics2D
1.23 -import javax.swing.JButton
1.24 -import javax.swing.JTextField
1.25
1.26 /**
1.27 * <code>paint</code>s a <code>Box</code> according to
1.28 @@ -18,7 +18,10 @@
1.29 * specific layouts defined in <code>CalcUtil</code>.
1.30 */
1.31 object BoxUtil {
1.32 -
1.33 +
1.34 +
1.35 +
1.36 +
1.37 def Draw(box : DrawBox, g: Graphics) : Unit = box.name match {
1.38 case "GAP" => drawGap(g, box)
1.39 case "CURSOR" => drawCursor(g, box)
1.40 @@ -33,9 +36,12 @@
1.41 box.children.foreach( Draw(_, g) )
1.42 }
1.43 }
1.44 +
1.45 +
1.46 def drawGap(g: Graphics, box : DrawBox) {
1.47 g.fillRoundRect(box.x, box.y- box.height, box.width, box.height, 15, 15)
1.48 drawBox(box, g)
1.49 +
1.50 }
1.51 def drawCursor(g: Graphics, box : DrawBox) = System.currentTimeMillis() match {
1.52 case n if (n / 250) % 1 == 0 => box.ast match {
1.53 @@ -43,10 +49,19 @@
1.54 g.setColor(Color.RED)
1.55 g.asInstanceOf[Graphics2D].drawLine(box.x, box.y, box.x + box.width , box.y)
1.56 g.asInstanceOf[Graphics2D].drawLine(box.x, box.y, box.x, box.y - box.height)
1.57 -
1.58 +
1.59 +
1.60 + // g.drawRect(box.x, box.y - box.height, box.width, box.height)
1.61 g.setColor(Color.BLACK)
1.62 - if (box.children.length >= 1) Draw(box.children.head, g)
1.63 + if (box.children.length >= 1)
1.64 + Draw(box.children.head, g)
1.65 +
1.66 +
1.67 + // Box.drawBox(box, g)
1.68 +
1.69 +
1.70 }
1.71 +
1.72 case Appl(List(a, Constant("CURSOR"))) => {
1.73 g.setColor(Color.RED)
1.74 g.asInstanceOf[Graphics2D].drawLine(box.x, box.y, box.x + box.width , box.y)
1.75 @@ -56,19 +71,28 @@
1.76 if (box.children.length >= 1)
1.77 Draw(box.children.head, g)
1.78 }
1.79 +
1.80 }
1.81 case _ => {
1.82 if (box.children.length >= 1)
1.83 Draw(box.children.head, g)
1.84 }
1.85 +
1.86 }
1.87 +
1.88 +
1.89 +
1.90 +
1.91 +
1.92 def drawPlus(g: Graphics, box : DrawBox) {
1.93 val font_var = new Font("CMCSC8", Font.PLAIN, CalcUtil.fontsizeOf(box.level))
1.94 g.setFont(font_var)
1.95
1.96 g.drawString("+", box.x0, box.y0)
1.97 drawBox(box, g)
1.98 +
1.99 }
1.100 +
1.101 def drawDivide(g: Graphics, box : DrawBox) {
1.102 g.drawLine(box.x, box.y, box.x + box.width, box.y)
1.103 drawBox(box, g)
1.104 @@ -82,6 +106,7 @@
1.105 g.setFont(font_var)
1.106 g.drawString(charIndex.toChar.toString(), box.x0, box.y0)
1.107 drawBox(box, g)
1.108 +
1.109 }
1.110 case None => {
1.111 // Ident
1.112 @@ -97,6 +122,8 @@
1.113 }
1.114 }
1.115
1.116 +
1.117 +
1.118 }
1.119
1.120