From 30b389a9b0dede4363a5e67b13debf280f536832 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Tue, 3 Dec 2013 18:39:21 -0800 Subject: Modularize the swing library. The Scala Swing library will still ship with 2.11 (albeit unsupported). It now resides at https://github.com/scala/scala-swing. --- src/build/bnd/scala-swing.bnd | 2 +- src/build/dbuild-meta-json-gen.scala | 4 - src/build/maven/maven-deploy.xml | 1 - src/build/maven/scala-swing-pom.xml | 62 ---- src/intellij/parser-combinators.iml.SAMPLE | 22 -- src/intellij/partest.iml.SAMPLE | 24 -- src/intellij/scala-lang.ipr.SAMPLE | 4 - src/intellij/swing.iml.SAMPLE | 24 -- src/intellij/xml.iml.SAMPLE | 22 -- src/swing/doc/README | 39 --- src/swing/doc/build.xml | 83 ------ src/swing/scala/swing/AbstractButton.scala | 87 ------ src/swing/scala/swing/Action.scala | 162 ----------- src/swing/scala/swing/Adjustable.scala | 53 ---- src/swing/scala/swing/Alignment.scala | 32 --- src/swing/scala/swing/Applet.scala | 46 --- src/swing/scala/swing/BorderPanel.scala | 60 ---- src/swing/scala/swing/BoxPanel.scala | 26 -- src/swing/scala/swing/BufferWrapper.scala | 34 --- src/swing/scala/swing/Button.scala | 34 --- src/swing/scala/swing/ButtonGroup.scala | 38 --- src/swing/scala/swing/CheckBox.scala | 26 -- src/swing/scala/swing/ColorChooser.scala | 45 --- src/swing/scala/swing/ComboBox.scala | 209 -------------- src/swing/scala/swing/Component.scala | 295 ------------------- src/swing/scala/swing/Container.scala | 64 ----- src/swing/scala/swing/EditorPane.scala | 28 -- src/swing/scala/swing/FileChooser.scala | 111 ------- src/swing/scala/swing/FlowPanel.scala | 46 --- src/swing/scala/swing/FormattedTextField.scala | 40 --- src/swing/scala/swing/GridBagPanel.scala | 114 -------- src/swing/scala/swing/GridPanel.scala | 51 ---- src/swing/scala/swing/Label.scala | 62 ---- src/swing/scala/swing/LayoutContainer.scala | 73 ----- src/swing/scala/swing/ListView.scala | 246 ---------------- src/swing/scala/swing/MainFrame.scala | 17 -- src/swing/scala/swing/Menu.scala | 70 ----- src/swing/scala/swing/Orientable.scala | 27 -- src/swing/scala/swing/Orientation.scala | 19 -- src/swing/scala/swing/Oriented.scala | 35 --- src/swing/scala/swing/Panel.scala | 20 -- src/swing/scala/swing/PasswordField.scala | 34 --- src/swing/scala/swing/PopupMenu.scala | 65 ----- src/swing/scala/swing/ProgressBar.scala | 40 --- src/swing/scala/swing/RadioButton.scala | 25 -- src/swing/scala/swing/Reactions.scala | 54 ---- src/swing/scala/swing/Reactor.scala | 30 -- src/swing/scala/swing/RichWindow.scala | 195 ------------- src/swing/scala/swing/RootPanel.scala | 38 --- src/swing/scala/swing/ScrollBar.scala | 39 --- src/swing/scala/swing/ScrollPane.scala | 88 ------ src/swing/scala/swing/Scrollable.scala | 43 --- src/swing/scala/swing/Separator.scala | 23 -- src/swing/scala/swing/SequentialContainer.scala | 36 --- src/swing/scala/swing/SimpleSwingApplication.scala | 36 --- src/swing/scala/swing/Slider.scala | 71 ----- src/swing/scala/swing/SplitPane.scala | 63 ---- src/swing/scala/swing/Swing.scala | 141 --------- src/swing/scala/swing/SwingApplication.scala | 17 -- src/swing/scala/swing/TabbedPane.scala | 131 --------- src/swing/scala/swing/Table.scala | 320 --------------------- src/swing/scala/swing/TextArea.scala | 43 --- src/swing/scala/swing/TextComponent.scala | 75 ----- src/swing/scala/swing/TextField.scala | 79 ----- src/swing/scala/swing/ToggleButton.scala | 22 -- src/swing/scala/swing/UIElement.scala | 133 --------- src/swing/scala/swing/Window.scala | 78 ----- src/swing/scala/swing/event/ActionEvent.scala | 18 -- src/swing/scala/swing/event/AdjustingEvent.scala | 24 -- .../scala/swing/event/BackgroundChanged.scala | 14 - src/swing/scala/swing/event/ButtonClicked.scala | 15 - src/swing/scala/swing/event/CaretUpdate.scala | 14 - src/swing/scala/swing/event/ColorChanged.scala | 14 - src/swing/scala/swing/event/ComponentEvent.scala | 16 -- src/swing/scala/swing/event/ContainerEvent.scala | 17 -- src/swing/scala/swing/event/EditDone.scala | 14 - src/swing/scala/swing/event/Event.scala | 14 - src/swing/scala/swing/event/FocusEvent.scala | 23 -- src/swing/scala/swing/event/FontChanged.scala | 14 - .../scala/swing/event/ForegroundChanged.scala | 14 - src/swing/scala/swing/event/InputEvent.scala | 20 -- src/swing/scala/swing/event/Key.scala | 232 --------------- src/swing/scala/swing/event/KeyEvent.scala | 43 --- src/swing/scala/swing/event/ListEvent.scala | 43 --- src/swing/scala/swing/event/MouseEvent.scala | 79 ----- src/swing/scala/swing/event/PopupMenuEvent.scala | 18 -- src/swing/scala/swing/event/SelectionEvent.scala | 34 --- src/swing/scala/swing/event/TableEvent.scala | 46 --- src/swing/scala/swing/event/UIEvent.scala | 21 -- src/swing/scala/swing/event/ValueChanged.scala | 18 -- src/swing/scala/swing/event/WindowActivated.scala | 14 - src/swing/scala/swing/event/WindowClosed.scala | 4 - src/swing/scala/swing/event/WindowClosing.scala | 14 - .../scala/swing/event/WindowDeactivated.scala | 14 - .../scala/swing/event/WindowDeiconified.scala | 14 - src/swing/scala/swing/event/WindowEvent.scala | 14 - src/swing/scala/swing/event/WindowIconified.scala | 14 - src/swing/scala/swing/event/WindowOpened.scala | 14 - src/swing/scala/swing/model/Matrix.scala | 121 -------- src/swing/scala/swing/package.scala | 20 -- src/swing/swing.version.properties | 2 - 101 files changed, 1 insertion(+), 5385 deletions(-) delete mode 100644 src/build/maven/scala-swing-pom.xml delete mode 100644 src/intellij/parser-combinators.iml.SAMPLE delete mode 100644 src/intellij/partest.iml.SAMPLE delete mode 100644 src/intellij/swing.iml.SAMPLE delete mode 100644 src/intellij/xml.iml.SAMPLE delete mode 100644 src/swing/doc/README delete mode 100644 src/swing/doc/build.xml delete mode 100644 src/swing/scala/swing/AbstractButton.scala delete mode 100644 src/swing/scala/swing/Action.scala delete mode 100644 src/swing/scala/swing/Adjustable.scala delete mode 100644 src/swing/scala/swing/Alignment.scala delete mode 100644 src/swing/scala/swing/Applet.scala delete mode 100644 src/swing/scala/swing/BorderPanel.scala delete mode 100644 src/swing/scala/swing/BoxPanel.scala delete mode 100644 src/swing/scala/swing/BufferWrapper.scala delete mode 100644 src/swing/scala/swing/Button.scala delete mode 100644 src/swing/scala/swing/ButtonGroup.scala delete mode 100644 src/swing/scala/swing/CheckBox.scala delete mode 100644 src/swing/scala/swing/ColorChooser.scala delete mode 100644 src/swing/scala/swing/ComboBox.scala delete mode 100644 src/swing/scala/swing/Component.scala delete mode 100644 src/swing/scala/swing/Container.scala delete mode 100644 src/swing/scala/swing/EditorPane.scala delete mode 100644 src/swing/scala/swing/FileChooser.scala delete mode 100644 src/swing/scala/swing/FlowPanel.scala delete mode 100644 src/swing/scala/swing/FormattedTextField.scala delete mode 100644 src/swing/scala/swing/GridBagPanel.scala delete mode 100644 src/swing/scala/swing/GridPanel.scala delete mode 100644 src/swing/scala/swing/Label.scala delete mode 100644 src/swing/scala/swing/LayoutContainer.scala delete mode 100644 src/swing/scala/swing/ListView.scala delete mode 100644 src/swing/scala/swing/MainFrame.scala delete mode 100644 src/swing/scala/swing/Menu.scala delete mode 100644 src/swing/scala/swing/Orientable.scala delete mode 100644 src/swing/scala/swing/Orientation.scala delete mode 100644 src/swing/scala/swing/Oriented.scala delete mode 100644 src/swing/scala/swing/Panel.scala delete mode 100644 src/swing/scala/swing/PasswordField.scala delete mode 100644 src/swing/scala/swing/PopupMenu.scala delete mode 100644 src/swing/scala/swing/ProgressBar.scala delete mode 100644 src/swing/scala/swing/RadioButton.scala delete mode 100644 src/swing/scala/swing/Reactions.scala delete mode 100644 src/swing/scala/swing/Reactor.scala delete mode 100644 src/swing/scala/swing/RichWindow.scala delete mode 100644 src/swing/scala/swing/RootPanel.scala delete mode 100644 src/swing/scala/swing/ScrollBar.scala delete mode 100644 src/swing/scala/swing/ScrollPane.scala delete mode 100644 src/swing/scala/swing/Scrollable.scala delete mode 100644 src/swing/scala/swing/Separator.scala delete mode 100644 src/swing/scala/swing/SequentialContainer.scala delete mode 100644 src/swing/scala/swing/SimpleSwingApplication.scala delete mode 100644 src/swing/scala/swing/Slider.scala delete mode 100644 src/swing/scala/swing/SplitPane.scala delete mode 100644 src/swing/scala/swing/Swing.scala delete mode 100644 src/swing/scala/swing/SwingApplication.scala delete mode 100644 src/swing/scala/swing/TabbedPane.scala delete mode 100644 src/swing/scala/swing/Table.scala delete mode 100644 src/swing/scala/swing/TextArea.scala delete mode 100644 src/swing/scala/swing/TextComponent.scala delete mode 100644 src/swing/scala/swing/TextField.scala delete mode 100644 src/swing/scala/swing/ToggleButton.scala delete mode 100644 src/swing/scala/swing/UIElement.scala delete mode 100644 src/swing/scala/swing/Window.scala delete mode 100644 src/swing/scala/swing/event/ActionEvent.scala delete mode 100644 src/swing/scala/swing/event/AdjustingEvent.scala delete mode 100644 src/swing/scala/swing/event/BackgroundChanged.scala delete mode 100644 src/swing/scala/swing/event/ButtonClicked.scala delete mode 100644 src/swing/scala/swing/event/CaretUpdate.scala delete mode 100644 src/swing/scala/swing/event/ColorChanged.scala delete mode 100644 src/swing/scala/swing/event/ComponentEvent.scala delete mode 100644 src/swing/scala/swing/event/ContainerEvent.scala delete mode 100644 src/swing/scala/swing/event/EditDone.scala delete mode 100644 src/swing/scala/swing/event/Event.scala delete mode 100644 src/swing/scala/swing/event/FocusEvent.scala delete mode 100644 src/swing/scala/swing/event/FontChanged.scala delete mode 100644 src/swing/scala/swing/event/ForegroundChanged.scala delete mode 100644 src/swing/scala/swing/event/InputEvent.scala delete mode 100644 src/swing/scala/swing/event/Key.scala delete mode 100644 src/swing/scala/swing/event/KeyEvent.scala delete mode 100644 src/swing/scala/swing/event/ListEvent.scala delete mode 100644 src/swing/scala/swing/event/MouseEvent.scala delete mode 100644 src/swing/scala/swing/event/PopupMenuEvent.scala delete mode 100644 src/swing/scala/swing/event/SelectionEvent.scala delete mode 100644 src/swing/scala/swing/event/TableEvent.scala delete mode 100644 src/swing/scala/swing/event/UIEvent.scala delete mode 100644 src/swing/scala/swing/event/ValueChanged.scala delete mode 100644 src/swing/scala/swing/event/WindowActivated.scala delete mode 100644 src/swing/scala/swing/event/WindowClosed.scala delete mode 100644 src/swing/scala/swing/event/WindowClosing.scala delete mode 100644 src/swing/scala/swing/event/WindowDeactivated.scala delete mode 100644 src/swing/scala/swing/event/WindowDeiconified.scala delete mode 100644 src/swing/scala/swing/event/WindowEvent.scala delete mode 100644 src/swing/scala/swing/event/WindowIconified.scala delete mode 100644 src/swing/scala/swing/event/WindowOpened.scala delete mode 100644 src/swing/scala/swing/model/Matrix.scala delete mode 100644 src/swing/scala/swing/package.scala delete mode 100644 src/swing/swing.version.properties (limited to 'src') diff --git a/src/build/bnd/scala-swing.bnd b/src/build/bnd/scala-swing.bnd index eeacb9bd3f..7cccb1343b 100644 --- a/src/build/bnd/scala-swing.bnd +++ b/src/build/bnd/scala-swing.bnd @@ -1,5 +1,5 @@ Bundle-Name: Scala Swing -Bundle-SymbolicName: org.scala-lang.scala-swing +Bundle-SymbolicName: org.scala-lang.modules.scala-swing ver: @VERSION@ Bundle-Version: ${ver} Export-Package: *;version=${ver} diff --git a/src/build/dbuild-meta-json-gen.scala b/src/build/dbuild-meta-json-gen.scala index 1693513203..d1d4c12b3f 100644 --- a/src/build/dbuild-meta-json-gen.scala +++ b/src/build/dbuild-meta-json-gen.scala @@ -30,10 +30,6 @@ val meta = // Seq(ProjectRef("scala-interactive", "org.scala-lang")), // Seq(ProjectRef("scala-compiler", "org.scala-lang"), ProjectRef("scaladoc", "org.scala-lang"))), - Project("scala-swing", "org.scala-lang", - Seq(ProjectRef("scala-swing", "org.scala-lang")), - Seq(ProjectRef("scala-library", "org.scala-lang"))), - Project("scala-actors", "org.scala-lang", Seq(ProjectRef("scala-actors", "org.scala-lang")), Seq(ProjectRef("scala-library", "org.scala-lang"))), diff --git a/src/build/maven/maven-deploy.xml b/src/build/maven/maven-deploy.xml index 5146abd830..412d7caab6 100644 --- a/src/build/maven/maven-deploy.xml +++ b/src/build/maven/maven-deploy.xml @@ -124,7 +124,6 @@ --> - diff --git a/src/build/maven/scala-swing-pom.xml b/src/build/maven/scala-swing-pom.xml deleted file mode 100644 index 01c89f9bea..0000000000 --- a/src/build/maven/scala-swing-pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - 4.0.0 - org.scala-lang - scala-swing - jar - @VERSION@ - Scala Swing library - Swing for Scala - http://www.scala-lang.org/ - 2002 - - LAMP/EPFL - http://lamp.epfl.ch/ - - - - BSD 3-Clause - http://www.scala-lang.org/license.html - repo - - - - scm:git:git://github.com/scala/scala.git - https://github.com/scala/scala.git - - - JIRA - https://issues.scala-lang.org/ - - - http://www.scala-lang.org/api/@VERSION@/ - - - - org.scala-lang - scala-library - @VERSION@ - - - - - scala-tools.org - @RELEASE_REPOSITORY@ - - - scala-tools.org - @SNAPSHOT_REPOSITORY@ - false - - - - - lamp - EPFL LAMP - - - Typesafe - Typesafe, Inc. - - - diff --git a/src/intellij/parser-combinators.iml.SAMPLE b/src/intellij/parser-combinators.iml.SAMPLE deleted file mode 100644 index 1ef913dbe4..0000000000 --- a/src/intellij/parser-combinators.iml.SAMPLE +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/src/intellij/partest.iml.SAMPLE b/src/intellij/partest.iml.SAMPLE deleted file mode 100644 index 893236b621..0000000000 --- a/src/intellij/partest.iml.SAMPLE +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/src/intellij/scala-lang.ipr.SAMPLE b/src/intellij/scala-lang.ipr.SAMPLE index 975014cb6d..a0765b3e99 100644 --- a/src/intellij/scala-lang.ipr.SAMPLE +++ b/src/intellij/scala-lang.ipr.SAMPLE @@ -205,16 +205,12 @@ - - - - diff --git a/src/intellij/swing.iml.SAMPLE b/src/intellij/swing.iml.SAMPLE deleted file mode 100644 index c97bfdf91f..0000000000 --- a/src/intellij/swing.iml.SAMPLE +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/src/intellij/xml.iml.SAMPLE b/src/intellij/xml.iml.SAMPLE deleted file mode 100644 index b721f4e7f2..0000000000 --- a/src/intellij/xml.iml.SAMPLE +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/src/swing/doc/README b/src/swing/doc/README deleted file mode 100644 index cdfee01f82..0000000000 --- a/src/swing/doc/README +++ /dev/null @@ -1,39 +0,0 @@ -scala.swing BETA - -This is a UI library that will wrap most of Java Swing for Scala in a straightforward manner. -The widget class hierarchy loosely resembles that of Java Swing. The main differences are: - - In Java Swing all components are containers per default. This doesn't make much sense for - a number of components, like TextField, CheckBox, RadioButton, and so on. Our guess is that - this architecture was chosen because Java lacks multiple inheritance. - In scala.swing, components that can have child components extend the Container trait. - - Layout managers and panels are coupled. There is no way to exchange the layout manager - of a panel. As a result, the layout constraints for widgets can be typed. - (Note that you gain more type-safety and don't loose much flexibility here. Besides - being not a common operation, exchanging the layout manager of a panel in Java - Swing almost always leads to exchanging the layout constraints for every of the panel's - child component. In the end, it is not more work to move all children to a newly created - panel.) - - The event system. TODO - - -The library comprises three main packages: - - scala.swing - All widget classes and traits. - - scala.swing.event - The event hierarchy. - - scala.swing.test - A set of demos. - - -Notes: - -Visual appearance of combo boxes using the GTK LaF is broken on JDKs < 1.7b30. -This is a Java Swing problem. - -To download the latest version, go to http://lamp.epfl.ch/~imaier or use sbaz. diff --git a/src/swing/doc/build.xml b/src/swing/doc/build.xml deleted file mode 100644 index 20e141152b..0000000000 --- a/src/swing/doc/build.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/swing/scala/swing/AbstractButton.scala b/src/swing/scala/swing/AbstractButton.scala deleted file mode 100644 index fd84d6f151..0000000000 --- a/src/swing/scala/swing/AbstractButton.scala +++ /dev/null @@ -1,87 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import event._ -import javax.swing.{AbstractButton => JAbstractButton, Icon} - -/** - * Base class of all button-like widgets, such as push buttons, - * check boxes, and radio buttons. - * - * @see javax.swing.AbstractButton - */ -abstract class AbstractButton extends Component with Action.Trigger.Wrapper with Publisher { - override lazy val peer: JAbstractButton = new JAbstractButton with SuperMixin {} - - def text: String = peer.getText - def text_=(s: String) = peer.setText(s) - - def icon: Icon = peer.getIcon - def icon_=(i: Icon) = peer.setIcon(i) - def pressedIcon: Icon = peer.getPressedIcon - def pressedIcon_=(i: Icon) = peer.setPressedIcon(i) - def selectedIcon: Icon = peer.getSelectedIcon - def selectedIcon_=(i: Icon) = peer.setSelectedIcon(i) - def disabledIcon: Icon = peer.getDisabledIcon - def disabledIcon_=(i: Icon) = peer.setDisabledIcon(i) - def disabledSelectedIcon: Icon = peer.getDisabledSelectedIcon - def disabledSelectedIcon_=(i: Icon) = peer.setDisabledSelectedIcon(i) - def rolloverIcon: Icon = peer.getRolloverIcon - def rolloverIcon_=(b: Icon) = peer.setRolloverIcon(b) - def rolloverSelectedIcon: Icon = peer.getRolloverSelectedIcon - def rolloverSelectedIcon_=(b: Icon) = peer.setRolloverSelectedIcon(b) - - peer.addActionListener(Swing.ActionListener { e => - publish(ButtonClicked(AbstractButton.this)) - }) - - def selected: Boolean = peer.isSelected - def selected_=(b: Boolean) = peer.setSelected(b) - - def contentAreaFilled: Boolean = peer.isContentAreaFilled - def contentAreaFilled_=(b: Boolean) { peer.setContentAreaFilled(b) } - - def borderPainted: Boolean = peer.isBorderPainted - def borderPainted_=(b: Boolean) { peer.setBorderPainted(b) } - def focusPainted: Boolean = peer.isFocusPainted - def focusPainted_=(b: Boolean) { peer.setFocusPainted(b) } - - def rolloverEnabled: Boolean = peer.isRolloverEnabled - def rolloverEnabled_=(b: Boolean) = peer.setRolloverEnabled(b) - - def verticalTextPosition: Alignment.Value = Alignment(peer.getVerticalTextPosition) - def verticalTextPosition_=(a: Alignment.Value) { peer.setVerticalTextPosition(a.id) } - def verticalAlignment: Alignment.Value = Alignment(peer.getVerticalAlignment) - def verticalAlignment_=(a: Alignment.Value) { peer.setVerticalAlignment(a.id) } - - def horizontalTextPosition: Alignment.Value = Alignment(peer.getHorizontalTextPosition) - def horizontalTextPosition_=(a: Alignment.Value) { peer.setHorizontalTextPosition(a.id) } - def horizontalAlignment: Alignment.Value = Alignment(peer.getHorizontalAlignment) - def horizontalAlignment_=(a: Alignment.Value) { peer.setHorizontalAlignment(a.id) } - - def iconTextGap: Int = peer.getIconTextGap - def iconTextGap_=(x: Int) { peer.setIconTextGap(x) } - - def mnemonic: Key.Value = Key(peer.getMnemonic) - def mnemonic_=(k: Key.Value) { peer.setMnemonic(k.id) } - def displayedMnemonicIndex: Int = peer.getDisplayedMnemonicIndex - def displayedMnemonicIndex_=(n: Int) { peer.setDisplayedMnemonicIndex(n) } - - def multiClickThreshold: Long = peer.getMultiClickThreshhold - def multiClickThreshold_=(n: Long) { peer.setMultiClickThreshhold(n) } - - def doClick() { peer.doClick() } - def doClick(times: Int) { peer.doClick(times) } - - def margin: Insets = peer.getMargin - def margin_=(i: Insets) { peer.setMargin(i) } -} diff --git a/src/swing/scala/swing/Action.scala b/src/swing/scala/swing/Action.scala deleted file mode 100644 index 98b9fee2ee..0000000000 --- a/src/swing/scala/swing/Action.scala +++ /dev/null @@ -1,162 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import javax.swing.{KeyStroke, Icon} -import java.awt.event.ActionListener - -object Action { - /** - * Special action that has an empty title and all default properties and does nothing. - * Use this as a "null action", i.e., to tell components that they do not have any - * associated action. A component may then obtain its properties from its direct members - * instead of from its action. - * In Java Swing, one would use `null` instead of a designated action. - */ - case object NoAction extends Action("") { def apply() {} } - - object Trigger { - trait Wrapper extends Action.Trigger { - def peer: javax.swing.JComponent { - def addActionListener(a: ActionListener) - def removeActionListener(a: ActionListener) - def setAction(a: javax.swing.Action) - def getAction(): javax.swing.Action - } - - // TODO: we need an action cache - private var _action: Action = Action.NoAction - def action: Action = _action - def action_=(a: Action) { - _action = a; - - import scala.language.reflectiveCalls - peer.setAction(a.peer) - } - - //1.6: def hideActionText: Boolean = peer.getHideActionText - //def hideActionText_=(b: Boolean) = peer.setHideActionText(b) - } - } - - /** - * Something that triggers an action. - */ - trait Trigger { - def action: Action - def action_=(a: Action) - - //1.6: def hideActionText: Boolean - //def hideActionText_=(b: Boolean) - } - - /** - * Convenience method to create an action with a given title and body to run. - */ - def apply(title: String)(body: =>Unit) = new Action(title) { - def apply() { body } - } -} - -/** - * An abstract action to be performed in reaction to user input. - * - * Not every action component will honor every property of its action. - * An action itself can generally be configured so that certain properties - * should be ignored and instead taken from the component directly. In the - * end, it is up to a component which property it uses in which way. - * - * @see javax.swing.Action - */ -abstract class Action(title0: String) { - import Swing._ - - lazy val peer: javax.swing.Action = new javax.swing.AbstractAction(title0) { - def actionPerformed(a: java.awt.event.ActionEvent) = apply() - } - - /** - * Title is not optional. - */ - def title: String = ifNull(peer.getValue(javax.swing.Action.NAME),"") - def title_=(t: String) { peer.putValue(javax.swing.Action.NAME, t) } - - /** - * None if large icon and small icon are not equal. - */ - def icon: Icon = smallIcon //if(largeIcon == smallIcon) largeIcon else None - def icon_=(i: Icon) { /*largeIcon = i;*/ smallIcon = i } - // 1.6: def largeIcon: Icon = toNoIcon(peer.getValue(javax.swing.Action.LARGE_ICON_KEY).asInstanceOf[Icon]) - // def largeIcon_=(i: Icon) { peer.putValue(javax.swing.Action.LARGE_ICON_KEY, toNullIcon(i)) } - def smallIcon: Icon = toNoIcon(peer.getValue(javax.swing.Action.SMALL_ICON).asInstanceOf[Icon]) - def smallIcon_=(i: Icon) { peer.putValue(javax.swing.Action.SMALL_ICON, toNullIcon(i)) } - - /** - * For all components. - */ - def toolTip: String = - ifNull(peer.getValue(javax.swing.Action.SHORT_DESCRIPTION), "") - def toolTip_=(t: String) { - peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, t) - } - /** - * Can be used for status bars, for example. - */ - def longDescription: String = - ifNull(peer.getValue(javax.swing.Action.LONG_DESCRIPTION), "") - def longDescription_=(t: String) { - peer.putValue(javax.swing.Action.LONG_DESCRIPTION, t) - } - - /** - * Default: java.awt.event.KeyEvent.VK_UNDEFINED, i.e., no mnemonic key. - * For all buttons and thus menu items. - */ - def mnemonic: Int = ifNull(peer.getValue(javax.swing.Action.MNEMONIC_KEY), - java.awt.event.KeyEvent.VK_UNDEFINED) - def mnemonic_=(m: Int) { peer.putValue(javax.swing.Action.MNEMONIC_KEY, m) } - - /*/** - * Indicates which character of the title should be underlined to indicate the mnemonic key. - * Ignored if out of bounds of the title string. Default: -1, i.e., ignored. - * For all buttons and thus menu items. - */ - 1.6: def mnemonicIndex: Int = - ifNull(peer.getValue(javax.swing.Action.DISPLAYED_MNEMONIC_INDEX_KEY), -1) - def mnemonicIndex_=(n: Int) { peer.putValue(javax.swing.Action.DISPLAYED_MNEMONIC_INDEX_KEY, n) } - */ - - /** - * For menus. - */ - def accelerator: Option[KeyStroke] = - toOption(peer.getValue(javax.swing.Action.ACCELERATOR_KEY)) - def accelerator_=(k: Option[KeyStroke]) { - peer.putValue(javax.swing.Action.ACCELERATOR_KEY, k.orNull) - } - - /** - * For all components. - */ - def enabled: Boolean = peer.isEnabled - def enabled_=(b: Boolean) { peer.setEnabled(b) } - - /*/** - * Only honored if not None. For various buttons. - */ - 1.6: def selected: Option[Boolean] = Option(peer.getValue(javax.swing.Action.SELECTED_KEY)) - def selected_=(b: Option[Boolean]) { - peer.putValue(javax.swing.Action.SELECTED_KEY, - if (b == None) null else new java.lang.Boolean(b.get)) - }*/ - - def apply() -} diff --git a/src/swing/scala/swing/Adjustable.scala b/src/swing/scala/swing/Adjustable.scala deleted file mode 100644 index 590153fb33..0000000000 --- a/src/swing/scala/swing/Adjustable.scala +++ /dev/null @@ -1,53 +0,0 @@ -package scala.swing - -import java.awt.{Adjustable => JAdjustable} - -object Adjustable { - trait Wrapper extends Oriented.Wrapper with Adjustable { - def peer: JAdjustable with OrientedMixin - - def unitIncrement = peer.getUnitIncrement - def unitIncrement_=(i: Int) = peer.setUnitIncrement(i) - def blockIncrement = peer.getBlockIncrement - def blockIncrement_=(i: Int) = peer.setBlockIncrement(i) - - def value = peer.getValue - def value_=(v: Int) = peer.setValue(v) - - def visibleAmount = peer.getVisibleAmount - def visibleAmount_=(v: Int) = peer.setVisibleAmount(v) - - def minimum = peer.getMinimum - def minimum_=(m: Int) = peer.setMinimum(m) - def maximum = peer.getMaximum - def maximum_=(m: Int) = peer.setMaximum(m) - } -} - -trait Adjustable extends Oriented { - def unitIncrement: Int - def unitIncrement_=(i: Int) - def blockIncrement: Int - def blockIncrement_=(i: Int) - - def value: Int - def value_=(v : Int) - - def visibleAmount: Int - def visibleAmount_=(v: Int) - - def minimum: Int - def minimum_=(m: Int) - def maximum: Int - def maximum_=(m: Int) - -// Needs implementation of AdjustmentEvent -// -// val adjustments: Publisher = new Publisher { -// peer.addAdjustmentListener(new AdjustmentListener { -// def adjustmentValueChanged(e: java.awt.event.AdjustmentEvent) { -// publish(new AdjustmentEvent(e)) -// } -// }) -// } -} diff --git a/src/swing/scala/swing/Alignment.scala b/src/swing/scala/swing/Alignment.scala deleted file mode 100644 index b49e89dbd9..0000000000 --- a/src/swing/scala/swing/Alignment.scala +++ /dev/null @@ -1,32 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import javax.swing.SwingConstants._ - -/** - * Horizontal and vertical alignments. We sacrifice a bit of type-safety - * for simplicity here. - * - * @see javax.swing.SwingConstants - */ -object Alignment extends Enumeration { - val Left = Value(LEFT) - val Right = Value(RIGHT) - val Center = Value(CENTER) - val Top = Value(TOP) - val Bottom = Value(BOTTOM) - //1.6: val Baseline = Value(BASELINE) - - val Leading = Value(LEADING) - val Trailing = Value(TRAILING) -} - diff --git a/src/swing/scala/swing/Applet.scala b/src/swing/scala/swing/Applet.scala deleted file mode 100644 index b8ba4eabc0..0000000000 --- a/src/swing/scala/swing/Applet.scala +++ /dev/null @@ -1,46 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import javax.swing.JApplet - -/**

- * Clients should implement the ui field. See the SimpleApplet - * demo for an example. - *

- *

- * Note: Applet extends javax.swing.JApplet - * to satisfy Java's applet loading mechanism. The usual component wrapping - * scheme doesn't work here. - *

- * - * @see javax.swing.JApplet - */ -abstract class Applet extends JApplet { outer => - val ui: UI - - override def init() { ui.init() } - override def start() { ui.start() } - override def stop() { ui.stop() } - - abstract class UI extends RootPanel { - def peer = outer - override def contents_=(c: Component) { - super.contents_=(c) - peer.validate() - } - - def init() - def start() {} - def stop() {} - } -} - diff --git a/src/swing/scala/swing/BorderPanel.scala b/src/swing/scala/swing/BorderPanel.scala deleted file mode 100644 index 75bb721ffc..0000000000 --- a/src/swing/scala/swing/BorderPanel.scala +++ /dev/null @@ -1,60 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import java.awt.BorderLayout - -object BorderPanel { - /** - * The position of a component in a BorderPanel - */ - object Position extends Enumeration { - val North = Value(BorderLayout.NORTH) - val South = Value(BorderLayout.SOUTH) - val West = Value(BorderLayout.WEST) - val East = Value(BorderLayout.EAST) - val Center = Value(BorderLayout.CENTER) - } - private[swing] def wrapPosition(s: String): Position.Value = s match { - case BorderLayout.NORTH => Position.North - case BorderLayout.SOUTH => Position.South - case BorderLayout.WEST => Position.West - case BorderLayout.EAST => Position.East - case BorderLayout.CENTER => Position.Center - } -} - -/** - * A container that arranges its children around a central component that - * takes most of the space. The other children are placed on one of four - * borders: north, east, south, west. - * - * @see javax.swing.BorderLayout - */ -class BorderPanel extends Panel with LayoutContainer { - import BorderPanel._ - def layoutManager = peer.getLayout.asInstanceOf[BorderLayout] - override lazy val peer = new javax.swing.JPanel(new BorderLayout) with SuperMixin - - type Constraints = Position.Value - - protected def constraintsFor(comp: Component) = - wrapPosition(layoutManager.getConstraints(comp.peer).asInstanceOf[String]) - - protected def areValid(c: Constraints): (Boolean, String) = (true, "") - protected def add(c: Component, l: Constraints) { - // we need to remove previous components with the same constraints as the new one, - // otherwise the layout manager loses track of the old one - val old = layoutManager.getLayoutComponent(l.toString) - if(old != null) peer.remove(old) - peer.add(c.peer, l.toString) - } -} diff --git a/src/swing/scala/swing/BoxPanel.scala b/src/swing/scala/swing/BoxPanel.scala deleted file mode 100644 index f5859a8bb1..0000000000 --- a/src/swing/scala/swing/BoxPanel.scala +++ /dev/null @@ -1,26 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -/** - * A panel that lays out its contents one after the other, - * either horizontally or vertically. - * - * @see javax.swing.BoxLayout - */ -class BoxPanel(orientation: Orientation.Value) extends Panel with SequentialContainer.Wrapper { - override lazy val peer = { - val p = new javax.swing.JPanel with SuperMixin - val l = new javax.swing.BoxLayout(p, orientation.id) - p.setLayout(l) - p - } -} diff --git a/src/swing/scala/swing/BufferWrapper.scala b/src/swing/scala/swing/BufferWrapper.scala deleted file mode 100644 index 38230ba6eb..0000000000 --- a/src/swing/scala/swing/BufferWrapper.scala +++ /dev/null @@ -1,34 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import scala.collection.mutable.Buffer -import scala.collection.Iterator - -/** - * Default partial implementation for buffer adapters. - */ -protected[swing] abstract class BufferWrapper[A] extends Buffer[A] { outer => - def clear() { for (i <- 0 until length) remove(0) } - def update(n: Int, a: A) { - remove(n) - insertAt(n, a) - } - def insertAll(n: Int, elems: Traversable[A]) { - var i = n - for (el <- elems) { - insertAt(i, el) - i += 1 - } - } - protected def insertAt(n: Int, a: A) - - def +=:(a: A): this.type = { insertAt(0, a); this } - def iterator = Iterator.range(0,length).map(apply(_)) -} diff --git a/src/swing/scala/swing/Button.scala b/src/swing/scala/swing/Button.scala deleted file mode 100644 index 0170727e3b..0000000000 --- a/src/swing/scala/swing/Button.scala +++ /dev/null @@ -1,34 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import javax.swing._ - -object Button { - def apply(text0: String)(op: => Unit) = new Button(Action(text0)(op)) -} - -/** - * A button that can be clicked, usually to perform some action. - * - * @see javax.swing.JButton - */ -class Button(text0: String) extends AbstractButton with Publisher { - override lazy val peer: JButton = new JButton(text0) with SuperMixin - def this() = this("") - def this(a: Action) = { - this("") - action = a - } - - def defaultButton: Boolean = peer.isDefaultButton - - def defaultCapable: Boolean = peer.isDefaultCapable - def defaultCapable_=(capable: Boolean) { peer.setDefaultCapable(capable) } -} diff --git a/src/swing/scala/swing/ButtonGroup.scala b/src/swing/scala/swing/ButtonGroup.scala deleted file mode 100644 index 0b04d20837..0000000000 --- a/src/swing/scala/swing/ButtonGroup.scala +++ /dev/null @@ -1,38 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import scala.collection.mutable - -/** - * A button mutex. At most one of its associated buttons is selected - * at a time. - * - * @see javax.swing.ButtonGroup - */ -class ButtonGroup(initialButtons: AbstractButton*) { - val peer: javax.swing.ButtonGroup = new javax.swing.ButtonGroup - - val buttons: mutable.Set[AbstractButton] = new mutable.Set[AbstractButton] { - def -=(b: AbstractButton): this.type = { peer.remove(b.peer); this } - def +=(b: AbstractButton): this.type = { peer.add(b.peer); this } - def contains(b: AbstractButton) = this.iterator.contains(b) - override def size = peer.getButtonCount - def iterator: Iterator[AbstractButton] = new Iterator[AbstractButton] { - val enum = peer.getElements - def next = UIElement.cachedWrapper[AbstractButton](enum.nextElement) - def hasNext = enum.hasMoreElements - } - } - buttons ++= initialButtons - - //1.6: def deselectAll() { peer.clearSelection } - def selected: Option[AbstractButton] = buttons.find(_.selected) - def select(b: AbstractButton) { peer.setSelected(b.peer.getModel, true) } -} diff --git a/src/swing/scala/swing/CheckBox.scala b/src/swing/scala/swing/CheckBox.scala deleted file mode 100644 index 7287c95a5d..0000000000 --- a/src/swing/scala/swing/CheckBox.scala +++ /dev/null @@ -1,26 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import javax.swing._ - -/** - * Two state button that can either be checked or unchecked. - * - * @see javax.swing.JCheckBox - */ -class CheckBox(text: String) extends ToggleButton { - override lazy val peer: JCheckBox = new JCheckBox(text) with SuperMixin - def this() = this("") - - def borderPaintedFlat: Boolean = peer.isBorderPaintedFlat - def borderPaintedFlat_=(flat: Boolean) { peer.setBorderPaintedFlat(flat) } -} diff --git a/src/swing/scala/swing/ColorChooser.scala b/src/swing/scala/swing/ColorChooser.scala deleted file mode 100644 index 591e652f1c..0000000000 --- a/src/swing/scala/swing/ColorChooser.scala +++ /dev/null @@ -1,45 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import javax.swing.JColorChooser -import event._ - -/** - * Wrapper for JColorChooser. Publishes `ColorChanged` events, when the color selection changes. - * - * @author andy@hicks.net - * @author Ingo Maier - * @see javax.swing.JColorChooser - */ -object ColorChooser { - def showDialog(parent: Component, title: String, color: Color): scala.Option[Color] = { - toOption[Color](javax.swing.JColorChooser.showDialog(parent.peer, title, color)) - } -} - -class ColorChooser(color0: Color) extends Component { - def this() = this(java.awt.Color.white) - - override lazy val peer: JColorChooser = new JColorChooser(color0) with SuperMixin - - peer.getSelectionModel.addChangeListener(new javax.swing.event.ChangeListener { - def stateChanged(e: javax.swing.event.ChangeEvent) { - publish(ColorChanged(ColorChooser.this, peer.getColor)) - } - }) - - def color: Color = peer.getColor - def color_=(c: Color) = peer.setColor(c) - - def dragEnabled: Boolean = peer.getDragEnabled - def dragEnabled_=(b: Boolean) = peer.setDragEnabled(b) -} \ No newline at end of file diff --git a/src/swing/scala/swing/ComboBox.scala b/src/swing/scala/swing/ComboBox.scala deleted file mode 100644 index a075d22a7e..0000000000 --- a/src/swing/scala/swing/ComboBox.scala +++ /dev/null @@ -1,209 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import event._ -import javax.swing.{JList, JComponent, JComboBox, JTextField, ComboBoxModel, AbstractListModel, ListCellRenderer} -import java.awt.event.ActionListener -import scala.language.implicitConversions - -object ComboBox { - /** - * An editor for a combo box. Let's you edit the currently selected item. - * It is highly recommended to use the BuiltInEditor class. For anything - * else, one cannot guarantee that it integrates nicely with the current - * LookAndFeel. - * - * Publishes action events. - */ - trait Editor[A] extends Publisher { - lazy val comboBoxPeer: javax.swing.ComboBoxEditor = new javax.swing.ComboBoxEditor with Publisher { - def addActionListener(l: ActionListener) { - this match { - // TODO case w: Action.Trigger.Wrapper => - // w.peer.addActionListener(l) - case _ => - this.subscribe(new Reactions.Wrapper(l) ({ - case ActionEvent(c) => l.actionPerformed(new java.awt.event.ActionEvent(c.peer, 0, "")) - })) - } - } - def removeActionListener(l: ActionListener) { - this match { - // TODO case w: Action.Trigger.Wrapper => - // w.peer.removeActionListener(l) - case _ => - this.unsubscribe(new Reactions.Wrapper(l)({ case _ => })) - } - } - def getEditorComponent: JComponent = Editor.this.component.peer - def getItem(): AnyRef = item.asInstanceOf[AnyRef] - def selectAll() { startEditing() } - def setItem(a: Any) { item = a.asInstanceOf[A] } - } - def component: Component - def item: A - def item_=(a: A) - def startEditing() - } - - /** - * Use this editor, if you want to reuse the builtin editor supplied by the current - * Look and Feel. This is restricted to a text field as the editor widget. The - * conversion from and to a string is done by the supplied functions. - * - * It's okay if string2A throws exceptions. They are caught by an input verifier. - */ - class BuiltInEditor[A](comboBox: ComboBox[A])(string2A: String => A, - a2String: A => String) extends ComboBox.Editor[A] { - protected[swing] class DelegatedEditor(editor: javax.swing.ComboBoxEditor) extends javax.swing.ComboBoxEditor { - var value: A = { - val v = comboBox.peer.getSelectedItem - try { - v match { - case s: String => string2A(s) - case _ => v.asInstanceOf[A] - } - } catch { - case _: Exception => - throw new IllegalArgumentException("ComboBox not initialized with a proper value, was '" + v + "'.") - } - } - def addActionListener(l: ActionListener) { - editor.addActionListener(l) - } - def removeActionListener(l: ActionListener) { - editor.removeActionListener(l) - } - - def getEditorComponent: JComponent = editor.getEditorComponent.asInstanceOf[JComponent] - def selectAll() { editor.selectAll() } - def getItem(): AnyRef = { verifier.verify(getEditorComponent); value.asInstanceOf[AnyRef] } - def setItem(a: Any) { editor.setItem(a) } - - val verifier = new javax.swing.InputVerifier { - // TODO: should chain with potentially existing verifier in editor - def verify(c: JComponent) = try { - value = string2A(c.asInstanceOf[JTextField].getText) - true - } - catch { - case e: Exception => false - } - } - - def textEditor = getEditorComponent.asInstanceOf[JTextField] - textEditor.setInputVerifier(verifier) - textEditor.addActionListener(Swing.ActionListener{ a => - getItem() // make sure our value is updated - textEditor.setText(a2String(value)) - }) - } - - override lazy val comboBoxPeer: javax.swing.ComboBoxEditor = new DelegatedEditor(comboBox.peer.getEditor) - - def component = Component.wrap(comboBoxPeer.getEditorComponent.asInstanceOf[JComponent]) - def item: A = { comboBoxPeer.asInstanceOf[DelegatedEditor].value } - def item_=(a: A) { comboBoxPeer.setItem(a2String(a)) } - def startEditing() { comboBoxPeer.selectAll() } - } - - implicit def stringEditor(c: ComboBox[String]): Editor[String] = new BuiltInEditor(c)(s => s, s => s) - implicit def intEditor(c: ComboBox[Int]): Editor[Int] = new BuiltInEditor(c)(s => s.toInt, s => s.toString) - implicit def floatEditor(c: ComboBox[Float]): Editor[Float] = new BuiltInEditor(c)(s => s.toFloat, s => s.toString) - implicit def doubleEditor(c: ComboBox[Double]): Editor[Double] = new BuiltInEditor(c)(s => s.toDouble, s => s.toString) - - def newConstantModel[A](items: Seq[A]): ComboBoxModel = { - new AbstractListModel with ComboBoxModel { - private var selected: A = if (items.isEmpty) null.asInstanceOf[A] else items(0) - def getSelectedItem: AnyRef = selected.asInstanceOf[AnyRef] - def setSelectedItem(a: Any) { - if ((selected != null && selected != a) || - selected == null && a != null) { - selected = a.asInstanceOf[A] - fireContentsChanged(this, -1, -1) - } - } - def getElementAt(n: Int) = items(n).asInstanceOf[AnyRef] - def getSize = items.size - } - } - - /*def newMutableModel[A, Self](items: Seq[A] with scala.collection.mutable.Publisher[scala.collection.mutable.Message[A], Self]): ComboBoxModel = { - new AbstractListModel with ComboBoxModel { - private var selected = items(0) - def getSelectedItem: AnyRef = selected.asInstanceOf[AnyRef] - def setSelectedItem(a: Any) { selected = a.asInstanceOf[A] } - def getElementAt(n: Int) = items(n).asInstanceOf[AnyRef] - def getSize = items.size - } - } - - def newConstantModel[A](items: Seq[A]): ComboBoxModel = items match { - case items: Seq[A] with scala.collection.mutable.Publisher[scala.collection.mutable.Message[A], Self] => newMutableModel - case _ => newConstantModel(items) - }*/ -} - -/** - * Let's the user make a selection from a list of predefined items. Visually, - * this is implemented as a button-like component with a pull-down menu. - * - * @see javax.swing.JComboBox - */ -class ComboBox[A](items: Seq[A]) extends Component with Publisher { - override lazy val peer: JComboBox = new JComboBox(ComboBox.newConstantModel(items)) with SuperMixin - - object selection extends Publisher { - def index: Int = peer.getSelectedIndex - def index_=(n: Int) { peer.setSelectedIndex(n) } - def item: A = peer.getSelectedItem.asInstanceOf[A] - def item_=(a: A) { peer.setSelectedItem(a) } - - peer.addActionListener(Swing.ActionListener { e => - publish(event.SelectionChanged(ComboBox.this)) - }) - } - - /** - * Sets the renderer for this combo box's items. Index -1 is - * passed to the renderer for the selected item (not in the pull-down menu). - * - * The underlying combo box renders all items in a ListView - * (both, in the pull-down menu as well as in the box itself), hence the - * ListView.Renderer. - * - * Note that the UI peer of a combo box usually changes the colors - * of the component to its own defaults _after_ the renderer has been - * configured. That's Swing's principle of most suprise. - */ - def renderer: ListView.Renderer[A] = ListView.Renderer.wrap[A](peer.getRenderer) - def renderer_=(r: ListView.Renderer[A]) { peer.setRenderer(r.peer) } - - /* XXX: currently not safe to expose: - def editor: ComboBox.Editor[A] = - def editor_=(r: ComboBox.Editor[A]) { peer.setEditor(r.comboBoxPeer) } - */ - def editable: Boolean = peer.isEditable - - /** - * Makes this combo box editable. In order to do so, this combo needs an - * editor which is supplied by the implicit argument. For default - * editors, see ComboBox companion object. - */ - def makeEditable()(implicit editor: ComboBox[A] => ComboBox.Editor[A]) { - peer.setEditable(true) - peer.setEditor(editor(this).comboBoxPeer) - } - - def prototypeDisplayValue: Option[A] = toOption[A](peer.getPrototypeDisplayValue) - def prototypeDisplayValue_=(v: Option[A]) { - peer.setPrototypeDisplayValue((v map toAnyRef).orNull) - } -} diff --git a/src/swing/scala/swing/Component.scala b/src/swing/scala/swing/Component.scala deleted file mode 100644 index 3a47784562..0000000000 --- a/src/swing/scala/swing/Component.scala +++ /dev/null @@ -1,295 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import event._ - -import java.awt.Graphics -import java.awt.event._ -import javax.swing.JComponent -import javax.swing.border.Border - -/** - * Utility methods, mostly for wrapping components. - */ -object Component { - /** - * Wraps a given Java Swing Component into a new wrapper. - */ - def wrap(c: JComponent): Component = { - val w = UIElement.cachedWrapper[Component](c) - if (w != null) w - else new Component { override lazy val peer = c } - } -} - -/** - * Base class for all UI elements that can be displayed in a window. - * Components are publishers that fire the following event classes: - * ComponentEvent, FocusEvent, FontChanged, ForegroundChanged, BackgroundChanged. - * - * @note [Java Swing] Unlike in Java Swing, not all components are also containers. - * - * @see javax.swing.JComponent - * @see http://java.sun.com/products/jfc/tsc/articles/painting/ for the component - * painting mechanism - */ -abstract class Component extends UIElement { - override lazy val peer: javax.swing.JComponent = new javax.swing.JComponent with SuperMixin {} - var initP: JComponent = null - - /** - * This trait is used to redirect certain calls from the peer to the wrapper - * and back. Useful to expose methods that can be customized by overriding. - */ - protected trait SuperMixin extends JComponent { - override def paintComponent(g: Graphics) { - Component.this.paintComponent(g.asInstanceOf[Graphics2D]) - } - def __super__paintComponent(g: Graphics) { - super.paintComponent(g) - } - override def paintBorder(g: Graphics) { - Component.this.paintBorder(g.asInstanceOf[Graphics2D]) - } - def __super__paintBorder(g: Graphics) { - super.paintBorder(g) - } - override def paintChildren(g: Graphics) { - Component.this.paintChildren(g.asInstanceOf[Graphics2D]) - } - def __super__paintChildren(g: Graphics) { - super.paintChildren(g) - } - - override def paint(g: Graphics) { - Component.this.paint(g.asInstanceOf[Graphics2D]) - } - def __super__paint(g: Graphics) { - super.paint(g) - } - } - - def name: String = peer.getName - def name_=(s: String) = peer.setName(s) - - /** - * Used by certain layout managers, e.g., BoxLayout or OverlayLayout to - * align components relative to each other. - */ - def xLayoutAlignment: Double = peer.getAlignmentX.toDouble - def xLayoutAlignment_=(x: Double) = peer.setAlignmentX(x.toFloat) - def yLayoutAlignment: Double = peer.getAlignmentY.toDouble - def yLayoutAlignment_=(y: Double) = peer.setAlignmentY(y.toFloat) - - def border: Border = peer.getBorder - def border_=(b: Border) { peer.setBorder(b) } - - def opaque: Boolean = peer.isOpaque - def opaque_=(b: Boolean) = peer.setOpaque(b) - - def enabled: Boolean = peer.isEnabled - def enabled_=(b: Boolean) = peer.setEnabled(b) - - def tooltip: String = peer.getToolTipText - def tooltip_=(t: String) = peer.setToolTipText(t) - - def inputVerifier: Component => Boolean = { a => - Option(peer.getInputVerifier) forall (_ verify a.peer) - } - def inputVerifier_=(v: Component => Boolean) { - peer.setInputVerifier(new javax.swing.InputVerifier { - def verify(c: javax.swing.JComponent) = v(UIElement.cachedWrapper[Component](c)) - }) - } - - /*def verifyOnTraversal: (Component, Component) => Boolean = { a => - peer.getInputVerifier().verify(a.peer) - } - def verifyOnTraversal_=(v: (Component, Component) => Boolean) { - peer.setInputVerifier(new javax.swing.InputVerifier { - def verify(c: javax.swing.JComponent) = v(UIElement.cachedWrapper[Component](c)) - }) - }*/ - /** - * Contains publishers for various mouse events. They are separated for - * efficiency reasons. - */ - object mouse { - /** - * Publishes clicks, presses and releases. - */ - val clicks: Publisher = new LazyPublisher { - lazy val l = new MouseListener { - def mouseEntered(e: java.awt.event.MouseEvent) {} - def mouseExited(e: java.awt.event.MouseEvent) {} - def mouseClicked(e: java.awt.event.MouseEvent) { - publish(new MouseClicked(e)) - } - def mousePressed(e: java.awt.event.MouseEvent) { - publish(new MousePressed(e)) - } - def mouseReleased(e: java.awt.event.MouseEvent) { - publish(new MouseReleased(e)) - } - } - - def onFirstSubscribe() = peer.addMouseListener(l) - def onLastUnsubscribe() = peer.removeMouseListener(l) - } - /** - * Publishes enters, exits, moves, and drags. - */ - val moves: Publisher = new LazyPublisher { - lazy val mouseListener = new MouseListener { - def mouseEntered(e: java.awt.event.MouseEvent) { - publish(new MouseEntered(e)) - } - def mouseExited(e: java.awt.event.MouseEvent) { - publish(new MouseExited(e)) - } - def mouseClicked(e: java.awt.event.MouseEvent) {} - def mousePressed(e: java.awt.event.MouseEvent) {} - def mouseReleased(e: java.awt.event.MouseEvent) {} - } - - lazy val mouseMotionListener = new MouseMotionListener { - def mouseMoved(e: java.awt.event.MouseEvent) { - publish(new MouseMoved(e)) - } - def mouseDragged(e: java.awt.event.MouseEvent) { - publish(new MouseDragged(e)) - } - } - def onFirstSubscribe() { - peer.addMouseListener(mouseListener) - peer.addMouseMotionListener(mouseMotionListener) - } - def onLastUnsubscribe() { - peer.removeMouseListener(mouseListener) - peer.removeMouseMotionListener(mouseMotionListener) - } - } - /** - * Publishes mouse wheel moves. - */ - val wheel: Publisher = new LazyPublisher { - // We need to subscribe lazily and unsubscribe, since components in scroll panes capture - // mouse wheel events if there is a listener installed. See ticket #1442. - lazy val l = new MouseWheelListener { - def mouseWheelMoved(e: java.awt.event.MouseWheelEvent) { - publish(new MouseWheelMoved(e)) - } - } - def onFirstSubscribe() = peer.addMouseWheelListener(l) - def onLastUnsubscribe() = peer.removeMouseWheelListener(l) - } - } - - object keys extends Publisher { - peer.addKeyListener(new KeyListener { - def keyPressed(e: java.awt.event.KeyEvent) { publish(new KeyPressed(e)) } - def keyReleased(e: java.awt.event.KeyEvent) { publish(new KeyReleased(e)) } - def keyTyped(e: java.awt.event.KeyEvent) { publish(new KeyTyped(e)) } - }) - } - - def focusable: Boolean = peer.isFocusable - def focusable_=(b: Boolean) = peer.setFocusable(b) - def requestFocus() = peer.requestFocus() - def requestFocusInWindow() = peer.requestFocusInWindow() - def hasFocus: Boolean = peer.isFocusOwner - - protected override def onFirstSubscribe() { - super.onFirstSubscribe - // TODO: deprecated, remove after 2.8 - peer.addComponentListener(new java.awt.event.ComponentListener { - def componentHidden(e: java.awt.event.ComponentEvent) { - publish(UIElementHidden(Component.this)) - } - def componentShown(e: java.awt.event.ComponentEvent) { - publish(UIElementShown(Component.this)) - } - def componentMoved(e: java.awt.event.ComponentEvent) { - publish(UIElementMoved(Component.this)) - } - def componentResized(e: java.awt.event.ComponentEvent) { - publish(UIElementResized(Component.this)) - } - }) - - peer.addFocusListener(new java.awt.event.FocusListener { - def other(e: java.awt.event.FocusEvent) = e.getOppositeComponent match { - case c: JComponent => Some(UIElement.cachedWrapper[Component](c)) - case _ => None - } - - def focusGained(e: java.awt.event.FocusEvent) { - publish(FocusGained(Component.this, other(e), e.isTemporary)) - } - def focusLost(e: java.awt.event.FocusEvent) { - publish(FocusLost(Component.this, other(e), e.isTemporary)) - } - }) - - peer.addPropertyChangeListener(new java.beans.PropertyChangeListener { - def propertyChange(e: java.beans.PropertyChangeEvent) { - e.getPropertyName match { - case "font" => publish(FontChanged(Component.this)) - case "background" => publish(BackgroundChanged(Component.this)) - case "foreground" => publish(ForegroundChanged(Component.this)) - case _ => - /*case "focusable" => - case "focusTraversalKeysEnabled" => - case "forwardFocusTraversalKeys" => - case "backwardFocusTraversalKeys" => - case "upCycleFocusTraversalKeys" => - case "downCycleFocusTraversalKeys" => - case "focusTraversalPolicy" => - case "focusCycleRoot" =>*/ - } - } - }) - } - - def revalidate() { peer.revalidate() } - - /** - * For custom painting, users should usually override this method. - */ - protected def paintComponent(g: Graphics2D) { - peer match { - case peer: SuperMixin => peer.__super__paintComponent(g) - case _ => - } - } - - protected def paintBorder(g: Graphics2D) { - peer match { - case peer: SuperMixin => peer.__super__paintBorder(g) - case _ => - } - } - - protected def paintChildren(g: Graphics2D) { - peer match { - case peer: SuperMixin => peer.__super__paintChildren(g) - case _ => - } - } - - def paint(g: Graphics2D) { - peer match { - case peer: SuperMixin => peer.__super__paint(g) - case _ => peer.paint(g) - } - } - - override def toString = "scala.swing wrapper " + peer.toString -} diff --git a/src/swing/scala/swing/Container.scala b/src/swing/scala/swing/Container.scala deleted file mode 100644 index 24889f0ceb..0000000000 --- a/src/swing/scala/swing/Container.scala +++ /dev/null @@ -1,64 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import event._ -import scala.collection.mutable.Buffer - -object Container { - /** - * Utility trait for wrapping containers. Provides an immutable - * implementation of the contents member. - */ - trait Wrapper extends Container with Publisher { - override def peer: javax.swing.JComponent - - protected val _contents = new Content - def contents: Seq[Component] = _contents - - protected class Content extends BufferWrapper[Component] { - override def clear() { peer.removeAll() } - override def remove(n: Int): Component = { - val c = peer.getComponent(n) - peer.remove(n) - UIElement.cachedWrapper[Component](c) - } - protected def insertAt(n: Int, c: Component) { peer.add(c.peer, n) } - def +=(c: Component): this.type = { peer.add(c.peer) ; this } - def length = peer.getComponentCount - def apply(n: Int) = UIElement.cachedWrapper[Component](peer.getComponent(n)) - } - - peer.addContainerListener(new java.awt.event.ContainerListener { - def componentAdded(e: java.awt.event.ContainerEvent) { - publish(ComponentAdded(Wrapper.this, - UIElement.cachedWrapper[Component](e.getChild.asInstanceOf[javax.swing.JComponent]))) - } - def componentRemoved(e: java.awt.event.ContainerEvent) { - publish(ComponentRemoved(Wrapper.this, - UIElement.cachedWrapper[Component](e.getChild.asInstanceOf[javax.swing.JComponent]))) - } - }) - } -} - -/** - * The base traits for UI elements that can contain Components. - * - * @note [Java Swing] This is not the wrapper for java.awt.Container but a trait - * that extracts a common interface for components, menus, and windows. - */ -trait Container extends UIElement { - /** - * The child components of this container. - */ - def contents: Seq[Component] -} diff --git a/src/swing/scala/swing/EditorPane.scala b/src/swing/scala/swing/EditorPane.scala deleted file mode 100644 index 9b1aab7874..0000000000 --- a/src/swing/scala/swing/EditorPane.scala +++ /dev/null @@ -1,28 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import javax.swing._ -import javax.swing.text._ - -/** - * A text component that allows multiline text input and display. - * - * @see javax.swing.JEditorPane - */ -class EditorPane(contentType0: String, text0: String) extends TextComponent { - override lazy val peer: JEditorPane = new JEditorPane(contentType0, text0) with SuperMixin - def this() = this("text/plain", "") - - def contentType: String = peer.getContentType - def contentType_=(t: String) = peer.setContentType(t) - - def editorKit: EditorKit = peer.getEditorKit - def editorKit_=(k: EditorKit) = peer.setEditorKit(k) -} diff --git a/src/swing/scala/swing/FileChooser.scala b/src/swing/scala/swing/FileChooser.scala deleted file mode 100644 index e731c676c2..0000000000 --- a/src/swing/scala/swing/FileChooser.scala +++ /dev/null @@ -1,111 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import java.io.File -import javax.swing._ -import javax.swing.filechooser._ - -object FileChooser { - /** - * The result of a file dialog. The precise meaning of the `Approve` - * result depends on the specific dialog type. Could be `"save"` or - * `"open"` for instance. - */ - object Result extends Enumeration { - val Cancel = Value(JFileChooser.CANCEL_OPTION) - val Approve = Value(JFileChooser.APPROVE_OPTION) - val Error = Value(JFileChooser.ERROR_OPTION) - } - - /** - * The kind of elements a user can select in a file dialog. - */ - object SelectionMode extends Enumeration { - val FilesOnly = Value(JFileChooser.FILES_ONLY) - val DirectoriesOnly = Value(JFileChooser.DIRECTORIES_ONLY) - val FilesAndDirectories = Value(JFileChooser.FILES_AND_DIRECTORIES) - } -} - -/** - * Used to open file dialogs. - * - * @see [[javax.swing.JFileChooser]] - */ -class FileChooser(dir: File) { - import FileChooser._ - lazy val peer: JFileChooser = new JFileChooser(dir) - - def this() = this(null) - - import Swing._ - def showOpenDialog(over: Component): Result.Value = Result(peer.showOpenDialog(nullPeer(over))) - def showSaveDialog(over: Component): Result.Value = Result(peer.showSaveDialog(nullPeer(over))) - def showDialog(over: Component, approveText: String): Result.Value = Result(peer.showDialog(nullPeer(over), approveText)) - - def controlButtonsAreShown: Boolean = peer.getControlButtonsAreShown - def controlButtonsAreShown_=(b: Boolean) { peer.setControlButtonsAreShown(b) } - - def title: String = peer.getDialogTitle - def title_=(t: String) { peer.setDialogTitle(t) } - - def accessory: Component = UIElement.cachedWrapper[Component](peer.getAccessory) - def accessory_=(c: Component) { peer.setAccessory(c.peer) } - - def fileHidingEnabled: Boolean = peer.isFileHidingEnabled - def fileHidingEnabled_=(b: Boolean) { peer.setFileHidingEnabled(b) } - def fileSelectionMode: SelectionMode.Value = SelectionMode(peer.getFileSelectionMode) - def fileSelectionMode_=(s: SelectionMode.Value) { peer.setFileSelectionMode(s.id) } - def fileFilter: FileFilter = peer.getFileFilter - def fileFilter_=(f: FileFilter) { peer setFileFilter f } - - def selectedFile: File = peer.getSelectedFile - def selectedFile_=(file: File) { peer.setSelectedFile(file) } - def selectedFiles: Seq[File] = peer.getSelectedFiles - def selectedFiles_=(files: File*) { peer.setSelectedFiles(files.toArray) } - - def multiSelectionEnabled: Boolean = peer.isMultiSelectionEnabled - def multiSelectionEnabled_=(b: Boolean) { peer.setMultiSelectionEnabled(b) } - - def iconFor(f: File) = peer.getIcon(f) - def descriptionFor(f: File) = peer.getDescription(f) - def nameFor(f: File) = peer.getName(f) - def typeDescriptionFor(f: File) = peer.getTypeDescription(f) - def traversable(f: File) = peer.isTraversable(f) - - def acceptAllFileFilter = peer.getAcceptAllFileFilter - - /*peer.addPropertyChangeListener(new java.beans.PropertyChangeListener { - def propertyChange(e: java.beans.PropertyChangeEvent) { - import JFileChooser._ - e.getPropertyName match { - case APPROVE_BUTTON_TEXT_CHANGED_PROPERTY => - case ACCESSORY_CHANGED_PROPERTY => - case APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY => - case APPROVE_BUTTON_TEXT_CHANGED_PROPERTY => - case APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY => - case CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY => - case CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY => - case DIALOG_TITLE_CHANGED_PROPERTY => - case DIALOG_TYPE_CHANGED_PROPERTY => - case DIRECTORY_CHANGED_PROPERTY => - case FILE_FILTER_CHANGED_PROPERTY => - case FILE_HIDING_CHANGED_PROPERTY => - case FILE_SELECTION_MODE_CHANGED_PROPERTY => - case FILE_SYSTEM_VIEW_CHANGED_PROPERTY => - case FILE_VIEW_CHANGED_PROPERTY => - case MULTI_SELECTION_ENABLED_CHANGED_PROPERTY => - case SELECTED_FILE_CHANGED_PROPERTY => - case SELECTED_FILES_CHANGED_PROPERTY => - case _ => - } - } - })*/ -} diff --git a/src/swing/scala/swing/FlowPanel.scala b/src/swing/scala/swing/FlowPanel.scala deleted file mode 100644 index feeb3d4742..0000000000 --- a/src/swing/scala/swing/FlowPanel.scala +++ /dev/null @@ -1,46 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import java.awt.FlowLayout -import javax.swing.JPanel - -object FlowPanel { - object Alignment extends Enumeration { - val Leading = Value(FlowLayout.LEADING) - val Trailing = Value(FlowLayout.TRAILING) - val Left = Value(FlowLayout.LEFT) - val Right = Value(FlowLayout.RIGHT) - val Center = Value(FlowLayout.CENTER) - } -} - -/** - * A panel that arranges its contents horizontally, one after the other. - * If they don't fit, this panel will try to insert line breaks. - * - * @see java.awt.FlowLayout - */ -class FlowPanel(alignment: FlowPanel.Alignment.Value)(contents0: Component*) extends Panel with SequentialContainer.Wrapper { - override lazy val peer: JPanel = - new JPanel(new java.awt.FlowLayout(alignment.id)) with SuperMixin - def this(contents0: Component*) = this(FlowPanel.Alignment.Center)(contents0: _*) - def this() = this(FlowPanel.Alignment.Center)() - - contents ++= contents0 - - private def layoutManager = peer.getLayout.asInstanceOf[java.awt.FlowLayout] - - def vGap: Int = layoutManager.getVgap - def vGap_=(n: Int) { layoutManager.setVgap(n) } - def hGap: Int = layoutManager.getHgap - def hGap_=(n: Int) { layoutManager.setHgap(n) } -} diff --git a/src/swing/scala/swing/FormattedTextField.scala b/src/swing/scala/swing/FormattedTextField.scala deleted file mode 100644 index b08075850c..0000000000 --- a/src/swing/scala/swing/FormattedTextField.scala +++ /dev/null @@ -1,40 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import javax.swing._ - -object FormattedTextField { - /** - * The behavior of a formatted text field when it loses its focus. - */ - object FocusLostBehavior extends Enumeration { - val Commit = Value(JFormattedTextField.COMMIT) - val CommitOrRevert = Value(JFormattedTextField.COMMIT_OR_REVERT) - val Persist = Value(JFormattedTextField.PERSIST) - val Revert = Value(JFormattedTextField.REVERT) - } -} - -/** - * A text field with formatted input. - * - * @see javax.swing.JFormattedTextField - */ -class FormattedTextField(format: java.text.Format) extends TextComponent { - override lazy val peer: JFormattedTextField = new JFormattedTextField(format) with SuperMixin - - import FormattedTextField._ - - def commitEdit() { peer.commitEdit() } - def editValid: Boolean = peer.isEditValid - - def focusLostBehavior: FocusLostBehavior.Value = FocusLostBehavior(peer.getFocusLostBehavior) - def focusLostBehavior_=(b: FocusLostBehavior.Value) { peer.setFocusLostBehavior(b.id) } -} diff --git a/src/swing/scala/swing/GridBagPanel.scala b/src/swing/scala/swing/GridBagPanel.scala deleted file mode 100644 index c58d398737..0000000000 --- a/src/swing/scala/swing/GridBagPanel.scala +++ /dev/null @@ -1,114 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import java.awt.{GridBagConstraints, GridBagLayout} -import scala.language.implicitConversions - -object GridBagPanel { - object Fill extends Enumeration { - val None = Value(GridBagConstraints.NONE) - val Horizontal = Value(GridBagConstraints.HORIZONTAL) - val Vertical = Value(GridBagConstraints.VERTICAL) - val Both = Value(GridBagConstraints.BOTH) - } - object Anchor extends Enumeration { - val North = Value(GridBagConstraints.NORTH) - val NorthEast = Value(GridBagConstraints.NORTHEAST) - val East = Value(GridBagConstraints.EAST) - val SouthEast = Value(GridBagConstraints.SOUTHEAST) - val South = Value(GridBagConstraints.SOUTH) - val SouthWest = Value(GridBagConstraints.SOUTHWEST) - val West = Value(GridBagConstraints.WEST) - val NorthWest = Value(GridBagConstraints.NORTHWEST) - val Center = Value(GridBagConstraints.CENTER) - - val PageStart = Value(GridBagConstraints.PAGE_START) - val PageEnd = Value(GridBagConstraints.PAGE_END) - val LineStart = Value(GridBagConstraints.LINE_START) - val LineEnd = Value(GridBagConstraints.LINE_END) - val FirstLineStart = Value(GridBagConstraints.FIRST_LINE_START) - val FirstLineEnd = Value(GridBagConstraints.FIRST_LINE_END) - val LastLineStart = Value(GridBagConstraints.LAST_LINE_START) - val LastLineEnd = Value(GridBagConstraints.LAST_LINE_END) - } -} - -/** - * A panel that arranges its children in a grid. Layout details can be - * given for each cell of the grid. - * - * @see java.awt.GridBagLayout - */ -class GridBagPanel extends Panel with LayoutContainer { - override lazy val peer = new javax.swing.JPanel(new GridBagLayout) with SuperMixin - import GridBagPanel._ - - private def layoutManager = peer.getLayout.asInstanceOf[GridBagLayout] - - /** - * Convenient conversion from xy-coords given as pairs to - * grid bag constraints. - */ - implicit def pair2Constraints(p: (Int, Int)): Constraints = { - val c = new Constraints - c.gridx = p._1 - c.gridy = p._2 - c - } - - class Constraints(val peer: GridBagConstraints) extends Proxy { - def self = peer - def this(gridx: Int, gridy: Int, - gridwidth: Int, gridheight: Int, - weightx: Double, weighty: Double, - anchor: Int, fill: Int, insets: Insets, - ipadx: Int, ipady: Int) = - this(new GridBagConstraints(gridx, gridy, - gridwidth, gridheight, - weightx, weighty, - anchor, fill, insets, - ipadx, ipady)) - def this() = this(new GridBagConstraints()) - def gridx: Int = peer.gridx - def gridx_=(x: Int) { peer.gridx = x } - def gridy: Int = peer.gridy - def gridy_=(y: Int) { peer.gridy = y } - def grid: (Int, Int) = (gridx, gridy) - def grid_=(c: (Int, Int)) = { - gridx = c._1 - gridy = c._2 - } - - def gridwidth: Int = peer.gridwidth - def gridwidth_=(w: Int) { peer.gridwidth = w } - def gridheight: Int = peer.gridheight - def gridheight_=(h: Int) { peer.gridheight = h } - def weightx: Double = peer.weightx - def weightx_=(x: Double) { peer.weightx = x } - def weighty: Double = peer.weighty - def weighty_=(y: Double) { peer.weighty = y } - def anchor: Anchor.Value = Anchor(peer.anchor) - def anchor_=(a: Anchor.Value) { peer.anchor = a.id } - def fill: Fill.Value = Fill(peer.fill) - def fill_=(f: Fill.Value) { peer.fill = f.id } - def insets: Insets = peer.insets - def insets_=(i: Insets) { peer.insets = i } - def ipadx: Int = peer.ipadx - def ipadx_=(x: Int) { peer.ipadx = x } - def ipady: Int = peer.ipady - def ipady_=(y: Int) { peer.ipady = y } - } - - protected def constraintsFor(comp: Component) = - new Constraints(layoutManager.getConstraints(comp.peer)) - - protected def areValid(c: Constraints): (Boolean, String) = (true, "") - protected def add(c: Component, l: Constraints) { peer.add(c.peer, l.peer) } -} diff --git a/src/swing/scala/swing/GridPanel.scala b/src/swing/scala/swing/GridPanel.scala deleted file mode 100644 index d41f9e1c13..0000000000 --- a/src/swing/scala/swing/GridPanel.scala +++ /dev/null @@ -1,51 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -object GridPanel { - val Adapt = 0 -} - -/** - * A panel that lays out its contents in a uniform grid. - * - * @see java.awt.GridLayout - */ -class GridPanel(rows0: Int, cols0: Int) extends Panel with SequentialContainer.Wrapper { - override lazy val peer = - new javax.swing.JPanel(new java.awt.GridLayout(rows0, cols0)) with SuperMixin - - /*type Constraints = (Int, Int) - - protected def constraintsFor(comp: Component) = { - assert(peer.getComponentOrientation.isHorizontal) - val idx = contents.indexOf(comp) - val (r, c) = (((idx-1)/columns)+1, ((idx-1)%columns)+1) - if (peer.getComponentOrientation.isLeftToRight) (r, c) - else (r, columns-c+1) - } - - protected def add(c: Component, l: Constraints) { peer.add(c.peer, (l._1-1)*columns+l._2) } - protected def areValid(c: Constraints): (Boolean, String) = - ((c._1 > 0 && c._2 > 0), "Grid coordinates (row,col) must be >= 1 but where " + c)*/ - - private def layoutManager = peer.getLayout.asInstanceOf[java.awt.GridLayout] - - def rows: Int = layoutManager.getRows - def rows_=(n: Int) { layoutManager.setRows(n) } - def columns: Int = layoutManager.getColumns - def columns_=(n: Int) { layoutManager.setColumns(n) } - - def vGap: Int = layoutManager.getVgap - def vGap_=(n: Int) { layoutManager.setVgap(n) } - def hGap: Int = layoutManager.getHgap - def hGap_=(n: Int) { layoutManager.setHgap(n) } -} diff --git a/src/swing/scala/swing/Label.scala b/src/swing/scala/swing/Label.scala deleted file mode 100644 index 65d43cbe19..0000000000 --- a/src/swing/scala/swing/Label.scala +++ /dev/null @@ -1,62 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import javax.swing._ -import scala.swing.Swing._ - -/** - * A label component that display either a text, an icon, or both. - * - * @see javax.swing.JLabel - */ -class Label(text0: String, icon0: Icon, align: Alignment.Value) extends Component { - override lazy val peer: JLabel = - new JLabel(text0, toNullIcon(icon0), align.id) with SuperMixin - - def this() = this("", EmptyIcon, Alignment.Center) - def this(s: String) = this(s, EmptyIcon, Alignment.Center) - def text: String = peer.getText - def text_=(s: String) = peer.setText(s) - def icon: Icon = peer.getIcon - def icon_=(i: Icon) = peer.setIcon(i) - - /** - * The alignment of the label's contents relative to its bounding box. - */ - def xAlignment: Alignment.Value = Alignment(peer.getHorizontalAlignment) - def xAlignment_=(x: Alignment.Value) { peer.setHorizontalAlignment(x.id) } - def yAlignment: Alignment.Value = Alignment(peer.getVerticalAlignment) - def yAlignment_=(x: Alignment.Value) { peer.setVerticalAlignment(x.id) } - - /** @see javax.swing.JLabel#getHorizontalAlignment() */ - def horizontalAlignment: Alignment.Value = Alignment(peer.getHorizontalAlignment) - /** @see javax.swing.JLabel#setHorizontalAlignment() */ - def horizontalAlignment_=(x: Alignment.Value) { peer.setHorizontalAlignment(x.id) } - - def verticalAlignment: Alignment.Value = Alignment(peer.getVerticalAlignment) - def verticalAlignment_=(x: Alignment.Value) { peer.setVerticalAlignment(x.id) } - - def horizontalTextPosition: Alignment.Value = Alignment(peer.getHorizontalTextPosition) - def horizontalTextPosition_=(x: Alignment.Value) { peer.setHorizontalTextPosition(x.id) } - - def verticalTextPosition: Alignment.Value = Alignment(peer.getVerticalTextPosition) - def verticalTextPosition_=(x: Alignment.Value) { peer.setVerticalTextPosition(x.id) } - - def disabledIcon: Icon = peer.getDisabledIcon - def disabledIcon_=(icon: Icon) { peer.setDisabledIcon(icon) } - - def iconTextGap: Int = peer.getIconTextGap - def iconTextGap_=(gap: Int) { peer.setIconTextGap(gap) } - - def displayedMnemonicIndex: Int = peer.getDisplayedMnemonicIndex - def displayedMnemonicIndex_=(index: Int) { peer.setDisplayedMnemonicIndex(index) } -} diff --git a/src/swing/scala/swing/LayoutContainer.scala b/src/swing/scala/swing/LayoutContainer.scala deleted file mode 100644 index 37d351459e..0000000000 --- a/src/swing/scala/swing/LayoutContainer.scala +++ /dev/null @@ -1,73 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import javax.swing.JComponent -import scala.collection.mutable - -/** A container that associates layout constraints of member type - * `Constraints` with its children. - * - * See `GridBagPanel` for an example container with custom constraints. - * - * @note [Java Swing] In scala.swing, panels and layout managers are - * combined into subclasses of this base class. This approach allows for - * typed component constraints. - */ -trait LayoutContainer extends Container.Wrapper { - /** - * The type of component constraints for this container. - */ - type Constraints <: AnyRef - - /** - * Obtains the constraints for the given component from the underlying - * Swing layout manager. - */ - protected def constraintsFor(c: Component): Constraints - /** - * Checks whether the given constraints are valid. Additionally returns - * an error string that is only fetched if the constraints aren't valid. - */ - protected def areValid(c: Constraints): (Boolean, String) - /** - * Adds a component with the given constraints to the underlying layout - * manager and the component peer. This method needs to interact properly - * with method `constraintsFor`, i.e., it might need to remove previously - * held components in order to maintain layout consistency. See `BorderPanel` - * for an example. - */ - protected def add(comp: Component, c: Constraints) - - /** - * A map of components to the associated layout constraints. - * Any element in this map is automatically added to the contents of this - * panel. Therefore, specifying the layout of a component via - * - * layout(myComponent) = myConstraints - * - * also ensures that myComponent is properly added to this container. - */ - def layout: mutable.Map[Component, Constraints] = new mutable.Map[Component, Constraints] { - def -= (c: Component): this.type = { _contents -= c; this } - def += (cl: (Component, Constraints)): this.type = { update(cl._1, cl._2); this } - override def update (c: Component, l: Constraints) { - val (v, msg) = areValid(l) - if (!v) throw new IllegalArgumentException(msg) - add(c, l) - } - def get(c: Component) = Option(constraintsFor(c)) - override def size = peer.getComponentCount - def iterator: Iterator[(Component, Constraints)] = - peer.getComponents.iterator.map { c => - val comp = UIElement.cachedWrapper[Component](c.asInstanceOf[JComponent]) - (comp, constraintsFor(comp)) - } - } -} diff --git a/src/swing/scala/swing/ListView.scala b/src/swing/scala/swing/ListView.scala deleted file mode 100644 index 6904afd78a..0000000000 --- a/src/swing/scala/swing/ListView.scala +++ /dev/null @@ -1,246 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import event._ -import javax.swing._ -import javax.swing.event._ - -object ListView { - /** - * The supported modes of user selections. - */ - object IntervalMode extends Enumeration { - val Single = Value(ListSelectionModel.SINGLE_SELECTION) - val SingleInterval = Value(ListSelectionModel.SINGLE_INTERVAL_SELECTION) - val MultiInterval = Value(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) - } - - def wrap[A](c: JList) = new ListView[A] { - override lazy val peer = c - } - - object Renderer { - def wrap[A](r: ListCellRenderer): Renderer[A] = new Wrapped[A](r) - - /** - * Wrapper for javax.swing.ListCellRenderers - */ - class Wrapped[A](override val peer: ListCellRenderer) extends Renderer[A] { - def componentFor(list: ListView[_], isSelected: Boolean, focused: Boolean, a: A, index: Int) = { - Component.wrap(peer.getListCellRendererComponent(list.peer, a, index, isSelected, focused).asInstanceOf[JComponent]) - } - } - - /** - * Returns a renderer for items of type A. The given function - * converts items of type A to items of type B - * for which a renderer is implicitly given. This allows chaining of - * renderers, e.g.: - * - * - * case class Person(name: String, email: String) - * val persons = List(Person("John", "j.doe@a.com"), Person("Mary", "m.jane@b.com")) - * new ListView(persons) { - * renderer = ListView.Renderer(_.name) - * } - * - */ - def apply[A,B](f: A => B)(implicit renderer: Renderer[B]): Renderer[A] = new Renderer[A] { - def componentFor(list: ListView[_], isSelected: Boolean, focused: Boolean, a: A, index: Int): Component = - renderer.componentFor(list, isSelected, focused, f(a), index) - } - } - - /** - * Item renderer for a list view. This is contravariant on the type of the - * items, so a more general renderer can be used in place of a more specific - * one. For instance, an Any renderer can be used for a list view - * of strings. - * - * @see javax.swing.ListCellRenderer - */ - abstract class Renderer[-A] { - def peer: ListCellRenderer = new ListCellRenderer { - def getListCellRendererComponent(list: JList, a: Any, index: Int, isSelected: Boolean, focused: Boolean) = - componentFor(ListView.wrap[A](list), isSelected, focused, a.asInstanceOf[A], index).peer - } - def componentFor(list: ListView[_], isSelected: Boolean, focused: Boolean, a: A, index: Int): Component - } - - /** - * A default renderer that maintains a single component for item rendering - * and preconfigures it to sensible defaults. It is polymorphic on the - * component's type so clients can easily use component specific attributes - * during configuration. - */ - abstract class AbstractRenderer[-A, C<:Component](protected val component: C) extends Renderer[A] { - // The renderer component is responsible for painting selection - // backgrounds. Hence, make sure it is opaque to let it draw - // the background. - component.opaque = true - - /** - * Standard preconfiguration that is commonly done for any component. - * This includes foreground and background colors, as well as colors - * of item selections. - */ - def preConfigure(list: ListView[_], isSelected: Boolean, focused: Boolean, a: A, index: Int) { - if (isSelected) { - component.background = list.selectionBackground - component.foreground = list.selectionForeground - } else { - component.background = list.background - component.foreground = list.foreground - } - } - /** - * Configuration that is specific to the component and this renderer. - */ - def configure(list: ListView[_], isSelected: Boolean, focused: Boolean, a: A, index: Int) - - /** - * Configures the component before returning it. - */ - def componentFor(list: ListView[_], isSelected: Boolean, focused: Boolean, a: A, index: Int): Component = { - preConfigure(list, isSelected, focused, a, index) - configure(list, isSelected, focused, a, index) - component - } - } - - /** - * A generic renderer that uses Swing's built-in renderers. If there is no - * specific renderer for a type, this renderer falls back to a renderer - * that renders the string returned from an item's toString. - */ - implicit object GenericRenderer extends Renderer[Any] { - override lazy val peer: ListCellRenderer = new DefaultListCellRenderer - def componentFor(list: ListView[_], isSelected: Boolean, focused: Boolean, a: Any, index: Int): Component = { - val c = peer.getListCellRendererComponent(list.peer, a, index, isSelected, focused).asInstanceOf[JComponent] - Component.wrap(c) - } - } -} - -/** - * A component that displays a number of elements in a list. A list view does - * not support inline editing of items. If you need it, use a table view instead. - * - * Named ListView to avoid a clash with the frequently used - * scala.List - * - * @see javax.swing.JList - */ -class ListView[A] extends Component { - import ListView._ - override lazy val peer: JList = new JList with SuperMixin - - def this(items: Seq[A]) = { - this() - listData = items - } - - protected class ModelWrapper(val items: Seq[A]) extends AbstractListModel { - def getElementAt(n: Int) = items(n).asInstanceOf[AnyRef] - def getSize = items.size - } - - def listData: Seq[A] = peer.getModel match { - case model: ModelWrapper => model.items - case model @ _ => new Seq[A] { selfSeq => - def length = model.getSize - def iterator = new Iterator[A] { - var idx = 0 - def next = { idx += 1; apply(idx-1) } - def hasNext = idx < selfSeq.length - } - def apply(n: Int) = model.getElementAt(n).asInstanceOf[A] - } - } - - def listData_=(items: Seq[A]) { - peer.setModel(new AbstractListModel { - def getElementAt(n: Int) = items(n).asInstanceOf[AnyRef] - def getSize = items.size - }) - } - - /** - * The current item selection. - */ - object selection extends Publisher { - protected abstract class Indices[A](a: =>Seq[A]) extends scala.collection.mutable.Set[A] { - def -=(n: A): this.type - def +=(n: A): this.type - def contains(n: A) = a.contains(n) - override def size = a.length - def iterator = a.iterator - } - - def leadIndex: Int = peer.getSelectionModel.getLeadSelectionIndex - def anchorIndex: Int = peer.getSelectionModel.getAnchorSelectionIndex - - /** - * The indices of the currently selected items. - */ - object indices extends Indices(peer.getSelectedIndices) { - def -=(n: Int): this.type = { peer.removeSelectionInterval(n,n); this } - def +=(n: Int): this.type = { peer.addSelectionInterval(n,n); this } - } - - /** - * The currently selected items. - */ - lazy val items = peer.getSelectedValues.map(_.asInstanceOf[A]) - - def intervalMode: IntervalMode.Value = IntervalMode(peer.getSelectionModel.getSelectionMode) - def intervalMode_=(m: IntervalMode.Value) { peer.getSelectionModel.setSelectionMode(m.id) } - - peer.getSelectionModel.addListSelectionListener(new ListSelectionListener { - def valueChanged(e: javax.swing.event.ListSelectionEvent) { - publish(new ListSelectionChanged(ListView.this, e.getFirstIndex to e.getLastIndex, e.getValueIsAdjusting)) - } - }) - - def adjusting = peer.getSelectionModel.getValueIsAdjusting - } - - def renderer: ListView.Renderer[A] = ListView.Renderer.wrap[A](peer.getCellRenderer) - def renderer_=(r: ListView.Renderer[A]) { peer.setCellRenderer(r.peer) } - - def fixedCellWidth = peer.getFixedCellWidth - def fixedCellWidth_=(x: Int) = peer.setFixedCellWidth(x) - - def fixedCellHeight = peer.getFixedCellHeight - def fixedCellHeight_=(x: Int) = peer.setFixedCellHeight(x) - - def prototypeCellValue: A = peer.getPrototypeCellValue.asInstanceOf[A] - def prototypeCellValue_=(a: A) { peer.setPrototypeCellValue(a) } - - def visibleRowCount = peer.getVisibleRowCount - def visibleRowCount_=(n: Int) = peer.setVisibleRowCount(n) - - def ensureIndexIsVisible(idx: Int) = peer.ensureIndexIsVisible(idx) - - def selectionForeground: Color = peer.getSelectionForeground - def selectionForeground_=(c: Color) = peer.setSelectionForeground(c) - def selectionBackground: Color = peer.getSelectionBackground - def selectionBackground_=(c: Color) = peer.setSelectionBackground(c) - - def selectIndices(ind: Int*) = peer.setSelectedIndices(ind.toArray) - - peer.getModel.addListDataListener(new ListDataListener { - def contentsChanged(e: ListDataEvent) { publish(ListChanged(ListView.this)) } - def intervalRemoved(e: ListDataEvent) { publish(ListElementsRemoved(ListView.this, e.getIndex0 to e.getIndex1)) } - def intervalAdded(e: ListDataEvent) { publish(ListElementsAdded(ListView.this, e.getIndex0 to e.getIndex1)) } - }) -} diff --git a/src/swing/scala/swing/MainFrame.scala b/src/swing/scala/swing/MainFrame.scala deleted file mode 100644 index 1dfc155f9c..0000000000 --- a/src/swing/scala/swing/MainFrame.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -/** - * A frame that can be used for main application windows. Shuts down the - * framework and quits the application when closed. - */ -class MainFrame(gc: java.awt.GraphicsConfiguration = null) extends Frame(gc) { - override def closeOperation() { sys.exit(0) } -} diff --git a/src/swing/scala/swing/Menu.scala b/src/swing/scala/swing/Menu.scala deleted file mode 100644 index 38b1787cfc..0000000000 --- a/src/swing/scala/swing/Menu.scala +++ /dev/null @@ -1,70 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import scala.collection.mutable -import javax.swing._ - -object MenuBar { - case object NoMenuBar extends MenuBar -} - -/** - * A menu bar. Each window can contain at most one. Contains a number of menus. - * - * @see javax.swing.JMenuBar - */ -class MenuBar extends Component with SequentialContainer.Wrapper { - override lazy val peer: JMenuBar = new JMenuBar with SuperMixin - - def menus: mutable.Seq[Menu] = contents.filter(_.isInstanceOf[Menu]).map(_.asInstanceOf[Menu]) - - // Not implemented by Swing - //def helpMenu: Menu = UIElement.cachedWrapper(peer.getHelpMenu) - //def helpMenu_=(m: Menu) { peer.setHelpMenu(m.peer) } -} - -/** - * A menu item that can be used in a menu. - * - * @see javax.swing.JMenuItem - */ -class MenuItem(title0: String) extends AbstractButton { - override lazy val peer: JMenuItem = new JMenuItem(title0) - def this(a: Action) = { - this("") - action = a - } -} - -/** - * A menu. Contains menu items. Being a menu item itself, menus can be nested. - * - * @see javax.swing.JMenu - */ -class Menu(title0: String) extends MenuItem(title0) with SequentialContainer.Wrapper { self: Menu => - override lazy val peer: JMenu = new JMenu(title0) -} - -/** - * A menu item with a radio button. - * - * @see javax.swing.JRadioButtonMenuItem - */ -class RadioMenuItem(title0: String) extends MenuItem(title0) { - override lazy val peer: JRadioButtonMenuItem = new JRadioButtonMenuItem(title0) -} -/** - * A menu item with a check box. - * - * @see javax.swing.JCheckBoxMenuItem - */ -class CheckMenuItem(title0: String) extends MenuItem(title0) { - override lazy val peer: JCheckBoxMenuItem = new JCheckBoxMenuItem(title0) -} diff --git a/src/swing/scala/swing/Orientable.scala b/src/swing/scala/swing/Orientable.scala deleted file mode 100644 index db7cf09f27..0000000000 --- a/src/swing/scala/swing/Orientable.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -object Orientable { - trait Wrapper extends Oriented.Wrapper with Orientable { - def orientation_=(o: Orientation.Value) { - import scala.language.reflectiveCalls - peer.setOrientation(o.id) - } - } -} - -/** - * An Oriented whose orientation can be changed. - */ -trait Orientable extends Oriented { - def orientation_=(o: Orientation.Value) -} diff --git a/src/swing/scala/swing/Orientation.scala b/src/swing/scala/swing/Orientation.scala deleted file mode 100644 index ad616ec690..0000000000 --- a/src/swing/scala/swing/Orientation.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import java.awt.Adjustable._ - -object Orientation extends Enumeration { - val Horizontal = Value(HORIZONTAL) - val Vertical = Value(VERTICAL) - val NoOrientation = Value(NO_ORIENTATION) -} diff --git a/src/swing/scala/swing/Oriented.scala b/src/swing/scala/swing/Oriented.scala deleted file mode 100644 index 72d7d574e2..0000000000 --- a/src/swing/scala/swing/Oriented.scala +++ /dev/null @@ -1,35 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -object Oriented { - trait Wrapper extends Oriented { - def peer: OrientedMixin - - /* - * Need to revert to structural type, since scroll bars are oriented - * and these are created by scroll panes. Shouldn't be a bootleneck. - */ - protected type OrientedMixin = { - def getOrientation(): Int - def setOrientation(n: Int) - } - import scala.language.reflectiveCalls - def orientation: Orientation.Value = Orientation(peer.getOrientation) - } -} - -/** - * Something that can have an orientation. - */ -trait Oriented { - def orientation: Orientation.Value -} diff --git a/src/swing/scala/swing/Panel.scala b/src/swing/scala/swing/Panel.scala deleted file mode 100644 index 89ad4d3d66..0000000000 --- a/src/swing/scala/swing/Panel.scala +++ /dev/null @@ -1,20 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -/** - * A component that can contain other components. - * - * @see javax.swing.JPanel - */ -abstract class Panel extends Component with Container.Wrapper { - override lazy val peer: javax.swing.JPanel = new javax.swing.JPanel with SuperMixin -} diff --git a/src/swing/scala/swing/PasswordField.scala b/src/swing/scala/swing/PasswordField.scala deleted file mode 100644 index fd0b586a0f..0000000000 --- a/src/swing/scala/swing/PasswordField.scala +++ /dev/null @@ -1,34 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import javax.swing._ - -/** - * A password field, that displays a replacement character for each character in the password. - * - * @see javax.swing.JPasswordField - */ -class PasswordField(text0: String, columns0: Int) extends TextField(text0, columns0) { - override lazy val peer: JPasswordField = new JPasswordField(text0, columns0) with SuperMixin - def this(text: String) = this(text, 0) - def this(columns: Int) = this("", columns) - def this() = this("") - - def echoChar: Char = peer.getEchoChar - def echoChar_=(c: Char) = peer.setEchoChar(c) - - /** - * The text property should not be used on a password field for - * security reasons. - */ - override def text: String = "" - override def text_=(s: String) {} - def password: Array[Char] = peer.getPassword -} diff --git a/src/swing/scala/swing/PopupMenu.scala b/src/swing/scala/swing/PopupMenu.scala deleted file mode 100644 index e82c3a1b28..0000000000 --- a/src/swing/scala/swing/PopupMenu.scala +++ /dev/null @@ -1,65 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import javax.swing.JPopupMenu -import javax.swing.event.{PopupMenuListener, PopupMenuEvent} -import event._ - -/** - * A popup menu. - * - * Example usage: - * - * {{{ - * val popupMenu = new PopupMenu { - * contents += new Menu("menu 1") { - * contents += new RadioMenuItem("radio 1.1") - * contents += new RadioMenuItem("radio 1.2") - * } - * contents += new Menu("menu 2") { - * contents += new RadioMenuItem("radio 2.1") - * contents += new RadioMenuItem("radio 2.2") - * } - * } - * val button = new Button("Show Popup Menu") - * reactions += { - * case e: ButtonClicked => popupMenu.show(button, 0, button.bounds.height) - * } - * listenTo(button) - * }}} - * - * @author John Sullivan - * @author Ingo Maier - * @see javax.swing.JPopupMenu - */ -class PopupMenu extends Component with SequentialContainer.Wrapper with Publisher { - override lazy val peer: JPopupMenu = new JPopupMenu with SuperMixin - - peer.addPopupMenuListener(new PopupMenuListener { - def popupMenuCanceled(e: PopupMenuEvent) { - publish(PopupMenuCanceled(PopupMenu.this)) - } - def popupMenuWillBecomeInvisible(e: PopupMenuEvent) { - publish(PopupMenuWillBecomeInvisible(PopupMenu.this)) - } - def popupMenuWillBecomeVisible(e: PopupMenuEvent) { - publish(PopupMenuWillBecomeVisible(PopupMenu.this)) - } - }) - - def show(invoker: Component, x: Int, y: Int): Unit = peer.show(invoker.peer, x, y) - - def margin: Insets = peer.getMargin - def label: String = peer.getLabel - def label_=(s: String) { peer.setLabel(s) } -} - diff --git a/src/swing/scala/swing/ProgressBar.scala b/src/swing/scala/swing/ProgressBar.scala deleted file mode 100644 index 81e2989c3e..0000000000 --- a/src/swing/scala/swing/ProgressBar.scala +++ /dev/null @@ -1,40 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -/** - * A bar indicating progress of some action. Can be in indeterminate mode, - * in which it indicates that the action is in progress (usually by some - * animation) but does not indicate the amount of work done or to be done. - * - * @see javax.swing.JProgressBar - */ -class ProgressBar extends Component with Orientable.Wrapper { - override lazy val peer: javax.swing.JProgressBar = - new javax.swing.JProgressBar with SuperMixin - - def min: Int = peer.getMinimum - def min_=(v: Int) { peer.setMinimum(v) } - def max: Int = peer.getMaximum - def max_=(v: Int) { peer.setMaximum(v) } - def value: Int = peer.getValue - def value_=(v: Int) { peer.setValue(v) } - - def labelPainted: Boolean = peer.isStringPainted - def labelPainted_=(v: Boolean) { peer.setStringPainted(v) } - - def label: String = peer.getString - def label_=(v: String) = peer.setString(v) - - def indeterminate: Boolean = peer.isIndeterminate - def indeterminate_=(v: Boolean) { peer.setIndeterminate(v) } - - def paintBorder: Boolean = peer.isBorderPainted - def paintBorder(v: Boolean) { peer.setBorderPainted(v) } -} diff --git a/src/swing/scala/swing/RadioButton.scala b/src/swing/scala/swing/RadioButton.scala deleted file mode 100644 index 64f8b23756..0000000000 --- a/src/swing/scala/swing/RadioButton.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import javax.swing._ - -/** - * A two state button that is usually used in a ButtonGroup - * together with other RadioButtons, in order to indicate - * that at most one of them can be selected. - * - * @see javax.swing.JRadioButton - */ -class RadioButton(text0: String) extends ToggleButton { - override lazy val peer: JRadioButton = new JRadioButton(text0) with SuperMixin - def this() = this("") -} diff --git a/src/swing/scala/swing/Reactions.scala b/src/swing/scala/swing/Reactions.scala deleted file mode 100644 index c32212cf3a..0000000000 --- a/src/swing/scala/swing/Reactions.scala +++ /dev/null @@ -1,54 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import event.Event -import scala.collection.mutable.{Buffer, ListBuffer} - -object Reactions { - class Impl extends Reactions { - private val parts: Buffer[Reaction] = new ListBuffer[Reaction] - def isDefinedAt(e: Event) = parts.exists(_ isDefinedAt e) - def += (r: Reaction): this.type = { parts += r; this } - def -= (r: Reaction): this.type = { parts -= r; this } - def apply(e: Event) { - for (p <- parts) if (p isDefinedAt e) p(e) - } - } - - type Reaction = PartialFunction[Event, Unit] - - /** - * A Reaction implementing this trait is strongly referenced in the reaction list - */ - trait StronglyReferenced - - class Wrapper(listener: Any)(r: Reaction) extends Reaction with StronglyReferenced with Proxy { - def self = listener - def isDefinedAt(e: Event) = r.isDefinedAt(e) - def apply(e: Event) { r(e) } - } -} - -/** - * Used by reactors to let clients register custom event reactions. - */ -abstract class Reactions extends Reactions.Reaction { - /** - * Add a reaction. - */ - def += (r: Reactions.Reaction): this.type - - /** - * Remove the given reaction. - */ - def -= (r: Reactions.Reaction): this.type -} diff --git a/src/swing/scala/swing/Reactor.scala b/src/swing/scala/swing/Reactor.scala deleted file mode 100644 index 8f74831a5d..0000000000 --- a/src/swing/scala/swing/Reactor.scala +++ /dev/null @@ -1,30 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -/** - * The counterpart to publishers. Listens to events from registered publishers. - */ -trait Reactor { - /** - * All reactions of this reactor. - */ - val reactions: Reactions = new Reactions.Impl - /** - * Listen to the given publisher as long as deafTo isn't called for - * them. - */ - def listenTo(ps: Publisher*) = for (p <- ps) p.subscribe(reactions) - /** - * Installed reaction won't receive events from the given publisher anylonger. - */ - def deafTo(ps: Publisher*) = for (p <- ps) p.unsubscribe(reactions) -} diff --git a/src/swing/scala/swing/RichWindow.scala b/src/swing/scala/swing/RichWindow.scala deleted file mode 100644 index a60cdd339e..0000000000 --- a/src/swing/scala/swing/RichWindow.scala +++ /dev/null @@ -1,195 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import java.awt.{ Window => AWTWindow, Frame => AWTFrame } -import javax.swing._ -import Swing._ - -object RichWindow { - /** - * Mixin this trait if you want an undecorated window. - */ - trait Undecorated extends RichWindow { - // we do a mixin here, since setUndecorated is only allowed to be called - // when the component is not displayable. - peer.setUndecorated(true) - } -} - -/** - * A window that adds some functionality to the plain Window class and serves as - * the common base class for frames and dialogs. - * - * Implementation note: this class is sealed since we need to know that a rich - * window is either a dialog or a frame at some point. - */ -sealed trait RichWindow extends Window { - def peer: AWTWindow with InterfaceMixin - - trait InterfaceMixin extends super.InterfaceMixin { - def getJMenuBar(): JMenuBar - def setJMenuBar(b: JMenuBar) - def setUndecorated(b: Boolean) - def setTitle(s: String) - def getTitle(): String - def setResizable(b: Boolean) - def isResizable(): Boolean - } - - def title: String = peer.getTitle - def title_=(s: String) = peer.setTitle(s) - - /** - * The menu bar of this frame or `NoMenuBar` if no menu bar is set. - */ - def menuBar: MenuBar = { - val m = UIElement.cachedWrapper[MenuBar](peer.getJMenuBar) - if (m != null) m else MenuBar.NoMenuBar - } - /** - * Set the current menu bar of this frame. Pass `NoMenuBar` if this frame - * should not show a menu bar. - */ - def menuBar_=(m: MenuBar) = - peer.setJMenuBar(if (m == MenuBar.NoMenuBar) null else m.peer) - - def resizable_=(b: Boolean) { peer.setResizable(b) } - def resizable = peer.isResizable -} - -/** - * A window with decoration such as a title, border, and action buttons. - * - * An AWT window cannot be wrapped dynamically with this class, i.e., you cannot - * write something like new Window { def peer = myAWTWindow } - * - * @see javax.swing.JFrame - */ -class Frame(gc: java.awt.GraphicsConfiguration = null) extends RichWindow { - override lazy val peer: JFrame with InterfaceMixin = new JFrame(gc) with InterfaceMixin with SuperMixin - - def iconify() { peer.setExtendedState(peer.getExtendedState | AWTFrame.ICONIFIED) } - def uniconify() { peer.setExtendedState(peer.getExtendedState & ~AWTFrame.ICONIFIED) } - def iconified: Boolean = (peer.getExtendedState & AWTFrame.ICONIFIED) != 0 - def maximize() { peer.setExtendedState(peer.getExtendedState | AWTFrame.MAXIMIZED_BOTH) } - def unmaximize() { peer.setExtendedState(peer.getExtendedState & ~AWTFrame.MAXIMIZED_BOTH) } - def maximized: Boolean = (peer.getExtendedState & AWTFrame.MAXIMIZED_BOTH) != 0 - - def iconImage: Image = peer.getIconImage - def iconImage_=(i: Image) { peer.setIconImage(i) } -} - -/** - * Simple predefined dialogs. - * - * @see javax.swing.JOptionPane - */ -object Dialog { - /** - * The message type of a dialog. - */ - object Message extends Enumeration { - val Error = Value(JOptionPane.ERROR_MESSAGE) - val Info = Value(JOptionPane.INFORMATION_MESSAGE) - val Warning = Value(JOptionPane.WARNING_MESSAGE) - val Question = Value(JOptionPane.QUESTION_MESSAGE) - val Plain = Value(JOptionPane.PLAIN_MESSAGE) - } - - /** - * The possible answers a user can select. - */ - object Options extends Enumeration { - val Default = Value(JOptionPane.DEFAULT_OPTION) - val YesNo = Value(JOptionPane.YES_NO_OPTION) - val YesNoCancel = Value(JOptionPane.YES_NO_CANCEL_OPTION) - val OkCancel = Value(JOptionPane.OK_CANCEL_OPTION) - } - - /** - * The selected result of dialog. - */ - object Result extends Enumeration { - val Yes = Value(JOptionPane.YES_OPTION) - val Ok = Yes - val No = Value(JOptionPane.NO_OPTION) - val Cancel = Value(JOptionPane.CANCEL_OPTION) - val Closed = Value(JOptionPane.CLOSED_OPTION) - } - - private def uiString(txt: String) = UIManager.getString(txt) - - def showConfirmation(parent: Component = null, - message: Any, - title: String = uiString("OptionPane.titleText"), - optionType: Options.Value = Options.YesNo, - messageType: Message.Value = Message.Question, - icon: Icon = EmptyIcon): Result.Value = - Result(JOptionPane.showConfirmDialog(nullPeer(parent), message, title, - optionType.id, messageType.id, Swing.wrapIcon(icon))) - - def showOptions(parent: Component = null, - message: Any, - title: String = uiString("OptionPane.titleText"), - optionType: Options.Value = Options.YesNo, - messageType: Message.Value = Message.Question, - icon: Icon = EmptyIcon, - entries: Seq[Any], - initial: Int): Result.Value = { - val r = JOptionPane.showOptionDialog(nullPeer(parent), message, title, - optionType.id, messageType.id, Swing.wrapIcon(icon), - (entries map toAnyRef).toArray, entries(initial)) - Result(r) - } - - def showInput[A](parent: Component = null, - message: Any, - title: String = uiString("OptionPane.inputDialogTitle"), - messageType: Message.Value = Message.Question, - icon: Icon = EmptyIcon, - entries: Seq[A] = Nil, - initial: A): Option[A] = { - val e = if (entries.isEmpty) null - else (entries map toAnyRef).toArray - val r = JOptionPane.showInputDialog(nullPeer(parent), message, title, - messageType.id, Swing.wrapIcon(icon), - e, initial) - - toOption[A](r) - } - def showMessage(parent: Component = null, - message: Any, - title: String = uiString("OptionPane.messageDialogTitle"), - messageType: Message.Value = Message.Info, - icon: Icon = EmptyIcon) { - JOptionPane.showMessageDialog(nullPeer(parent), message, title, - messageType.id, Swing.wrapIcon(icon)) - } -} - -/** - * A dialog window. - * - * @see javax.swing.JDialog - */ -class Dialog(owner: Window, gc: java.awt.GraphicsConfiguration = null) extends RichWindow { - override lazy val peer: JDialog with InterfaceMixin = - if (owner == null) new JDialog with InterfaceMixin with SuperMixin - else owner match { - case f: Frame => new JDialog(f.peer, "", false, gc) with InterfaceMixin with SuperMixin - case d: Dialog => new JDialog(d.peer, "", false, gc) with InterfaceMixin with SuperMixin - } - - def this() = this(null) - - def modal_=(b: Boolean) { peer.setModal(b) } - def modal = peer.isModal -} - diff --git a/src/swing/scala/swing/RootPanel.scala b/src/swing/scala/swing/RootPanel.scala deleted file mode 100644 index 7e4882d7da..0000000000 --- a/src/swing/scala/swing/RootPanel.scala +++ /dev/null @@ -1,38 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -/** - * The root of a component hierarchy. Contains at most one component. - * - * @see javax.swing.RootPaneContainer - */ -trait RootPanel extends Container { - def peer: java.awt.Component with javax.swing.RootPaneContainer - - /** - * At most one component. - */ - def contents: Seq[Component] = - if (peer.getContentPane.getComponentCount == 0) Nil - else { - val c = peer.getContentPane.getComponent(0).asInstanceOf[javax.swing.JComponent] - List(UIElement.cachedWrapper[Component](c)) - } - - def contents_=(c: Component) { - if (peer.getContentPane.getComponentCount > 0) { - val old = peer.getContentPane.getComponent(0) - peer.getContentPane.remove(old) - } - peer.getContentPane.add(c.peer) - } -} diff --git a/src/swing/scala/swing/ScrollBar.scala b/src/swing/scala/swing/ScrollBar.scala deleted file mode 100644 index 6a1acdca04..0000000000 --- a/src/swing/scala/swing/ScrollBar.scala +++ /dev/null @@ -1,39 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import javax.swing.{JScrollBar, BoundedRangeModel} -import java.awt.event.{AdjustmentListener} - -object ScrollBar { - def wrap(c: JScrollBar): ScrollBar = { - val w = UIElement.cachedWrapper[ScrollBar](c) - if (w != null) w - else new ScrollBar { override lazy val peer = c } - } -} - -class ScrollBar extends Component with Orientable.Wrapper with Adjustable.Wrapper { - override lazy val peer: JScrollBar = new JScrollBar with SuperMixin - - def valueIsAjusting = peer.getValueIsAdjusting - def valueIsAjusting_=(b : Boolean) = peer.setValueIsAdjusting(b) - - // TODO: can we find a better interface? - //def setValues(value: Int = this.value, visible: Int = visibleAmount, - // min: Int = minimum, max: Int = maximum) = - // peer.setValues(value, visible, min, max) - -// Not currently needed, requires wrapper for BoundedRangeModel -// -// def model = peer.getModel -// def model_=(m : BoundedRangeModel) = peer.setModel(m) -} diff --git a/src/swing/scala/swing/ScrollPane.scala b/src/swing/scala/swing/ScrollPane.scala deleted file mode 100644 index afd6cf27fb..0000000000 --- a/src/swing/scala/swing/ScrollPane.scala +++ /dev/null @@ -1,88 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import javax.swing.{JScrollPane, ScrollPaneConstants} - -object ScrollPane { - object BarPolicy extends Enumeration { - import ScrollPaneConstants._ - val AsNeeded = new Value(HORIZONTAL_SCROLLBAR_AS_NEEDED, - VERTICAL_SCROLLBAR_AS_NEEDED) - val Never = new Value(HORIZONTAL_SCROLLBAR_NEVER, - VERTICAL_SCROLLBAR_NEVER) - val Always = new Value(HORIZONTAL_SCROLLBAR_ALWAYS, - VERTICAL_SCROLLBAR_ALWAYS) - - def wrap(id: Int) = id match { - case HORIZONTAL_SCROLLBAR_AS_NEEDED | VERTICAL_SCROLLBAR_AS_NEEDED => AsNeeded - case HORIZONTAL_SCROLLBAR_NEVER | VERTICAL_SCROLLBAR_NEVER => Never - case HORIZONTAL_SCROLLBAR_ALWAYS | VERTICAL_SCROLLBAR_ALWAYS => Always - } - class Value(val horizontalPeer: Int, val verticalPeer: Int) extends super.Val { - override def id = horizontalPeer - } - } -} - -/** - * Can have at most a single child component, which will be put inside a canvas (the viewport) - * that can be scrolled. - * - * @see javax.swing.JScrollPane - */ -class ScrollPane extends Component with Container { - import ScrollPane._ - - override lazy val peer: JScrollPane = new JScrollPane with SuperMixin - def this(c: Component) = { - this() - contents = c - } - def contents: Seq[Component] = - List(UIElement.cachedWrapper[Component](peer.getViewport.getView.asInstanceOf[javax.swing.JComponent])) - - /** - * Sets the single child. - */ - def contents_=(c: Component) { peer.setViewportView(c.peer) } - - /** - * The component being displayed in this pane's row header. - * - * If you want to create a row header for lists or tables, you probably - * want to let the row header be a list view with the same row height as - * the viewport component. - */ - def rowHeaderView: Option[Component] = - Option(peer.getRowHeader.getView) map UIElement.cachedWrapper[Component] - def rowHeaderView_=(c: Component) = peer.setRowHeaderView(c.peer) - def rowHeaderView_=(c: Option[Component]) = peer.setRowHeaderView(c.map(_.peer).orNull) - - def columnHeaderView: Option[Component] = - Option(peer.getColumnHeader.getView) map UIElement.cachedWrapper[Component] - def columnHeaderView_=(c: Component) = peer.setColumnHeaderView(c.peer) - def columnHeaderView_=(c: Option[Component]) = peer.setColumnHeaderView(c.map(_.peer).orNull) - - def viewportView: Option[Component] = - Option(peer.getViewport.getView) map UIElement.cachedWrapper[Component] - def viewportView_=(c: Component) = peer.setViewportView(c.peer) - def viewportView_=(c: Option[Component]) = peer.setViewportView(c.map(_.peer).orNull) - - def verticalScrollBarPolicy = BarPolicy.wrap(peer.getVerticalScrollBarPolicy) - def verticalScrollBarPolicy_=(p: BarPolicy.Value) = peer.setVerticalScrollBarPolicy(p.verticalPeer) - - def horizontalScrollBarPolicy = BarPolicy.wrap(peer.getHorizontalScrollBarPolicy) - def horizontalScrollBarPolicy_=(p: BarPolicy.Value) = peer.setHorizontalScrollBarPolicy(p.horizontalPeer) - - def horizontalScrollBar = ScrollBar.wrap(peer.getHorizontalScrollBar) - def verticalScrollBar = ScrollBar.wrap(peer.getVerticalScrollBar) -} diff --git a/src/swing/scala/swing/Scrollable.scala b/src/swing/scala/swing/Scrollable.scala deleted file mode 100644 index 1253ac8df0..0000000000 --- a/src/swing/scala/swing/Scrollable.scala +++ /dev/null @@ -1,43 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -object Scrollable { - trait Wrapper extends Scrollable { - protected def scrollablePeer: javax.swing.Scrollable - def preferredViewportSize = scrollablePeer.getPreferredScrollableViewportSize - - def tracksViewportHeight: Boolean = scrollablePeer.getScrollableTracksViewportHeight - def tracksViewportWidth: Boolean = scrollablePeer.getScrollableTracksViewportWidth - - def blockIncrement(visibleRect: Rectangle, orientation: Orientation.Value, direction: Int): Int = - scrollablePeer.getScrollableBlockIncrement(visibleRect, orientation.id, direction) - - def unitIncrement(visibleRect: Rectangle, orientation: Orientation.Value, direction: Int): Int = - scrollablePeer.getScrollableUnitIncrement(visibleRect, orientation.id, direction) - } -} - -/** - * A component that is specially suitable for being placed inside a - * ScrollPane. - * - * @see javax.swing.Scrollable - */ -trait Scrollable extends Component { - def preferredViewportSize: Dimension - - def tracksViewportHeight: Boolean - def tracksViewportWidth: Boolean - - def blockIncrement(visibleRect: Rectangle, orientation: Orientation.Value, direction: Int): Int - def unitIncrement(visibleRect: Rectangle, orientation: Orientation.Value, direction: Int): Int -} diff --git a/src/swing/scala/swing/Separator.scala b/src/swing/scala/swing/Separator.scala deleted file mode 100644 index 32d209d579..0000000000 --- a/src/swing/scala/swing/Separator.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import javax.swing._ - -/** - * A bar that can be used a separator, most commonly in menus. - * - * @see javax.swing.JSeparator - */ -class Separator(o: Orientation.Value) extends Component with Oriented.Wrapper { - override lazy val peer: JSeparator = new JSeparator(o.id) with SuperMixin - def this() = this(Orientation.Horizontal) -} diff --git a/src/swing/scala/swing/SequentialContainer.scala b/src/swing/scala/swing/SequentialContainer.scala deleted file mode 100644 index 5f32b08d25..0000000000 --- a/src/swing/scala/swing/SequentialContainer.scala +++ /dev/null @@ -1,36 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import scala.collection.mutable.Buffer - -object SequentialContainer { - /** - * Utility trait for wrapping sequential containers. - */ - trait Wrapper extends SequentialContainer with Container.Wrapper { - override val contents: Buffer[Component] = new Content - //def contents_=(c: Component*) { contents.clear(); contents ++= c } - } -} - -/** - * A container for which a sequential order of children makes sense, such as - * flow panels, or menus. Its contents are mutable. - */ -trait SequentialContainer extends Container { - /** - * The mutable child components of this container. The order matters and - * usually indicates the layout of the children. - */ - override def contents: Buffer[Component] - //def contents_=(c: Component*) -} diff --git a/src/swing/scala/swing/SimpleSwingApplication.scala b/src/swing/scala/swing/SimpleSwingApplication.scala deleted file mode 100644 index cd0f2be874..0000000000 --- a/src/swing/scala/swing/SimpleSwingApplication.scala +++ /dev/null @@ -1,36 +0,0 @@ -package scala.swing - -/** - * Extend this class for most simple UI applications. Clients need to - * implement the `top` method. Framework initialization is done by this class. - * - * In order to conform to Swing's threading policy, never implement top or any - * additional member that created Swing components as a value unless component - * creation happens on the EDT (see `Swing.onEDT` and `Swing.onEDTWait`). - * Lazy values are okay for the same reason if they are initialized on the EDT - * always. - */ -abstract class SimpleSwingApplication extends SwingApplication { - - /** - * A GUI application's version of the main method. Called by the default - * main method implementation provided by this class. - * Implement to return the top-level frame of this application. - */ - def top: Frame - - /** - * Calls `top`, packs the frame, and displays it. - */ - override def startup(args: Array[String]) { - val t = top - if (t.size == new Dimension(0,0)) t.pack() - t.visible = true - } - - def resourceFromClassloader(path: String): java.net.URL = - this.getClass.getResource(path) - - def resourceFromUserDirectory(path: String): java.io.File = - new java.io.File(util.Properties.userDir, path) -} diff --git a/src/swing/scala/swing/Slider.scala b/src/swing/scala/swing/Slider.scala deleted file mode 100644 index 241876587b..0000000000 --- a/src/swing/scala/swing/Slider.scala +++ /dev/null @@ -1,71 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import javax.swing.{JSlider, JLabel} -import event._ - -/** - * Lets users select a value from a given range. Visually, this is represented - * as a draggable knob on a horizontal or vertical bar. - * - * Fires a ValueChanged event whenever the slider's value changes and - * when the knob is released. - * - * @see javax.swing.JSlider - */ -class Slider extends Component with Orientable.Wrapper with Publisher { - override lazy val peer: JSlider = new JSlider with SuperMixin - - def min: Int = peer.getMinimum - def min_=(v: Int) { peer.setMinimum(v) } - def max: Int = peer.getMaximum - def max_=(v: Int) { peer.setMaximum(v) } - def value: Int = peer.getValue - def value_=(v: Int) { peer.setValue(v) } - def extent: Int = peer.getExtent - def extent_=(v: Int) { peer.setExtent(v) } - - def paintLabels: Boolean = peer.getPaintLabels - def paintLabels_=(v: Boolean) { peer.setPaintLabels(v) } - def paintTicks: Boolean = peer.getPaintTicks - def paintTicks_=(v: Boolean) { peer.setPaintTicks(v) } - def paintTrack: Boolean = peer.getPaintTrack - def paintTrack_=(v: Boolean) { peer.setPaintTrack(v) } - - def snapToTicks: Boolean = peer.getSnapToTicks - def snapToTicks_=(v: Boolean) { peer.setSnapToTicks(v) } - - def minorTickSpacing: Int = peer.getMinorTickSpacing - def minorTickSpacing_=(v: Int) { peer.setMinorTickSpacing(v) } - def majorTickSpacing: Int = peer.getMajorTickSpacing - def majorTickSpacing_=(v: Int) { peer.setMajorTickSpacing(v) } - - def adjusting = peer.getValueIsAdjusting - - def labels: scala.collection.Map[Int, Label] = { - val labelTable = peer.getLabelTable.asInstanceOf[java.util.Hashtable[Int, JLabel]] - new scala.collection.convert.Wrappers.JMapWrapper(labelTable) - .mapValues(v => UIElement.cachedWrapper[Label](v)) - } - def labels_=(l: scala.collection.Map[Int, Label]) { - // TODO: do some lazy wrapping - val table = new java.util.Hashtable[Any, Any] - for ((k,v) <- l) table.put(k, v.peer) - peer.setLabelTable(table) - } - - peer.addChangeListener(new javax.swing.event.ChangeListener { - def stateChanged(e: javax.swing.event.ChangeEvent) { - publish(new ValueChanged(Slider.this)) - } - }) -} diff --git a/src/swing/scala/swing/SplitPane.scala b/src/swing/scala/swing/SplitPane.scala deleted file mode 100644 index f61dfedbf4..0000000000 --- a/src/swing/scala/swing/SplitPane.scala +++ /dev/null @@ -1,63 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import Swing._ - -/** - * A container with exactly two children. Arranges them side by side, either - * horizontally or vertically. Displays a draggable divider component between - * them that lets the user adjust the size ratio of the children. - * - * @see javax.swing.JSplitPane - */ -class SplitPane(o: Orientation.Value, left: Component, right: Component) extends Component with Container with Orientable.Wrapper { - override lazy val peer: javax.swing.JSplitPane = - new javax.swing.JSplitPane(o.id, left.peer, right.peer) with SuperMixin - def this(o: Orientation.Value) = this(o, new Component {}, new Component {}) - def this() = this(Orientation.Horizontal) - - def contents: Seq[Component] = List(leftComponent, rightComponent) - def contents_=(left: Component, right: Component) { - peer.setLeftComponent(nullPeer(left)) - peer.setRightComponent(nullPeer(right)) - } - - def topComponent: Component = - UIElement.cachedWrapper[Component](peer.getTopComponent.asInstanceOf[javax.swing.JComponent]) - def topComponent_=(c: Component) { peer.setTopComponent(nullPeer(c)) } - def bottomComponent: Component = - UIElement.cachedWrapper[Component](peer.getBottomComponent.asInstanceOf[javax.swing.JComponent]) - def bottomComponent_=(c: Component) { peer.setBottomComponent(nullPeer(c)) } - - def leftComponent: Component = topComponent - def leftComponent_=(c: Component) { topComponent = c } - def rightComponent: Component = bottomComponent - def rightComponent_=(c: Component) { bottomComponent = c } - - def dividerLocation: Int = peer.getDividerLocation - def dividerLocation_=(n: Int) { peer.setDividerLocation(n) } - - /*def proportionalDividerLocation: Double = - if (orientation == Orientation.Vertical) dividerLocation / (size.height - dividerSize) - else dividerLocation / (size.width - dividerSize)*/ - def dividerLocation_=(f: Double) { peer.setDividerLocation(f) } - - def dividerSize: Int = peer.getDividerSize - def dividerSize_=(n: Int) { peer.setDividerSize(n) } - def resizeWeight: Double = peer.getResizeWeight - def resizeWeight_=(n: Double) { peer.setResizeWeight(n) } - - def resetToPreferredSizes() { peer.resetToPreferredSizes() } - - def oneTouchExpandable: Boolean = peer.isOneTouchExpandable - def oneTouchExpandable_=(b: Boolean) { peer.setOneTouchExpandable(b) } - def continuousLayout: Boolean = peer.isContinuousLayout - def continuousLayout_=(b: Boolean) { peer.setContinuousLayout(b) } -} diff --git a/src/swing/scala/swing/Swing.scala b/src/swing/scala/swing/Swing.scala deleted file mode 100644 index e2c8479354..0000000000 --- a/src/swing/scala/swing/Swing.scala +++ /dev/null @@ -1,141 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import java.awt.event._ -import javax.swing.event._ -import javax.swing.border._ -import javax.swing.{JComponent, Icon, BorderFactory, SwingUtilities} -import scala.language.implicitConversions - - -/** - * Helpers for this package. - */ -object Swing { - protected[swing] def toNoIcon(i: Icon): Icon = if(i == null) EmptyIcon else i - protected[swing] def toNullIcon(i: Icon): Icon = if(i == EmptyIcon) null else i - protected[swing] def nullPeer(c: Component) = if (c != null) c.peer else null - - implicit def pair2Dimension(p: (Int, Int)): Dimension = new Dimension(p._1, p._2) - implicit def pair2Point(p: (Int, Int)): Point = new Point(p._1, p._2) - implicit def pair2Point(p: (Int, Int, Int, Int)): Rectangle = new Rectangle(p._1, p._2, p._3, p._4) - - @inline final def Runnable(@inline block: =>Unit) = new Runnable { - def run = block - } - final def ChangeListener(f: ChangeEvent => Unit) = new ChangeListener { - def stateChanged(e: ChangeEvent) { f(e) } - } - final def ActionListener(f: ActionEvent => Unit) = new ActionListener { - def actionPerformed(e: ActionEvent) { f(e) } - } - - def Box(min: Dimension, pref: Dimension, max: Dimension) = new Component { - override lazy val peer = new javax.swing.Box.Filler(min, pref, max) - } - def HGlue = new Component { - override lazy val peer = javax.swing.Box.createHorizontalGlue.asInstanceOf[JComponent] - } - def VGlue = new Component { - override lazy val peer = javax.swing.Box.createVerticalGlue.asInstanceOf[JComponent] - } - def Glue = new Component { - override lazy val peer = javax.swing.Box.createGlue.asInstanceOf[JComponent] - } - def RigidBox(dim: Dimension) = new Component { - override lazy val peer = javax.swing.Box.createRigidArea(dim).asInstanceOf[JComponent] - } - def HStrut(width: Int) = new Component { - override lazy val peer = javax.swing.Box.createHorizontalStrut(width).asInstanceOf[JComponent] - } - def VStrut(height: Int) = new Component { - override lazy val peer = javax.swing.Box.createVerticalStrut(height).asInstanceOf[JComponent] - } - - def Icon(image: java.awt.Image) = new javax.swing.ImageIcon(image) - def Icon(filename: String) = new javax.swing.ImageIcon(filename) - def Icon(url: java.net.URL) = new javax.swing.ImageIcon(url) - - /** - * The empty icon. Use this icon instead of null to indicate - * that you don't want an icon. - */ - case object EmptyIcon extends Icon { - def getIconHeight: Int = 0 - def getIconWidth: Int = 0 - def paintIcon(c: java.awt.Component, g: java.awt.Graphics, x: Int, y: Int) {} - } - - def unwrapIcon(icon: Icon): Icon = if (icon == null) EmptyIcon else icon - def wrapIcon(icon: Icon): Icon = if (icon == EmptyIcon) null else icon - - def EmptyBorder = BorderFactory.createEmptyBorder() - def EmptyBorder(weight: Int) = - BorderFactory.createEmptyBorder(weight, weight, weight, weight) - def EmptyBorder(top: Int, left: Int, bottom: Int, right: Int) = - BorderFactory.createEmptyBorder(top, left, bottom, right) - - def LineBorder(c: Color) = BorderFactory.createLineBorder(c) - def LineBorder(c: Color, weight: Int) = BorderFactory.createLineBorder(c, weight) - - def BeveledBorder(kind: Embossing) = BorderFactory.createBevelBorder(kind.bevelPeer) - def BeveledBorder(kind: Embossing, highlight: Color, shadow: Color) = - BorderFactory.createBevelBorder(kind.bevelPeer, highlight, shadow) - def BeveledBorder(kind: Embossing, - highlightOuter: Color, highlightInner: Color, - shadowOuter: Color, shadowInner: Color) = - BorderFactory.createBevelBorder(kind.bevelPeer, - highlightOuter, highlightInner, - shadowOuter, shadowInner) - - sealed abstract class Embossing { - def bevelPeer: Int - def etchPeer: Int - } - case object Lowered extends Embossing { - def bevelPeer = BevelBorder.LOWERED - def etchPeer = javax.swing.border.EtchedBorder.LOWERED - } - case object Raised extends Embossing { - def bevelPeer = BevelBorder.RAISED - def etchPeer = javax.swing.border.EtchedBorder.RAISED - } - - def EtchedBorder = BorderFactory.createEtchedBorder() - def EtchedBorder(kind: Embossing) = - BorderFactory.createEtchedBorder(kind.etchPeer) - def EtchedBorder(kind: Embossing, highlight: Color, shadow: Color) = - BorderFactory.createEtchedBorder(kind.etchPeer, highlight, shadow) - - def MatteBorder(top: Int, left: Int, bottom: Int, right: Int, color: Color) = - BorderFactory.createMatteBorder(top, left, bottom, right, color) - def MatteBorder(top: Int, left: Int, bottom: Int, right: Int, icon: Icon) = - BorderFactory.createMatteBorder(top, left, bottom, right, icon) - - def CompoundBorder(outside: Border, inside: Border) = - BorderFactory.createCompoundBorder(outside, inside) - - def TitledBorder(border: Border, title: String) = - BorderFactory.createTitledBorder(border, title) - - /** - * Schedule the given code to be executed on the Swing event dispatching - * thread (EDT). Returns immediately. - */ - @inline final def onEDT(op: =>Unit) = SwingUtilities invokeLater Runnable(op) - - /** - * Schedule the given code to be executed on the Swing event dispatching - * thread (EDT). Blocks until after the code has been run. - */ - @inline final def onEDTWait(op: =>Unit) = SwingUtilities invokeAndWait Runnable(op) -} diff --git a/src/swing/scala/swing/SwingApplication.scala b/src/swing/scala/swing/SwingApplication.scala deleted file mode 100644 index 214001f72a..0000000000 --- a/src/swing/scala/swing/SwingApplication.scala +++ /dev/null @@ -1,17 +0,0 @@ -package scala.swing - -/** Convenience class with utility methods for GUI applications. */ -abstract class SwingApplication extends Reactor { - - /** Initializes the application and runs the given program. */ - def main(args: Array[String]) = Swing.onEDT { startup(args) } - - /** Called before the GUI is created. Override to customize. */ - def startup(args: Array[String]) - - /** Finalizes the application by calling `shutdown` and exits.*/ - def quit() { shutdown(); sys.exit(0) } - - /** Called before the application is exited. Override to customize. */ - def shutdown() {} -} diff --git a/src/swing/scala/swing/TabbedPane.scala b/src/swing/scala/swing/TabbedPane.scala deleted file mode 100644 index 6e46256f86..0000000000 --- a/src/swing/scala/swing/TabbedPane.scala +++ /dev/null @@ -1,131 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import event._ -import scala.collection.mutable.Buffer -import javax.swing.{JTabbedPane, JComponent} - - -object TabbedPane { - object Layout extends Enumeration { - val Wrap = Value(JTabbedPane.WRAP_TAB_LAYOUT) - val Scroll = Value(JTabbedPane.SCROLL_TAB_LAYOUT) - } - - class Page protected[TabbedPane](parent0: TabbedPane, title0: String, content0: Component, tip0: String) extends Proxy { - def self = content0 - - def this(title0: String, content0: Component, tip0: String) = - this(null, title0, content0, tip0) - def this(title0: String, content0: Component) = - this(title0, content0, "") - content = content0 // first add component, *then* set other things - title = title0 - tip = tip0 - - protected[TabbedPane] var parent: TabbedPane = parent0 - - protected var _title = title0 - def title: String = _title - def title_=(t: String) { - // beware to keep this order since, index depends on the _old_ title - if (parent != null) parent.peer.setTitleAt(index, t) - _title = t - } - protected var _content = content0 - def content: Component = _content//UIElement.cachedWrapper(peer.getComponentAt(index).asInstanceOf[JComponent]) - def content_=(c: Component) { _content = c; if (parent != null) parent.peer.setComponentAt(index, c.peer) } - protected var _tip = tip0 - def tip: String = _tip//peer.getToolTipTextAt(index) - def tip_=(t: String) { _tip = t; if (parent != null) parent.peer.setToolTipTextAt(index, t) } - protected var _enabled = true - def enabled: Boolean = _enabled//peer.isEnabledAt(index) - def enabled_=(b: Boolean) { _enabled = b; if (parent != null) parent.peer.setEnabledAt(index, b) } - protected var _mnemonic = -1 - def mnemonic: Int = _mnemonic//peer.getMnemonicAt(index) - def mnemonic_=(k: Int) { _mnemonic = k; if (parent != null) parent.peer.setMnemonicAt(index, k)} - protected var _foreground: Color = null - def foreground: Color = _foreground//peer.getForegroundAt(index) - def foreground_=(c: Color) { _foreground = c; if (parent != null) parent.peer.setForegroundAt(index, c)} - protected var _background: Color = null - def background: Color = _background //peer.getBackgroundAt(index) - def background_=(c: Color) { _background = c; if (parent != null) parent.peer.setBackgroundAt(index, c)} - def bounds: Rectangle = parent.peer.getBoundsAt(index) - - // TODO: icon, disabledIcon - - def index = if(parent != null) parent.peer.indexOfTab(title) else 0//_index - //protected[TabbedPane] var _index: Int = index0 - } -} - -/** - * Displays the contents of one of several pages at a time. For each page a tab is - * visible at all times. The user can click on one of these tabs to move the - * corresponding page to the front. - * - * @see javax.swing.JTabbedPane - */ -class TabbedPane extends Component with Publisher { - override lazy val peer: JTabbedPane = new JTabbedPane with SuperMixin - import TabbedPane._ - - object pages extends BufferWrapper[Page] { - def runCount: Int = peer.getTabRunCount - - def remove(n: Int): Page = { - val t = apply(n) - peer.removeTabAt(n) - t.parent = null - //for(i <- n to length) apply(i)._index -= 1 - t - } - protected def insertAt(n: Int, t: Page) { - //for(i <- n to length) apply(i)._index += 1 - t.parent = TabbedPane.this - peer.insertTab(t.title, null, t.content.peer, t.tip, n) - } - - def +=(t: Page): this.type = { t.parent = TabbedPane.this; peer.addTab(t.title, null, t.content.peer, t.tip); this } - def length = peer.getTabCount - def apply(n: Int) = new Page(TabbedPane.this, peer.getTitleAt(n), - UIElement.cachedWrapper[Component](peer.getComponentAt(n).asInstanceOf[javax.swing.JComponent]), - peer.getToolTipTextAt(n)) - } - - def tabLayoutPolicy: Layout.Value = Layout(peer.getTabLayoutPolicy) - def tabLayoutPolicy_=(p: Layout.Value) { peer.setTabLayoutPolicy(p.id) } - - - def tabPlacement: Alignment.Value = Alignment(peer.getTabPlacement) - /** - * Possible values are Left, Right, Top, Bottom. - */ - def tabPlacement_=(b: Alignment.Value) { peer.setTabPlacement(b.id) } - - /** - * The current page selection - */ - object selection extends Publisher { - def page: Page = pages(index) - def page_=(p: Page) { index = p.index } - - def index: Int = peer.getSelectedIndex - def index_=(n: Int) { peer.setSelectedIndex(n) } - - peer.addChangeListener(new javax.swing.event.ChangeListener { - def stateChanged(e: javax.swing.event.ChangeEvent) { - publish(SelectionChanged(TabbedPane.this)) - } - }) - } -} diff --git a/src/swing/scala/swing/Table.scala b/src/swing/scala/swing/Table.scala deleted file mode 100644 index 45053f0411..0000000000 --- a/src/swing/scala/swing/Table.scala +++ /dev/null @@ -1,320 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import event._ -import javax.swing._ -import javax.swing.table._ -import javax.swing.event._ -import scala.collection.mutable - -object Table { - object AutoResizeMode extends Enumeration { - import JTable._ - val Off = Value(AUTO_RESIZE_OFF, "Off") - val NextColumn = Value(AUTO_RESIZE_NEXT_COLUMN, "NextColumn") - val SubsequentColumns = Value(AUTO_RESIZE_SUBSEQUENT_COLUMNS, "SubsequentColumns") - val LastColumn = Value(AUTO_RESIZE_LAST_COLUMN, "LastColumn") - val AllColumns = Value(AUTO_RESIZE_ALL_COLUMNS, "AllColumns") - } - - object IntervalMode extends Enumeration { - val Single = Value(ListSelectionModel.SINGLE_SELECTION) - val SingleInterval = Value(ListSelectionModel.SINGLE_INTERVAL_SELECTION) - val MultiInterval = Value(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) - } - object ElementMode extends Enumeration { - val Row, Column, Cell, None = Value - } - - /** - * A table item renderer. - * - * @see javax.swing.table.TableCellRenderer - */ - abstract class Renderer[-A] { - def peer: TableCellRenderer = new TableCellRenderer { - def getTableCellRendererComponent(table: JTable, value: AnyRef, isSelected: Boolean, hasFocus: Boolean, row: Int, column: Int) = { - componentFor(table match { - case t: JTableMixin => t.tableWrapper - case _ => assert(false); null - }, isSelected, hasFocus, value.asInstanceOf[A], row, column).peer - } - } - def componentFor(table: Table, isSelected: Boolean, hasFocus: Boolean, a: A, row: Int, column: Int): Component - } - - abstract class AbstractRenderer[-A, C<:Component](val component: C) extends Renderer[A] { - // The renderer component is responsible for painting selection - // backgrounds. Hence, make sure it is opaque to let it draw - // the background. - component.opaque = true - - /** - * Standard preconfiguration that is commonly done for any component. - */ - def preConfigure(table: Table, isSelected: Boolean, hasFocus: Boolean, a: A, row: Int, column: Int) { - if (isSelected) { - component.background = table.selectionBackground - component.foreground = table.selectionForeground - } else { - component.background = table.background - component.foreground = table.foreground - } - } - /** - * Configuration that is specific to the component and this renderer. - */ - def configure(table: Table, isSelected: Boolean, hasFocus: Boolean, a: A, row: Int, column: Int) - - /** - * Configures the component before returning it. - */ - def componentFor(table: Table, isSelected: Boolean, hasFocus: Boolean, a: A, row: Int, column: Int): Component = { - preConfigure(table, isSelected, hasFocus, a, row, column) - configure(table, isSelected, hasFocus, a, row, column) - component - } - } - - class LabelRenderer[A](convert: A => (Icon, String)) extends AbstractRenderer[A, Label](new Label) { - def this() { - this{ a => (null, a.toString) } - } - - def configure(table: Table, isSelected: Boolean, hasFocus: Boolean, a: A, row: Int, column: Int) { - val (icon, text) = convert(a) - component.icon = icon - component.text = text - } - } - - private[swing] trait JTableMixin { def tableWrapper: Table } -} - -/** - * Displays a matrix of items. - * - * To obtain a scrollable table or row and columns headers, - * wrap the table in a scroll pane. - * - * @see javax.swing.JTable - */ -class Table extends Component with Scrollable.Wrapper { - override lazy val peer: JTable = new JTable with Table.JTableMixin with SuperMixin { - def tableWrapper = Table.this - override def getCellRenderer(r: Int, c: Int) = new TableCellRenderer { - def getTableCellRendererComponent(table: JTable, value: AnyRef, isSelected: Boolean, hasFocus: Boolean, row: Int, column: Int) = - Table.this.rendererComponent(isSelected, hasFocus, row, column).peer - } - override def getCellEditor(r: Int, c: Int) = editor(r, c) - override def getValueAt(r: Int, c: Int) = Table.this.apply(r,c).asInstanceOf[AnyRef] - } - import Table._ - - // TODO: use IndexedSeq[_ <: IndexedSeq[Any]], see ticket #2005 - def this(rowData: Array[Array[Any]], columnNames: Seq[_]) = { - this() - model = new AbstractTableModel { - override def getColumnName(column: Int) = columnNames(column).toString - def getRowCount() = rowData.length - def getColumnCount() = columnNames.length - def getValueAt(row: Int, col: Int): AnyRef = rowData(row)(col).asInstanceOf[AnyRef] - override def isCellEditable(row: Int, column: Int) = true - override def setValueAt(value: Any, row: Int, col: Int) { - rowData(row)(col) = value - fireTableCellUpdated(row, col) - } - } - } - def this(rows: Int, columns: Int) = { - this() - model = new DefaultTableModel(rows, columns) { - override def setValueAt(value: Any, row: Int, col: Int) { - super.setValueAt(value, row, col) - } - } - } - - protected def scrollablePeer = peer - - def rowHeight = peer.getRowHeight - def rowHeight_=(x: Int) = peer.setRowHeight(x) - - def rowCount = peer.getRowCount - - def model = peer.getModel() - def model_=(x: TableModel) = { - peer.setModel(x) - model.removeTableModelListener(modelListener) - model.addTableModelListener(modelListener) - } - - def autoResizeMode: AutoResizeMode.Value = AutoResizeMode(peer.getAutoResizeMode) - def autoResizeMode_=(x: Table.AutoResizeMode.Value) = peer.setAutoResizeMode(x.id) - - def showGrid = peer.getShowHorizontalLines && peer.getShowVerticalLines - def showGrid_=(grid: Boolean) = peer.setShowGrid(grid) - - def gridColor = peer.getGridColor - def gridColor_=(color: Color) = peer.setGridColor(color) - - def preferredViewportSize_=(dim: Dimension) = peer.setPreferredScrollableViewportSize(dim) - //1.6: def fillsViewportHeight: Boolean = peer.getFillsViewportHeight - //def fillsViewportHeight_=(b: Boolean) = peer.setFillsViewportHeight(b) - - object selection extends Publisher { - // TODO: could be a sorted set - protected abstract class SelectionSet[A](a: =>Seq[A]) extends mutable.Set[A] { - def -=(n: A): this.type - def +=(n: A): this.type - def contains(n: A) = a.contains(n) - override def size = a.length - def iterator = a.iterator - } - - object rows extends SelectionSet(peer.getSelectedRows) { - def -=(n: Int) = { peer.removeRowSelectionInterval(n,n); this } - def +=(n: Int) = { peer.addRowSelectionInterval(n,n); this } - - def leadIndex: Int = peer.getSelectionModel.getLeadSelectionIndex - def anchorIndex: Int = peer.getSelectionModel.getAnchorSelectionIndex - } - - object columns extends SelectionSet(peer.getSelectedColumns) { - def -=(n: Int) = { peer.removeColumnSelectionInterval(n,n); this } - def +=(n: Int) = { peer.addColumnSelectionInterval(n,n); this } - - def leadIndex: Int = peer.getColumnModel.getSelectionModel.getLeadSelectionIndex - def anchorIndex: Int = peer.getColumnModel.getSelectionModel.getAnchorSelectionIndex - } - - def cells: mutable.Set[(Int, Int)] = - new SelectionSet[(Int, Int)]((for(r <- selection.rows; c <- selection.columns) yield (r,c)).toSeq) { outer => - def -=(n: (Int, Int)) = { - peer.removeRowSelectionInterval(n._1,n._1) - peer.removeColumnSelectionInterval(n._2,n._2) - this - } - def +=(n: (Int, Int)) = { - peer.addRowSelectionInterval(n._1,n._1) - peer.addColumnSelectionInterval(n._2,n._2) - this - } - override def size = peer.getSelectedRowCount * peer.getSelectedColumnCount - } - - /** - * From the JTable Swing tutorial: - * You can specify selection by cell in multiple interval selection mode, - * but the result is a table that does not produce useful selections. - */ - def intervalMode: IntervalMode.Value = IntervalMode(peer.getSelectionModel.getSelectionMode) - def intervalMode_=(m: IntervalMode.Value) { peer.setSelectionMode(m.id) } - def elementMode: ElementMode.Value = - if(peer.getColumnSelectionAllowed && peer.getRowSelectionAllowed) ElementMode.Cell - else if(peer.getColumnSelectionAllowed) ElementMode.Column - else if(peer.getRowSelectionAllowed) ElementMode.Row - else ElementMode.None - def elementMode_=(m: ElementMode.Value) { - m match { - case ElementMode.Cell => peer.setCellSelectionEnabled(true) - case ElementMode.Column => peer.setRowSelectionAllowed(false); peer.setColumnSelectionAllowed(true) - case ElementMode.Row => peer.setRowSelectionAllowed(true); peer.setColumnSelectionAllowed(false) - case ElementMode.None => peer.setRowSelectionAllowed(false); peer.setColumnSelectionAllowed(false) - } - } - - peer.getColumnModel.getSelectionModel.addListSelectionListener(new ListSelectionListener { - def valueChanged(e: javax.swing.event.ListSelectionEvent) { - publish(TableColumnsSelected(Table.this, e.getFirstIndex to e.getLastIndex, e.getValueIsAdjusting)) - } - }) - peer.getSelectionModel.addListSelectionListener(new ListSelectionListener { - def valueChanged(e: javax.swing.event.ListSelectionEvent) { - publish(TableRowsSelected(Table.this, e.getFirstIndex to e.getLastIndex, e.getValueIsAdjusting)) - } - }) - } - - /** - * Supplies a renderer component for a given cell. - */ - protected def rendererComponent(isSelected: Boolean, focused: Boolean, row: Int, column: Int): Component = - new Component { - override lazy val peer = { - val v = apply(row, column).asInstanceOf[AnyRef] - if (v != null) - Table.this.peer.getDefaultRenderer(v.getClass).getTableCellRendererComponent(Table.this.peer, - v, isSelected, focused, row, column).asInstanceOf[JComponent] - else Table.this.peer.getDefaultRenderer(classOf[Object]).getTableCellRendererComponent(Table.this.peer, - v, isSelected, focused, row, column).asInstanceOf[JComponent] - } - } - - // TODO: a public API for setting editors - protected def editor(row: Int, column: Int) = { - val v = apply(row, column).asInstanceOf[AnyRef] - if (v != null) - Table.this.peer.getDefaultEditor(v.getClass) - else - Table.this.peer.getDefaultEditor(classOf[Object]) - } - - /** - * Get the current value of the given cell. - * The given cell coordinates are in view coordinates and thus not - * necessarily the same as for the model. - */ - def apply(row: Int, column: Int): Any = model.getValueAt(row, viewToModelColumn(column)) - - // TODO: this is Java 6 stuff - // def apply(row: Int, column: Int): Any = model.getValueAt(viewToModelRow(row), viewToModelColumn(column)) - //def viewToModelRow(idx: Int) = peer.convertRowIndexToModel(idx) - //def modelToViewRow(idx: Int) = peer.convertRowIndexToView(idx) - - def viewToModelColumn(idx: Int) = peer.convertColumnIndexToModel(idx) - def modelToViewColumn(idx: Int) = peer.convertColumnIndexToView(idx) - - - /** - * Change the value of the given cell. - */ - def update(row: Int, column: Int, value: Any) { model.setValueAt(value, row, viewToModelColumn(column)) } - - /** - * Visually update the given cell. - */ - def updateCell(row: Int, column: Int) = update(row, column, apply(row, column)) - - def selectionForeground: Color = peer.getSelectionForeground - def selectionForeground_=(c: Color) = peer.setSelectionForeground(c) - def selectionBackground: Color = peer.getSelectionBackground - def selectionBackground_=(c: Color) = peer.setSelectionBackground(c) - - protected val modelListener = new TableModelListener { - def tableChanged(e: TableModelEvent) = publish( - e.getType match { - case TableModelEvent.UPDATE => - if (e.getFirstRow == 0 && e.getLastRow == Int.MaxValue && e.getColumn == TableModelEvent.ALL_COLUMNS) - TableChanged(Table.this) - else if (e.getFirstRow == TableModelEvent.HEADER_ROW) - TableStructureChanged(Table.this) - else - TableUpdated(Table.this, e.getFirstRow to e.getLastRow, e.getColumn) - case TableModelEvent.INSERT => - TableRowsAdded(Table.this, e.getFirstRow to e.getLastRow) - case TableModelEvent.DELETE => - TableRowsRemoved(Table.this, e.getFirstRow to e.getLastRow) - } - ) - } -} diff --git a/src/swing/scala/swing/TextArea.scala b/src/swing/scala/swing/TextArea.scala deleted file mode 100644 index 2f6bdca119..0000000000 --- a/src/swing/scala/swing/TextArea.scala +++ /dev/null @@ -1,43 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import javax.swing._ - -/** - * A text component that allows multiline text input and display. - * - * @see javax.swing.JTextArea - */ -class TextArea(text0: String, rows0: Int, columns0: Int) extends TextComponent - with TextComponent.HasColumns with TextComponent.HasRows { - override lazy val peer: JTextArea = new JTextArea(text0, rows0, columns0) with SuperMixin - def this(text: String) = this(text, 0, 0) - def this(rows: Int, columns: Int) = this("", rows, columns) - def this() = this("", 0, 0) - - // TODO: we could make contents StringBuilder-like - def append(t: String) { peer.append(t) } - - def rows: Int = peer.getRows - def rows_=(n: Int) = peer.setRows(n) - def columns: Int = peer.getColumns - def columns_=(n: Int) = peer.setColumns(n) - - def tabSize: Int = peer.getTabSize - def tabSize_=(n: Int) = peer.setTabSize(n) - def lineCount: Int = peer.getLineCount - - def lineWrap: Boolean = peer.getLineWrap - def lineWrap_=(w: Boolean) = peer.setLineWrap(w) - def wordWrap: Boolean = peer.getWrapStyleWord - def wordWrap_=(w: Boolean) = peer.setWrapStyleWord(w) - def charWrap: Boolean = !peer.getWrapStyleWord - def charWrap_=(w: Boolean) = peer.setWrapStyleWord(!w) -} diff --git a/src/swing/scala/swing/TextComponent.scala b/src/swing/scala/swing/TextComponent.scala deleted file mode 100644 index 4d23399737..0000000000 --- a/src/swing/scala/swing/TextComponent.scala +++ /dev/null @@ -1,75 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import event._ -import javax.swing.text._ -import javax.swing.event._ - -object TextComponent { - trait HasColumns extends TextComponent { - def columns: Int - def columns_=(n: Int) - } - trait HasRows extends TextComponent { - def rows: Int - def rows_=(n: Int) - } -} - -/** - * A component that allows some kind of text input and display. - * - * @see javax.swing.JTextComponent - */ -class TextComponent extends Component with Publisher { - override lazy val peer: JTextComponent = new JTextComponent with SuperMixin {} - def text: String = peer.getText - def text_=(t: String) = peer.setText(t) - - class Caret extends Publisher { - def dot: Int = peer.getCaret.getDot - def dot_=(n: Int) { peer.getCaret.setDot(n) } - def mark: Int = peer.getCaret.getMark - def moveDot(n: Int) { peer.getCaret.moveDot(n) } - def visible: Boolean = peer.getCaret.isVisible - def visible_=(b: Boolean) { peer.getCaret.setVisible(b) } - def selectionVisible: Boolean = peer.getCaret.isSelectionVisible - def selectionVisible_=(b: Boolean) { peer.getCaret.setSelectionVisible(b) } - def blinkRate: Int = peer.getCaret.getBlinkRate - def blinkRate_=(n: Int) { peer.getCaret.setBlinkRate(n) } - def color: Color = peer.getCaretColor - def color_=(c: Color) = peer.setCaretColor(c) - def position: Int = peer.getCaretPosition - def position_=(p: Int) = peer.setCaretPosition(p) - - peer.addCaretListener { - new CaretListener { - def caretUpdate(e: CaretEvent) { publish(CaretUpdate(TextComponent.this)) } - } - } - } - - object caret extends Caret - - def editable: Boolean = peer.isEditable - def editable_=(x: Boolean) = peer.setEditable(x) - def cut() { peer.cut() } - def copy() { peer.copy() } - def paste() { peer.paste() } - def selected: String = peer.getSelectedText - - def selectAll() { peer.selectAll() } - - peer.getDocument.addDocumentListener(new DocumentListener { - def changedUpdate(e:DocumentEvent) { publish(new ValueChanged(TextComponent.this)) } - def insertUpdate(e:DocumentEvent) { publish(new ValueChanged(TextComponent.this)) } - def removeUpdate(e:DocumentEvent) { publish(new ValueChanged(TextComponent.this)) } - }) -} diff --git a/src/swing/scala/swing/TextField.scala b/src/swing/scala/swing/TextField.scala deleted file mode 100644 index a28e8f84e6..0000000000 --- a/src/swing/scala/swing/TextField.scala +++ /dev/null @@ -1,79 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing - -import event._ -import javax.swing._ -import java.awt.event._ - - -/*object TextField { - object FocusLostBehavior extends Enumeration { - val Revert = Value(JFormattedTextField.REVERT) - val Commit = Value(JFormattedTextField.REVERT) - val CommitOrRevert = Value(JFormattedTextField.REVERT) - val Persist = Value(JFormattedTextField.REVERT) - } -}*/ - -/** - * A text component that allows single line text input and display. - * - * @see javax.swing.JTextField - */ -class TextField(text0: String, columns0: Int) extends TextComponent with TextComponent.HasColumns with Action.Trigger.Wrapper { - override lazy val peer: JTextField = new JTextField(text0, columns0) with SuperMixin - def this(text: String) = this(text, 0) - def this(columns: Int) = this("", columns) - def this() = this("") - - def columns: Int = peer.getColumns - def columns_=(n: Int) = peer.setColumns(n) - - /** @see javax.swing.JTextField#getHorizontalAlignment() */ - def horizontalAlignment: Alignment.Value = Alignment(peer.getHorizontalAlignment) - /** @see javax.swing.JTextField#setHorizontalAlignment() */ - def horizontalAlignment_=(x: Alignment.Value) { peer.setHorizontalAlignment(x.id) } - - private lazy val actionListener = Swing.ActionListener { e => - publish(EditDone(TextField.this)) - } - - protected override def onFirstSubscribe() { - super.onFirstSubscribe - peer.addActionListener(actionListener) - peer.addFocusListener(new FocusAdapter { - override def focusLost(e: java.awt.event.FocusEvent) { publish(EditDone(TextField.this)) } - }) - } - - protected override def onLastUnsubscribe() { - super.onLastUnsubscribe - peer.removeActionListener(actionListener) - } - - def verifier: String => Boolean = s => Option(peer.getInputVerifier) forall (_ verify peer) - def verifier_=(v: String => Boolean) { - peer.setInputVerifier(new InputVerifier { - private val old = Option(peer.getInputVerifier) - def verify(c: JComponent) = v(text) - override def shouldYieldFocus(c: JComponent) = old forall (_ shouldYieldFocus c) - }) - } - def shouldYieldFocus: String => Boolean = s => Option(peer.getInputVerifier) forall (_ shouldYieldFocus peer) - def shouldYieldFocus_=(y: String=>Boolean) { - peer.setInputVerifier(new InputVerifier { - private val old = peer.getInputVerifier - def verify(c: JComponent) = old.verify(c) - override def shouldYieldFocus(c: JComponent) = y(text) - }) - } -} diff --git a/src/swing/scala/swing/ToggleButton.scala b/src/swing/scala/swing/ToggleButton.scala deleted file mode 100644 index 8f210d00d8..0000000000 --- a/src/swing/scala/swing/ToggleButton.scala +++ /dev/null @@ -1,22 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import javax.swing._ - -/** - * A two state button with a push button like user interface. - * Usually used in tool bars. - * - * @see javax.swing.JToggleButton - */ -class ToggleButton(text0: String) extends AbstractButton { - override lazy val peer: JToggleButton = new JToggleButton(text0) with SuperMixin - def this() = this("") -} diff --git a/src/swing/scala/swing/UIElement.scala b/src/swing/scala/swing/UIElement.scala deleted file mode 100644 index 16b8738392..0000000000 --- a/src/swing/scala/swing/UIElement.scala +++ /dev/null @@ -1,133 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import java.awt.Cursor -import event._ -import scala.ref._ -import java.util.WeakHashMap - -object UIElement { - private val ClientKey = "scala.swingWrapper" - private[this] val wrapperCache = new WeakHashMap[java.awt.Component, WeakReference[UIElement]] - - private def cache(e: UIElement) = e.peer match { - case p: javax.swing.JComponent => p.putClientProperty(ClientKey, e) - case _ => wrapperCache.put(e.peer, new WeakReference(e)) - } - - /** - * Looks up the internal component cache for a wrapper of the given - * Java Swing peer. If this method finds one of the given type `C`, - * it will return that wrapper. Otherwise it returns `null`. This - * method never throws an exception. - * - * Clients should be extremely careful with type parameter `C` and - * its interaction with type inference. Better err on the side of caution - * and explicitly specify `C`. - */ - private[swing] def cachedWrapper[C>:Null<:UIElement](c: java.awt.Component): C = { - val w = c match { - case c: javax.swing.JComponent => c.getClientProperty(ClientKey) - case _ => wrapperCache.get(c) - } - try { w.asInstanceOf[C] } catch { case _: Exception => null } - } - - /** - * Returns a wrapper for a given Java Swing peer. If there is a - * compatible wrapper in use, this method will return it. - * - * `wrap` methods in companion objects of subclasses of `UIElement` have - * the same behavior, except that they return more specific wrappers. - */ - def wrap(c: java.awt.Component): UIElement = { - val w = cachedWrapper[UIElement](c) - if (w != null) w - else new UIElement { def peer = c } - } -} - -/** - * The base trait of all user interface elements. Subclasses belong to one - * of two groups: top-level elements such as windows and dialogs, or - * `Component`s. - * - * @note [Java Swing] This trait does not have an exact counterpart in - * Java Swing. The peer is of type java.awt.Component since this is the - * least common upper bound of possible underlying peers. - * - * @note [Implementation] A UIElement automatically adds itself to the - * component cache on creation. - * - * @see java.awt.Component - */ -trait UIElement extends Proxy with LazyPublisher { - /** - * The underlying Swing peer. - */ - def peer: java.awt.Component - def self = peer - - UIElement.cache(this) - - def foreground: Color = peer.getForeground - def foreground_=(c: Color) = peer setForeground c - def background: Color = peer.getBackground - def background_=(c: Color) = peer setBackground c - - def minimumSize = peer.getMinimumSize - def minimumSize_=(x: Dimension) = peer setMinimumSize x - def maximumSize = peer.getMaximumSize - def maximumSize_=(x: Dimension) = peer setMaximumSize x - def preferredSize = peer.getPreferredSize - def preferredSize_=(x: Dimension) = peer setPreferredSize x - - def font: Font = peer.getFont - def font_=(f: Font) = peer setFont f - - def locationOnScreen = peer.getLocationOnScreen - def location = peer.getLocation - def bounds = peer.getBounds - def size = peer.getSize - - def locale = peer.getLocale - def toolkit = peer.getToolkit - - def cursor: Cursor = peer.getCursor - def cursor_=(c: Cursor) { peer.setCursor(c) } - - def visible: Boolean = peer.isVisible - def visible_=(b: Boolean) { peer.setVisible(b) } - def showing: Boolean = peer.isShowing - def displayable: Boolean = peer.isDisplayable - - def repaint() { peer.repaint } - def repaint(rect: Rectangle) { peer.repaint(rect.x, rect.y, rect.width, rect.height) } - def ignoreRepaint: Boolean = peer.getIgnoreRepaint - def ignoreRepaint_=(b: Boolean) { peer.setIgnoreRepaint(b) } - - protected def onFirstSubscribe() { - peer.addComponentListener(new java.awt.event.ComponentListener { - def componentHidden(e: java.awt.event.ComponentEvent) { - publish(UIElementHidden(UIElement.this)) - } - def componentShown(e: java.awt.event.ComponentEvent) { - publish(UIElementShown(UIElement.this)) - } - def componentMoved(e: java.awt.event.ComponentEvent) { - publish(UIElementMoved(UIElement.this)) - } - def componentResized(e: java.awt.event.ComponentEvent) { - publish(UIElementResized(UIElement.this)) - } - }) - } - protected def onLastUnsubscribe() {} -} diff --git a/src/swing/scala/swing/Window.scala b/src/swing/scala/swing/Window.scala deleted file mode 100644 index a9f4ae7538..0000000000 --- a/src/swing/scala/swing/Window.scala +++ /dev/null @@ -1,78 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.swing - -import java.awt.{Window => AWTWindow} -import event._ - -/** - * A window with decoration such as a title, border, and action buttons. - * - * An AWT window cannot be wrapped dynamically with this class, i.e., you cannot - * write something like new Window { def peer = myAWTWindow } - * - * @see javax.swing.JFrame - */ -abstract class Window extends UIElement with RootPanel with Publisher { outer => - def peer: AWTWindow with InterfaceMixin - - protected trait InterfaceMixin extends javax.swing.RootPaneContainer - - protected trait SuperMixin extends AWTWindow { - override protected def processWindowEvent(e: java.awt.event.WindowEvent) { - super.processWindowEvent(e) - if (e.getID() == java.awt.event.WindowEvent.WINDOW_CLOSING) - closeOperation() - } - } - - /** - * This method is called when the window is closing, after all other window - * event listeners have been processed. - */ - def closeOperation() {} - - override def contents_=(c: Component) { - super.contents_=(c) - peer.pack() // pack also validates, which is generally required after an add - } - def defaultButton: Option[Button] = - toOption(peer.getRootPane.getDefaultButton) map UIElement.cachedWrapper[Button] - def defaultButton_=(b: Button) { - peer.getRootPane.setDefaultButton(b.peer) - } - def defaultButton_=(b: Option[Button]) { - peer.getRootPane.setDefaultButton(b.map(_.peer).orNull) - } - - def dispose() { peer.dispose() } - - def pack(): this.type = { peer.pack(); this } - - def setLocationRelativeTo(c: UIElement) { peer.setLocationRelativeTo(c.peer) } - def centerOnScreen() { peer.setLocationRelativeTo(null) } - def location_=(p: Point) { peer.setLocation(p) } - def size_=(size: Dimension) { peer.setSize(size) } - def bounds_=(rect: Rectangle) { peer.setBounds(rect) } - - def owner: Window = UIElement.cachedWrapper[Window](peer.getOwner) - - def open() { peer setVisible true } - def close() { peer setVisible false } - - peer.addWindowListener(new java.awt.event.WindowListener { - def windowActivated(e: java.awt.event.WindowEvent) { publish(WindowActivated(outer)) } - def windowClosed(e: java.awt.event.WindowEvent) { publish(WindowClosed(outer)) } - def windowClosing(e: java.awt.event.WindowEvent) { publish(WindowClosing(outer)) } - def windowDeactivated(e: java.awt.event.WindowEvent) { publish(WindowDeactivated(outer)) } - def windowDeiconified(e: java.awt.event.WindowEvent) { publish(WindowDeiconified(outer)) } - def windowIconified(e: java.awt.event.WindowEvent) { publish(WindowIconified(outer)) } - def windowOpened(e: java.awt.event.WindowEvent) { publish(WindowOpened(outer)) } - }) -} diff --git a/src/swing/scala/swing/event/ActionEvent.scala b/src/swing/scala/swing/event/ActionEvent.scala deleted file mode 100644 index 7b2de43dc8..0000000000 --- a/src/swing/scala/swing/event/ActionEvent.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -object ActionEvent { - def unapply(a: ActionEvent): Option[Component] = Some(a.source) -} - -class ActionEvent(override val source: Component) extends ComponentEvent diff --git a/src/swing/scala/swing/event/AdjustingEvent.scala b/src/swing/scala/swing/event/AdjustingEvent.scala deleted file mode 100644 index a4b7d29c7d..0000000000 --- a/src/swing/scala/swing/event/AdjustingEvent.scala +++ /dev/null @@ -1,24 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -/** An event that indicates some editing operation that can be still - * in progress. - * - * Example: dragging a slider creates a number of `AdjustmentEvents` - * with `adjusting == '''true'''` until the user finally releases the - * mouse button. - */ -trait AdjustingEvent extends ComponentEvent { - def adjusting: Boolean - def committed: Boolean = !adjusting -} diff --git a/src/swing/scala/swing/event/BackgroundChanged.scala b/src/swing/scala/swing/event/BackgroundChanged.scala deleted file mode 100644 index bdd67f9525..0000000000 --- a/src/swing/scala/swing/event/BackgroundChanged.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -case class BackgroundChanged(override val source: Component) extends ComponentEvent diff --git a/src/swing/scala/swing/event/ButtonClicked.scala b/src/swing/scala/swing/event/ButtonClicked.scala deleted file mode 100644 index d02201909e..0000000000 --- a/src/swing/scala/swing/event/ButtonClicked.scala +++ /dev/null @@ -1,15 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -case class ButtonClicked(override val source: AbstractButton) extends ActionEvent(source) - diff --git a/src/swing/scala/swing/event/CaretUpdate.scala b/src/swing/scala/swing/event/CaretUpdate.scala deleted file mode 100644 index 2821175ec0..0000000000 --- a/src/swing/scala/swing/event/CaretUpdate.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -case class CaretUpdate(override val source: TextComponent) extends ComponentEvent diff --git a/src/swing/scala/swing/event/ColorChanged.scala b/src/swing/scala/swing/event/ColorChanged.scala deleted file mode 100644 index 6cb35e7755..0000000000 --- a/src/swing/scala/swing/event/ColorChanged.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -case class ColorChanged(source: Component, c: Color) extends ComponentEvent with SelectionEvent diff --git a/src/swing/scala/swing/event/ComponentEvent.scala b/src/swing/scala/swing/event/ComponentEvent.scala deleted file mode 100644 index 701b962934..0000000000 --- a/src/swing/scala/swing/event/ComponentEvent.scala +++ /dev/null @@ -1,16 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -trait ComponentEvent extends UIEvent { - val source: Component -} diff --git a/src/swing/scala/swing/event/ContainerEvent.scala b/src/swing/scala/swing/event/ContainerEvent.scala deleted file mode 100644 index 46f3768e97..0000000000 --- a/src/swing/scala/swing/event/ContainerEvent.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -abstract class ContainerEvent(override val source: Container) extends UIEvent - -case class ComponentAdded(override val source: Container, child: Component) extends ContainerEvent(source) -case class ComponentRemoved(override val source: Container, child: Component) extends ContainerEvent(source) diff --git a/src/swing/scala/swing/event/EditDone.scala b/src/swing/scala/swing/event/EditDone.scala deleted file mode 100644 index 9d38234757..0000000000 --- a/src/swing/scala/swing/event/EditDone.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -case class EditDone(override val source: TextField) extends ValueChanged(source) diff --git a/src/swing/scala/swing/event/Event.scala b/src/swing/scala/swing/event/Event.scala deleted file mode 100644 index fd1135601d..0000000000 --- a/src/swing/scala/swing/event/Event.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -trait Event diff --git a/src/swing/scala/swing/event/FocusEvent.scala b/src/swing/scala/swing/event/FocusEvent.scala deleted file mode 100644 index 5c29d8f6d2..0000000000 --- a/src/swing/scala/swing/event/FocusEvent.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -/** - * The other component is None if it is a non Swing, i.e., AWT or native, component. - */ -abstract class FocusEvent(override val source: Component, val other: Option[Component], val temporary: Boolean) extends ComponentEvent - -case class FocusGained(override val source: Component, override val other: Option[Component], override val temporary: Boolean) - extends FocusEvent(source, other, temporary) - -case class FocusLost(override val source: Component, override val other: Option[Component], override val temporary: Boolean) - extends FocusEvent(source, other, temporary) diff --git a/src/swing/scala/swing/event/FontChanged.scala b/src/swing/scala/swing/event/FontChanged.scala deleted file mode 100644 index ca936e1924..0000000000 --- a/src/swing/scala/swing/event/FontChanged.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -case class FontChanged(override val source: Component) extends ComponentEvent diff --git a/src/swing/scala/swing/event/ForegroundChanged.scala b/src/swing/scala/swing/event/ForegroundChanged.scala deleted file mode 100644 index 42b45aae54..0000000000 --- a/src/swing/scala/swing/event/ForegroundChanged.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -case class ForegroundChanged(override val source: Component) extends ComponentEvent diff --git a/src/swing/scala/swing/event/InputEvent.scala b/src/swing/scala/swing/event/InputEvent.scala deleted file mode 100644 index b515b01525..0000000000 --- a/src/swing/scala/swing/event/InputEvent.scala +++ /dev/null @@ -1,20 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -trait InputEvent extends ComponentEvent { - def peer: java.awt.event.InputEvent - def when: Long = peer.getWhen - def modifiers: Key.Modifiers - def consume() { peer.consume() } - def consumed: Boolean = peer.isConsumed -} diff --git a/src/swing/scala/swing/event/Key.scala b/src/swing/scala/swing/event/Key.scala deleted file mode 100644 index 5e9e0cbecd..0000000000 --- a/src/swing/scala/swing/event/Key.scala +++ /dev/null @@ -1,232 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -/** - * Enumeration of key codes used by key events. - */ -object Key extends Enumeration { - import java.awt.event.KeyEvent._ - - object Location extends Enumeration { - val Left = Value(java.awt.event.KeyEvent.KEY_LOCATION_LEFT) - val Right = Value(java.awt.event.KeyEvent.KEY_LOCATION_RIGHT) - val Numpad = Value(java.awt.event.KeyEvent.KEY_LOCATION_NUMPAD) - val Standard = Value(java.awt.event.KeyEvent.KEY_LOCATION_STANDARD) - val Unknown = Value(java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN) - } - - type Modifiers = Int - - object Modifier { - import java.awt.event.InputEvent._ - val Shift = SHIFT_DOWN_MASK - val Control = CTRL_DOWN_MASK - val Alt = ALT_DOWN_MASK - val AltGraph = ALT_GRAPH_DOWN_MASK - val Meta = META_DOWN_MASK - def text(mods: Int) = java.awt.event.KeyEvent.getKeyModifiersText(mods) - } - - //def text(k: Value) = java.awt.event.KeyEvent.getKeyText(k.id) - - val Shift = Value(VK_SHIFT, getKeyText(VK_SHIFT)) - val Control = Value(VK_CONTROL, getKeyText(VK_CONTROL)) - val Alt = Value(VK_ALT, getKeyText(VK_ALT)) - val AltGraph = Value(VK_ALT_GRAPH, getKeyText(VK_ALT_GRAPH)) - val Meta = Value(VK_META, getKeyText(VK_META)) - - val Enter = Value(VK_ENTER, getKeyText(VK_ENTER)) - val BackSpace = Value(VK_BACK_SPACE, getKeyText(VK_BACK_SPACE)) - val Tab = Value(VK_TAB, getKeyText(VK_TAB)) - val Cancel = Value(VK_CANCEL, getKeyText(VK_CANCEL)) - val Clear = Value(VK_CLEAR, getKeyText(VK_CLEAR)) - - val Pause = Value(VK_PAUSE, getKeyText(VK_PAUSE)) - val CapsLock = Value(VK_CAPS_LOCK, getKeyText(VK_CAPS_LOCK)) - val Escape = Value(VK_ESCAPE, getKeyText(VK_ESCAPE)) - val Space = Value(VK_SPACE, getKeyText(VK_SPACE)) - val PageUp = Value(VK_PAGE_UP, getKeyText(VK_PAGE_UP)) - val PageDown = Value(VK_PAGE_DOWN, getKeyText(VK_PAGE_DOWN)) - val End = Value(VK_END, getKeyText(VK_END)) - val Home = Value(VK_HOME, getKeyText(VK_HOME)) - val Left = Value(VK_LEFT, getKeyText(VK_LEFT)) - val Up = Value(VK_UP, getKeyText(VK_UP)) - val Right = Value(VK_RIGHT, getKeyText(VK_RIGHT)) - val Down = Value(VK_DOWN, getKeyText(VK_DOWN)) - val Comma = Value(VK_COMMA, getKeyText(VK_COMMA)) - val Minus = Value(VK_MINUS, getKeyText(VK_MINUS)) - val Period = Value(VK_PERIOD, getKeyText(VK_PERIOD)) - val Slash = Value(VK_SLASH, getKeyText(VK_SLASH)) - val Key0 = Value(VK_0, getKeyText(VK_0)) - val Key1 = Value(VK_1, getKeyText(VK_1)) - val Key2 = Value(VK_2, getKeyText(VK_2)) - val Key3 = Value(VK_3, getKeyText(VK_3)) - val Key4 = Value(VK_4, getKeyText(VK_4)) - val Key5 = Value(VK_5, getKeyText(VK_5)) - val Key6 = Value(VK_6, getKeyText(VK_6)) - val Key7 = Value(VK_7, getKeyText(VK_7)) - val Key8 = Value(VK_8, getKeyText(VK_8)) - val Key9 = Value(VK_9, getKeyText(VK_9)) - val Semicolon = Value(VK_SEMICOLON, getKeyText(VK_SEMICOLON)) - val Equals = Value(VK_EQUALS, getKeyText(VK_EQUALS)) - val A = Value(VK_A, getKeyText(VK_A)) - val B = Value(VK_B, getKeyText(VK_B)) - val C = Value(VK_C, getKeyText(VK_C)) - val D = Value(VK_D, getKeyText(VK_D)) - val E = Value(VK_E, getKeyText(VK_E)) - val F = Value(VK_F, getKeyText(VK_F)) - val G = Value(VK_G, getKeyText(VK_G)) - val H = Value(VK_H, getKeyText(VK_H)) - val I = Value(VK_I, getKeyText(VK_I)) - val J = Value(VK_J, getKeyText(VK_J)) - val K = Value(VK_K, getKeyText(VK_K)) - val L = Value(VK_L, getKeyText(VK_L)) - val M = Value(VK_M, getKeyText(VK_M)) - val N = Value(VK_N, getKeyText(VK_N)) - val O = Value(VK_O, getKeyText(VK_O)) - val P = Value(VK_P, getKeyText(VK_P)) - val Q = Value(VK_Q, getKeyText(VK_Q)) - val R = Value(VK_R, getKeyText(VK_R)) - val S = Value(VK_S, getKeyText(VK_S)) - val T = Value(VK_T, getKeyText(VK_T)) - val U = Value(VK_U, getKeyText(VK_U)) - val V = Value(VK_V, getKeyText(VK_V)) - val W = Value(VK_W, getKeyText(VK_W)) - val X = Value(VK_X, getKeyText(VK_X)) - val Y = Value(VK_Y, getKeyText(VK_Y)) - val Z = Value(VK_Z, getKeyText(VK_Z)) - val OpenBracket = Value(VK_OPEN_BRACKET, getKeyText(VK_OPEN_BRACKET)) - val BackSlash = Value(VK_BACK_SLASH, getKeyText(VK_BACK_SLASH)) - val CloseBracket = Value(VK_CLOSE_BRACKET, getKeyText(VK_CLOSE_BRACKET)) - val Numpad0 = Value(VK_NUMPAD0, getKeyText(VK_NUMPAD0)) - val Numpad1 = Value(VK_NUMPAD1, getKeyText(VK_NUMPAD1)) - val Numpad2 = Value(VK_NUMPAD2, getKeyText(VK_NUMPAD2)) - val Numpad3 = Value(VK_NUMPAD3, getKeyText(VK_NUMPAD3)) - val Numpad4 = Value(VK_NUMPAD4, getKeyText(VK_NUMPAD4)) - val Numpad5 = Value(VK_NUMPAD5, getKeyText(VK_NUMPAD5)) - val Numpad6 = Value(VK_NUMPAD6, getKeyText(VK_NUMPAD6)) - val Numpad7 = Value(VK_NUMPAD7, getKeyText(VK_NUMPAD7)) - val Numpad8 = Value(VK_NUMPAD8, getKeyText(VK_NUMPAD8)) - val Numpad9 = Value(VK_NUMPAD9, getKeyText(VK_NUMPAD9)) - val Multiply = Value(VK_MULTIPLY, getKeyText(VK_MULTIPLY)) - val Add = Value(VK_ADD, getKeyText(VK_ADD)) - val Separator = Value(VK_SEPARATOR, getKeyText(VK_SEPARATOR)) - val Subtract = Value(VK_SUBTRACT, getKeyText(VK_SUBTRACT)) - val Decimal = Value(VK_DECIMAL, getKeyText(VK_DECIMAL)) - val Divide = Value(VK_DIVIDE, getKeyText(VK_DIVIDE)) - val Delete = Value(VK_DELETE, getKeyText(VK_DELETE)) - val NumLock = Value(VK_NUM_LOCK, getKeyText(VK_NUM_LOCK)) - val ScrollLock = Value(VK_SCROLL_LOCK, getKeyText(VK_SCROLL_LOCK)) - val F1 = Value(VK_F1, getKeyText(VK_F1)) - val F2 = Value(VK_F2, getKeyText(VK_F2)) - val F3 = Value(VK_F3, getKeyText(VK_F3)) - val F4 = Value(VK_F4, getKeyText(VK_F4)) - val F5 = Value(VK_F5, getKeyText(VK_F5)) - val F6 = Value(VK_F6, getKeyText(VK_F6)) - val F7 = Value(VK_F7, getKeyText(VK_F7)) - val F8 = Value(VK_F8, getKeyText(VK_F8)) - val F9 = Value(VK_F9, getKeyText(VK_F9)) - val F10 = Value(VK_F10, getKeyText(VK_F10)) - val F11 = Value(VK_F11, getKeyText(VK_F11)) - val F12 = Value(VK_F12, getKeyText(VK_F12)) - val F13 = Value(VK_F13, getKeyText(VK_F13)) - val F14 = Value(VK_F14, getKeyText(VK_F14)) - val F15 = Value(VK_F15, getKeyText(VK_F15)) - val F16 = Value(VK_F16, getKeyText(VK_F16)) - val F17 = Value(VK_F17, getKeyText(VK_F17)) - val F18 = Value(VK_F18, getKeyText(VK_F18)) - val F19 = Value(VK_F19, getKeyText(VK_F19)) - val F20 = Value(VK_F20, getKeyText(VK_F20)) - val F21 = Value(VK_F21, getKeyText(VK_F21)) - val F22 = Value(VK_F22, getKeyText(VK_F22)) - val F23 = Value(VK_F23, getKeyText(VK_F23)) - val F24 = Value(VK_F24, getKeyText(VK_F24)) - val Printscreen = Value(VK_PRINTSCREEN, getKeyText(VK_PRINTSCREEN)) - val Insert = Value(VK_INSERT, getKeyText(VK_INSERT)) - val Help = Value(VK_HELP, getKeyText(VK_HELP)) - val BackQuote = Value(VK_BACK_QUOTE, getKeyText(VK_BACK_QUOTE)) - val Quote = Value(VK_QUOTE, getKeyText(VK_QUOTE)) - val KpUp = Value(VK_KP_UP, getKeyText(VK_KP_UP)) - val KpDown = Value(VK_KP_DOWN, getKeyText(VK_KP_DOWN)) - val KpLeft = Value(VK_KP_LEFT, getKeyText(VK_KP_LEFT)) - val KpRight = Value(VK_KP_RIGHT, getKeyText(VK_KP_RIGHT)) - val DeadGrave = Value(VK_DEAD_GRAVE, getKeyText(VK_DEAD_GRAVE)) - val DeadAcute = Value(VK_DEAD_ACUTE, getKeyText(VK_DEAD_ACUTE)) - val DeadCircumflex = Value(VK_DEAD_CIRCUMFLEX, getKeyText(VK_DEAD_CIRCUMFLEX)) - val DeadTilde = Value(VK_DEAD_TILDE, getKeyText(VK_DEAD_TILDE)) - val DeadMacron = Value(VK_DEAD_MACRON, getKeyText(VK_DEAD_MACRON)) - val DeadBreve = Value(VK_DEAD_BREVE, getKeyText(VK_DEAD_BREVE)) - val DeadAbovedot = Value(VK_DEAD_ABOVEDOT, getKeyText(VK_DEAD_ABOVEDOT)) - val DeadDiaeresis = Value(VK_DEAD_DIAERESIS, getKeyText(VK_DEAD_DIAERESIS)) - val DeadAbovering = Value(VK_DEAD_ABOVERING, getKeyText(VK_DEAD_ABOVERING)) - val DeadDoubleacute = Value(VK_DEAD_DOUBLEACUTE, getKeyText(VK_DEAD_DOUBLEACUTE)) - val DeadCaron = Value(VK_DEAD_CARON, getKeyText(VK_DEAD_CARON)) - val DeadCedilla = Value(VK_DEAD_CEDILLA, getKeyText(VK_DEAD_CEDILLA)) - val DeadOgonek = Value(VK_DEAD_OGONEK, getKeyText(VK_DEAD_OGONEK)) - val DeadIota = Value(VK_DEAD_IOTA, getKeyText(VK_DEAD_IOTA)) - val DeadVoicedSound = Value(VK_DEAD_VOICED_SOUND, getKeyText(VK_DEAD_VOICED_SOUND)) - val DeadSemivoicedSound = Value(VK_DEAD_SEMIVOICED_SOUND, getKeyText(VK_DEAD_SEMIVOICED_SOUND)) - val Ampersand = Value(VK_AMPERSAND, getKeyText(VK_AMPERSAND)) - val Asterisk = Value(VK_ASTERISK, getKeyText(VK_ASTERISK)) - val Quotedbl = Value(VK_QUOTEDBL, getKeyText(VK_QUOTEDBL)) - val Less = Value(VK_LESS, getKeyText(VK_LESS)) - val Greater = Value(VK_GREATER, getKeyText(VK_GREATER)) - val Braceleft = Value(VK_BRACELEFT, getKeyText(VK_BRACELEFT)) - val Braceright = Value(VK_BRACERIGHT, getKeyText(VK_BRACERIGHT)) - val At = Value(VK_AT, getKeyText(VK_AT)) - val Colon = Value(VK_COLON, getKeyText(VK_COLON)) - val Circumflex = Value(VK_CIRCUMFLEX, getKeyText(VK_CIRCUMFLEX)) - val Dollar = Value(VK_DOLLAR, getKeyText(VK_DOLLAR)) - val EuroSign = Value(VK_EURO_SIGN, getKeyText(VK_EURO_SIGN)) - val ExclamationMark = Value(VK_EXCLAMATION_MARK, getKeyText(VK_EXCLAMATION_MARK)) - val InvertedExclamationMark = Value(VK_INVERTED_EXCLAMATION_MARK, getKeyText(VK_INVERTED_EXCLAMATION_MARK)) - val LeftParenthesis = Value(VK_LEFT_PARENTHESIS, getKeyText(VK_LEFT_PARENTHESIS)) - val NumberSign = Value(VK_NUMBER_SIGN, getKeyText(VK_NUMBER_SIGN)) - val Plus = Value(VK_PLUS, getKeyText(VK_PLUS)) - val RightParenthesis = Value(VK_RIGHT_PARENTHESIS, getKeyText(VK_RIGHT_PARENTHESIS)) - val Underscore = Value(VK_UNDERSCORE, getKeyText(VK_UNDERSCORE)) - val Windows = Value(VK_WINDOWS, getKeyText(VK_WINDOWS)) - val ContextMenu = Value(VK_CONTEXT_MENU, getKeyText(VK_CONTEXT_MENU)) - val Final = Value(VK_FINAL, getKeyText(VK_FINAL)) - val Convert = Value(VK_CONVERT, getKeyText(VK_CONVERT)) - val Nonconvert = Value(VK_NONCONVERT, getKeyText(VK_NONCONVERT)) - val Accept = Value(VK_ACCEPT, getKeyText(VK_ACCEPT)) - val Modechange = Value(VK_MODECHANGE, getKeyText(VK_MODECHANGE)) - val Kana = Value(VK_KANA, getKeyText(VK_KANA)) - val Kanji = Value(VK_KANJI, getKeyText(VK_KANJI)) - val Alphanumeric = Value(VK_ALPHANUMERIC, getKeyText(VK_ALPHANUMERIC)) - val Katakana = Value(VK_KATAKANA, getKeyText(VK_KATAKANA)) - val Hiragana = Value(VK_HIRAGANA, getKeyText(VK_HIRAGANA)) - val FullWidth = Value(VK_FULL_WIDTH, getKeyText(VK_FULL_WIDTH)) - val HalfWidth = Value(VK_HALF_WIDTH, getKeyText(VK_HALF_WIDTH)) - val RomanCharacters = Value(VK_ROMAN_CHARACTERS, getKeyText(VK_ROMAN_CHARACTERS)) - val AllCandidates = Value(VK_ALL_CANDIDATES, getKeyText(VK_ALL_CANDIDATES)) - val PreviousCandidate = Value(VK_PREVIOUS_CANDIDATE, getKeyText(VK_PREVIOUS_CANDIDATE)) - val CodeInput = Value(VK_CODE_INPUT, getKeyText(VK_CODE_INPUT)) - val JapaneseKatakana = Value(VK_JAPANESE_KATAKANA, getKeyText(VK_JAPANESE_KATAKANA)) - val JapaneseHiragana = Value(VK_JAPANESE_HIRAGANA, getKeyText(VK_JAPANESE_HIRAGANA)) - val JapaneseRoman = Value(VK_JAPANESE_ROMAN, getKeyText(VK_JAPANESE_ROMAN)) - val KanaLock = Value(VK_KANA_LOCK, getKeyText(VK_KANA_LOCK)) - val InputMethodOnOff = Value(VK_INPUT_METHOD_ON_OFF, getKeyText(VK_INPUT_METHOD_ON_OFF)) - val Cut = Value(VK_CUT, getKeyText(VK_CUT)) - val Copy = Value(VK_COPY, getKeyText(VK_COPY)) - val Paste = Value(VK_PASTE, getKeyText(VK_PASTE)) - val Undo = Value(VK_UNDO, getKeyText(VK_UNDO)) - val Again = Value(VK_AGAIN, getKeyText(VK_AGAIN)) - val Find = Value(VK_FIND, getKeyText(VK_FIND)) - val Props = Value(VK_PROPS, getKeyText(VK_PROPS)) - val Stop = Value(VK_STOP, getKeyText(VK_STOP)) - val Compose = Value(VK_COMPOSE, getKeyText(VK_COMPOSE)) - val Begin = Value(VK_BEGIN, getKeyText(VK_BEGIN)) - val Undefined = Value(VK_UNDEFINED, getKeyText(VK_UNDEFINED)) -} diff --git a/src/swing/scala/swing/event/KeyEvent.scala b/src/swing/scala/swing/event/KeyEvent.scala deleted file mode 100644 index 1345c77479..0000000000 --- a/src/swing/scala/swing/event/KeyEvent.scala +++ /dev/null @@ -1,43 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -import javax.swing.JComponent - -sealed abstract class KeyEvent extends InputEvent { - def peer: java.awt.event.KeyEvent -} - -case class KeyTyped(val source: Component, char: Char, val modifiers: Key.Modifiers, - location: Key.Location.Value) - (val peer: java.awt.event.KeyEvent) extends KeyEvent { - def this(e: java.awt.event.KeyEvent) = - this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]), - e.getKeyChar, e.getModifiersEx, - Key.Location(e.getKeyLocation))(e) -} - -case class KeyPressed(val source: Component, key: Key.Value, val modifiers: Key.Modifiers, - location: Key.Location.Value) - (val peer: java.awt.event.KeyEvent) extends KeyEvent { - def this(e: java.awt.event.KeyEvent) = - this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]), - Key(e.getKeyCode), e.getModifiersEx, Key.Location(e.getKeyLocation))(e) -} - -case class KeyReleased(val source: Component, key: Key.Value, val modifiers: Key.Modifiers, - location: Key.Location.Value) - (val peer: java.awt.event.KeyEvent) extends KeyEvent { - def this(e: java.awt.event.KeyEvent) = - this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]), - Key(e.getKeyCode), e.getModifiersEx, Key.Location(e.getKeyLocation))(e) -} diff --git a/src/swing/scala/swing/event/ListEvent.scala b/src/swing/scala/swing/event/ListEvent.scala deleted file mode 100644 index bdb769d45b..0000000000 --- a/src/swing/scala/swing/event/ListEvent.scala +++ /dev/null @@ -1,43 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -trait ListEvent[A] extends ComponentEvent { - override val source: ListView[A] -} - -//case class ElementSelected[A](override val source: ListView[A], range: Range, live: Boolean) -// extends ListEvent[A] with AdjustingEvent with ListSelectionEvent - -abstract class ListChange[A](override val source: ListView[A]) extends ListEvent[A] - -object ListChanged { - def unapply[A](e: ListChanged[A]) = Some(e.source) - def apply[A](source: ListView[A]) = new ListChanged(source) -} - -class ListChanged[A](override val source: ListView[A]) extends ListChange(source) - -object ListElementsAdded { - def unapply[A](e: ListElementsAdded[A]) = Some((e.source, e.range)) - def apply[A](source: ListView[A], range: Range) = new ListElementsAdded(source, range) -} - -class ListElementsAdded[A](override val source: ListView[A], val range: Range) - extends ListChange(source) - -object ListElementsRemoved { - def unapply[A](e: ListElementsRemoved[A]) = Some((e.source, e.range)) - def apply[A](source: ListView[A], range: Range) = new ListElementsRemoved(source, range) -} -class ListElementsRemoved[A](override val source: ListView[A], val range: Range) - extends ListChange(source) diff --git a/src/swing/scala/swing/event/MouseEvent.scala b/src/swing/scala/swing/event/MouseEvent.scala deleted file mode 100644 index 8629d71db2..0000000000 --- a/src/swing/scala/swing/event/MouseEvent.scala +++ /dev/null @@ -1,79 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -import java.awt.Point -import javax.swing.JComponent - -sealed abstract class MouseEvent extends InputEvent { - def peer: java.awt.event.MouseEvent - def point: Point -} - -sealed abstract class MouseButtonEvent extends MouseEvent { - def clicks: Int - def triggersPopup: Boolean -} -case class MouseClicked(val source: Component, point: Point, val modifiers: Key.Modifiers, - clicks: Int, triggersPopup: Boolean)(val peer: java.awt.event.MouseEvent) - extends MouseButtonEvent { - def this(e: java.awt.event.MouseEvent) = - this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]), - e.getPoint, e.getModifiersEx, e.getClickCount, e.isPopupTrigger)(e) -} -case class MousePressed(val source: Component, point: Point, val modifiers: Key.Modifiers, - clicks: Int, triggersPopup: Boolean)(val peer: java.awt.event.MouseEvent) - extends MouseButtonEvent { - def this(e: java.awt.event.MouseEvent) = - this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]), - e.getPoint, e.getModifiersEx, e.getClickCount, e.isPopupTrigger)(e) -} -case class MouseReleased(val source: Component, point: Point, val modifiers: Key.Modifiers, - clicks: Int, triggersPopup: Boolean)(val peer: java.awt.event.MouseEvent) - extends MouseButtonEvent { - def this(e: java.awt.event.MouseEvent) = - this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]), - e.getPoint, e.getModifiersEx, e.getClickCount, e.isPopupTrigger)(e) -} - -sealed abstract class MouseMotionEvent extends MouseEvent -case class MouseMoved(val source: Component, point: Point, val modifiers: Key.Modifiers)(val peer: java.awt.event.MouseEvent) - extends MouseMotionEvent { - def this(e: java.awt.event.MouseEvent) = - this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]), - e.getPoint, e.getModifiersEx)(e) -} -case class MouseDragged(val source: Component, point: Point, val modifiers: Key.Modifiers)(val peer: java.awt.event.MouseEvent) - extends MouseMotionEvent { - def this(e: java.awt.event.MouseEvent) = - this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]), - e.getPoint, e.getModifiersEx)(e) -} -case class MouseEntered(val source: Component, point: Point, val modifiers: Key.Modifiers)(val peer: java.awt.event.MouseEvent) - extends MouseMotionEvent { - def this(e: java.awt.event.MouseEvent) = - this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]), - e.getPoint, e.getModifiersEx)(e) -} -case class MouseExited(val source: Component, point: Point, val modifiers: Key.Modifiers)(val peer: java.awt.event.MouseEvent) - extends MouseMotionEvent { - def this(e: java.awt.event.MouseEvent) = - this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]), - e.getPoint, e.getModifiersEx)(e) -} - -case class MouseWheelMoved(val source: Component, point: Point, val modifiers: Key.Modifiers, rotation: Int)(val peer: java.awt.event.MouseEvent) - extends MouseEvent { - def this(e: java.awt.event.MouseWheelEvent) = - this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]), - e.getPoint, e.getModifiersEx, e.getWheelRotation)(e) -} diff --git a/src/swing/scala/swing/event/PopupMenuEvent.scala b/src/swing/scala/swing/event/PopupMenuEvent.scala deleted file mode 100644 index ad39eb351a..0000000000 --- a/src/swing/scala/swing/event/PopupMenuEvent.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -abstract class PopupMenuEvent extends ComponentEvent - -case class PopupMenuCanceled(source: PopupMenu) extends PopupMenuEvent -case class PopupMenuWillBecomeInvisible(source: PopupMenu) extends PopupMenuEvent -case class PopupMenuWillBecomeVisible(source: PopupMenu) extends PopupMenuEvent \ No newline at end of file diff --git a/src/swing/scala/swing/event/SelectionEvent.scala b/src/swing/scala/swing/event/SelectionEvent.scala deleted file mode 100644 index 39d6a13bc2..0000000000 --- a/src/swing/scala/swing/event/SelectionEvent.scala +++ /dev/null @@ -1,34 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -/** - * An event that indicates a change in a selection such as in a list view or a table. - */ -trait SelectionEvent - -/** - * An event that indicates a selection of a range of indices. - */ -trait ListSelectionEvent extends SelectionEvent { - def range: Range -} - -case class SelectionChanged(override val source: Component) extends ComponentEvent with SelectionEvent - -object ListSelectionChanged { - def unapply[A](e: ListSelectionChanged[A]): Option[(ListView[A], Range, Boolean)] = - Some((e.source, e.range, e.live)) -} - -class ListSelectionChanged[A](override val source: ListView[A], val range: Range, val live: Boolean) - extends SelectionChanged(source) with ListEvent[A] diff --git a/src/swing/scala/swing/event/TableEvent.scala b/src/swing/scala/swing/event/TableEvent.scala deleted file mode 100644 index c420ea275d..0000000000 --- a/src/swing/scala/swing/event/TableEvent.scala +++ /dev/null @@ -1,46 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -abstract class TableEvent(override val source: Table) extends ComponentEvent - -abstract class TableChange(override val source: Table) extends TableEvent(source) - -/** - * The most general table change. The table might have changed completely, - * i.e., columns might have been reordered, rows added or removed, etc. - * No other event indicates that the structure might have changed. - */ -case class TableStructureChanged(override val source: Table) extends TableChange(source) -/** - * The table structure, i.e., the column order, names, and types stay the same, - * but anything else might have changed. - */ -case class TableChanged(override val source: Table) extends TableChange(source) -/** - * The size of the table stays the same, but the given range of rows might - * have changed but only in the given column. A value of -1 for the column - * denotes all columns. - */ -case class TableUpdated(override val source: Table, range: Range, column: Int) - extends TableChange(source) -/** - * Any change that caused the table to change it's size - */ -class TableResized(override val source: Table) extends TableChange(source) -case class TableRowsAdded(override val source: Table, range: Range) extends TableResized(source) -case class TableRowsRemoved(override val source: Table, range: Range) extends TableResized(source) - -case class TableColumnsSelected(override val source: Table, range: Range, adjusting: Boolean) - extends TableEvent(source) with AdjustingEvent with ListSelectionEvent -case class TableRowsSelected(override val source: Table, range: Range, adjusting: Boolean) - extends TableEvent(source) with AdjustingEvent with ListSelectionEvent diff --git a/src/swing/scala/swing/event/UIEvent.scala b/src/swing/scala/swing/event/UIEvent.scala deleted file mode 100644 index a4644b02b2..0000000000 --- a/src/swing/scala/swing/event/UIEvent.scala +++ /dev/null @@ -1,21 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -trait UIEvent extends Event { - val source: UIElement -} - -case class UIElementMoved(source: UIElement) extends UIEvent -case class UIElementResized(source: UIElement) extends UIEvent -case class UIElementShown(source: UIElement) extends UIEvent -case class UIElementHidden(source: UIElement) extends UIEvent diff --git a/src/swing/scala/swing/event/ValueChanged.scala b/src/swing/scala/swing/event/ValueChanged.scala deleted file mode 100644 index ef08085705..0000000000 --- a/src/swing/scala/swing/event/ValueChanged.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -object ValueChanged { - def unapply(a: ValueChanged): Option[Component] = Some(a.source) -} - -class ValueChanged(override val source: Component) extends ComponentEvent diff --git a/src/swing/scala/swing/event/WindowActivated.scala b/src/swing/scala/swing/event/WindowActivated.scala deleted file mode 100644 index 1473242e5c..0000000000 --- a/src/swing/scala/swing/event/WindowActivated.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -case class WindowActivated(override val source: Window) extends WindowEvent(source) diff --git a/src/swing/scala/swing/event/WindowClosed.scala b/src/swing/scala/swing/event/WindowClosed.scala deleted file mode 100644 index 80afe1a99f..0000000000 --- a/src/swing/scala/swing/event/WindowClosed.scala +++ /dev/null @@ -1,4 +0,0 @@ -package scala.swing -package event - -case class WindowClosed(override val source: Window) extends WindowEvent(source) diff --git a/src/swing/scala/swing/event/WindowClosing.scala b/src/swing/scala/swing/event/WindowClosing.scala deleted file mode 100644 index 3c64aeb0f5..0000000000 --- a/src/swing/scala/swing/event/WindowClosing.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -case class WindowClosing(override val source: Window) extends WindowEvent(source) diff --git a/src/swing/scala/swing/event/WindowDeactivated.scala b/src/swing/scala/swing/event/WindowDeactivated.scala deleted file mode 100644 index f0eec57913..0000000000 --- a/src/swing/scala/swing/event/WindowDeactivated.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -case class WindowDeactivated(override val source: Window) extends WindowEvent(source) diff --git a/src/swing/scala/swing/event/WindowDeiconified.scala b/src/swing/scala/swing/event/WindowDeiconified.scala deleted file mode 100644 index 6e07f8534b..0000000000 --- a/src/swing/scala/swing/event/WindowDeiconified.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -case class WindowDeiconified(override val source: Window) extends WindowEvent(source) diff --git a/src/swing/scala/swing/event/WindowEvent.scala b/src/swing/scala/swing/event/WindowEvent.scala deleted file mode 100644 index b8ca329a2a..0000000000 --- a/src/swing/scala/swing/event/WindowEvent.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -abstract class WindowEvent(override val source: Window) extends UIEvent diff --git a/src/swing/scala/swing/event/WindowIconified.scala b/src/swing/scala/swing/event/WindowIconified.scala deleted file mode 100644 index 3b5139f740..0000000000 --- a/src/swing/scala/swing/event/WindowIconified.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -case class WindowIconified(override val source: Window) extends WindowEvent(source) diff --git a/src/swing/scala/swing/event/WindowOpened.scala b/src/swing/scala/swing/event/WindowOpened.scala deleted file mode 100644 index f5854edc32..0000000000 --- a/src/swing/scala/swing/event/WindowOpened.scala +++ /dev/null @@ -1,14 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala.swing -package event - -case class WindowOpened(override val source: Window) extends WindowEvent(source) diff --git a/src/swing/scala/swing/model/Matrix.scala b/src/swing/scala/swing/model/Matrix.scala deleted file mode 100644 index 664d44a962..0000000000 --- a/src/swing/scala/swing/model/Matrix.scala +++ /dev/null @@ -1,121 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - -package scala.swing -package model - -// Dummy to keep ant from recompiling on every run. -trait Matrix { } - -/*trait Matrix[A] extends Function2[Int, Int, A] { - - val width: Int - val height: Int - - assert(width > 0 && height > 0) - - private val delegate = new Array[A](width * height) - - override def apply(col: Int, row: Int): A = - delegate(col * height + row) - - def apply(coord: (Int, Int)): A = - apply(coord._1, coord._2) - - def col(index: Int): Matrix.FlatSeq[A] = - new Matrix.SubArray[A](delegate, index * height, height) - - def row(index: Int): Matrix.FlatSeq[A] = - new Matrix.SparseArray[A](delegate, index, height) - - def update(xpos: Int, ypos: Int, elem: A) { - delegate(xpos % width * height + ypos % height) = elem - } - - def update(coord: (Int, Int), elem: A) { - update(coord._1, coord._2, elem) - } - - def initializeWith(f: (Int, Int) => A): this.type = { - for (index <- 0 until (width * height)) - delegate(index) = f(index / height, index % height) - this - } - - def initializeTo(v: => A): this.type = { - for (index <- 0 until (width * height)) - delegate(index) = v - this - } - - def size: (Int, Int) = (width, height) - - /** A flattened view of the matrix. The flattening is done on columns i.e. - * the first values of the flattened sequence are the cells of the first - * column. As this is a view of the matrix, any change to the matrix will - * also be visible in the flattened array, and vice-versa. */ - def flat: Array[A] = delegate - -} - -object Matrix { - - def apply[A](columns: Int, rows: Int) = new Matrix[A] { - val width = columns - val height = rows - } - - def apply[A](default: (Int, Int) => A, columns: Int, rows: Int) = new Matrix[A] { - val width = columns - val height = rows - initializeWith(default) - } - - def apply[A](default: => A, columns: Int, rows: Int) = new Matrix[A] { - val width = columns - val height = rows - initializeTo(default) - } - - trait FlatSeq[A] extends RandomAccessSeq[A] { - def update (index: Int, elem: A): Unit - } - - private class SubArray[A](delegate: Array[A], start: Int, val length: Int) extends FlatSeq[A] { - def apply(index: Int): A = - if (index < length) - delegate(index + start) - else throw new IndexOutOfBoundsException - def update(index: Int, elem: A): Unit = - if (index < length) - delegate(index + start) = elem - else throw new IndexOutOfBoundsException - } - - private class SparseArray[A](delegate: Array[A], start: Int, span: Int) extends FlatSeq[A] { - def apply(index: Int): A = { - if (index < length) - delegate((index * span) + start) - else throw new IndexOutOfBoundsException - } - def length: Int = delegate.length / span - def update(index: Int, elem: A): Unit = - if (index < length) - delegate((index * span) + start) = elem - else throw new IndexOutOfBoundsException - } - - implicit def MatrixToSeqs[A](matrix: Matrix[A]): Seq[Seq[A]] = { - val result = new Array[SubArray[A]](matrix.width) - for (col <- 0 until matrix.width) - result(col) = new SubArray[A](matrix.delegate, col * matrix.height, matrix.height) - result - } - -}*/ diff --git a/src/swing/scala/swing/package.scala b/src/swing/scala/swing/package.scala deleted file mode 100644 index d5095f021b..0000000000 --- a/src/swing/scala/swing/package.scala +++ /dev/null @@ -1,20 +0,0 @@ -package scala - -/** - * Useful imports that don't have wrappers. - */ -package object swing { - type Point = java.awt.Point - type Dimension = java.awt.Dimension - type Rectangle = java.awt.Rectangle - type Insets = java.awt.Insets - - type Graphics2D = java.awt.Graphics2D - type Color = java.awt.Color - type Image = java.awt.Image - type Font = java.awt.Font - - private[swing] def ifNull[A](o: Object, a: A): A = if(o eq null) a else o.asInstanceOf[A] - private[swing] def toOption[A](o: Object): Option[A] = if(o eq null) None else Some(o.asInstanceOf[A]) - private[swing] def toAnyRef(x: Any): AnyRef = x.asInstanceOf[AnyRef] -} diff --git a/src/swing/swing.version.properties b/src/swing/swing.version.properties deleted file mode 100644 index ba3675fa05..0000000000 --- a/src/swing/swing.version.properties +++ /dev/null @@ -1,2 +0,0 @@ -version.major=0 -version.minor=4 -- cgit v1.2.3