src/Pure/GUI/gui.scala
author wenzelm
Sat, 15 Feb 2025 16:12:29 +0100
changeset 82183 a519b9d1e1c1
parent 82142 508a673c87ac
child 82544 b572e7324bfb
permissions -rw-r--r--
refrain from fancy GUI style (in contrast to 904b2144e9c5), which looks bad in Isabelle/VSCode;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
53783
f5e9d182f645 clarified location of GUI modules (which depend on Swing of JFX);
wenzelm
parents: 53778
diff changeset
     1
/*  Title:      Pure/GUI/gui.scala
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
     3
53712
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
     4
Basic GUI tools (for AWT/Swing).
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
     5
*/
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
     6
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
     7
package isabelle
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
     8
73909
1d0d9772fff0 tuned imports;
wenzelm
parents: 73878
diff changeset
     9
import java.util.{Map => JMap}
73037
473509b160d9 more operations;
wenzelm
parents: 72975
diff changeset
    10
import java.awt.{Component, Container, Font, Image, Insets, KeyboardFocusManager, Window, Point,
73117
6a6e987552c7 clarified list of presented look-and-feels;
wenzelm
parents: 73116
diff changeset
    11
  Rectangle, Dimension, GraphicsEnvironment, MouseInfo, Toolkit}
82142
508a673c87ac removed unused imports;
wenzelm
parents: 82050
diff changeset
    12
import java.awt.event.{KeyAdapter, KeyEvent}
72974
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
    13
import java.awt.font.{FontRenderContext, LineMetrics, TextAttribute, TransformAttribute}
53785
e64edcc2f8bf tuned signature;
wenzelm
parents: 53783
diff changeset
    14
import java.awt.geom.AffineTransform
82142
508a673c87ac removed unused imports;
wenzelm
parents: 82050
diff changeset
    15
import javax.swing.{ImageIcon, JButton, JLabel, JLayeredPane, JOptionPane,
508a673c87ac removed unused imports;
wenzelm
parents: 82050
diff changeset
    16
  RootPaneContainer, JTextField, JComboBox, LookAndFeel, UIManager, SwingUtilities}
76492
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
    17
82142
508a673c87ac removed unused imports;
wenzelm
parents: 82050
diff changeset
    18
import scala.swing.{CheckBox, ComboBox, ScrollPane, TextArea, ListView, Separator}
75852
fcc25bb49def clarified signature;
wenzelm
parents: 75839
diff changeset
    19
import scala.swing.event.{ButtonClicked, SelectionChanged}
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
    20
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
    21
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
    22
