SFCViewer.py
changeset 27 dae55dd9ee14
parent 9 b29105e29081
child 28 fc23e1f415d8
--- a/SFCViewer.py	Sat Jul 07 11:35:17 2007 +0200
+++ b/SFCViewer.py	Mon Jul 09 11:10:14 2007 +0200
@@ -23,7 +23,6 @@
 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 from wxPython.wx import *
-from wxPython.grid import *
 import wx
 from types import *
 
@@ -31,6 +30,7 @@
 from graphics.GraphicCommons import *
 from graphics.SFC_Objects import *
 from Viewer import *
+from Dialogs import *
 
 class SFC_Viewer(Viewer):
     
@@ -178,8 +178,11 @@
 #-------------------------------------------------------------------------------
 
     def OnViewerLeftDown(self, event):
-        if self.Mode == MODE_SELECTION:
-            pos = event.GetPosition()
+        if self.GetDrawingMode() == FREEDRAWING_MODE:
+            Viewer.OnViewerLeftDown(self, event)
+        elif self.Mode == MODE_SELECTION:
+            dc = self.GetLogicalDC()
+            pos = event.GetLogicalPosition(dc)
             if event.ControlDown():
                 element = self.FindElement(pos, True)
                 if element and element not in self.Wires:
@@ -207,16 +210,16 @@
                     self.Refresh()
                 if element:
                     self.SelectedElement = element
-                    self.SelectedElement.OnLeftDown(event, self.Scaling)
+                    self.SelectedElement.OnLeftDown(event, dc, self.Scaling)
                     self.Refresh()
                 else:
                     self.rubberBand.Reset()
-                    self.rubberBand.OnLeftDown(event, self.Scaling)
+                    self.rubberBand.OnLeftDown(event, dc, self.Scaling)
         elif self.Mode == MODE_COMMENT:
             self.rubberBand.Reset()
-            self.rubberBand.OnLeftDown(event, self.Scaling)
+            self.rubberBand.OnLeftDown(event, self.GetLogicalDC(), self.Scaling)
         elif self.Mode == MODE_WIRE:
-            pos = GetScaledEventPosition(event, self.Scaling)
+            pos = GetScaledEventPosition(event, self.GetLogicalDC(), self.Scaling)
             wire = Wire(self, [wxPoint(pos.x, pos.y), SOUTH], [wxPoint(pos.x, pos.y), NORTH])
             wire.oldPos = pos
             wire.Handle = (HANDLE_POINT, 0)
@@ -231,10 +234,12 @@
         event.Skip()
 
     def OnViewerLeftUp(self, event):
-        if self.rubberBand.IsShown():
+        if self.GetDrawingMode() == FREEDRAWING_MODE:
+            Viewer.OnViewerLeftUp(self, event)
+        elif self.rubberBand.IsShown():
             if self.Mode == MODE_SELECTION:
                 elements = self.SearchElements(self.rubberBand.GetCurrentExtent())
-                self.rubberBand.OnLeftUp(event, self.Scaling)
+                self.rubberBand.OnLeftUp(event, self.GetLogicalDC(), self.Scaling)
                 if len(elements) > 0:
                     self.SelectedElement = Graphic_Group(self)
                     self.SelectedElement.SetElements(elements)
@@ -242,21 +247,21 @@
                     self.Refresh()
             elif self.Mode == MODE_COMMENT:
                 bbox = self.rubberBand.GetCurrentExtent()
-                self.rubberBand.OnLeftUp(event, self.Scaling)
+                self.rubberBand.OnLeftUp(event, self.GetLogicalDC(), self.Scaling)
                 wxCallAfter(self.AddComment, bbox)
-        elif self.Mode == MODE_INITIAL_STEP:
-            wxCallAfter(self.AddInitialStep, GetScaledEventPosition(event, self.Scaling))
+        elif self.Mode == MODE_INITIALSTEP:
+            wxCallAfter(self.AddInitialStep, GetScaledEventPosition(event, self.GetLogicalDC(), self.Scaling))
         elif self.Mode == MODE_SELECTION and self.SelectedElement:
             if self.SelectedElement in self.Wires:
                 self.SelectedElement.SetSelectedSegment(0)
             else:
-                self.SelectedElement.OnLeftUp(event, self.Scaling)
+                self.SelectedElement.OnLeftUp(event, self.GetLogicalDC(), self.Scaling)
             wxCallAfter(self.SetCursor, wxNullCursor)
             self.ReleaseMouse()
             self.Refresh()
         elif self.Mode == MODE_WIRE and self.SelectedElement:
             self.SelectedElement.ResetPoints()
