equal
deleted
inserted
replaced
9 |
9 |
10 import isabelle._ |
10 import isabelle._ |
11 |
11 |
12 import java.awt.{Color, Point, BorderLayout, Dimension} |
12 import java.awt.{Color, Point, BorderLayout, Dimension} |
13 import java.awt.event.{FocusAdapter, FocusEvent} |
13 import java.awt.event.{FocusAdapter, FocusEvent} |
14 import javax.swing.{SwingUtilities, JWindow, JPanel, JComponent, PopupFactory} |
14 import javax.swing.{JWindow, JPanel, JComponent, PopupFactory} |
15 import javax.swing.border.LineBorder |
15 import javax.swing.border.LineBorder |
16 |
16 |
17 import scala.swing.{FlowPanel, Label} |
17 import scala.swing.{FlowPanel, Label} |
18 import scala.swing.event.MouseClicked |
18 import scala.swing.event.MouseClicked |
19 |
19 |
38 |
38 |
39 def apply( |
39 def apply( |
40 view: View, |
40 view: View, |
41 parent: JComponent, |
41 parent: JComponent, |
42 rendering: Rendering, |
42 rendering: Rendering, |
43 mouse_x: Int, mouse_y: Int, |
43 screen_point: Point, |
44 results: Command.Results, |
44 results: Command.Results, |
45 body: XML.Body): Pretty_Tooltip = |
45 body: XML.Body): Pretty_Tooltip = |
46 { |
46 { |
47 Swing_Thread.require() |
47 Swing_Thread.require() |
48 |
48 |
51 case Some(tip) => hierarchy(tip).getOrElse((stack, Nil)) |
51 case Some(tip) => hierarchy(tip).getOrElse((stack, Nil)) |
52 case None => (stack, Nil) |
52 case None => (stack, Nil) |
53 } |
53 } |
54 old.foreach(_.hide_popup) |
54 old.foreach(_.hide_popup) |
55 |
55 |
56 val tip = new Pretty_Tooltip(view, rendering, parent, mouse_x, mouse_y, results, body) |
56 val tip = new Pretty_Tooltip(view, rendering, parent, screen_point, results, body) |
57 stack = tip :: rest |
57 stack = tip :: rest |
58 tip |
58 tip |
59 } |
59 } |
60 |
60 |
61 |
61 |
124 |
124 |
125 class Pretty_Tooltip private( |
125 class Pretty_Tooltip private( |
126 view: View, |
126 view: View, |
127 rendering: Rendering, |
127 rendering: Rendering, |
128 parent: JComponent, |
128 parent: JComponent, |
129 mouse_x: Int, mouse_y: Int, |
129 screen_point: Point, |
130 results: Command.Results, |
130 results: Command.Results, |
131 body: XML.Body) extends JPanel(new BorderLayout) |
131 body: XML.Body) extends JPanel(new BorderLayout) |
132 { |
132 { |
133 tip => |
133 tip => |
134 |
134 |
192 |
192 |
193 /* popup */ |
193 /* popup */ |
194 |
194 |
195 private val popup = |
195 private val popup = |
196 { |
196 { |
197 val screen_point = new Point(mouse_x, mouse_y) |
|
198 SwingUtilities.convertPointToScreen(screen_point, parent) |
|
199 val screen_bounds = JEdit_Lib.screen_bounds(screen_point) |
197 val screen_bounds = JEdit_Lib.screen_bounds(screen_point) |
200 |
198 |
201 val painter = pretty_text_area.getPainter |
199 val painter = pretty_text_area.getPainter |
202 val metric = JEdit_Lib.pretty_metric(painter) |
200 val metric = JEdit_Lib.pretty_metric(painter) |
203 val margin = rendering.tooltip_margin * metric.average |
201 val margin = rendering.tooltip_margin * metric.average |