object GUI {
73116
b84887a67cc6 clarified default L&F of Isabelle/Scala (not Isabelle/jEdit);
wenzelm
parents: 73111
diff changeset
    23
  /* Swing look-and-feel */
59201
702e0971d617 added system property isabelle.laf, notably for initial system dialog;
wenzelm
parents: 59183
diff changeset
    24
82050
0f22f7b370b2 clarified default of flatlaf.useNativeLibrary=false, for cross-platform GUI uniformity;
wenzelm
parents: 81674
diff changeset
    25
  def init_laf(): Unit = {
0f22f7b370b2 clarified default of flatlaf.useNativeLibrary=false, for cross-platform GUI uniformity;
wenzelm
parents: 81674
diff changeset
    26
    val prop = com.formdev.flatlaf.FlatSystemProperties.USE_NATIVE_LIBRARY
0f22f7b370b2 clarified default of flatlaf.useNativeLibrary=false, for cross-platform GUI uniformity;
wenzelm
parents: 81674
diff changeset
    27
    System.setProperty(prop, System.getProperty(prop, "false"))
0f22f7b370b2 clarified default of flatlaf.useNativeLibrary=false, for cross-platform GUI uniformity;
wenzelm
parents: 81674
diff changeset
    28
    com.formdev.flatlaf.FlatLightLaf.setup()
0f22f7b370b2 clarified default of flatlaf.useNativeLibrary=false, for cross-platform GUI uniformity;
wenzelm
parents: 81674
diff changeset
    29
  }
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
    30
81335
fe32eaea366c clarified signature;
wenzelm
parents: 81333
diff changeset
    31
  def current_laf(): String = UIManager.getLookAndFeel.getClass.getName()
72975
315f9b4f9e7a tuned signature;
wenzelm
parents: 72974
diff changeset
    32
73367
77ef8bef0593 clarified signature --- fewer warnings;
wenzelm
parents: 73340
diff changeset
    33
  def is_macos_laf: Boolean =
81335
fe32eaea366c clarified signature;
wenzelm
parents: 81333
diff changeset
    34
    Platform.is_macos && UIManager.getSystemLookAndFeelClassName() == current_laf()
53848
8d7029eb0c31 disable standard behaviour of Mac OS X text field (i.e. select-all after focus gain) in order to make completion work more smoothly;
wenzelm
parents: 53786
diff changeset
    35
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
    36
  class Look_And_Feel(laf: LookAndFeel) extends Isabelle_System.Service {
73117
6a6e987552c7 clarified list of presented look-and-feels;
wenzelm
parents: 73116
diff changeset
    37
    def info: UIManager.LookAndFeelInfo =
6a6e987552c7 clarified list of presented look-and-feels;
wenzelm
parents: 73116
diff changeset
    38
      new UIManager.LookAndFeelInfo(laf.getName, laf.getClass.getName)
73111
01f4965fd09b support for additional look-and-feels;
wenzelm
parents: 73095
diff changeset
    39
  }
01f4965fd09b support for additional look-and-feels;
wenzelm
parents: 73095
diff changeset
    40
01f4965fd09b support for additional look-and-feels;
wenzelm
parents: 73095
diff changeset
    41
  lazy val look_and_feels: List[Look_And_Feel] =
01f4965fd09b support for additional look-and-feels;
wenzelm
parents: 73095
diff changeset
    42
    Isabelle_System.make_services(classOf[Look_And_Feel])
01f4965fd09b support for additional look-and-feels;
wenzelm
parents: 73095
diff changeset
    43
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
    44
  def init_lafs(): Unit = {
73117
6a6e987552c7 clarified list of presented look-and-feels;
wenzelm
parents: 73116
diff changeset
    45
    val old_lafs =
6a6e987552c7 clarified list of presented look-and-feels;
wenzelm
parents: 73116
diff changeset
    46
      Set(
6a6e987552c7 clarified list of presented look-and-feels;
wenzelm
parents: 73116
diff changeset
    47
        "com.sun.java.swing.plaf.motif.MotifLookAndFeel",
6a6e987552c7 clarified list of presented look-and-feels;
wenzelm
parents: 73116
diff changeset
    48
        "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel")
6a6e987552c7 clarified list of presented look-and-feels;
wenzelm
parents: 73116
diff changeset
    49
    val lafs =
6a6e987552c7 clarified list of presented look-and-feels;
wenzelm
parents: 73116
diff changeset
    50
      UIManager.getInstalledLookAndFeels().toList
6a6e987552c7 clarified list of presented look-and-feels;
wenzelm
parents: 73116
diff changeset
    51
        .filterNot(info => old_lafs(info.getClassName))
6a6e987552c7 clarified list of presented look-and-feels;
wenzelm
parents: 73116
diff changeset
    52
    val more_lafs = look_and_feels.map(_.info)
6a6e987552c7 clarified list of presented look-and-feels;
wenzelm
parents: 73116
diff changeset
    53
    UIManager.setInstalledLookAndFeels((more_lafs ::: lafs).toArray)
81322
0521e65af41e tuned GUI;
wenzelm
parents: 81320
diff changeset
    54
0521e65af41e tuned GUI;
wenzelm
parents: 81320
diff changeset
    55
    // see https://www.formdev.com/flatlaf/customizing
0521e65af41e tuned GUI;
wenzelm
parents: 81320
diff changeset
    56
    UIManager.put("Component.arrowType", "triangle")
73117
6a6e987552c7 clarified list of presented look-and-feels;
wenzelm
parents: 73116
diff changeset
    57
  }
73111
01f4965fd09b support for additional look-and-feels;
wenzelm
parents: 73095
diff changeset
    58
01f4965fd09b support for additional look-and-feels;
wenzelm
parents: 73095
diff changeset
    59
73116
b84887a67cc6 clarified default L&F of Isabelle/Scala (not Isabelle/jEdit);
wenzelm
parents: 73111
diff changeset
    60
  /* additional look-and-feels */
b84887a67cc6 clarified default L&F of Isabelle/Scala (not Isabelle/jEdit);
wenzelm
parents: 73111
diff changeset
    61
56752
72b4205f4de9 uniform focus traversal via TAB / Shift-TAB for all fields, in contrast to Java defaults, but in accordance to occasional jEdit practice;
wenzelm
parents: 56622
diff changeset
    62
  /* plain focus traversal, notably for text fields */
72b4205f4de9 uniform focus traversal via TAB / Shift-TAB for all fields, in contrast to Java defaults, but in accordance to occasional jEdit practice;
wenzelm
parents: 56622
diff changeset
    63
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
    64
  def plain_focus_traversal(component: Component): Unit = {
56752
72b4205f4de9 uniform focus traversal via TAB / Shift-TAB for all fields, in contrast to Java defaults, but in accordance to occasional jEdit practice;
wenzelm
parents: 56622
diff changeset
    65
    val dummy_button = new JButton
72b4205f4de9 uniform focus traversal via TAB / Shift-TAB for all fields, in contrast to Java defaults, but in accordance to occasional jEdit practice;
wenzelm
parents: 56622
diff changeset
    66
    def apply(id: Int): Unit =
72b4205f4de9 uniform focus traversal via TAB / Shift-TAB for all fields, in contrast to Java defaults, but in accordance to occasional jEdit practice;
wenzelm
parents: 56622
diff changeset
    67
      component.setFocusTraversalKeys(id, dummy_button.getFocusTraversalKeys(id))
72b4205f4de9 uniform focus traversal via TAB / Shift-TAB for all fields, in contrast to Java defaults, but in accordance to occasional jEdit practice;
wenzelm
parents: 56622
diff changeset
    68
    apply(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS)
72b4205f4de9 uniform focus traversal via TAB / Shift-TAB for all fields, in contrast to Java defaults, but in accordance to occasional jEdit practice;
wenzelm
parents: 56622
diff changeset
    69
    apply(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS)
72b4205f4de9 uniform focus traversal via TAB / Shift-TAB for all fields, in contrast to Java defaults, but in accordance to occasional jEdit practice;
wenzelm
parents: 56622
diff changeset
    70
  }
72b4205f4de9 uniform focus traversal via TAB / Shift-TAB for all fields, in contrast to Java defaults, but in accordance to occasional jEdit practice;
wenzelm
parents: 56622
diff changeset
    71
72b4205f4de9 uniform focus traversal via TAB / Shift-TAB for all fields, in contrast to Java defaults, but in accordance to occasional jEdit practice;
wenzelm
parents: 56622
diff changeset
    72
81655
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
    73
  /* style */
81648
c98cfdcb2df0 clarified signature;
wenzelm
parents: 81382
diff changeset
    74
81655
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
    75
  class Style {
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
    76
    def enclose(body: String): String = body
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
    77
    def make_text(str: String): String = str
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
    78
    def make_bold(str: String): String = str
81657
4210fd10e776 clarified signature;
wenzelm
parents: 81655
diff changeset
    79
    def enclose_text(str: String): String = enclose(make_text(str))
4210fd10e776 clarified signature;
wenzelm
parents: 81655
diff changeset
    80
    def enclose_bold(str: String): String = enclose(make_bold(str))
81659
a904fcbbbdbc clarified signature;
wenzelm
parents: 81657
diff changeset
    81
    def spaces(n: Int): String = Symbol.spaces(n)
81655
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
    82
  }
81649
904b2144e9c5 more GUI styles;
wenzelm
parents: 81648
diff changeset
    83
81655
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
    84
  class Style_HTML extends Style {
81670
3e51429404cd minor performance tuning;
wenzelm
parents: 81666
diff changeset
    85
    override def enclose(body: String): String = enclose_style("", body)
81655
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
    86
    override def make_text(str: String): String = HTML.output(str)
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
    87
    override def make_bold(str: String): String = "<b>" + make_text(str) + "</b>"
81659
a904fcbbbdbc clarified signature;
wenzelm
parents: 81657
diff changeset
    88
    override def spaces(n: Int): String = HTML.spaces(n)
81665
6afd01d5ddd6 clarified signature;
wenzelm
parents: 81662
diff changeset
    89
81666
8a8814ab36f6 clarified signature: more operations;
wenzelm
parents: 81665
diff changeset
    90
    def enclose_style(style: String, body: String): String =
81670
3e51429404cd minor performance tuning;
wenzelm
parents: 81666
diff changeset
    91
      if (style.isEmpty) {
3e51429404cd minor performance tuning;
wenzelm
parents: 81666
diff changeset
    92
        Library.string_builder(body.length + 13) { s =>
3e51429404cd minor performance tuning;
wenzelm
parents: 81666
diff changeset
    93
          s ++= "<html>"
3e51429404cd minor performance tuning;
wenzelm
parents: 81666
diff changeset
    94
          s ++= body
3e51429404cd minor performance tuning;
wenzelm
parents: 81666
diff changeset
    95
          s ++= "</html>"
3e51429404cd minor performance tuning;
wenzelm
parents: 81666
diff changeset
    96
        }
3e51429404cd minor performance tuning;
wenzelm
parents: 81666
diff changeset
    97
      }
81666
8a8814ab36f6 clarified signature: more operations;
wenzelm
parents: 81665
diff changeset
    98
      else {
8a8814ab36f6 clarified signature: more operations;
wenzelm
parents: 81665
diff changeset
    99
        Library.string_builder(style.length + body.length + 35) { s =>
8a8814ab36f6 clarified signature: more operations;
wenzelm
parents: 81665
diff changeset
   100
          s ++= "<html><span style=\""
8a8814ab36f6 clarified signature: more operations;
wenzelm
parents: 81665
diff changeset
   101
          s ++= style
8a8814ab36f6 clarified signature: more operations;
wenzelm
parents: 81665
diff changeset
   102
          s ++= "\">"
8a8814ab36f6 clarified signature: more operations;
wenzelm
parents: 81665
diff changeset
   103
          s ++= body
8a8814ab36f6 clarified signature: more operations;
wenzelm
parents: 81665
diff changeset
   104
          s ++= "</span></html>"
8a8814ab36f6 clarified signature: more operations;
wenzelm
parents: 81665
diff changeset
   105
        }
8a8814ab36f6 clarified signature: more operations;
wenzelm
parents: 81665
diff changeset
   106
      }
8a8814ab36f6 clarified signature: more operations;
wenzelm
parents: 81665
diff changeset
   107
81674
70d2f72098df proper bullet symbols for GUI text -- in contrast to Isabelle \<bullet> 0x002219;
wenzelm
parents: 81670
diff changeset
   108
    def regular_bullet: String = "\u2022"
70d2f72098df proper bullet symbols for GUI text -- in contrast to Isabelle \<bullet> 0x002219;
wenzelm
parents: 81670
diff changeset
   109
    def triangular_bullet: String = "\u2023"
81655
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   110
  }
81654
f13d04506126 more robust: proper HTML.output;
wenzelm
parents: 81650
diff changeset
   111
81655
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   112
  abstract class Style_Symbol extends Style {
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   113
    def bold: String
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   114
    override def make_bold(str: String): String =
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   115
      Symbol.iterator(str)
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   116
        .flatMap(s => if (Symbol.is_controllable(s)) List(bold, s) else List(s))
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   117
        .mkString
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   118
  }
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   119
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   120
  object Style_Plain extends Style { override def toString: String = "plain" }
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   121
81665
6afd01d5ddd6 clarified signature;
wenzelm
parents: 81662
diff changeset
   122
  object Style_HTML extends Style_HTML { override def toString: String = "html" }
81655
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   123
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   124
  object Style_Symbol_Encoded extends Style_Symbol {
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   125
    override def toString: String = "symbol_encoded"
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   126
    override def bold: String = Symbol.bold
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   127
  }
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   128
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   129
  object Style_Symbol_Decoded extends Style_Symbol {
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   130
    override def toString: String = "symbol_decoded"
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   131
    override def bold: String = Symbol.bold_decoded
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   132
  }
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   133
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   134
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   135
  /* named items */
81649
904b2144e9c5 more GUI styles;
wenzelm
parents: 81648
diff changeset
   136
904b2144e9c5 more GUI styles;
wenzelm
parents: 81648
diff changeset
   137
  sealed case class Name(
904b2144e9c5 more GUI styles;
wenzelm
parents: 81648
diff changeset
   138
    name: String,
904b2144e9c5 more GUI styles;
wenzelm
parents: 81648
diff changeset
   139
    kind: String = "",
904b2144e9c5 more GUI styles;
wenzelm
parents: 81648
diff changeset
   140
    prefix: String = "",
81655
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   141
    style: Style = Style_Plain
81649
904b2144e9c5 more GUI styles;
wenzelm
parents: 81648
diff changeset
   142
  ) {
81661
98ecc0ed6af1 clarified signature: ensure uniform style;
wenzelm
parents: 81659
diff changeset
   143
    def set_style(new_style: Style): Name = copy(style = new_style)
98ecc0ed6af1 clarified signature: ensure uniform style;
wenzelm
parents: 81659
diff changeset
   144
81648
c98cfdcb2df0 clarified signature;
wenzelm
parents: 81382
diff changeset
   145
    override def toString: String = {
c98cfdcb2df0 clarified signature;
wenzelm
parents: 81382
diff changeset
   146
      val a = kind.nonEmpty
c98cfdcb2df0 clarified signature;
wenzelm
parents: 81382
diff changeset
   147
      val b = name.nonEmpty
81655
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   148
      style.make_text(prefix) +
81654
f13d04506126 more robust: proper HTML.output;
wenzelm
parents: 81650
diff changeset
   149
        if_proper(a || b,
82183
a519b9d1e1c1 refrain from fancy GUI style (in contrast to 904b2144e9c5), which looks bad in Isabelle/VSCode;
wenzelm
parents: 82142
diff changeset
   150
          if_proper(prefix, ": ") + if_proper(kind, style.make_text(kind)) +
81655
775514416939 clarified signature;
wenzelm
parents: 81654
diff changeset
   151
          if_proper(a && b, " ") + if_proper(b, style.make_text(quote(name))))
81648
c98cfdcb2df0 clarified signature;
wenzelm
parents: 81382
diff changeset
   152
    }
c98cfdcb2df0 clarified signature;
wenzelm
parents: 81382
diff changeset
   153
  }
c98cfdcb2df0 clarified signature;
wenzelm
parents: 81382
diff changeset
   154
c98cfdcb2df0 clarified signature;
wenzelm
parents: 81382
diff changeset
   155
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   156
  /* simple dialogs */
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   157
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   158
  def scrollable_text(
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   159
    raw_txt: String,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   160
    width: Int = 60,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   161
    height: Int = 20,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   162
    editable: Boolean = false
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   163
  ) : ScrollPane = {
80817
e31ebb2be437 clarified signature;
wenzelm
parents: 80553
diff changeset
   164
    val txt = Protocol_Message.clean_output(raw_txt)
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   165
    val text = new TextArea(txt)
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   166
    if (width > 0) text.columns = width
53714
89fb20ae9b73 limit for text height;
wenzelm
parents: 53712
diff changeset
   167
    if (height > 0 && split_lines(txt).length > height) text.rows = height
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   168
    text.editable = editable
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   169
    new ScrollPane(text)
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   170
  }
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   171
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   172
  private def simple_dialog(
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   173
    kind: Int,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   174
    default_title: String,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   175
    parent: Component,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   176
    title: String,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   177
    message: Iterable[Any]
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   178
  ): Unit = {
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 57044
diff changeset
   179
    GUI_Thread.now {
65370
wenzelm
parents: 65083
diff changeset
   180
      val java_message =
wenzelm
parents: 65083
diff changeset
   181
        message.iterator.map({ case x: scala.swing.Component => x.peer case x => x }).
wenzelm
parents: 65083
diff changeset
   182
          toArray.asInstanceOf[Array[AnyRef]]
wenzelm
parents: 65083
diff changeset
   183
      JOptionPane.showMessageDialog(parent, java_message,
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   184
        if (title == null) default_title else title, kind)
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   185
    }
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   186
  }
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   187
57639
wenzelm
parents: 57612
diff changeset
   188
  def dialog(parent: Component, title: String, message: Any*): Unit =
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   189
    simple_dialog(JOptionPane.PLAIN_MESSAGE, null, parent, title, message)
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   190
57639
wenzelm
parents: 57612
diff changeset
   191
  def warning_dialog(parent: Component, title: String, message: Any*): Unit =
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   192
    simple_dialog(JOptionPane.WARNING_MESSAGE, "Warning", parent, title, message)
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   193
57639
wenzelm
parents: 57612
diff changeset
   194
  def error_dialog(parent: Component, title: String, message: Any*): Unit =
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   195
    simple_dialog(JOptionPane.ERROR_MESSAGE, "Error", parent, title, message)
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   196
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   197
  def confirm_dialog(parent: Component, title: String, option_type: Int, message: Any*): Int =
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 57044
diff changeset
   198
    GUI_Thread.now {
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   199
      val java_message = message map { case x: scala.swing.Component => x.peer case x => x }
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   200
      JOptionPane.showConfirmDialog(parent,
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   201
        java_message.toArray.asInstanceOf[Array[AnyRef]], title,
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   202
          option_type, JOptionPane.QUESTION_MESSAGE)
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   203
    }
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   204
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   205
75852
fcc25bb49def clarified signature;
wenzelm
parents: 75839
diff changeset
   206
  /* basic GUI components */
fcc25bb49def clarified signature;
wenzelm
parents: 75839
diff changeset
   207
75853
f981111768ec clarified signature;
wenzelm
parents: 75852
diff changeset
   208
  class Button(label: String) extends scala.swing.Button(label) {
f981111768ec clarified signature;
wenzelm
parents: 75852
diff changeset
   209
    def clicked(): Unit = {}
f981111768ec clarified signature;
wenzelm
parents: 75852
diff changeset
   210
f981111768ec clarified signature;
wenzelm
parents: 75852
diff changeset
   211
    reactions += { case ButtonClicked(_) => clicked() }
f981111768ec clarified signature;
wenzelm
parents: 75852
diff changeset
   212
  }
f981111768ec clarified signature;
wenzelm
parents: 75852
diff changeset
   213
75854
2163772eeaf2 tuned signature;
wenzelm
parents: 75853
diff changeset
   214
  class Check(label: String, init: Boolean = false) extends CheckBox(label) {
75852
fcc25bb49def clarified signature;
wenzelm
parents: 75839
diff changeset
   215
    def clicked(state: Boolean): Unit = {}
fcc25bb49def clarified signature;
wenzelm
parents: 75839
diff changeset
   216
    def clicked(): Unit = {}
fcc25bb49def clarified signature;
wenzelm
parents: 75839
diff changeset
   217
fcc25bb49def clarified signature;
wenzelm
parents: 75839
diff changeset
   218
    selected = init
fcc25bb49def clarified signature;
wenzelm
parents: 75839
diff changeset
   219
    reactions += { case ButtonClicked(_) => clicked(selected); clicked() }
fcc25bb49def clarified signature;
wenzelm
parents: 75839
diff changeset
   220
  }
75839
29441f2bfe81 clarified signature: more explicit types;
wenzelm
parents: 75809
diff changeset
   221
76492
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   222
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   223
  /* list selector */
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   224
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   225
  object Selector {
76505
e0d797283638 tuned signature;
wenzelm
parents: 76504
diff changeset
   226
    sealed abstract class Entry[A] { def get_value: Option[A] = Value.unapply(this) }
76504
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   227
    object Value {
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   228
      def unapply[A](entry: Entry[A]): Option[A] =
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   229
        entry match {
76502
08b950ca0313 tuned signature;
wenzelm
parents: 76494
diff changeset
   230
          case item: Item[_] => Some(item.value)
76492
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   231
          case _ => None
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   232
        }
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   233
    }
76505
e0d797283638 tuned signature;
wenzelm
parents: 76504
diff changeset
   234
    def item[A](value: A): Entry[A] = Item(value, "", 0)
e0d797283638 tuned signature;
wenzelm
parents: 76504
diff changeset
   235
    def item_description[A](value: A, description: String): Entry[A] = Item(value, description, 0)
e0d797283638 tuned signature;
wenzelm
parents: 76504
diff changeset
   236
76504
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   237
    private case class Item[A](value: A, description: String, batch: Int) extends Entry[A] {
76502
08b950ca0313 tuned signature;
wenzelm
parents: 76494
diff changeset
   238
      override def toString: String = proper_string(description) getOrElse value.toString
76492
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   239
    }
76504
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   240
    private case class Separator[A](batch: Int) extends Entry[A] {
76503
5944f9e70d98 clarified signature: only support nameless separator;
wenzelm
parents: 76502
diff changeset
   241
      override def toString: String = "---"
76492
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   242
    }
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   243
76505
e0d797283638 tuned signature;
wenzelm
parents: 76504
diff changeset
   244
    private def make_entries[A](batches: List[List[Entry[A]]]): List[Entry[A]] = {
76789
wenzelm
parents: 76505
diff changeset
   245
      val item_batches = batches.map(_.flatMap(Library.as_subclass(classOf[Item[A]])))
76504
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   246
      val sep_entries: List[Entry[A]] =
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   247
        item_batches.filter(_.nonEmpty).zipWithIndex.flatMap({ case (batch, i) =>
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   248
          Separator[A](i) :: batch.map(_.copy(batch = i))
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   249
        })
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   250
      sep_entries.tail
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   251
    }
76492
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   252
  }
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   253
76504
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   254
  class Selector[A](batches: List[Selector.Entry[A]]*)
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   255
  extends ComboBox[Selector.Entry[A]](Selector.make_entries(batches.toList)) {
75839
29441f2bfe81 clarified signature: more explicit types;
wenzelm
parents: 75809
diff changeset
   256
    def changed(): Unit = {}
29441f2bfe81 clarified signature: more explicit types;
wenzelm
parents: 75809
diff changeset
   257
76504
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   258
    lazy val entries: List[Selector.Entry[A]] = Selector.make_entries(batches.toList)
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   259
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   260
    def find_value(pred: A => Boolean): Option[Selector.Entry[A]] =
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   261
      entries.find({ case item: Selector.Item[A] => pred(item.value) case _ => false })
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   262
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   263
    def selection_value: Option[A] = selection.item.get_value
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   264
76494
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   265
    override lazy val peer: JComboBox[Selector.Entry[A]] =
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   266
      new JComboBox[Selector.Entry[A]](ComboBox.newConstantModel(entries)) with SuperMixin {
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   267
        private var key_released = false
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   268
        private var sep_selected = false
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   269
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   270
        addKeyListener(new KeyAdapter {
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   271
          override def keyPressed(e: KeyEvent): Unit = { key_released = false }
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   272
          override def keyReleased(e: KeyEvent): Unit = { key_released = true }
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   273
        })
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   274
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   275
        override def setSelectedIndex(i: Int): Unit = {
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   276
          getItemAt(i) match {
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   277
            case _: Selector.Separator[_] =>
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   278
              if (key_released) { sep_selected = true }
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   279
              else {
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   280
                val k = getSelectedIndex()
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   281
                val j = if (i > k) i + 1 else i - 1
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   282
                if (0 <= j && j < dataModel.getSize()) super.setSelectedIndex(j)
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   283
              }
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   284
            case _ => super.setSelectedIndex(i)
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   285
          }
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   286
        }
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   287
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   288
        override def setPopupVisible(visible: Boolean): Unit = {
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   289
          if (sep_selected) { sep_selected = false}
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   290
          else super.setPopupVisible(visible)
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   291
        }
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   292
      }
9686049ce988 more robust selection: avoid duplicates via "batch" number;
wenzelm
parents: 76492
diff changeset
   293
76492
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   294
    private val default_renderer = renderer
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   295
    private val render_separator = new Separator
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   296
    renderer =
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   297
      (list: ListView[_ <: Selector.Entry[A]], selected: Boolean, focus: Boolean, entry: Selector.Entry[A], i: Int) => {
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   298
        entry match {
76503
5944f9e70d98 clarified signature: only support nameless separator;
wenzelm
parents: 76502
diff changeset
   299
          case _: Selector.Separator[_] => render_separator
76492
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   300
          case _ => default_renderer.componentFor(list, selected, focus, entry, i)
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   301
        }
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   302
      }
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   303
75839
29441f2bfe81 clarified signature: more explicit types;
wenzelm
parents: 75809
diff changeset
   304
    listenTo(selection)
29441f2bfe81 clarified signature: more explicit types;
wenzelm
parents: 75809
diff changeset
   305
    reactions += { case SelectionChanged(_) => changed() }
29441f2bfe81 clarified signature: more explicit types;
wenzelm
parents: 75809
diff changeset
   306
  }
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   307
75852
fcc25bb49def clarified signature;
wenzelm
parents: 75839
diff changeset
   308
fcc25bb49def clarified signature;
wenzelm
parents: 75839
diff changeset
   309
  /* zoom factor */
fcc25bb49def clarified signature;
wenzelm
parents: 75839
diff changeset
   310
81382
5e8287d34295 clarified signature;
wenzelm
parents: 81335
diff changeset
   311
  private val Percent = "([0-9]+)%?".r
57044
042d6e58cb40 more uniform Font_Info.Zoom_Box;
wenzelm
parents: 56888
diff changeset
   312
75839
29441f2bfe81 clarified signature: more explicit types;
wenzelm
parents: 75809
diff changeset
   313
  class Zoom extends Selector[String](
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   314
    List("50%", "70%", "85%", "100%", "125%", "150%", "175%", "200%", "300%", "400%")
76504
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   315
      .map(GUI.Selector.item)
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   316
  ) {
81382
5e8287d34295 clarified signature;
wenzelm
parents: 81335
diff changeset
   317
    def percent: Int = parse(selection.item.toString)
5e8287d34295 clarified signature;
wenzelm
parents: 81335
diff changeset
   318
    def scale: Double = 0.01 * percent
57044
042d6e58cb40 more uniform Font_Info.Zoom_Box;
wenzelm
parents: 56888
diff changeset
   319
042d6e58cb40 more uniform Font_Info.Zoom_Box;
wenzelm
parents: 56888
diff changeset
   320
    private def parse(text: String): Int =
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   321
      text match {
81382
5e8287d34295 clarified signature;
wenzelm
parents: 81335
diff changeset
   322
        case Percent(s) =>
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   323
          val i = Integer.parseInt(s)
56874
5d78bce4f5a4 tuned GUI layout;
wenzelm
parents: 56752
diff changeset
   324
          if (10 <= i && i < 1000) i else 100
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   325
        case _ => 100
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   326
      }
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   327
57044
042d6e58cb40 more uniform Font_Info.Zoom_Box;
wenzelm
parents: 56888
diff changeset
   328
    private def print(i: Int): String = i.toString + "%"
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   329
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   330
    def set_item(i: Int): Unit = {
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   331
      peer.getEditor match {
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   332
        case null =>
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   333
        case editor => editor.setItem(print(i))
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   334
      }
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   335
    }
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   336
76492
e228be7cd375 clarified GUI.Selector, with support for separator as pseudo-entry;
wenzelm
parents: 75854
diff changeset
   337
    makeEditable()(c =>
76504
15b058bb2416 clarified signature: ensure that entries are well-formed --- no consecutive separators, no separators at start/end;
wenzelm
parents: 76503
diff changeset
   338
      new ComboBox.BuiltInEditor(c)(text => Selector.item(print(parse(text))), _.toString))
56874
5d78bce4f5a4 tuned GUI layout;
wenzelm
parents: 56752
diff changeset
   339
    peer.getEditor.getEditorComponent match {
56888
3e8cbb624cc5 tuned GUI for Windows L&F;
wenzelm
parents: 56874
diff changeset
   340
      case text: JTextField => text.setColumns(4)
56874
5d78bce4f5a4 tuned GUI layout;
wenzelm
parents: 56752
diff changeset
   341
      case _ =>
5d78bce4f5a4 tuned GUI layout;
wenzelm
parents: 56752
diff changeset
   342
    }
5d78bce4f5a4 tuned GUI layout;
wenzelm
parents: 56752
diff changeset
   343
57044
042d6e58cb40 more uniform Font_Info.Zoom_Box;
wenzelm
parents: 56888
diff changeset
   344
    selection.index = 3
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   345
  }
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   346
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   347
53786
wenzelm
parents: 53785
diff changeset
   348
  /* tooltip with multi-line support */
wenzelm
parents: 53785
diff changeset
   349
56622
891d1b8b64fb clarified tooltip_lines: HTML.encode already takes care of newline (but not space);
wenzelm
parents: 54965
diff changeset
   350
  def tooltip_lines(text: String): String =
891d1b8b64fb clarified tooltip_lines: HTML.encode already takes care of newline (but not space);
wenzelm
parents: 54965
diff changeset
   351
    if (text == null || text == "") null
81657
4210fd10e776 clarified signature;
wenzelm
parents: 81655
diff changeset
   352
    else Style_HTML.enclose_text(text)
53786
wenzelm
parents: 53785
diff changeset
   353
wenzelm
parents: 53785
diff changeset
   354
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   355
  /* icon */
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   356
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   357
  def isabelle_icon(): ImageIcon =
54676
6b2ca4850b71 uniform use of transparent icons, as for main "apps";
wenzelm
parents: 54659
diff changeset
   358
    new ImageIcon(getClass.getClassLoader.getResource("isabelle/isabelle_transparent-32.gif"))
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   359
54709
87402674fe2f alternative hires icon;
wenzelm
parents: 54676
diff changeset
   360
  def isabelle_icons(): List[ImageIcon] =
87402674fe2f alternative hires icon;
wenzelm
parents: 54676
diff changeset
   361
    for (icon <- List("isabelle/isabelle_transparent-32.gif", "isabelle/isabelle_transparent.gif"))
87402674fe2f alternative hires icon;
wenzelm
parents: 54676
diff changeset
   362
      yield new ImageIcon(getClass.getClassLoader.getResource(icon))
87402674fe2f alternative hires icon;
wenzelm
parents: 54676
diff changeset
   363
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   364
  def isabelle_image(): Image = isabelle_icon().getImage
53712
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   365
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   366
72974
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   367
  /* location within multi-screen environment */
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   368
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   369
  final case class Screen_Location(point: Point, bounds: Rectangle) {
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   370
    def relative(parent: Component, size: Dimension): Point = {
72974
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   371
      val w = size.width
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   372
      val h = size.height
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   373
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   374
      val x0 = parent.getLocationOnScreen.x
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   375
      val y0 = parent.getLocationOnScreen.y
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   376
      val x1 = x0 + parent.getWidth - w
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   377
      val y1 = y0 + parent.getHeight - h
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   378
      val x2 = point.x min (bounds.x + bounds.width - w)
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   379
      val y2 = point.y min (bounds.y + bounds.height - h)
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   380
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   381
      val location = new Point((x2 min x1) max x0, (y2 min y1) max y0)
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   382
      SwingUtilities.convertPointFromScreen(location, parent)
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   383
      location
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   384
    }
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   385
  }
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   386
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   387
  def screen_location(component: Component, point: Point): Screen_Location = {
72974
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   388
    val screen_point = new Point(point.x, point.y)
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   389
    if (component != null) SwingUtilities.convertPointToScreen(screen_point, component)
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   390
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   391
    val ge = GraphicsEnvironment.getLocalGraphicsEnvironment
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   392
    val screen_bounds =
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   393
      (for {
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   394
        device <- ge.getScreenDevices.iterator
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   395
        config <- device.getConfigurations.iterator
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   396
        bounds = config.getBounds
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   397
      } yield bounds).find(_.contains(screen_point)) getOrElse ge.getMaximumWindowBounds
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   398
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   399
    Screen_Location(screen_point, screen_bounds)
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   400
  }
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   401
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   402
  def mouse_location(): Screen_Location =
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   403
    screen_location(null, MouseInfo.getPointerInfo.getLocation)
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   404
3afd293347cc clarified modules;
wenzelm
parents: 72786
diff changeset
   405
73037
473509b160d9 more operations;
wenzelm
parents: 72975
diff changeset
   406
  /* screen size */
473509b160d9 more operations;
wenzelm
parents: 72975
diff changeset
   407
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   408
  sealed case class Screen_Size(bounds: Rectangle, insets: Insets) {
73038
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   409
    def full_screen_bounds: Rectangle =
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   410
      if (Platform.is_linux) {
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   411
        // avoid menu bar and docking areas
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   412
        new Rectangle(
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   413
          bounds.x + insets.left,
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   414
          bounds.y + insets.top,
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   415
          bounds.width - insets.left - insets.right,
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   416
          bounds.height - insets.top - insets.bottom)
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   417
      }
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   418
      else if (Platform.is_macos) {
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   419
        // avoid menu bar, but ignore docking areas
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   420
        new Rectangle(
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   421
          bounds.x,
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   422
          bounds.y + insets.top,
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   423
          bounds.width,
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   424
          bounds.height - insets.top)
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   425
      }
3b14f7315dd2 some attempts at multi-platform full-screen mode;
wenzelm
parents: 73037
diff changeset
   426
      else bounds
73037
473509b160d9 more operations;
wenzelm
parents: 72975
diff changeset
   427
  }
473509b160d9 more operations;
wenzelm
parents: 72975
diff changeset
   428
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   429
  def screen_size(component: Component): Screen_Size = {
73037
473509b160d9 more operations;
wenzelm
parents: 72975
diff changeset
   430
    val config = component.getGraphicsConfiguration
473509b160d9 more operations;
wenzelm
parents: 72975
diff changeset
   431
    val bounds = config.getBounds
473509b160d9 more operations;
wenzelm
parents: 72975
diff changeset
   432
    val insets = Toolkit.getDefaultToolkit.getScreenInsets(config)
473509b160d9 more operations;
wenzelm
parents: 72975
diff changeset
   433
    Screen_Size(bounds, insets)
473509b160d9 more operations;
wenzelm
parents: 72975
diff changeset
   434
  }
473509b160d9 more operations;
wenzelm
parents: 72975
diff changeset
   435
473509b160d9 more operations;
wenzelm
parents: 72975
diff changeset
   436
53712
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   437
  /* component hierachy */
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   438
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   439
  def get_parent(component: Component): Option[Container] =
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   440
    component.getParent match {
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   441
      case null => None
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   442
      case parent => Some(parent)
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   443
    }
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   444
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   445
  def ancestors(component: Component): Iterator[Container] = new Iterator[Container] {
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   446
    private var next_elem = get_parent(component)
73337
0af9e7e4476f tuned --- fewer warnings;
wenzelm
parents: 73117
diff changeset
   447
    def hasNext: Boolean = next_elem.isDefined
53712
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   448
    def next(): Container =
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   449
      next_elem match {
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   450
        case Some(parent) =>
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   451
          next_elem = get_parent(parent)
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   452
          parent
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   453
        case None => Iterator.empty.next()
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   454
      }
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   455
  }
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   456
ea51046be71b tuned signature;
wenzelm
parents: 53452
diff changeset
   457
  def parent_window(component: Component): Option[Window] =
80553
wenzelm
parents: 76789
diff changeset
   458
    ancestors(component).collectFirst({ case c: Window => c })
53778
29eaacff4078 proper layered pane at root of parent component, not global view (e.g. relevant for tooltips for detached info windows);
wenzelm
parents: 53714
diff changeset
   459
29eaacff4078 proper layered pane at root of parent component, not global view (e.g. relevant for tooltips for detached info windows);
wenzelm
parents: 53714
diff changeset
   460
  def layered_pane(component: Component): Option[JLayeredPane] =
29eaacff4078 proper layered pane at root of parent component, not global view (e.g. relevant for tooltips for detached info windows);
wenzelm
parents: 53714
diff changeset
   461
    parent_window(component) match {
80553
wenzelm
parents: 76789
diff changeset
   462
      case Some(c: RootPaneContainer) => Some(c.getLayeredPane)
53778
29eaacff4078 proper layered pane at root of parent component, not global view (e.g. relevant for tooltips for detached info windows);
wenzelm
parents: 53714
diff changeset
   463
      case _ => None
29eaacff4078 proper layered pane at root of parent component, not global view (e.g. relevant for tooltips for detached info windows);
wenzelm
parents: 53714
diff changeset
   464
    }
53785
e64edcc2f8bf tuned signature;
wenzelm
parents: 53783
diff changeset
   465
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   466
  def traverse_components(component: Component, apply: Component => Unit): Unit = {
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   467
    def traverse(comp: Component): Unit = {
63874
e2393cfde472 handle font-size events;
wenzelm
parents: 63420
diff changeset
   468
      apply(comp)
e2393cfde472 handle font-size events;
wenzelm
parents: 63420
diff changeset
   469
      comp match {
e2393cfde472 handle font-size events;
wenzelm
parents: 63420
diff changeset
   470
        case cont: Container =>
e2393cfde472 handle font-size events;
wenzelm
parents: 63420
diff changeset
   471
          for (i <- 0 until cont.getComponentCount)
e2393cfde472 handle font-size events;
wenzelm
parents: 63420
diff changeset
   472
            traverse(cont.getComponent(i))
e2393cfde472 handle font-size events;
wenzelm
parents: 63420
diff changeset
   473
        case _ =>
e2393cfde472 handle font-size events;
wenzelm
parents: 63420
diff changeset
   474
      }
e2393cfde472 handle font-size events;
wenzelm
parents: 63420
diff changeset
   475
    }
e2393cfde472 handle font-size events;
wenzelm
parents: 63420
diff changeset
   476
    traverse(component)
e2393cfde472 handle font-size events;
wenzelm
parents: 63420
diff changeset
   477
  }
e2393cfde472 handle font-size events;
wenzelm
parents: 63420
diff changeset
   478
53785
e64edcc2f8bf tuned signature;
wenzelm
parents: 53783
diff changeset
   479
e64edcc2f8bf tuned signature;
wenzelm
parents: 53783
diff changeset
   480
  /* font operations */
e64edcc2f8bf tuned signature;
wenzelm
parents: 53783
diff changeset
   481
61742
fd3b214b0979 clarified font: GUI defaults might change dynamically;
wenzelm
parents: 61529
diff changeset
   482
  def copy_font(font: Font): Font =
fd3b214b0979 clarified font: GUI defaults might change dynamically;
wenzelm
parents: 61529
diff changeset
   483
    if (font == null) null
fd3b214b0979 clarified font: GUI defaults might change dynamically;
wenzelm
parents: 61529
diff changeset
   484
    else new Font(font.getFamily, font.getStyle, font.getSize)
fd3b214b0979 clarified font: GUI defaults might change dynamically;
wenzelm
parents: 61529
diff changeset
   485
59230
cae3ef2897f2 tuned signature;
wenzelm
parents: 59201
diff changeset
   486
  def line_metrics(font: Font): LineMetrics =
53785
e64edcc2f8bf tuned signature;
wenzelm
parents: 53783
diff changeset
   487
    font.getLineMetrics("", new FontRenderContext(null, false, false))
e64edcc2f8bf tuned signature;
wenzelm
parents: 53783
diff changeset
   488
69376
wenzelm
parents: 69368
diff changeset
   489
  def transform_font(font: Font, transform: AffineTransform): Font =
73909
1d0d9772fff0 tuned imports;
wenzelm
parents: 73878
diff changeset
   490
    font.deriveFont(JMap.of(TextAttribute.TRANSFORM, new TransformAttribute(transform)))
69376
wenzelm
parents: 69368
diff changeset
   491
wenzelm
parents: 69368
diff changeset
   492
  def font(family: String = Isabelle_Fonts.sans, size: Int = 1, bold: Boolean = false): Font =
wenzelm
parents: 69368
diff changeset
   493
    new Font(family, if (bold) Font.BOLD else Font.PLAIN, size)
wenzelm
parents: 69368
diff changeset
   494
69377
81ae5893c556 use Isabelle fonts for all GUI look-and-feels;
wenzelm
parents: 69376
diff changeset
   495
  def label_font(): Font = (new JLabel).getFont
81ae5893c556 use Isabelle fonts for all GUI look-and-feels;
wenzelm
parents: 69376
diff changeset
   496
69376
wenzelm
parents: 69368
diff changeset
   497
wenzelm
parents: 69368
diff changeset
   498
  /* Isabelle fonts */
wenzelm
parents: 69368
diff changeset
   499
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   500
  def imitate_font(
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   501
    font: Font,
69358
71ef6e6da3dc prefer Isabelle_Fonts.sans (not mono) as derived GUI font;
wenzelm
parents: 69357
diff changeset
   502
    family: String = Isabelle_Fonts.sans,
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   503
    scale: Double = 1.0
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   504
  ): Font = {
53785
e64edcc2f8bf tuned signature;
wenzelm
parents: 53783
diff changeset
   505
    val font1 = new Font(family, font.getStyle, font.getSize)
59286
ac74eedb910a GUI.imitate_font: more explicit result size, e.g. relevant for caching;
wenzelm
parents: 59230
diff changeset
   506
    val rel_size = line_metrics(font).getHeight.toDouble / line_metrics(font1).getHeight
ac74eedb910a GUI.imitate_font: more explicit result size, e.g. relevant for caching;
wenzelm
parents: 59230
diff changeset
   507
    new Font(family, font.getStyle, (scale * rel_size * font.getSize).toInt)
59183
ec83638b6bfb imitate font more carefully: err on smaller size;
wenzelm
parents: 59080
diff changeset
   508
  }
ec83638b6bfb imitate font more carefully: err on smaller size;
wenzelm
parents: 59080
diff changeset
   509
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   510
  def imitate_font_css(
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   511
    font: Font,
69358
71ef6e6da3dc prefer Isabelle_Fonts.sans (not mono) as derived GUI font;
wenzelm
parents: 69357
diff changeset
   512
    family: String = Isabelle_Fonts.sans,
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   513
    scale: Double = 1.0
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   514
  ): String = {
59183
ec83638b6bfb imitate font more carefully: err on smaller size;
wenzelm
parents: 59080
diff changeset
   515
    val font1 = new Font(family, font.getStyle, font.getSize)
59230
cae3ef2897f2 tuned signature;
wenzelm
parents: 59201
diff changeset
   516
    val rel_size = line_metrics(font).getHeight.toDouble / line_metrics(font1).getHeight
59183
ec83638b6bfb imitate font more carefully: err on smaller size;
wenzelm
parents: 59080
diff changeset
   517
    "font-family: " + family + "; font-size: " + (scale * rel_size * 100).toInt + "%;"
53785
e64edcc2f8bf tuned signature;
wenzelm
parents: 53783
diff changeset
   518
  }
69377
81ae5893c556 use Isabelle fonts for all GUI look-and-feels;
wenzelm
parents: 69376
diff changeset
   519
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   520
  def use_isabelle_fonts(): Unit = {
69377
81ae5893c556 use Isabelle fonts for all GUI look-and-feels;
wenzelm
parents: 69376
diff changeset
   521
    val default_font = label_font()
81ae5893c556 use Isabelle fonts for all GUI look-and-feels;
wenzelm
parents: 69376
diff changeset
   522
    val ui = UIManager.getDefaults
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   523
    for (prop <-
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   524
      List(
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   525
        "ToggleButton.font",
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   526
        "CheckBoxMenuItem.font",
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   527
        "Label.font",
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   528
        "Menu.font",
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   529
        "MenuItem.font",
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   530
        "PopupMenu.font",
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   531
        "Table.font",
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   532
        "TableHeader.font",
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   533
        "TextArea.font",
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   534
        "TextField.font",
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   535
        "TextPane.font",
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   536
        "ToolTip.font",
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73909
diff changeset
   537
        "Tree.font")) {
69377
81ae5893c556 use Isabelle fonts for all GUI look-and-feels;
wenzelm
parents: 69376
diff changeset
   538
      val font = ui.get(prop) match { case font: Font => font case _ => default_font }
81ae5893c556 use Isabelle fonts for all GUI look-and-feels;
wenzelm
parents: 69376
diff changeset
   539
      ui.put(prop, GUI.imitate_font(font))
81ae5893c556 use Isabelle fonts for all GUI look-and-feels;
wenzelm
parents: 69376
diff changeset
   540
    }
81ae5893c556 use Isabelle fonts for all GUI look-and-feels;
wenzelm
parents: 69376
diff changeset
   541
  }
51619
95b7da3430d4 added missing file;
wenzelm
parents:
diff changeset
   542
}
73111
01f4965fd09b support for additional look-and-feels;
wenzelm
parents: 73095
diff changeset
   543
01f4965fd09b support for additional look-and-feels;
wenzelm
parents: 73095
diff changeset
   544
class FlatLightLaf extends GUI.Look_And_Feel(new com.formdev.flatlaf.FlatLightLaf)
01f4965fd09b support for additional look-and-feels;
wenzelm
parents: 73095
diff changeset
   545
class FlatDarkLaf extends GUI.Look_And_Feel(new com.formdev.flatlaf.FlatDarkLaf)