GraphicViewer.py
changeset 586 9aa96a36cf33
parent 504 f88e0ebd8fe4
child 632 3ea55a5db68e
--- a/GraphicViewer.py	Mon Nov 07 10:55:17 2011 +0100
+++ b/GraphicViewer.py	Tue Nov 08 21:59:22 2011 +0100
@@ -25,7 +25,7 @@
 import wx
 import wx.lib.plot as plot
 from graphics.GraphicCommons import DebugViewer
-
+from controls import EditorPanel
 
 colours = ['blue', 'red', 'green', 'yellow', 'orange', 'purple', 'brown', 'cyan',
            'pink', 'grey']
@@ -45,7 +45,7 @@
  ID_GRAPHICVIEWERSTATICTEXT1, ID_GRAPHICVIEWERSTATICTEXT2,
 ] = [wx.NewId() for _init_ctrls in range(8)]
 
-class GraphicViewer(wx.Panel, DebugViewer):
+class GraphicViewer(EditorPanel, DebugViewer):
 
     def _init_coll_MainGridSizer_Items(self, parent):
         # generated method, don't edit
@@ -81,14 +81,14 @@
         self._init_coll_RangeSizer_Items(self.RangeSizer)
         self._init_coll_RangeSizer_Growables(self.RangeSizer)
         
-        self.SetSizer(self.MainGridSizer)
-    
-    def _init_ctrls(self, prnt):
-        wx.Panel.__init__(self, prnt, ID_GRAPHICVIEWER, wx.DefaultPosition, 
+        self.Editor.SetSizer(self.MainGridSizer)
+    
+    def _init_Editor(self, prnt):
+        self.Editor = wx.Panel(prnt, ID_GRAPHICVIEWER, wx.DefaultPosition, 
                  wx.DefaultSize, 0)
         
         self.Canvas = plot.PlotCanvas(id=ID_GRAPHICVIEWERCANVAS, 
-              name='Canvas', parent=self, pos=wx.Point(0, 0),
+              name='Canvas', parent=self.Editor, pos=wx.Point(0, 0),
               size=wx.Size(0, 0), style=0)
         def _axisInterval(spec, lower, upper):
             if spec == 'border':
@@ -103,22 +103,22 @@
         self.Canvas.SetYSpec('border')
 
         self.staticbox1 = wx.StaticText(id=ID_GRAPHICVIEWERSTATICTEXT1,
-              label=_('Range:'), name='staticText1', parent=self,
+              label=_('Range:'), name='staticText1', parent=self.Editor,
               pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
         
         self.CanvasRange = wx.ComboBox(id=ID_GRAPHICVIEWERCANVASRANGE,
-              name='CanvasRange', parent=self, pos=wx.Point(0, 0),
+              name='CanvasRange', parent=self.Editor, pos=wx.Point(0, 0),
               size=wx.Size(100, 28), choices=RANGE_VALUES, style=0)
         self.CanvasRange.SetStringSelection("25")
         self.Bind(wx.EVT_COMBOBOX, self.OnRangeChanged, id=ID_GRAPHICVIEWERCANVASRANGE)
         self.Bind(wx.EVT_TEXT_ENTER, self.OnRangeChanged, id=ID_GRAPHICVIEWERCANVASRANGE)
         
         self.staticText2 = wx.StaticText(id=ID_GRAPHICVIEWERSTATICTEXT2,
-              label=_('Position:'), name='staticText2', parent=self,
+              label=_('Position:'), name='staticText2', parent=self.Editor,
               pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
 
         self.CanvasPosition = wx.ScrollBar(id=ID_GRAPHICVIEWERCANVASPOSITION,
-              name='Position', parent=self, pos=wx.Point(0, 0),
+              name='Position', parent=self.Editor, pos=wx.Point(0, 0),
               size=wx.Size(0, 16), style=wx.SB_HORIZONTAL)
         self.CanvasPosition.SetScrollbar(0, 10, 100, 10)
         self.CanvasPosition.Bind(wx.EVT_SCROLL_THUMBTRACK, self.OnPositionChanging, 
@@ -133,22 +133,21 @@
               id = ID_GRAPHICVIEWERCANVASPOSITION)
         
         self.ResetButton = wx.Button(id=ID_GRAPHICVIEWERRESETBUTTON, label='Reset',
-              name='ResetButton', parent=self, pos=wx.Point(0, 0),
+              name='ResetButton', parent=self.Editor, pos=wx.Point(0, 0),
               size=wx.Size(72, 24), style=0)
         self.Bind(wx.EVT_BUTTON, self.OnResetButton, id=ID_GRAPHICVIEWERRESETBUTTON)
         
         self.CurrentButton = wx.Button(id=ID_GRAPHICVIEWERCURRENTBUTTON, label='Current',
-              name='CurrentButton', parent=self, pos=wx.Point(0, 0),
+              name='CurrentButton', parent=self.Editor, pos=wx.Point(0, 0),
               size=wx.Size(72, 24), style=0)
         self.Bind(wx.EVT_BUTTON, self.OnCurrentButton, id=ID_GRAPHICVIEWERCURRENTBUTTON)
         
         self._init_sizers()
 
     def __init__(self, parent, window, producer, instancepath = ""):
-        self._init_ctrls(parent)
+        EditorPanel.__init__(self, parent, "", window, None)
         DebugViewer.__init__(self, producer, True, False)
         
-        self.ParentWindow = window
         self.InstancePath = instancepath
 
         self.Datas = []
@@ -161,6 +160,11 @@
         DebugViewer.__del__(self)
         self.RemoveDataConsumer(self)
     
+    def GetTitle(self):
+        if len(self.InstancePath) > 15:
+            return "..." + self.InstancePath[-12:]
+        return self.InstancePath
+    
     def ResetView(self):
         self.Datas = []
         self.CurrentValue = 0
@@ -192,30 +196,12 @@
         self.RefreshScrollBar()
         self.Thaw()
     
-    def SetMode(self, mode):
-        pass
-    
-    def GetTagName(self):
-        return ""
-    
     def GetInstancePath(self):
         return self.InstancePath
     
     def IsViewing(self, tagname):
         return self.InstancePath == tagname
     
-    def ResetBuffer(self):
-        pass
-    
-    def RefreshScaling(self, refresh=True):
-        pass
-    
-    def SelectAll(self):
-        pass
-    
-    def ClearErrors(self):
-        pass
-    
     def NewValue(self, tick, value, forced=False):
         self.Datas.append((float(tick), {True:1., False:0.}.get(value, float(value))))
         if self.CurrentValue + self.CurrentRange == len(self.Datas) - 1: