11 Rectangle, Dimension, GraphicsEnvironment, MouseInfo, Toolkit} |
11 Rectangle, Dimension, GraphicsEnvironment, MouseInfo, Toolkit} |
12 import java.awt.font.{FontRenderContext, LineMetrics, TextAttribute, TransformAttribute} |
12 import java.awt.font.{FontRenderContext, LineMetrics, TextAttribute, TransformAttribute} |
13 import java.awt.geom.AffineTransform |
13 import java.awt.geom.AffineTransform |
14 import javax.swing.{ImageIcon, JButton, JDialog, JFrame, JLabel, JLayeredPane, JOptionPane, |
14 import javax.swing.{ImageIcon, JButton, JDialog, JFrame, JLabel, JLayeredPane, JOptionPane, |
15 JTextField, JWindow, LookAndFeel, UIManager, SwingUtilities} |
15 JTextField, JWindow, LookAndFeel, UIManager, SwingUtilities} |
16 import scala.swing.{ComboBox, ScrollPane, TextArea} |
16 import scala.swing.{CheckBox, ComboBox, ScrollPane, TextArea} |
17 import scala.swing.event.SelectionChanged |
17 import scala.swing.event.{ButtonClicked, SelectionChanged} |
18 |
18 |
19 |
19 |
20 object GUI { |
20 object GUI { |
21 /* Swing look-and-feel */ |
21 /* Swing look-and-feel */ |
22 |
22 |
109 java_message.toArray.asInstanceOf[Array[AnyRef]], title, |
109 java_message.toArray.asInstanceOf[Array[AnyRef]], title, |
110 option_type, JOptionPane.QUESTION_MESSAGE) |
110 option_type, JOptionPane.QUESTION_MESSAGE) |
111 } |
111 } |
112 |
112 |
113 |
113 |
114 /* variations on ComboBox */ |
114 /* basic GUI components */ |
|
115 |
|
116 class Bool(label: String, init: Boolean = false) extends CheckBox(label) { |
|
117 def clicked(state: Boolean): Unit = {} |
|
118 def clicked(): Unit = {} |
|
119 |
|
120 selected = init |
|
121 reactions += { case ButtonClicked(_) => clicked(selected); clicked() } |
|
122 } |
115 |
123 |
116 class Selector[A](val entries: List[A]) extends ComboBox[A](entries) { |
124 class Selector[A](val entries: List[A]) extends ComboBox[A](entries) { |
117 def changed(): Unit = {} |
125 def changed(): Unit = {} |
118 |
126 |
119 listenTo(selection) |
127 listenTo(selection) |
120 reactions += { case SelectionChanged(_) => changed() } |
128 reactions += { case SelectionChanged(_) => changed() } |
121 } |
129 } |
|
130 |
|
131 |
|
132 /* zoom factor */ |
122 |
133 |
123 private val Zoom_Factor = "([0-9]+)%?".r |
134 private val Zoom_Factor = "([0-9]+)%?".r |
124 |
135 |
125 class Zoom extends Selector[String]( |
136 class Zoom extends Selector[String]( |
126 List("50%", "70%", "85%", "100%", "125%", "150%", "175%", "200%", "300%", "400%") |
137 List("50%", "70%", "85%", "100%", "125%", "150%", "175%", "200%", "300%", "400%") |