--- a/graphics/GraphicCommons.py Tue Jan 17 18:46:06 2012 +0100
+++ b/graphics/GraphicCommons.py Tue Jan 17 20:04:52 2012 +0100
@@ -508,6 +508,21 @@
Class that implements a custom tool tip
"""
+if wx.Platform == '__WXMSW__':
+ faces = { 'times': 'Times New Roman',
+ 'mono' : 'Courier New',
+ 'helv' : 'Arial',
+ 'other': 'Comic Sans MS',
+ 'size' : 10,
+ }
+else:
+ faces = { 'times': 'Times',
+ 'mono' : 'Courier',
+ 'helv' : 'Helvetica',
+ 'other': 'new century schoolbook',
+ 'size' : 12,
+ }
+
class ToolTip(wx.PopupWindow):
def __init__(self, parent, tip):
@@ -528,9 +543,18 @@
self.CurrentPosition = pos
self.SetPosition(pos)
+ def GetTipExtent(self):
+ max_width = 0
+ max_height = 0
+ for line in self.Tip.splitlines():
+ w, h = self.GetTextExtent(line)
+ max_width = max(max_width, w)
+ max_height += h
+ return max_width, max_height
+
def RefreshTip(self):
if self:
- w, h = self.GetTextExtent(self.Tip)
+ w, h = self.GetTipExtent()
self.SetSize(wx.Size(w + 4, h + 4))
self.SetPosition(self.CurrentPosition)
self.Refresh()
@@ -540,10 +564,15 @@
dc.Clear()
dc.SetPen(MiterPen(wx.BLACK))
dc.SetBrush(wx.Brush(wx.Colour(255, 238, 170)))
+ dc.SetFont(wx.Font(faces["size"], wx.SWISS, wx.NORMAL, wx.NORMAL, faceName = faces["mono"]))
dc.BeginDrawing()
- w, h = dc.GetTextExtent(self.Tip)
+ w, h = self.GetTipExtent()
dc.DrawRectangle(0, 0, w + 4, h + 4)
- dc.DrawText(self.Tip, 2, 2)
+ offset = 0
+ for line in self.Tip.splitlines():
+ dc.DrawText(line, 2, offset + 2)
+ w, h = dc.GetTextExtent(line)
+ offset += h
dc.EndDrawing()
event.Skip()