diff options
author | Paul Phillips <paulp@improving.org> | 2012-10-31 07:15:01 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-10-31 07:54:24 -0700 |
commit | 202a949afeb4877318432ffff8e3ffdc14df9615 (patch) | |
tree | 4021376fcbcfe5d8bc5066ec6d9039fdd2097f88 /src/swing | |
parent | b480d991072e6e68ed46574d87e4483da778ff0e (diff) | |
parent | 8aec78470637f42f50981f8034215a709602dbad (diff) | |
download | scala-202a949afeb4877318432ffff8e3ffdc14df9615.tar.gz scala-202a949afeb4877318432ffff8e3ffdc14df9615.tar.bz2 scala-202a949afeb4877318432ffff8e3ffdc14df9615.zip |
Merge branch 'merge-2.10.0-wip' into merge-2.10.x
* merge-2.10.0-wip:
Use Typed rather than .setType
Wider use and a new variant of typedPos.
SI-6575 Plug inference leak of AbstractPartialFun
Remove compiler phases that don't influence scaladoc generation.
Disabled generation of _1, _2, etc. methods.
SI-6526 Additional test case.
Fix SI-6552, regression with self types.
avoid single-art assert where harmful in duration-tck
Fix for SI-6537, inaccurate unchecked warning.
Crash on missing accessor (internal bug in the lazy vals implementation) instead of trying to recover from the bug
Incorporated changes suggested in code review
Added one more test for SI-6358
Closes SI-6358. Move accessor generation for lazy vals to typers.
SI-6526 Tail call elimination should descend deeper.
Remove unneeded calls to substring()
Changes Tree and Type members from vals to defs.
Scaladoc knows the package structure of the libraries, so don't include them in external documentation setting.
Fixes SI-6170: issue with dragging scaladoc splitter over central iframe
Added a Swing ColorChooser wrapper
Added a Swing PopupMenu wrapper
Conflicts:
src/compiler/scala/reflect/reify/phases/Reshape.scala
src/compiler/scala/tools/nsc/typechecker/Duplicators.scala
src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala
src/reflect/scala/reflect/internal/Types.scala
test/files/neg/unchecked-knowable.check
Diffstat (limited to 'src/swing')
-rw-r--r-- | src/swing/scala/swing/ColorChooser.scala | 45 | ||||
-rw-r--r-- | src/swing/scala/swing/PopupMenu.scala | 65 | ||||
-rw-r--r-- | src/swing/scala/swing/event/ColorChanged.scala | 14 | ||||
-rw-r--r-- | src/swing/scala/swing/event/PopupMenuEvent.scala | 18 |
4 files changed, 142 insertions, 0 deletions
diff --git a/src/swing/scala/swing/ColorChooser.scala b/src/swing/scala/swing/ColorChooser.scala new file mode 100644 index 0000000000..9bd71e1df0 --- /dev/null +++ b/src/swing/scala/swing/ColorChooser.scala @@ -0,0 +1,45 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2007-2012, 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/PopupMenu.scala b/src/swing/scala/swing/PopupMenu.scala new file mode 100644 index 0000000000..0f292b11a2 --- /dev/null +++ b/src/swing/scala/swing/PopupMenu.scala @@ -0,0 +1,65 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2007-2012, 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/event/ColorChanged.scala b/src/swing/scala/swing/event/ColorChanged.scala new file mode 100644 index 0000000000..44387aa864 --- /dev/null +++ b/src/swing/scala/swing/event/ColorChanged.scala @@ -0,0 +1,14 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2007-2011, 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/PopupMenuEvent.scala b/src/swing/scala/swing/event/PopupMenuEvent.scala new file mode 100644 index 0000000000..f7083c06de --- /dev/null +++ b/src/swing/scala/swing/event/PopupMenuEvent.scala @@ -0,0 +1,18 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2007-2012, 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 |