--- a/GraphicViewer.py Tue Mar 24 17:31:11 2009 +0100
+++ b/GraphicViewer.py Tue Mar 24 17:31:42 2009 +0100
@@ -156,6 +156,14 @@
self.Controler.SubscribeDebugIECVariable(self.InstancePath.upper(), self)
+ def __del__(self):
+ self.Controler.UnsubscribeDebugIECVariable(self.InstancePath.upper(), self)
+
+ def ResetView(self):
+ self.Datas = []
+ self.CurrentValue = 0
+ self.RefreshView()
+
def RefreshView(self):
var_name = self.InstancePath.split(".")[-1]
@@ -225,9 +233,7 @@
event.Skip()
def OnResetButton(self, event):
- self.Datas = []
- self.CurrentValue = 0
- self.RefreshView()
+ self.ResetView()
event.Skip()
def OnCurrentButton(self, event):
--- a/Viewer.py Tue Mar 24 17:31:11 2009 +0100
+++ b/Viewer.py Tue Mar 24 17:31:42 2009 +0100
@@ -1539,9 +1539,16 @@
if not event.Dragging():
highlighted = self.FindElement(pos)
if self.HighlightedElement is not None and self.HighlightedElement != highlighted:
+ if isinstance(self.HighlightedElement, Wire):
+ self.HighlightedElement.ClearToolTip()
self.HighlightedElement.SetHighlighted(False)
self.HighlightedElement = None
if highlighted is not None and self.HighlightedElement != highlighted:
+ if isinstance(highlighted, Wire):
+ pos = self.ClientToScreen(event.GetPosition())
+ pos.x += 10
+ pos.y += 10
+ highlighted.CreateToolTip(pos)
highlighted.SetHighlighted(True)
self.HighlightedElement = highlighted
if self.rubberBand.IsShown():
@@ -1566,6 +1573,8 @@
if self.SelectedElement is not None and self.SelectedElement.GetDragging():
event.Skip()
elif self.HighlightedElement is not None:
+ if isinstance(self.HighlightedElement, Wire):
+ self.HighlightedElement.ClearToolTip()
self.HighlightedElement.SetHighlighted(False)
self.HighlightedElement = None
event.Skip()
--- a/graphics/GraphicCommons.py Tue Mar 24 17:31:11 2009 +0100
+++ b/graphics/GraphicCommons.py Tue Mar 24 17:31:42 2009 +0100
@@ -293,6 +293,42 @@
self.currentBox.height)
#-------------------------------------------------------------------------------
+# Viewer Rubberband
+#-------------------------------------------------------------------------------
+
+"""
+Class that implements a custom tool tip
+"""
+
+class ToolTip(wx.PopupWindow):
+
+ # Create a rubberband by indicated on which window it must be drawn
+ def __init__(self, parent, tip):
+ wx.PopupWindow.__init__(self, parent)
+ self.SetTip(tip)
+
+ self.Bind(wx.EVT_PAINT, self.OnPaint)
+
+ def SetTip(self, tip):
+ self.Tip = tip
+ dc = wx.ClientDC(self)
+ w, h = dc.GetTextExtent(tip)
+ self.SetSize(wx.Size(w + 4, h + 4))
+ self.Refresh()
+
+ def OnPaint(self, event):
+ dc = wx.AutoBufferedPaintDC(self)
+ dc.Clear()
+ dc.SetPen(wx.BLACK_PEN)
+ dc.SetBrush(wx.Brush(wx.Colour(255, 238, 170)))
+ dc.BeginDrawing()
+ w, h = dc.GetTextExtent(self.Tip)
+ dc.DrawRectangle(0, 0, w + 4, h + 4)
+ dc.DrawText(self.Tip, 2, 2)
+ dc.EndDrawing()
+ event.Skip()
+
+#-------------------------------------------------------------------------------
# Helper for highlighting error in drawn text
#-------------------------------------------------------------------------------
@@ -1385,12 +1421,28 @@
self.OverStart = False
self.OverEnd = False
self.ComputingType = False
+ self.ToolTip = None
self.Font = parent.GetMiniFont()
def Flush(self):
self.StartConnected = None
self.EndConnected = None
+ def CreateToolTip(self, pos):
+ if self.Value is not None and self.Value != "undefined" and not isinstance(self.Value, BooleanType):
+ if isinstance(self.Value, StringType):
+ self.ComputedValue = "\"%s\""%self.Value
+ else:
+ self.ComputedValue = str(self.Value)
+ self.ToolTip = ToolTip(self.Parent, self.ComputedValue)
+ self.ToolTip.SetPosition(pos)
+ self.ToolTip.Show()
+
+ def ClearToolTip(self):
+ if self.ToolTip is not None:
+ self.ToolTip.Destroy()
+ self.ToolTip = None
+
# Returns the RedrawRect
def GetRedrawRect(self, movex = 0, movey = 0):
rect = Graphic_Element.GetRedrawRect(self, movex, movey)
@@ -1532,15 +1584,17 @@
return False
def SetValue(self, value):
- if self.Value != value:
+ if self.Value != value and self.Parent:
self.Value = value
if value is not None and not isinstance(value, BooleanType):
if isinstance(value, StringType):
self.ComputedValue = "\"%s\""%value
else:
self.ComputedValue = str(value)
+ if self.ToolTip is not None:
+ self.ToolTip.SetTip(self.ComputedValue)
if len(self.ComputedValue) > 4:
- self.ComputedValue = self.ComputedValue[:4] + "..."
+ self.ComputedValue = self.ComputedValue[:4] + "..."
if isinstance(self.ComputedValue, StringType):
dc = wx.ClientDC(self.Parent)
dc.SetFont(self.Font)