-            self.SelectedElement.OnMotion(event, self.Scaling)
+            self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling)
             self.SelectedElement.GeneratePoints()
             self.SelectedElement.RefreshModel()
             self.SelectedElement.SetSelected(True)
@@ -264,40 +269,49 @@
         event.Skip()
     
     def OnViewerRightUp(self, event):
-        pos = event.GetPosition()
-        element = self.FindElement(pos)
-        if element:
-            if self.SelectedElement and self.SelectedElement != element:
-                self.SelectedElement.SetSelected(False)
-            self.SelectedElement = element
-            if self.SelectedElement in self.Wires:
-                self.SelectedElement.SetSelectedSegment(0)
-            else:
-                self.SelectedElement.SetSelected(True)
-                self.SelectedElement.OnRightUp(event, self.Scaling)
-            wxCallAfter(self.SetCursor, wxNullCursor)
-            self.ReleaseMouse()
-            self.Refresh()
+        if self.GetDrawingMode() == FREEDRAWING_MODE:
+            Viewer.OnViewerRightUp(self, event)
+        else:
+            dc = self.GetLogicalDC()
+            pos = event.GetLogicalPosition(dc)
+            element = self.FindElement(pos)
+            if element:
+                if self.SelectedElement and self.SelectedElement != element:
+                    self.SelectedElement.SetSelected(False)
+                self.SelectedElement = element
+                if self.SelectedElement in self.Wires:
+                    self.SelectedElement.SetSelectedSegment(0)
+                else:
+                    self.SelectedElement.SetSelected(True)
+                    self.SelectedElement.OnRightUp(event, dc, self.Scaling)
+                wxCallAfter(self.SetCursor, wxNullCursor)
+                self.ReleaseMouse()
+                self.Refresh()
         event.Skip()
     
     def OnViewerLeftDClick(self, event):
-        if self.Mode == MODE_SELECTION and self.SelectedElement:
-            self.SelectedElement.OnLeftDClick(event, self.Scaling)
+        if self.GetDrawingMode() == FREEDRAWING_MODE:
+            Viewer.OnViewerLeftDClick(self, event)
+        elif self.Mode == MODE_SELECTION and self.SelectedElement:
+            self.SelectedElement.OnLeftDClick(event, self.GetLogicalDC(), self.Scaling)
             self.Refresh()
         event.Skip()
     
     def OnViewerMotion(self, event):
-        if self.rubberBand.IsShown():
-            self.rubberBand.OnMotion(event, self.Scaling)
+        if self.GetDrawingMode() == FREEDRAWING_MODE:
+            Viewer.OnViewerMotion(self, event)
+        elif self.rubberBand.IsShown():
+            self.rubberBand.OnMotion(event, self.GetLogicalDC(), self.Scaling)
         elif self.Mode == MODE_SELECTION and self.SelectedElement:
             if self.SelectedElement not in self.Wires:
-                self.SelectedElement.OnMotion(event, self.Scaling)
+                self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling)
             self.Refresh()
         elif self.Mode == MODE_WIRE and self.SelectedElement:
             self.SelectedElement.ResetPoints()
-            self.SelectedElement.OnMotion(event, self.Scaling)
+            self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling)
             self.SelectedElement.GeneratePoints()
             self.Refresh()
+        Viewer.OnViewerMotion(self, event)
         event.Skip()
 
 #-------------------------------------------------------------------------------
@@ -1017,659 +1031,3 @@
     def DeleteWire(self, wire):
         pass
 
