|
| 1 | +/* __ *\ |
| 2 | +** ________ ___ / / ___ Scala API ** |
| 3 | +** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** |
| 4 | +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** |
| 5 | +** /____/\___/_/ |_/____/_/ | | ** |
| 6 | +** |/ ** |
| 7 | +\* */ |
| 8 | + |
| 9 | +package scala.swing |
| 10 | + |
| 11 | +import java.awt.{Font => JFont} |
| 12 | + |
| 13 | +object Font { |
| 14 | + def apply(name: String, style: Style.Value, size: Int): Font = |
| 15 | + new JFont(name, style.id, size) |
| 16 | + |
| 17 | + /** A String constant for the canonical family name of the |
| 18 | + * logical font "Dialog". It is useful in Font construction |
| 19 | + * to provide compile-time verification of the name. |
| 20 | + */ |
| 21 | + val Dialog: String = JFont.DIALOG |
| 22 | + |
| 23 | + /** A String constant for the canonical family name of the |
| 24 | + * logical font "DialogInput". It is useful in Font construction |
| 25 | + * to provide compile-time verification of the name. |
| 26 | + */ |
| 27 | + val DialogInput: String = JFont.DIALOG_INPUT |
| 28 | + |
| 29 | + /** A String constant for the canonical family name of the |
| 30 | + * logical font "SansSerif". It is useful in Font construction |
| 31 | + * to provide compile-time verification of the name. |
| 32 | + */ |
| 33 | + val SansSerif: String = JFont.SANS_SERIF |
| 34 | + |
| 35 | + /** A String constant for the canonical family name of the |
| 36 | + * logical font "Serif". It is useful in Font construction |
| 37 | + * to provide compile-time verification of the name. |
| 38 | + */ |
| 39 | + val Serif: String = JFont.SERIF |
| 40 | + |
| 41 | + /** A String constant for the canonical family name of the |
| 42 | + * logical font "Monospaced". It is useful in Font construction |
| 43 | + * to provide compile-time verification of the name. |
| 44 | + */ |
| 45 | + val Monospaced: String = JFont.MONOSPACED |
| 46 | + |
| 47 | + // Constants to be used for styles. Can be combined to mix styles. |
| 48 | + |
| 49 | + object Style extends Enumeration { |
| 50 | + val Plain : Style.Value = Value(JFont.PLAIN) |
| 51 | + val Bold : Style.Value = Value(JFont.BOLD) |
| 52 | + val Italic : Style.Value = Value(JFont.ITALIC) |
| 53 | + val BoldItalic: Style.Value = Value(JFont.BOLD | JFont.ITALIC) |
| 54 | + } |
| 55 | + |
| 56 | + // for convenience, have these values also directly in the `Font` name space |
| 57 | + val Plain : Style.Value = Style.Plain |
| 58 | + val Bold : Style.Value = Style.Bold |
| 59 | + val Italic : Style.Value = Style.Italic |
| 60 | + val BoldItalic: Style.Value = Style.BoldItalic |
| 61 | +} |
0 commit comments