src/Pure/GUI/gui.scala
changeset 73117 6a6e987552c7
parent 73116 b84887a67cc6
child 73337 0af9e7e4476f
equal deleted inserted replaced
73116:b84887a67cc6 73117:6a6e987552c7
     5 */
     5 */
     6 
     6 
     7 package isabelle
     7 package isabelle
     8 
     8 
     9 import java.awt.{Component, Container, Font, Image, Insets, KeyboardFocusManager, Window, Point,
     9 import java.awt.{Component, Container, Font, Image, Insets, KeyboardFocusManager, Window, Point,
    10   Rectangle, Dimension, GraphicsEnvironment, MouseInfo, Toolkit, Taskbar}
    10   Rectangle, Dimension, GraphicsEnvironment, MouseInfo, Toolkit}
    11 import java.awt.font.{FontRenderContext, LineMetrics, TextAttribute, TransformAttribute}
    11 import java.awt.font.{FontRenderContext, LineMetrics, TextAttribute, TransformAttribute}
    12 import java.awt.geom.AffineTransform
    12 import java.awt.geom.AffineTransform
    13 import javax.swing.{ImageIcon, JButton, JDialog, JFrame, JLabel, JLayeredPane, JOptionPane,
    13 import javax.swing.{ImageIcon, JButton, JDialog, JFrame, JLabel, JLayeredPane, JOptionPane,
    14   JTextField, JWindow, LookAndFeel, UIManager, SwingUtilities}
    14   JTextField, JWindow, LookAndFeel, UIManager, SwingUtilities}
    15 import scala.swing.{ComboBox, ScrollPane, TextArea}
    15 import scala.swing.{ComboBox, ScrollPane, TextArea}
    25   def current_laf(): String = UIManager.getLookAndFeel.getClass.getName()
    25   def current_laf(): String = UIManager.getLookAndFeel.getClass.getName()
    26 
    26 
    27   def is_macos_laf(): Boolean =
    27   def is_macos_laf(): Boolean =
    28     Platform.is_macos && UIManager.getSystemLookAndFeelClassName() == current_laf()
    28     Platform.is_macos && UIManager.getSystemLookAndFeelClassName() == current_laf()
    29 
    29 
    30   class Look_And_Feel(val laf: LookAndFeel) extends Isabelle_System.Service
    30   class Look_And_Feel(laf: LookAndFeel) extends Isabelle_System.Service
    31   {
    31   {
    32     def setup: Unit = UIManager.installLookAndFeel(laf.getName, laf.getClass.getName)
    32     def info: UIManager.LookAndFeelInfo =
       
    33       new UIManager.LookAndFeelInfo(laf.getName, laf.getClass.getName)
    33   }
    34   }
    34 
    35 
    35   lazy val look_and_feels: List[Look_And_Feel] =
    36   lazy val look_and_feels: List[Look_And_Feel] =
    36     Isabelle_System.make_services(classOf[Look_And_Feel])
    37     Isabelle_System.make_services(classOf[Look_And_Feel])
    37 
    38 
    38   def setup_lafs(): Unit = look_and_feels.foreach(_.setup)
    39   def init_lafs()
       
    40   {
       
    41     val old_lafs =
       
    42       Set(
       
    43         "com.sun.java.swing.plaf.motif.MotifLookAndFeel",
       
    44         "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel")
       
    45     val lafs =
       
    46       UIManager.getInstalledLookAndFeels().toList
       
    47         .filterNot(info => old_lafs(info.getClassName))
       
    48     val more_lafs = look_and_feels.map(_.info)
       
    49     UIManager.setInstalledLookAndFeels((more_lafs ::: lafs).toArray)
       
    50   }
    39 
    51 
    40 
    52 
    41   /* additional look-and-feels */
    53   /* additional look-and-feels */
    42 
    54 
    43   /* plain focus traversal, notably for text fields */
    55   /* plain focus traversal, notably for text fields */