graphics/GraphicCommons.py
changeset 634 cc3335911c01
parent 633 3536f4469cde
child 645 41782a92c2de
--- a/graphics/GraphicCommons.py	Mon Jan 30 16:12:19 2012 +0100
+++ b/graphics/GraphicCommons.py	Tue Jan 31 13:38:06 2012 +0100
@@ -333,8 +333,8 @@
     
     def AddDataConsumer(self, iec_path, consumer):
         if self.DataProducer is None:
-            return False
-        result = self.DataProducer.SubscribeDebugIECVariable(iec_path, consumer) is not None
+            return None
+        result = self.DataProducer.SubscribeDebugIECVariable(iec_path, consumer)
         if result is not None and consumer != self:
             self.DataConsumers[consumer] = iec_path
             consumer.SetDataType(self.GetDataType(iec_path))
@@ -1920,6 +1920,8 @@
             rect = rect.Union(self.StartConnected.GetRedrawRect(movex, movey))
         if self.EndConnected:
             rect = rect.Union(self.EndConnected.GetRedrawRect(movex, movey))
+        if self.ValueSize is None and isinstance(self.ComputedValue, (StringType, UnicodeType)):
+            self.ValueSize = self.Parent.GetMiniTextExtent(self.ComputedValue)
         if self.ValueSize is not None:
             width, height = self.ValueSize
             if self.BoundingBox[2] > width * 4 or self.BoundingBox[3] > height * 4:
@@ -2063,7 +2065,7 @@
             if self.EndConnected:
                 self.EndConnected.RefreshForced()
             if self.Visible:
-                self.Parent.UpdateRefreshRect(self.GetRedrawRect())
+                self.Parent.ElementNeedRefresh(self)
 
     def SetValue(self, value):
         if self.Value != value:
@@ -2077,16 +2079,13 @@
                     self.ToolTip.SetTip(self.ComputedValue)
                 if len(self.ComputedValue) > 4:
                     self.ComputedValue = self.ComputedValue[:4] + "..."
-            if isinstance(self.ComputedValue, (StringType, UnicodeType)):
-                self.ValueSize = self.Parent.GetMiniTextExtent(self.ComputedValue)
-            else:
-                self.ValueSize = None
+            self.ValueSize = None
             if self.StartConnected:
                 self.StartConnected.RefreshValue()
             if self.EndConnected:
                 self.EndConnected.RefreshValue()
             if self.Visible:
-                self.Parent.UpdateRefreshRect(self.GetRedrawRect())
+                self.Parent.ElementNeedRefresh(self)
             if isinstance(value, BooleanType) and self.StartConnected is not None:
                 block = self.StartConnected.GetParentBlock()
                 block.SpreadCurrent()
@@ -3001,6 +3000,8 @@
         if self.Value is not None and not isinstance(self.Value, BooleanType) and self.Value != "undefined":
             dc.SetFont(self.Parent.GetMiniFont())
             dc.SetTextForeground(wx.NamedColour("purple"))
+            if self.ValueSize is None and isinstance(self.ComputedValue, (StringType, UnicodeType)):
+                self.ValueSize = self.Parent.GetMiniTextExtent(self.ComputedValue)
             if self.ValueSize is not None:
                 width, height = self.ValueSize
                 if self.BoundingBox[2] > width * 4 or self.BoundingBox[3] > height * 4: