def default_foreground_color(): Color = if (is_dark_laf()) Color.WHITE else Color.BLACK def default_background_color(): Color = if (is_dark_laf()) Color.BLACK else Color.WHITE def default_intermediate_color(): Color = if (is_dark_laf()) Color.LIGHT_GRAY else Color.GRAY
class Look_And_Feel(laf: LookAndFeel) extends Isabelle_System.Service { def info: UIManager.LookAndFeelInfo = new UIManager.LookAndFeelInfo(laf.getName, laf.getClass.getName)
}
def enclose_style(style: String, body: String): String = if (style.isEmpty) {
Library.string_builder(body.length + 13) { s =>
s ++= ""
s ++= body
s ++= ""
}
} else {
Library.string_builder(style.length + body.length + 35) { s =>
s ++= ""
s ++= style
s ++= "\">"
s ++= body
s ++= ""
}
}
overridedef setSelectedIndex(i: Int): Unit = {
getItemAt(i) match { case _: Selector.Separator[_] => if (key_released) { sep_selected = true } else { val k = getSelectedIndex() val j = if (i > k) i + 1 else i - 1 if (0 <= j && j < dataModel.getSize()) super.setSelectedIndex(j)
} case _ => super.setSelectedIndex(i)
}
}
overridedef setPopupVisible(visible: Boolean): Unit = { if (sep_selected) { sep_selected = false} elsesuper.setPopupVisible(visible)
}
}
def set_item(i: Int): Unit = {
peer.getEditor match { casenull => case editor => editor.setItem(print(i))
}
}
makeEditable()(c => new ComboBox.BuiltInEditor(c)(text => Selector.item(print(parse(text))), _.toString))
peer.getEditor.getEditorComponent match { case text: JTextField => text.setColumns(4) case _ =>
}
selection.index = 3
}
/* tooltip with multi-line support */
def tooltip_lines(text: String): String = if (text == null || text == "") null else Style_HTML.enclose(split_lines(text).map(Style_HTML.make_text).mkString(" "))
/* icon */
def isabelle_icon(): ImageIcon = new ImageIcon(getClass.getClassLoader.getResource("isabelle/isabelle_transparent-32.gif"))
finalcaseclass Screen_Location(point: Point, bounds: Rectangle) { def relative(parent: Component, size: Dimension): Point = { val w = size.width val h = size.height
val x0 = parent.getLocationOnScreen.x val y0 = parent.getLocationOnScreen.y val x1 = x0 + parent.getWidth - w val y1 = y0 + parent.getHeight - h val x2 = point.x min (bounds.x + bounds.width - w) val y2 = point.y min (bounds.y + bounds.height - h)
val location = new Point((x2 min x1) max x0, (y2 min y1) max y0)
SwingUtilities.convertPointFromScreen(location, parent)
location
}
}
def screen_location(component: Component, point: Point): Screen_Location = { val screen_point = new Point(point.x, point.y) if (component != null) SwingUtilities.convertPointToScreen(screen_point, component)
val ge = GraphicsEnvironment.getLocalGraphicsEnvironment val screen_bounds =
(for {
device <- ge.getScreenDevices.iterator
config <- device.getConfigurations.iterator
bounds = config.getBounds
} yield bounds).find(_.contains(screen_point)) getOrElse ge.getMaximumWindowBounds
sealedcaseclass Screen_Size(bounds: Rectangle, insets: Insets) { def full_screen_bounds: Rectangle = if (Platform.is_linux) {
// avoid menu bar and docking areas new Rectangle(
bounds.x + insets.left,
bounds.y + insets.top,
bounds.width - insets.left - insets.right,
bounds.height - insets.top - insets.bottom)
} elseif (Platform.is_macos) {
// avoid menu bar, but ignore docking areas new Rectangle(
bounds.x,
bounds.y + insets.top,
bounds.width,
bounds.height - insets.top)
} else bounds
}
def screen_size(component: Component): Screen_Size = { val config = component.getGraphicsConfiguration val bounds = config.getBounds val insets = Toolkit.getDefaultToolkit.getScreenInsets(config)
Screen_Size(bounds, insets)
}
/* component hierachy */
def get_parent(component: Component): Option[Container] =
component.getParent match { casenull => None case parent => Some(parent)
}
def ancestors(component: Component): Iterator[Container] = new Iterator[Container] { privatevar next_elem = get_parent(component) def hasNext: Boolean = next_elem.isDefined def next(): Container =
next_elem match { case Some(parent) =>
next_elem = get_parent(parent)
parent case None => Iterator.empty.next()
}
}
def parent_window(component: Component): Option[Window] =
ancestors(component).collectFirst({ case c: Window => c })
def layered_pane(component: Component): Option[JLayeredPane] =
parent_window(component) match { case Some(c: RootPaneContainer) => Some(c.getLayeredPane) case _ => None
}
def traverse_components(component: Component, apply: Component => Unit): Unit = { def traverse(comp: Component): Unit = {
apply(comp)
comp match { case cont: Container => for (i <- 0 until cont.getComponentCount)
traverse(cont.getComponent(i)) case _ =>
}
}
traverse(component)
}
/* font operations */
def copy_font(font: Font): Font = if (font == null) null elsenew Font(font.getFamily, font.getStyle, font.getSize)
def line_metrics(font: Font): LineMetrics =
font.getLineMetrics("", new FontRenderContext(null, false, false))
def transform_font(font: Font, transform: AffineTransform): Font =
font.deriveFont(JMap.of(TextAttribute.TRANSFORM, new TransformAttribute(transform)))
def font(family: String = Isabelle_Fonts.sans, size: Int = 1, bold: Boolean = false): Font = new Font(family, if (bold) Font.BOLD else Font.PLAIN, size)
def label_font(): Font = (new JLabel).getFont
/* Isabelle fonts */
def imitate_font(
font: Font,
family: String = Isabelle_Fonts.sans,
scale: Double = 1.0
): Font = { val font1 = new Font(family, font.getStyle, font.getSize) val rel_size = line_metrics(font).getHeight.toDouble / line_metrics(font1).getHeight new Font(family, font.getStyle, (scale * rel_size * font.getSize).toInt)
}
def use_isabelle_fonts(): Unit = { val default_font = label_font() val ui = UIManager.getDefaults for (prop <-
List( "ToggleButton.font", "CheckBoxMenuItem.font", "Label.font", "Menu.font", "MenuItem.font", "PopupMenu.font", "Table.font", "TableHeader.font", "TextArea.font", "TextField.font", "TextPane.font", "ToolTip.font", "Tree.font")) { val font = ui.get(prop) match { case font: Font => font case _ => default_font }
ui.put(prop, GUI.imitate_font(font))
}
}
}
class FlatLightLaf extends GUI.Look_And_Feel(new flatlaf.FlatLightLaf) class FlatDarkLaf extends GUI.Look_And_Feel(new flatlaf.FlatDarkLaf) class FlatMacLightLaf extends GUI.Look_And_Feel(new flatlaf.themes.FlatMacLightLaf) class FlatMacDarkLaf extends GUI.Look_And_Feel(new flatlaf.themes.FlatMacDarkLaf)
¤ Dauer der Verarbeitung: 0.19 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.