def apply(
view: View,
parent: JComponent,
location: Point,
rendering: JEdit_Rendering,
results: Command.Results,
output: List[XML.Elem]
): Unit = {
GUI_Thread.require {}
stack match { case top :: _ if top.results == results && top.output == output => case _ =>
GUI.layered_pane(parent) match { case None => case Some(layered) => val (old, rest) =
GUI.ancestors(parent).collectFirst({ case x: Pretty_Tooltip => x }) match { case Some(pretty_tooltip) => hierarchy(pretty_tooltip).getOrElse((stack, Nil)) case None => (stack, Nil)
}
old.foreach(_.hide_popup())
val loc = SwingUtilities.convertPoint(parent, location, layered) val pretty_tooltip = new Pretty_Tooltip(view, layered, parent, loc, rendering, results, output)
stack = pretty_tooltip :: rest
pretty_tooltip.show_popup()
}
}
}
/* pending event and active state */ // owned by GUI thread
def dismiss_unfocused(): Unit = {
stack.span(pretty_tooltip => !pretty_tooltip.pretty_text_area.isFocusOwner) match { case (Nil, _) => case (unfocused, rest) =>
deactivate()
unfocused.foreach(_.hide_popup())
stack = rest
}
}
def dismiss(pretty_tooltip: Pretty_Tooltip): Unit = {
deactivate()
hierarchy(pretty_tooltip) match { case Some((old, _ :: rest)) =>
rest match { case top :: _ => top.request_focus() case Nil => JEdit_Lib.request_focus_view()
}
old.foreach(_.hide_popup())
pretty_tooltip.hide_popup()
stack = rest case _ =>
}
}
def dismiss_descendant(parent: JComponent): Unit =
descendant(parent).foreach(dismiss)
def tip_border(has_focus: Boolean): Unit = { val color = if (has_focus) GUI.default_foreground_color() else GUI.default_intermediate_color()
pretty_tooltip.setBorder(new LineBorder(color))
pretty_tooltip.repaint()
}
tip_border(true)
privateval popup: Popup = { val screen = GUI.screen_location(layered, location) val size = { val bounds = JEdit_Rendering.popup_bounds
val w_max = layered.getWidth min (screen.bounds.width * bounds).toInt val h_max = layered.getHeight min (screen.bounds.height * bounds).toInt
val painter = pretty_text_area.getPainter val geometry = JEdit_Lib.window_geometry(pretty_tooltip, painter) val metric = JEdit_Lib.font_metric(painter) val margin =
Rich_Text.make_margin(metric, rendering.tooltip_margin,
limit = ((w_max - geometry.deco_width) / metric.average_width).toInt)
val formatted = Rich_Text.format(output, margin, metric, cache = PIDE.session.cache) val lines = Rich_Text.formatted_lines(formatted)
val h = painter.getLineHeight * lines + geometry.deco_height val margin1 = if (h <= h_max) Rich_Text.formatted_margin(metric, formatted) else margin.toDouble val w = (metric.unit * (margin1 + 1)).round.toInt + geometry.deco_width
new Dimension(w min w_max, h min h_max)
} new Popup(layered, pretty_tooltip, screen.relative(layered, size), size)
}
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 und die Messung sind noch experimentell.