-
-#-------------------------------------------------------------------------------
-#                          Edit Transition Content Dialog
-#-------------------------------------------------------------------------------
-
-[wxID_TRANSITIONCONTENTDIALOG, wxID_TRANSITIONCONTENTDIALOGMAINPANEL, 
- wxID_TRANSITIONCONTENTDIALOGREFERENCE, wxID_TRANSITIONCONTENTDIALOGINLINE, 
- wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, 
-] = [wx.NewId() for _init_ctrls in range(6)]
-
-class TransitionContentDialog(wx.Dialog):
-    def _init_coll_flexGridSizer1_Items(self, parent):
-        # generated method, don't edit
-
-        parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
-
-    def _init_sizers(self):
-        # generated method, don't edit
-        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
-
-        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
-
-        self.SetSizer(self.flexGridSizer1)
-
-    def _init_ctrls(self, prnt):
-        # generated method, don't edit
-        wx.Dialog.__init__(self, id=wxID_TRANSITIONCONTENTDIALOG,
-              name='ProjectDialog', parent=prnt, pos=wx.Point(376, 223),
-              size=wx.Size(300, 200), style=wx.DEFAULT_DIALOG_STYLE,
-              title='Edit transition')
-        self.SetClientSize(wx.Size(300, 200))
-
-        self.MainPanel = wx.Panel(id=wxID_TRANSITIONCONTENTDIALOGMAINPANEL,
-              name='MainPanel', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(300, 200), style=wx.TAB_TRAVERSAL)
-        self.MainPanel.SetAutoLayout(True)
-
-        self.radioButton1 = wx.RadioButton(id=wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON1,
-              label='Reference', name='radioButton1', parent=self.MainPanel,
-              pos=wx.Point(24, 24), size=wx.Size(114, 24), style=0)
-        EVT_RADIOBUTTON(self, wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, self.OnTypeChanged)
-        self.radioButton1.SetValue(True)
-
-        self.Reference = wx.Choice(id=wxID_TRANSITIONCONTENTDIALOGREFERENCE,
-              name='Reference', parent=self.MainPanel, pos=wx.Point(48, 48), 
-              size=wx.Size(200, 24), style=0)
-
-        self.radioButton2 = wx.RadioButton(id=wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON2,
-              label='Inline', name='radioButton2', parent=self.MainPanel,
-              pos=wx.Point(24, 72), size=wx.Size(114, 24), style=0)
-        EVT_RADIOBUTTON(self, wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, self.OnTypeChanged)
-        self.radioButton2.SetValue(False)
-
-        self.Inline = wx.TextCtrl(id=wxID_TRANSITIONCONTENTDIALOGINLINE,
-              name='Inline', parent=self.MainPanel, pos=wx.Point(48, 96),
-              size=wx.Size(200, 24), style=0)
-
-        self._init_sizers()
-
-    def __init__(self, parent):
-        self._init_ctrls(parent)
-        self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
-        self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT)
-        
-        EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK)
-    
-    def OnOK(self, event):
-        error = []
-        if self.radioButton1.GetValue() and self.Reference.GetStringSelection() == "":
-            error.append("Reference")
-        if self.radioButton2.GetValue() and self.Inline.GetValue() == "":
-            error.append("Inline")
-        if len(error) > 0:
-            text = ""
-            for i, item in enumerate(error):
-                if i == 0:
-                    text += item
-                elif i == len(error) - 1:
-                    text += " and %s"%item
-                else:
-                    text += ", %s"%item 
-            message = wxMessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wxOK|wxICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        else:
-            self.EndModal(wxID_OK)
-
-    def OnTypeChanged(self, event):
-        if self.radioButton1.GetValue():
-            self.Reference.Enable(True)
-            self.Inline.Enable(False)
-        else:
-            self.Reference.Enable(False)
-            self.Inline.Enable(True)
-        event.Skip()
-
-    def SetTransitions(self, transitions):
-        for transition in transitions:
-            self.Reference.Append(transition)
-
-    def SetValues(self, values):
-        if values["type"] == "reference":
-            self.radioButton1.SetValue(True)
-            self.radioButton2.SetValue(False)
-            self.Reference.Enable(True)
-            self.Inline.Enable(False)
-            self.Reference.SetStringSelection(values["value"])
-        elif values["type"] == "inline":
-            self.radioButton1.SetValue(False)
-            self.radioButton2.SetValue(True)
-            self.Reference.Enable(False)
-            self.Inline.Enable(True)
-            self.Inline.SetValue(values["value"])
-                
-    def GetValues(self):
-        values = {}
-        if self.radioButton1.GetValue():
-            values["type"] = "reference"
-            values["value"] = self.Reference.GetStringSelection()
-        else:
-            values["type"] = "inline"
-            values["value"] = self.Inline.GetValue()
-        return values
-
-#-------------------------------------------------------------------------------
-#                         Create New Divergence Dialog
-#-------------------------------------------------------------------------------
-
-[wxID_DIVERGENCECREATEDIALOG, wxID_DIVERGENCECREATEDIALOGMAINPANEL, 
- wxID_DIVERGENCECREATEDIALOGRADIOBUTTON1, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON2,
- wxID_DIVERGENCECREATEDIALOGRADIOBUTTON3, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON4, 
- wxID_DIVERGENCECREATEDIALOGSEQUENCES, wxID_DIVERGENCECREATEDIALOGPREVIEW, 
- wxID_DIVERGENCECREATEDIALOGSTATICTEXT1, wxID_DIVERGENCECREATEDIALOGSTATICTEXT2, 
- wxID_DIVERGENCECREATEDIALOGSTATICTEXT3,  
-] = [wx.NewId() for _init_ctrls in range(11)]
-
-class DivergenceCreateDialog(wx.Dialog):
-    def _init_coll_flexGridSizer1_Items(self, parent):
-        # generated method, don't edit
-
-        parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
-
-    def _init_sizers(self):
-        # generated method, don't edit
-        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
-
-        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
-
-        self.SetSizer(self.flexGridSizer1)
-
-    def _init_ctrls(self, prnt):
-        # generated method, don't edit
-        wx.Dialog.__init__(self, id=wxID_DIVERGENCECREATEDIALOG,
-              name='DivergencePropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
-              size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE,
-              title='Create a new divergence or convergence')
-        self.SetClientSize(wx.Size(500, 260))
-
-        self.MainPanel = wx.Panel(id=wxID_DIVERGENCECREATEDIALOGMAINPANEL,
-              name='MainPanel', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(600, 220), style=wx.TAB_TRAVERSAL)
-        self.MainPanel.SetAutoLayout(True)
-
-        self.staticText1 = wx.StaticText(id=wxID_DIVERGENCECREATEDIALOGSTATICTEXT1,
-              label='Type:', name='staticText1', parent=self.MainPanel,
-              pos=wx.Point(24, 24), size=wx.Size(200, 17), style=0)
-
-        self.radioButton1 = wx.RadioButton(id=wxID_DIVERGENCECREATEDIALOGRADIOBUTTON1,
-              label='Selection Divergence', name='radioButton1', parent=self.MainPanel,
-              pos=wx.Point(24, 48), size=wx.Size(200, 24), style=0)
-        EVT_RADIOBUTTON(self, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON1, self.OnTypeChanged)
-        self.radioButton1.SetValue(True)
-
-        self.radioButton2 = wx.RadioButton(id=wxID_DIVERGENCECREATEDIALOGRADIOBUTTON2,
-              label='Selection Convergence', name='radioButton2', parent=self.MainPanel, 
-              pos=wx.Point(24, 72), size=wx.Size(200, 24), style=0)
-        EVT_RADIOBUTTON(self, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON2, self.OnTypeChanged)
-        self.radioButton2.SetValue(False)
-
-        self.radioButton3 = wx.RadioButton(id=wxID_DIVERGENCECREATEDIALOGRADIOBUTTON3,
-              label='Simultaneous Divergence', name='radioButton3', parent=self.MainPanel,
-              pos=wx.Point(24, 96), size=wx.Size(200, 24), style=0)
-        EVT_RADIOBUTTON(self, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON3, self.OnTypeChanged)
-        self.radioButton3.SetValue(False)
-
-        self.radioButton4 = wx.RadioButton(id=wxID_DIVERGENCECREATEDIALOGRADIOBUTTON4,
-              label='Simultaneous Convergence', name='radioButton4', parent=self.MainPanel, 
-              pos=wx.Point(24, 120), size=wx.Size(200, 24), style=0)
-        EVT_RADIOBUTTON(self, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON4, self.OnTypeChanged)
-        self.radioButton4.SetValue(False)
-
-        self.staticText2 = wx.StaticText(id=wxID_DIVERGENCECREATEDIALOGSTATICTEXT2,
-              label='Number of sequences:', name='staticText2', parent=self.MainPanel,
-              pos=wx.Point(24, 150), size=wx.Size(200, 17), style=0)
-
-        self.Sequences = wx.SpinCtrl(id=wxID_DIVERGENCECREATEDIALOGSEQUENCES,
-              name='Sequences', parent=self.MainPanel, pos=wx.Point(24, 174),
-              size=wx.Size(200, 24), style=0, min=2, max=20)
-        EVT_SPINCTRL(self, wxID_DIVERGENCECREATEDIALOGSEQUENCES, self.OnSequencesChanged)
-
-        self.staticText3 = wx.StaticText(id=wxID_DIVERGENCECREATEDIALOGSTATICTEXT3,
-              label='Preview:', name='staticText3', parent=self.MainPanel,
-              pos=wx.Point(250, 24), size=wx.Size(100, 17), style=0)
-
-        self.Preview = wx.Panel(id=wxID_DIVERGENCECREATEDIALOGPREVIEW,
-              name='Preview', parent=self.MainPanel, pos=wx.Point(250, 48),
-              size=wx.Size(225, 150), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
-        self.Preview.SetBackgroundColour(wxColour(255,255,255))
-
-        self._init_sizers()
-
-    def __init__(self, parent):
-        self._init_ctrls(parent)
-        self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
-        self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT)
-        
-        self.Divergence = None
-        
-        EVT_PAINT(self, self.OnPaint)
-
-    def GetValues(self):
-        values = {}
-        if self.radioButton1.GetValue():
-            values["type"] = SELECTION_DIVERGENCE
-        elif self.radioButton2.GetValue():
-            values["type"] = SELECTION_CONVERGENCE
-        elif self.radioButton3.GetValue():
-            values["type"] = SIMULTANEOUS_DIVERGENCE
-        else:
-            values["type"] = SIMULTANEOUS_CONVERGENCE
-        values["number"] = self.Sequences.GetValue()
-        return values
-
-    def OnTypeChanged(self, event):
-        self.RefreshPreview()
-        event.Skip()
-
-    def OnSequencesChanged(self, event):
-        self.RefreshPreview()
-        event.Skip()
-        
-    def RefreshPreview(self):
-        dc = wxClientDC(self.Preview)
-        dc.Clear()
-        if self.radioButton1.GetValue():
-            self.Divergence = SFC_Divergence(self.Preview, SELECTION_DIVERGENCE, self.Sequences.GetValue())
-        elif self.radioButton2.GetValue():
-            self.Divergence = SFC_Divergence(self.Preview, SELECTION_CONVERGENCE, self.Sequences.GetValue())
-        elif self.radioButton3.GetValue():
-            self.Divergence = SFC_Divergence(self.Preview, SIMULTANEOUS_DIVERGENCE, self.Sequences.GetValue())
-        else:
-            self.Divergence = SFC_Divergence(self.Preview, SIMULTANEOUS_CONVERGENCE, self.Sequences.GetValue())
-        width, height = self.Divergence.GetSize()
-        clientsize = self.Preview.GetClientSize()
-        x = (clientsize.width - width) / 2
-        y = (clientsize.height - height) / 2
-        self.Divergence.SetPosition(x, y)
-        self.Divergence.Draw(dc)
-
-    def OnPaint(self, event):
-        self.RefreshPreview()
-
-
-#-------------------------------------------------------------------------------
-#                            Action Block Dialog
-#-------------------------------------------------------------------------------
-
-class ActionTable(wxPyGridTableBase):
-    
-    """
-    A custom wxGrid Table using user supplied data
-    """
-    def __init__(self, parent, data, colnames):
-        # The base class must be initialized *first*
-        wxPyGridTableBase.__init__(self)
-        self.data = data
-        self.colnames = colnames
-        self.Parent = parent
-        # XXX
-        # we need to store the row length and collength to
-        # see if the table has changed size
-        self._rows = self.GetNumberRows()
-        self._cols = self.GetNumberCols()
-    
-    def GetNumberCols(self):
-        return len(self.colnames)
-        
-    def GetNumberRows(self):
-        return len(self.data)
-
-    def GetColLabelValue(self, col):
-        if col < len(self.colnames):
-            return self.colnames[col]
-
-    def GetRowLabelValues(self, row):
-        return row
-
-    def GetValue(self, row, col):
-        if row < self.GetNumberRows():
-            name = str(self.data[row].get(self.GetColLabelValue(col), ""))
-            return name
-    
-    def GetValueByName(self, row, colname):
-        return self.data[row].get(colname)
-
-    def SetValue(self, row, col, value):
-        if col < len(self.colnames):
-            self.data[row][self.GetColLabelValue(col)] = value
-        
-    def ResetView(self, grid):
-        """
-        (wxGrid) -> Reset the grid view.   Call this to
-        update the grid if rows and columns have been added or deleted
-        """
-        grid.BeginBatch()
-        for current, new, delmsg, addmsg in [
-            (self._rows, self.GetNumberRows(), wxGRIDTABLE_NOTIFY_ROWS_DELETED, wxGRIDTABLE_NOTIFY_ROWS_APPENDED),
-            (self._cols, self.GetNumberCols(), wxGRIDTABLE_NOTIFY_COLS_DELETED, wxGRIDTABLE_NOTIFY_COLS_APPENDED),
-        ]:
-            if new < current:
-                msg = wxGridTableMessage(self,delmsg,new,current-new)
-                grid.ProcessTableMessage(msg)
-            elif new > current:
-                msg = wxGridTableMessage(self,addmsg,new-current)
-                grid.ProcessTableMessage(msg)
-                self.UpdateValues(grid)
-        grid.EndBatch()
-
-        self._rows = self.GetNumberRows()
-        self._cols = self.GetNumberCols()
-        # update the column rendering scheme
-        self._updateColAttrs(grid)
-
-        # update the scrollbars and the displayed part of the grid
-        grid.AdjustScrollbars()
-        grid.ForceRefresh()
-
-    def UpdateValues(self, grid):
-        """Update all displayed values"""
-        # This sends an event to the grid table to update all of the values
-        msg = wxGridTableMessage(self, wxGRIDTABLE_REQUEST_VIEW_GET_VALUES)
-        grid.ProcessTableMessage(msg)
-
-    def _updateColAttrs(self, grid):
-        """
-        wxGrid -> update the column attributes to add the
-        appropriate renderer given the column name.
-
-        Otherwise default to the default renderer.
-        """
-        
-        for col in range(self.GetNumberCols()):
-            attr = wxGridCellAttr()
-            attr.SetAlignment(self.Parent.ColAlignements[col], wxALIGN_CENTRE)
-            grid.SetColAttr(col, attr)
-            grid.SetColSize(col, self.Parent.ColSizes[col])
-        
-        typelist = None
-        accesslist = None
-        for row in range(self.GetNumberRows()):
-            for col in range(self.GetNumberCols()):
-                editor = None
-                renderer = None
-                readonly = False
-                colname = self.GetColLabelValue(col)
-                if colname == "Qualifier":
-                    editor = wxGridCellChoiceEditor()
-                    editor.SetParameters(self.Parent.QualifierList)
-                if colname == "Duration":
-                    editor = wxGridCellTextEditor()
-                    renderer = wxGridCellStringRenderer()
-                    if self.Parent.DurationList[self.data[row]["Qualifier"]]:
-                        readonly = False
-                    else:
-                        readonly = True
-                        self.data[row]["Duration"] = ""
-                elif colname == "Type":
-                    editor = wxGridCellChoiceEditor()
-                    editor.SetParameters(self.Parent.TypeList)
-                elif colname == "Value":
-                    type = self.data[row]["Type"]
-                    if type == "Action":
-                        editor = wxGridCellChoiceEditor()
-                        editor.SetParameters(self.Parent.ActionList)
-                    elif type == "Variable":
-                        editor = wxGridCellChoiceEditor()
-                        editor.SetParameters(self.Parent.VariableList)
-                    elif type == "Inline":
-                        editor = wxGridCellTextEditor()
-                        renderer = wxGridCellStringRenderer()
-                elif colname == "Indicator":
-                    editor = wxGridCellChoiceEditor()
-                    editor.SetParameters(self.Parent.VariableList)
-                    
-                grid.SetCellEditor(row, col, editor)
-                grid.SetCellRenderer(row, col, renderer)
-                grid.SetReadOnly(row, col, readonly)
-                
-                grid.SetCellBackgroundColour(row, col, wxWHITE)
-    
-    def SetData(self, data):
-        self.data = data
-    
-    def GetData(self):
-        return self.data
-    
-    def GetCurrentIndex(self):
-        return self.CurrentIndex
-    
-    def SetCurrentIndex(self, index):
-        self.CurrentIndex = index
-    
-    def AppendRow(self, row_content):
-        self.data.append(row_content)
-
-    def RemoveRow(self, row_index):
-        self.data.pop(row_index)
-        
-    def MoveRow(self, row_index, move, grid):
-        new_index = max(0, min(row_index + move, len(self.data) - 1))
-        if new_index != row_index:
-            self.data.insert(new_index, self.data.pop(row_index))
-            grid.SetGridCursor(new_index, grid.GetGridCursorCol())
-
-    def Empty(self):
-        self.data = []
-        self.editors = []
-
-[wxID_ACTIONBLOCKDIALOG, wxID_ACTIONBLOCKDIALOGMAINPANEL, 
- wxID_ACTIONBLOCKDIALOGVARIABLESGRID, wxID_ACTIONBLOCKDIALOGSTATICTEXT1, 
- wxID_ACTIONBLOCKDIALOGADDBUTTON,wxID_ACTIONBLOCKDIALOGDELETEBUTTON, 
- wxID_ACTIONBLOCKDIALOGUPBUTTON, wxID_ACTIONBLOCKDIALOGDOWNBUTTON, 
-] = [wx.NewId() for _init_ctrls in range(8)]
-
-class ActionBlockDialog(wx.Dialog):
-    def _init_coll_flexGridSizer1_Items(self, parent):
-        # generated method, don't edit
-
-        parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
-
-    def _init_sizers(self):
-        # generated method, don't edit
-        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
-
-        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
-
-        self.SetSizer(self.flexGridSizer1)
-
-    def _init_ctrls(self, prnt):
-        # generated method, don't edit
-        wx.Dialog.__init__(self, id=wxID_ACTIONBLOCKDIALOG,
-              name='ActionBlockDialog', parent=prnt, pos=wx.Point(376, 223),
-              size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE,
-              title='Edit action block properties')
-        self.SetClientSize(wx.Size(500, 300))
-
-        self.MainPanel = wx.Panel(id=wxID_ACTIONBLOCKDIALOGMAINPANEL,
-              name='MainPanel', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(500, 300), style=wx.TAB_TRAVERSAL)
-        self.MainPanel.SetAutoLayout(True)
-
-        self.staticText1 = wx.StaticText(id=wxID_ACTIONBLOCKDIALOGSTATICTEXT1,
-              label='Actions:', name='staticText1', parent=self.MainPanel,
-              pos=wx.Point(24, 24), size=wx.Size(95, 17), style=0)
-
-        self.ActionsGrid = wx.grid.Grid(id=wxID_ACTIONBLOCKDIALOGVARIABLESGRID,
-              name='ActionsGrid', parent=self.MainPanel, pos=wx.Point(24, 44), 
-              size=wx.Size(450, 150), style=wxVSCROLL)
-        self.ActionsGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False,
-              'Sans'))
-        self.ActionsGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL,
-              False, 'Sans'))
-        self.ActionsGrid.DisableDragGridSize()
-        self.ActionsGrid.EnableScrolling(False, True)
-        EVT_GRID_CELL_CHANGE(self.ActionsGrid, self.OnActionsGridCellChange)
-
-        self.AddButton = wx.Button(id=wxID_ACTIONBLOCKDIALOGADDBUTTON, label='Add',
-              name='AddButton', parent=self.MainPanel, pos=wx.Point(245, 204),
-              size=wx.Size(72, 32), style=0)
-        EVT_BUTTON(self, wxID_ACTIONBLOCKDIALOGADDBUTTON, self.OnAddButton)
-
-        self.DeleteButton = wx.Button(id=wxID_ACTIONBLOCKDIALOGDELETEBUTTON, label='Delete',
-              name='DeleteButton', parent=self.MainPanel, pos=wx.Point(325, 204),
-              size=wx.Size(72, 32), style=0)
-        EVT_BUTTON(self, wxID_ACTIONBLOCKDIALOGDELETEBUTTON, self.OnDeleteButton)
-
-        self.UpButton = wx.Button(id=wxID_ACTIONBLOCKDIALOGUPBUTTON, label='^',
-              name='UpButton', parent=self.MainPanel, pos=wx.Point(405, 204),
-              size=wx.Size(32, 32), style=0)
-        EVT_BUTTON(self, wxID_ACTIONBLOCKDIALOGUPBUTTON, self.OnUpButton)
-
-        self.DownButton = wx.Button(id=wxID_ACTIONBLOCKDIALOGDOWNBUTTON, label='v',
-              name='DownButton', parent=self.MainPanel, pos=wx.Point(445, 204),
-              size=wx.Size(32, 32), style=0)
-        EVT_BUTTON(self, wxID_ACTIONBLOCKDIALOGDOWNBUTTON, self.OnDownButton)
-
-        self._init_sizers()
-
-    def __init__(self, parent):
-        self._init_ctrls(parent)
-        self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
-        self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT)
-        
-        self.DefaultValue = {"Qualifier" : "N", "Duration" : "", "Type" : "Action", "Value" : "", "Indicator" : ""}
-        self.Table = ActionTable(self, [], ["Qualifier","Duration","Type","Value","Indicator"])
-        self.TypeList = "Action,Variable,Inline"
-        self.ColSizes = [60, 90, 80, 110, 80]
-        self.ColAlignements = [wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT]
-        
-        self.ActionsGrid.SetTable(self.Table)
-        self.ActionsGrid.SetRowLabelSize(0)
-        
-        self.Table.ResetView(self.ActionsGrid)
-
-    def OnAddButton(self, event):
-        self.Table.AppendRow(self.DefaultValue.copy())
-        self.Table.ResetView(self.ActionsGrid)
-        event.Skip()
-
-    def OnDeleteButton(self, event):
-        row = self.ActionsGrid.GetGridCursorRow()
-        self.Table.RemoveRow(row)
-        self.Table.ResetView(self.ActionsGrid)
-        event.Skip()
-
-    def OnUpButton(self, event):
-        row = self.ActionsGrid.GetGridCursorRow()
-        self.Table.MoveRow(row, -1, self.ActionsGrid)
-        self.Table.ResetView(self.ActionsGrid)
-        event.Skip()
-
-    def OnDownButton(self, event):
-        row = self.ActionsGrid.GetGridCursorRow()
-        self.Table.MoveRow(row, 1, self.ActionsGrid)
-        self.Table.ResetView(self.ActionsGrid)
-        event.Skip()
-
-    def OnActionsGridCellChange(self, event):
-        self.Table.ResetView(self.ActionsGrid)
-        event.Skip()
-
-    def SetQualifierList(self, list):
-        self.QualifierList = ""
-        sep = ""
-        for qualifier in list.keys():
-            self.QualifierList += "%s%s"%(sep, qualifier)
-            sep = ","
-        self.DurationList = list
-
-    def SetVariableList(self, list):
-        self.VariableList = ""
-        sep = ""
-        for variable in list:
-            self.VariableList += "%s%s"%(sep, variable["Name"])
-            sep = ","
-
-    def SetActionList(self, list):
-        self.ActionList = ""
-        sep = ""
-        for action in list:
-            self.ActionList += "%s%s"%(sep, action)
-            sep = ","
-
-    def SetValues(self, actions):
-        for action in actions:
-            row = {"Qualifier" : action["qualifier"], "Value" : action["value"]}
-            if action["type"] == "reference":
-                if action["value"] in self.ActionList:
-                    row["Type"] = "Action"
-                elif action["value"] in self.VariableList:
-                    row["Type"] = "Variable"
-                else:
-                    row["Type"] = "Inline"
-            else:
-                row["Type"] = "Inline"
-            if "duration" in action:
-                row["Duration"] = action["duration"]
-            else:
-                row["Duration"] = ""
-            if "indicator" in action:
-                row["Indicator"] = action["indicator"]
-            else:
-                row["Indicator"] = ""
-            self.Table.AppendRow(row)
-        self.Table.ResetView(self.ActionsGrid)
-    
-    def GetValues(self):
-        values = []
-        for data in self.Table.GetData():
-            print data
-            action = {"qualifier" : data["Qualifier"], "value" : data["Value"]}
-            if data["Type"] in ["Action", "Variable"]:
-                action["type"] = "reference"
-            else:
-                action["type"] = "inline"
-            if data["Duration"] != "":
-                action["duration"] = data["Duration"]
-            if data["Indicator"] != "":
-                action["indicator"] = data["Indicator"]
-            values.append(action)
-        return values
-
-
-#-------------------------------------------------------------------------------
-#                          Edit Step Name Dialog
-#-------------------------------------------------------------------------------
-
-class StepNameDialog(wxTextEntryDialog):
-
-    def __init__(self, parent, message, caption = "Please enter text", defaultValue = "", 
-                       style = wxOK|wxCANCEL|wxCENTRE, pos = wxDefaultPosition):
-        wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)
-        
-        self.PouNames = []
-        self.Variables = []
-        self.StepNames = []
-        
-        EVT_BUTTON(self, self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId(), self.OnOK)
-        
-    def OnOK(self, event):
-        step_name = self.GetSizer().GetItem(1).GetWindow().GetValue()
-        if step_name == "":
-            message = wxMessageDialog(self, "You must type a name!", "Error", wxOK|wxICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif not TestIdentifier(step_name):
-            message = wxMessageDialog(self, "\"%s\" is not a valid identifier!"%step_name, "Error", wxOK|wxICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif step_name.upper() in IEC_KEYWORDS:
-            message = wxMessageDialog(self, "\"%s\" is a keyword. It can't be used!"%step_name, "Error", wxOK|wxICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif step_name.upper() in self.PouNames:
-            message = wxMessageDialog(self, "A pou with \"%s\" as name exists!"%step_name, "Error", wxOK|wxICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif step_name.upper() in self.Variables:
-            message = wxMessageDialog(self, "A variable with \"%s\" as name exists!"%step_name, "Error", wxOK|wxICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif step_name.upper() in self.StepNames:
-            message = wxMessageDialog(self, "\"%s\" step already exists!"%step_name, "Error", wxOK|wxICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        else:
-            self.EndModal(wxID_OK)
-
-    def SetPouNames(self, pou_names):
-        self.PouNames = [pou_name.upper() for pou_name in pou_names]
-
-    def SetVariables(self, variables):
-        self.Variables = [var["Name"].upper() for var in variables]
-
-    def SetStepNames(self, step_names):
-        self.StepNames = [step_name.upper() for step_name in step_names]