Dialogs.py
changeset 409 34c9f624c2fe
parent 408 0e389fa5b160
child 410 e1d4e9a93186
--- a/Dialogs.py	Tue Sep 15 15:02:23 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2597 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
-#based on the plcopen standard. 
-#
-#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
-#
-#See COPYING file for copyrights details.
-#
-#This library is free software; you can redistribute it and/or
-#modify it under the terms of the GNU General Public
-#License as published by the Free Software Foundation; either
-#version 2.1 of the License, or (at your option) any later version.
-#
-#This library is distributed in the hope that it will be useful,
-#but WITHOUT ANY WARRANTY; without even the implied warranty of
-#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#General Public License for more details.
-#
-#You should have received a copy of the GNU General Public
-#License along with this library; if not, write to the Free Software
-#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-import wx
-import wx.grid
-
-from graphics import *
-
-#-------------------------------------------------------------------------------
-#                          Create New Block Dialog
-#-------------------------------------------------------------------------------
-
-[ID_BLOCKPROPERTIESDIALOG, ID_BLOCKPROPERTIESDIALOGNAME, 
- ID_BLOCKPROPERTIESDIALOGTYPETREE, ID_BLOCKPROPERTIESDIALOGTYPEDESC, 
- ID_BLOCKPROPERTIESDIALOGINPUTS, ID_BLOCKPROPERTIESDIALOGPREVIEW, 
- ID_BLOCKPROPERTIESDIALOGEXECUTIONORDER, ID_BLOCKPROPERTIESDIALOGEXECUTIONCONTROL, 
- ID_BLOCKPROPERTIESDIALOGSTATICTEXT1, ID_BLOCKPROPERTIESDIALOGSTATICTEXT2, 
- ID_BLOCKPROPERTIESDIALOGSTATICTEXT3, ID_BLOCKPROPERTIESDIALOGSTATICTEXT4, 
- ID_BLOCKPROPERTIESDIALOGSTATICTEXT5, ID_BLOCKPROPERTIESDIALOGSTATICTEXT6, 
-] = [wx.NewId() for _init_ctrls in range(14)]
-
-[CATEGORY, BLOCK] = range(2)
-
-class BlockPropertiesDialog(wx.Dialog):
-    
-    if wx.VERSION < (2, 6, 0):
-        def Bind(self, event, function, id = None):
-            if id is not None:
-                event(self, id, function)
-            else:
-                event(self, function)
-    
-    def _init_coll_flexGridSizer1_Items(self, parent):
-        parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
-        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
-
-    def _init_coll_flexGridSizer1_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(0)
-
-    def _init_coll_MainSizer_Items(self, parent):
-        parent.AddSizer(self.LeftBoxSizer, 1, border=5, flag=wx.GROW|wx.RIGHT)
-        parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT)
-
-    def _init_coll_LeftBoxSizer_Items(self, parent):
-        parent.AddWindow(self.TypeTree, 3, border=5, flag=wx.GROW|wx.BOTTOM)
-        parent.AddWindow(self.TypeDesc, 1, border=0, flag=wx.GROW)
-
-    def _init_coll_RightGridSizer_Items(self, parent):
-        parent.AddSizer(self.RightUpGridSizer, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.staticText6, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
-
-    def _init_coll_RightGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(2)
-
-    def _init_coll_RightUpGridSizer_Items(self, parent):
-        parent.AddWindow(self.staticText2, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
-        parent.AddWindow(self.BlockName, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.staticText3, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
-        parent.AddWindow(self.Inputs, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.staticText4, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
-        parent.AddWindow(self.ExecutionOrder, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.staticText5, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
-        parent.AddWindow(self.ExecutionControl, 0, border=0, flag=wx.GROW)
-    
-    def _init_coll_RightUpGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(1)
-    
-    def _init_sizers(self):
-        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
-        self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
-        self.LeftBoxSizer = wx.StaticBoxSizer(self.staticbox1, wx.VERTICAL)
-        self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5)
-        self.RightUpGridSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=4, vgap=5)
-        
-        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
-        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
-        self._init_coll_MainSizer_Items(self.MainSizer)
-        self._init_coll_LeftBoxSizer_Items(self.LeftBoxSizer)
-        self._init_coll_RightGridSizer_Items(self.RightGridSizer)
-        self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
-        self._init_coll_RightUpGridSizer_Items(self.RightUpGridSizer)
-        self._init_coll_RightUpGridSizer_Growables(self.RightUpGridSizer)
-        
-        self.SetSizer(self.flexGridSizer1)
-
-    def _init_ctrls(self, prnt):
-        wx.Dialog.__init__(self, id=ID_BLOCKPROPERTIESDIALOG,
-              name='BlockPropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
-              size=wx.Size(600, 400), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
-              title=_('Block Properties'))
-        self.SetClientSize(wx.Size(600, 400))
-
-        self.staticbox1 = wx.StaticBox(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT1,
-              label=_('Type:'), name='staticBox1', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0)
-
-        self.staticText2 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT2,
-              label=_('Name:'), name='staticText2', parent=self,
-              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
-        self.staticText3 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT2,
-              label=_('Inputs:'), name='staticText4', parent=self,
-              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
-        self.staticText4 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT4,
-              label=_('Execution Order:'), name='staticText4', parent=self,
-              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
-        self.staticText5 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT5,
-              label=_('Execution Control:'), name='staticText5', parent=self,
-              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
-        self.staticText6 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT6,
-              label=_('Preview:'), name='staticText6', parent=self,
-              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
-        if wx.Platform == '__WXMSW__':
-            treestyle = wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER
-        else:
-            treestyle = wx.TR_HAS_BUTTONS|wx.TR_HIDE_ROOT|wx.TR_SINGLE|wx.SUNKEN_BORDER
-        self.TypeTree = wx.TreeCtrl(id=ID_BLOCKPROPERTIESDIALOGTYPETREE,
-              name='TypeTree', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=treestyle)
-        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnTypeTreeItemSelected,
-              id=ID_BLOCKPROPERTIESDIALOGTYPETREE)
-
-        self.TypeDesc = wx.TextCtrl(id=ID_BLOCKPROPERTIESDIALOGTYPEDESC,
-              name='TypeDesc', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.TE_READONLY|wx.TE_MULTILINE)
-
-        self.BlockName = wx.TextCtrl(id=ID_BLOCKPROPERTIESDIALOGNAME, value='',
-              name='BlockName', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_TEXT, self.OnNameChanged, id=ID_BLOCKPROPERTIESDIALOGNAME)
-
-        self.Inputs = wx.SpinCtrl(id=ID_BLOCKPROPERTIESDIALOGINPUTS,
-              name='Inputs', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=2, max=20)
-        self.Bind(wx.EVT_SPINCTRL, self.OnInputsChanged, id=ID_BLOCKPROPERTIESDIALOGINPUTS)
-
-        self.ExecutionOrder = wx.SpinCtrl(id=ID_BLOCKPROPERTIESDIALOGEXECUTIONORDER,
-              name='ExecutionOrder', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0)
-        self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, id=ID_BLOCKPROPERTIESDIALOGEXECUTIONORDER)
-
-        self.ExecutionControl = wx.CheckBox(id=ID_BLOCKPROPERTIESDIALOGEXECUTIONCONTROL,
-              name='ExecutionControl', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_CHECKBOX, self.OnExecutionOrderChanged, id=ID_BLOCKPROPERTIESDIALOGEXECUTIONCONTROL)
-
-        self.Preview = wx.Panel(id=ID_BLOCKPROPERTIESDIALOGPREVIEW,
-              name='Preview', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
-        self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
-        setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
-        setattr(self.Preview, "GetScaling", lambda:None)
-        setattr(self.Preview, "GetBlockType", self.Controler.GetBlockType)
-        setattr(self.Preview, "IsOfType", self.Controler.IsOfType)
-
-        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
-        if wx.VERSION >= (2, 5, 0):
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
-            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
-        else:
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
-            wx.EVT_PAINT(self.Preview, self.OnPaint)
-        
-        self._init_sizers()
-
-    def __init__(self, parent, controler):
-        self.Controler = controler
-        self._init_ctrls(parent)
-        self.BlockName.SetValue("")
-        self.BlockName.Enable(False)
-        self.Inputs.Enable(False)
-        self.Block = None
-        self.MinBlockSize = None
-        self.First = True
-        
-        self.PouNames = []
-        self.PouElementNames = []
-    
-    def SetPreviewFont(self, font):
-        self.Preview.SetFont(font)
-    
-    def FindTreeItem(self, root, name, inputs = None):
-        if root.IsOk():
-            pydata = self.TypeTree.GetPyData(root)
-            type_inputs = pydata.get("inputs", None)
-            type_extension = pydata.get("extension", None)
-            if inputs is not None and type_inputs is not None:
-                if type_extension is not None:
-                    same_inputs = type_inputs == inputs[:type_extension]
-                else:
-                    same_inputs = type_inputs == inputs
-            else:
-                same_inputs = True
-            if self.TypeTree.GetItemText(root) == name and same_inputs:
-                return root
-            else:
-                if wx.VERSION < (2, 6, 0):
-                    item, root_cookie = self.TypeTree.GetFirstChild(root, 0)
-                else:
-                    item, root_cookie = self.TypeTree.GetFirstChild(root)
-                while item.IsOk():
-                    result = self.FindTreeItem(item, name, inputs)
-                    if result:
-                        return result
-                    item, root_cookie = self.TypeTree.GetNextChild(root, root_cookie)
-        return None
-    
-    def OnOK(self, event):
-        selected = self.TypeTree.GetSelection()
-        block_name = self.BlockName.GetValue()
-        name_enabled = self.BlockName.IsEnabled()
-        if not selected.IsOk() or self.TypeTree.GetItemParent(selected) == self.TypeTree.GetRootItem() or selected == self.TypeTree.GetRootItem():
-            message = wx.MessageDialog(self, _("Form isn't complete. Valid block type must be selected!"), _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif name_enabled and block_name == "":
-            message = wx.MessageDialog(self, _("Form isn't complete. Name must be filled!"), _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif name_enabled and not TestIdentifier(block_name):
-            message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%block_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif name_enabled and block_name.upper() in IEC_KEYWORDS:
-            message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%block_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif name_enabled and block_name.upper() in self.PouNames:
-            message = wx.MessageDialog(self, _("\"%s\" pou already exists!")%block_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif name_enabled and block_name.upper() in self.PouElementNames:
-            message = wx.MessageDialog(self, _("\"%s\" element for this pou already exists!")%block_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        else:
-            self.EndModal(wx.ID_OK)
-
-    def SetBlockList(self, blocktypes):
-        if wx.Platform == '__WXMSW__':
-            root = self.TypeTree.AddRoot(_("Block Types"))
-        else:
-            root = self.TypeTree.AddRoot("")
-        self.TypeTree.SetPyData(root, {"type" : CATEGORY})
-        for category in blocktypes:
-            category_name = category["name"]
-            category_item = self.TypeTree.AppendItem(root, _(category_name))
-            self.TypeTree.SetPyData(category_item, {"type" : CATEGORY})
-            for blocktype in category["list"]:
-                blocktype_item = self.TypeTree.AppendItem(category_item, blocktype["name"])
-                block_data = {"type" : BLOCK, 
-                              "inputs" : tuple([type for name, type, modifier in blocktype["inputs"]]),
-                              "extension" : None}
-                if blocktype["extensible"]:
-                    block_data["extension"] = len(blocktype["inputs"])
-                self.TypeTree.SetPyData(blocktype_item, block_data)
-        if wx.Platform == '__WXMSW__':
-            self.TypeTree.Expand(root)
-
-    def SetMinBlockSize(self, size):
-        self.MinBlockSize = size
-
-    def SetPouNames(self, pou_names):
-        self.PouNames = [pou_name.upper() for pou_name in pou_names]
-        
-    def SetPouElementNames(self, element_names):
-        self.PouElementNames = [element_name.upper() for element_name in element_names]
-        
-    def SetValues(self, values):
-        blocktype = values.get("type", None)
-        if blocktype is not None:
-            inputs = values.get("inputs", None)
-            item = self.FindTreeItem(self.TypeTree.GetRootItem(), blocktype, inputs)
-            if item:
-                self.TypeTree.SelectItem(item)
-        for name, value in values.items():
-            if name == "name":
-                self.BlockName.SetValue(value)
-            elif name == "extension":
-                self.Inputs.SetValue(value)
-            elif name == "executionOrder":
-                self.ExecutionOrder.SetValue(value)
-            elif name == "executionControl":
-           	    self.ExecutionControl.SetValue(value)
-        self.RefreshPreview()
-
-    def GetValues(self):
-        values = {}
-        item = self.TypeTree.GetSelection()
-        values["type"] = self.TypeTree.GetItemText(item)
-        values["inputs"] = self.TypeTree.GetPyData(item)["inputs"]
-        if self.BlockName.GetValue() != "":
-            values["name"] = self.BlockName.GetValue()
-        values["width"], values["height"] = self.Block.GetSize()
-        values["extension"] = self.Inputs.GetValue()
-        values["executionOrder"] = self.ExecutionOrder.GetValue()
-        values["executionControl"] = self.ExecutionControl.GetValue()
-        return values
-
-    def OnTypeTreeItemSelected(self, event):
-        self.BlockName.SetValue("")
-        selected = event.GetItem()
-        pydata = self.TypeTree.GetPyData(selected)
-        if pydata["type"] != CATEGORY:
-            blocktype = self.Controler.GetBlockType(self.TypeTree.GetItemText(selected), pydata["inputs"])
-            if blocktype:
-                self.Inputs.SetValue(len(blocktype["inputs"]))
-                self.Inputs.Enable(blocktype["extensible"])
-                self.BlockName.Enable(blocktype["type"] != "function")
-                comment = blocktype["comment"]
-                self.TypeDesc.SetValue(_(comment) + blocktype.get("usage", ""))
-                wx.CallAfter(self.RefreshPreview)
-            else:
-                self.BlockName.Enable(False)
-                self.Inputs.Enable(False)
-                self.Inputs.SetValue(2)
-                self.TypeDesc.SetValue("")
-                wx.CallAfter(self.ErasePreview)
-        else:
-            self.BlockName.Enable(False)
-            self.Inputs.Enable(False)
-            self.Inputs.SetValue(2)
-            self.TypeDesc.SetValue("")
-            wx.CallAfter(self.ErasePreview)
-        event.Skip()
-
-    def OnNameChanged(self, event):
-        if self.BlockName.IsEnabled():
-            self.RefreshPreview()
-        event.Skip()
-    
-    def OnInputsChanged(self, event):
-        if self.Inputs.IsEnabled():
-            self.RefreshPreview()
-        event.Skip()
-    
-    def OnExecutionOrderChanged(self, event):
-        self.RefreshPreview()
-        event.Skip()
-    
-    def OnExecutionControlChanged(self, event):
-        self.RefreshPreview()
-        event.Skip()
-    
-    def ErasePreview(self):
-        dc = wx.ClientDC(self.Preview)
-        dc.Clear()
-        self.Block = None
-        
-    def RefreshPreview(self):
-        dc = wx.ClientDC(self.Preview)
-        dc.SetFont(self.Preview.GetFont())
-        dc.Clear()
-        item = self.TypeTree.GetSelection()
-        if item.IsOk():
-            pydata = self.TypeTree.GetPyData(item)
-            if pydata["type"] == CATEGORY:
-                self.Block = None
-            else:
-                blocktype = self.TypeTree.GetItemText(item)
-                if blocktype:
-                    self.Block = FBD_Block(self.Preview, blocktype, 
-                            self.BlockName.GetValue(), 
-                            extension = self.Inputs.GetValue(), 
-                            inputs = pydata["inputs"], 
-                            executionControl = self.ExecutionControl.GetValue(), 
-                            executionOrder = self.ExecutionOrder.GetValue())
-                    width, height = self.MinBlockSize
-                    min_width, min_height = self.Block.GetMinSize()
-                    width, height = max(min_width, width), max(min_height, height)
-                    self.Block.SetSize(width, height)
-                    clientsize = self.Preview.GetClientSize()
-                    x = (clientsize.width - width) / 2
-                    y = (clientsize.height - height) / 2
-                    self.Block.SetPosition(x, y)
-                    self.Block.Draw(dc)
-                else:
-                    self.Block = None
-
-    def OnPaint(self, event):
-        if self.Block is not None:
-            self.RefreshPreview()
-        event.Skip()
-
-#-------------------------------------------------------------------------------
-#                          Create New Variable Dialog
-#-------------------------------------------------------------------------------
-
-[ID_VARIABLEPROPERTIESDIALOG, ID_VARIABLEPROPERTIESDIALOGSPACER, 
- ID_VARIABLEPROPERTIESDIALOGNAME, ID_VARIABLEPROPERTIESDIALOGCLASS, 
- ID_VARIABLEPROPERTIESDIALOGPREVIEW, ID_VARIABLEPROPERTIESDIALOGEXPRESSION,
- ID_VARIABLEPROPERTIESDIALOGEXECUTIONORDER, ID_VARIABLEPROPERTIESDIALOGSTATICTEXT1, 
- ID_VARIABLEPROPERTIESDIALOGSTATICTEXT2, ID_VARIABLEPROPERTIESDIALOGSTATICTEXT3, 
- ID_VARIABLEPROPERTIESDIALOGSTATICTEXT4, ID_VARIABLEPROPERTIESDIALOGSTATICTEXT5
-] = [wx.NewId() for _init_ctrls in range(12)]
-
-VARIABLE_CLASSES_DICT = {INPUT : _("Input"),
-                         INOUT : _("InOut"),
-                         OUTPUT : _("Output")}
-VARIABLE_CLASSES_DICT_REVERSE = dict([(value, key) for key, value in VARIABLE_CLASSES_DICT.iteritems()])
-
-class VariablePropertiesDialog(wx.Dialog):
-    
-    if wx.VERSION < (2, 6, 0):
-        def Bind(self, event, function, id = None):
-            if id is not None:
-                event(self, id, function)
-            else:
-                event(self, function)
-    
-    def _init_coll_flexGridSizer1_Items(self, parent):
-        parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
-        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
-        
-    def _init_coll_flexGridSizer1_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(0)
-    
-    def _init_coll_MainSizer_Items(self, parent):
-        parent.AddSizer(self.TopSizer, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.staticText5, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
-        
-    def _init_coll_MainSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(2)
-    
-    def _init_coll_TopSizer_Items(self, parent):
-        parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT)
-        parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT)
-    
-    def _init_coll_LeftGridSizer_Items(self, parent):
-        parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Class, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Expression, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.ExecutionOrder, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
-    
-    def _init_coll_LeftGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(2)
-            
-    def _init_coll_RightGridSizer_Items(self, parent):
-        parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.VariableName, 0, border=0, flag=wx.GROW)
-        
-    def _init_coll_RightGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(1)
-        
-    def _init_sizers(self):
-        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
-        self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5)
-        self.TopSizer = wx.BoxSizer(wx.HORIZONTAL)
-        self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=5)
-        self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
-
-        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
-        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
-        self._init_coll_MainSizer_Items(self.MainSizer)
-        self._init_coll_MainSizer_Growables(self.MainSizer)
-        self._init_coll_TopSizer_Items(self.TopSizer)
-        self._init_coll_LeftGridSizer_Items(self.LeftGridSizer)
-        self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer)
-        self._init_coll_RightGridSizer_Items(self.RightGridSizer)
-        self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
-        
-        self.SetSizer(self.flexGridSizer1)
-
-    def _init_ctrls(self, prnt, ctrler):
-        wx.Dialog.__init__(self, id=ID_VARIABLEPROPERTIESDIALOG,
-              name='VariablePropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
-              size=wx.Size(400, 380), style=wx.DEFAULT_DIALOG_STYLE,
-              title=_('Variable Properties'))
-        self.SetClientSize(wx.Size(400, 380))
-
-        self.staticText1 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT1,
-              label=_('Class:'), name='staticText1', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.staticText2 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT2,
-              label=_('Expression:'), name='staticText2', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.staticText3 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT3,
-              label=_('Execution Order:'), name='staticText3', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.staticText4 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT4,
-              label=_('Name:'), name='staticText4', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.staticText5 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT5,
-              label=_('Preview:'), name='staticText5', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.Class = wx.ComboBox(id=ID_VARIABLEPROPERTIESDIALOGCLASS,
-              name='Class', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 28), style=wx.CB_READONLY)
-        self.Bind(wx.EVT_COMBOBOX, self.OnClassChanged, id=ID_VARIABLEPROPERTIESDIALOGCLASS)
-        
-        self.VariableName = wx.ListBox(id=ID_VARIABLEPROPERTIESDIALOGNAME,
-              name='Name', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 90), style=wx.LB_SINGLE|wx.LB_SORT)
-        self.Bind(wx.EVT_LISTBOX, self.OnNameChanged, id=ID_VARIABLEPROPERTIESDIALOGNAME)
-
-        self.Expression = wx.TextCtrl(id=ID_VARIABLEPROPERTIESDIALOGEXPRESSION,
-              name='Expression', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_TEXT, self.OnExpressionChanged, id=ID_VARIABLEPROPERTIESDIALOGEXPRESSION)
-
-        self.ExecutionOrder = wx.SpinCtrl(id=ID_VARIABLEPROPERTIESDIALOGEXECUTIONORDER,
-              name='ExecutionOrder', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0)
-        self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, id=ID_VARIABLEPROPERTIESDIALOGEXECUTIONORDER)
-
-        self.Spacer = wx.Panel(id=ID_VARIABLEPROPERTIESDIALOGSPACER,
-              name='Spacer', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
-
-        self.Preview = wx.Panel(id=ID_VARIABLEPROPERTIESDIALOGPREVIEW,
-              name='Preview', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
-        self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
-        setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
-        setattr(self.Preview, "GetScaling", lambda:None)
-        setattr(self.Preview, "IsOfType", ctrler.IsOfType)
-
-        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
-        if wx.VERSION >= (2, 5, 0):
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
-            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
-        else:
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
-            wx.EVT_PAINT(self.Preview, self.OnPaint)
-        
-        self._init_sizers()
-
-    def __init__(self, parent, controler, transition = ""):
-        self._init_ctrls(parent, controler)
-        self.Transition = transition
-        self.Variable = None
-        self.VarList = []
-        self.MinVariableSize = None
-        
-        for choice in VARIABLE_CLASSES_DICT.itervalues():
-            self.Class.Append(choice)
-        self.Class.SetStringSelection(VARIABLE_CLASSES_DICT[INPUT])
-
-        self.RefreshNameList()
-
-    def SetPreviewFont(self, font):
-        self.Preview.SetFont(font)
-
-    def RefreshNameList(self):
-        selected = self.VariableName.GetStringSelection()
-        var_class = VARIABLE_CLASSES_DICT_REVERSE[self.Class.GetStringSelection()]
-        self.VariableName.Clear()
-        self.VariableName.Append("")
-        for name, var_type, value_type in self.VarList:
-            if var_type != "Input" or var_class == INPUT:
-                self.VariableName.Append(name)
-        if selected != "" and self.VariableName.FindString(selected) != wx.NOT_FOUND:
-            self.VariableName.SetStringSelection(selected)
-            self.Expression.Enable(False)
-        else:
-            self.VariableName.SetStringSelection("")
-            self.Expression.Enable(var_class == INPUT)
-        self.VariableName.Enable(self.VariableName.GetCount() > 0)
-            
-    def SetMinVariableSize(self, size):
-        self.MinVariableSize = size
-
-    def SetVariables(self, vars):
-        self.VarList = vars
-        self.RefreshNameList()
-
-    def SetValues(self, values):
-        value_type = values.get("type", None)
-        value_name = values.get("name", None)
-        if value_type:
-            self.Class.SetStringSelection(VARIABLE_CLASSES_DICT[value_type])
-            self.RefreshNameList()
-        if value_name:
-            if self.VariableName.FindString(value_name) != wx.NOT_FOUND:
-                self.VariableName.SetStringSelection(value_name)
-                self.Expression.Enable(False)
-            else:
-                self.Expression.SetValue(value_name)
-                self.VariableName.Enable(False)
-        if "executionOrder" in values:
-            self.ExecutionOrder.SetValue(values["executionOrder"])
-        self.RefreshPreview()
-        
-    def GetValues(self):
-        values = {}
-        values["type"] = VARIABLE_CLASSES_DICT_REVERSE[self.Class.GetStringSelection()]
-        expression = self.Expression.GetValue()
-        if self.Expression.IsEnabled() and expression != "":
-            values["name"] = expression
-        else:
-            values["name"] = self.VariableName.GetStringSelection()
-        values["value_type"] = None
-        for var_name, var_type, value_type in self.VarList:
-            if var_name == values["name"]:
-                values["value_type"] = value_type
-        values["width"], values["height"] = self.Variable.GetSize()
-        values["executionOrder"] = self.ExecutionOrder.GetValue()
-        return values
-
-    def OnOK(self, event):
-        expression = self.Expression.GetValue()
-        if self.Expression.IsEnabled():
-            value = expression
-        else:
-            value = self.VariableName.GetStringSelection()
-        if value == "":
-            message = wx.MessageDialog(self, _("At least a variable or an expression must be selected!"), _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif value.upper() in IEC_KEYWORDS:
-            message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%value, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        else:
-            self.EndModal(wx.ID_OK)
-
-    def OnClassChanged(self, event):
-        self.RefreshNameList()
-        self.RefreshPreview()
-        event.Skip()
-
-    def OnNameChanged(self, event):
-        if self.VariableName.GetStringSelection() != "":
-            self.Expression.Enable(False)
-        elif VARIABLE_CLASSES_DICT_REVERSE[self.Class.GetStringSelection()] == INPUT:
-            self.Expression.Enable(True)
-        self.RefreshPreview()
-        event.Skip()
-    
-    def OnExpressionChanged(self, event):
-        if self.Expression.GetValue() != "":
-            self.VariableName.Enable(False)
-        else:
-            self.VariableName.Enable(True)
-        self.RefreshPreview()
-        event.Skip()
-    
-    def OnExecutionOrderChanged(self, event):
-        self.RefreshPreview()
-        event.Skip()
-    
-    def RefreshPreview(self):
-        dc = wx.ClientDC(self.Preview)
-        dc.SetFont(self.Preview.GetFont())
-        dc.Clear()
-        expression = self.Expression.GetValue()
-        if self.Expression.IsEnabled() and expression != "":
-            name = expression
-        else:
-            name = self.VariableName.GetStringSelection()
-        type = ""
-        for var_name, var_type, value_type in self.VarList:
-            if var_name == name:
-                type = value_type
-        classtype = VARIABLE_CLASSES_DICT_REVERSE[self.Class.GetStringSelection()]
-        self.Variable = FBD_Variable(self.Preview, classtype, name, type, executionOrder = self.ExecutionOrder.GetValue())
-        width, height = self.MinVariableSize
-        min_width, min_height = self.Variable.GetMinSize()
-        width, height = max(min_width, width), max(min_height, height)
-        self.Variable.SetSize(width, height)
-        clientsize = self.Preview.GetClientSize()
-        x = (clientsize.width - width) / 2
-        y = (clientsize.height - height) / 2
-        self.Variable.SetPosition(x, y)
-        self.Variable.Draw(dc)
-
-    def OnPaint(self, event):
-        self.RefreshPreview()
-        event.Skip()
-
-#-------------------------------------------------------------------------------
-#                          Create New Connection Dialog
-#-------------------------------------------------------------------------------
-
-[ID_CONNECTIONPROPERTIESDIALOG, ID_CONNECTIONPROPERTIESDIALOGSPACER, 
- ID_CONNECTIONPROPERTIESDIALOGNAME, ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, 
- ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, ID_CONNECTIONPROPERTIESDIALOGPREVIEW,
- ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1, ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2, 
- ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3, 
-] = [wx.NewId() for _init_ctrls in range(9)]
-
-class ConnectionPropertiesDialog(wx.Dialog):
-    
-    if wx.VERSION < (2, 6, 0):
-        def Bind(self, event, function, id = None):
-            if id is not None:
-                event(self, id, function)
-            else:
-                event(self, function)
-    
-    def _init_coll_flexGridSizer1_Items(self, parent):
-        parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
-        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
-        
-    def _init_coll_flexGridSizer1_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(0)
-    
-    def _init_coll_MainSizer_Items(self, parent):
-        parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT)
-        parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT)
-    
-    def _init_coll_LeftGridSizer_Items(self, parent):
-        parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.ConnectionName, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
-    
-    def _init_coll_LeftGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(5)
-            
-    def _init_coll_RightGridSizer_Items(self, parent):
-        parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
-        
-    def _init_coll_RightGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(1)
-
-    def _init_sizers(self):
-        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
-        self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
-        self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5)
-        self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
-
-        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
-        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
-        self._init_coll_MainSizer_Items(self.MainSizer)
-        self._init_coll_LeftGridSizer_Items(self.LeftGridSizer)
-        self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer)
-        self._init_coll_RightGridSizer_Items(self.RightGridSizer)
-        self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
-
-        self.SetSizer(self.flexGridSizer1)
-
-    def _init_ctrls(self, prnt, ctrler):
-        wx.Dialog.__init__(self, id=ID_CONNECTIONPROPERTIESDIALOG,
-              name='ConnectionPropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
-              size=wx.Size(350, 220), style=wx.DEFAULT_DIALOG_STYLE,
-              title=_('Connection Properties'))
-        self.SetClientSize(wx.Size(350, 220))
-
-        self.staticText1 = wx.StaticText(id=ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1,
-              label=_('Type:'), name='staticText1', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.staticText2 = wx.StaticText(id=ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2,
-              label=_('Name:'), name='staticText2', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.staticText3 = wx.StaticText(id=ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3,
-              label=_('Preview:'), name='staticText3', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.radioButton1 = wx.RadioButton(id=ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1,
-              label=_('Connector'), name='radioButton1', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP)
-        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1)
-        self.radioButton1.SetValue(True)
-
-        self.radioButton2 = wx.RadioButton(id=ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2,
-              label=_('Continuation'), name='radioButton2', parent=self, 
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2)
-        self.radioButton2.SetValue(False)
-        
-        self.ConnectionName = wx.TextCtrl(id=ID_CONNECTIONPROPERTIESDIALOGNAME,
-              name='Name', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_TEXT, self.OnNameChanged, id=ID_CONNECTIONPROPERTIESDIALOGNAME)
-
-        self.Preview = wx.Panel(id=ID_CONNECTIONPROPERTIESDIALOGPREVIEW,
-              name='Preview', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
-        self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
-        setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
-        setattr(self.Preview, "GetScaling", lambda:None)
-        setattr(self.Preview, "IsOfType", ctrler.IsOfType)
-
-        self.Spacer = wx.Panel(id=ID_CONNECTIONPROPERTIESDIALOGSPACER,
-              name='Spacer', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
-
-        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
-        if wx.VERSION >= (2, 5, 0):
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
-            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
-        else:
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
-            wx.EVT_PAINT(self.Preview, self.OnPaint)
-        
-        self._init_sizers()
-
-    def __init__(self, parent, controler):
-        self._init_ctrls(parent, controler)
-        self.Connection = None
-        self.MinConnectionSize = None
-        
-        self.PouNames = []
-        self.PouElementNames = []
-    
-    def SetPreviewFont(self, font):
-        self.Preview.SetFont(font)
-    
-    def SetMinConnectionSize(self, size):
-        self.MinConnectionSize = size
-    
-    def SetValues(self, values):
-        for name, value in values.items():
-            if name == "type":
-                if value == CONNECTOR:
-                    self.radioButton1.SetValue(True)
-                elif value == CONTINUATION:
-                    self.radioButton2.SetValue(True)
-            elif name == "name":
-                self.ConnectionName.SetValue(value)
-        self.RefreshPreview()
-    
-    def GetValues(self):
-        values = {}
-        if self.radioButton1.GetValue():
-            values["type"] = CONNECTOR
-        else:
-            values["type"] = CONTINUATION
-        values["name"] = self.ConnectionName.GetValue()
-        values["width"], values["height"] = self.Connection.GetSize()
-        return values
-
-    def SetPouNames(self, pou_names):
-        self.PouNames = [pou_name.upper() for pou_name in pou_names]
-        
-    def SetPouElementNames(self, element_names):
-        self.PouElementNames = [element_name.upper() for element_name in element_names]
-
-    def OnOK(self, event):
-        connection_name = self.ConnectionName.GetValue()
-        if connection_name == "":
-            message = wx.MessageDialog(self, _("Form isn't complete. Name must be filled!"), _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif not TestIdentifier(connection_name):
-            message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%connection_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif connection_name.upper() in IEC_KEYWORDS:
-            message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%connection_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif connection_name.upper() in self.PouNames:
-            message = wx.MessageDialog(self, _("\"%s\" pou already exists!")%connection_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif connection_name.upper() in self.PouElementNames:
-            message = wx.MessageDialog(self, _("\"%s\" element for this pou already exists!")%connection_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        else:
-            self.EndModal(wx.ID_OK)
-
-    def OnTypeChanged(self, event):
-        self.RefreshPreview()
-        event.Skip()
-
-    def OnNameChanged(self, event):
-        self.RefreshPreview()
-        event.Skip()
-        
-    def RefreshPreview(self):
-        dc = wx.ClientDC(self.Preview)
-        dc.SetFont(self.Preview.GetFont())
-        dc.Clear()
-        if self.radioButton1.GetValue():
-            self.Connection = FBD_Connector(self.Preview, CONNECTOR, self.ConnectionName.GetValue())
-        else:
-            self.Connection = FBD_Connector(self.Preview, CONTINUATION, self.ConnectionName.GetValue())
-        width, height = self.MinConnectionSize
-        min_width, min_height = self.Connection.GetMinSize()
-        width, height = max(min_width, width), max(min_height, height)
-        self.Connection.SetSize(width, height)
-        clientsize = self.Preview.GetClientSize()
-        x = (clientsize.width - width) / 2
-        y = (clientsize.height - height) / 2
-        self.Connection.SetPosition(x, y)
-        self.Connection.Draw(dc)
-
-    def OnPaint(self, event):
-        self.RefreshPreview()
-        event.Skip()
-
-#-------------------------------------------------------------------------------
-#                        Edit Ladder Element Properties Dialog
-#-------------------------------------------------------------------------------
-
-
-[ID_LDELEMENTDIALOG, ID_LDELEMENTDIALOGSPACER, 
- ID_LDELEMENTDIALOGNAME, ID_LDELEMENTDIALOGRADIOBUTTON1, 
- ID_LDELEMENTDIALOGRADIOBUTTON2, ID_LDELEMENTDIALOGRADIOBUTTON3,
- ID_LDELEMENTDIALOGRADIOBUTTON4, ID_LDELEMENTDIALOGRADIOBUTTON5,
- ID_LDELEMENTDIALOGRADIOBUTTON6, ID_LDELEMENTDIALOGPREVIEW,
- ID_LDELEMENTDIALOGSTATICTEXT1, ID_LDELEMENTDIALOGSTATICTEXT2, 
- ID_LDELEMENTDIALOGSTATICTEXT3, 
-] = [wx.NewId() for _init_ctrls in range(13)]
-
-class LDElementDialog(wx.Dialog):
-    
-    if wx.VERSION < (2, 6, 0):
-        def Bind(self, event, function, id = None):
-            if id is not None:
-                event(self, id, function)
-            else:
-                event(self, function)
-    
-    def _init_coll_flexGridSizer1_Items(self, parent):
-        parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
-        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
-        
-    def _init_coll_flexGridSizer1_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(0)
-    
-    def _init_coll_MainSizer_Items(self, parent):
-        parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT)
-        parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT)
-    
-    def _init_coll_LeftGridSizer_Items(self, parent):
-        parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
-        parent.AddSizer(self.RadioButtonSizer, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.ElementName, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
-        
-    def _init_coll_LeftGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(7)
-    
-    def _init_coll_RadioButtonSizer_Items(self, parent):
-        parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.radioButton4, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.radioButton5, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.radioButton6, 0, border=0, flag=wx.GROW)
-        
-    def _init_coll_RightGridSizer_Items(self, parent):
-        parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
-        
-    def _init_coll_RightGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(1)
-
-    def _init_sizers(self):
-        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
-        self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
-        self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=5, vgap=5)
-        self.RadioButtonSizer = wx.BoxSizer(wx.VERTICAL)
-        self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
-
-        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
-        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
-        self._init_coll_MainSizer_Items(self.MainSizer)
-        self._init_coll_LeftGridSizer_Items(self.LeftGridSizer)
-        self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer)
-        self._init_coll_RadioButtonSizer_Items(self.RadioButtonSizer)
-        self._init_coll_RightGridSizer_Items(self.RightGridSizer)
-        self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
-
-        self.SetSizer(self.flexGridSizer1)
-
-    def _init_ctrls(self, prnt, ctrler, title, extra_size = 0):
-        wx.Dialog.__init__(self, id=ID_LDELEMENTDIALOG,
-              name='LDElementDialog', parent=prnt, pos=wx.Point(376, 223),
-              size=wx.Size(350, 260 + extra_size), style=wx.DEFAULT_DIALOG_STYLE,
-              title=title)
-        self.SetClientSize(wx.Size(350, 260 + extra_size))
-
-        self.staticText1 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT1,
-              label=_('Modifier:'), name='staticText1', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.staticText2 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT2,
-              label=_('Name:'), name='staticText2', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.staticText3 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT3,
-              label=_('Preview:'), name='staticText3', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.radioButton1 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON1,
-              label=_("Normal"), name='radioButton1', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP)
-        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON1)
-        self.radioButton1.SetValue(True)
-
-        self.radioButton2 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON2,
-              label=_("Negated"), name='radioButton2', parent=self, 
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON2)
-
-        self.radioButton3 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON3,
-              label=_("Set"), name='radioButton3', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON3)
-
-        self.radioButton4 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON4,
-              label=_("Reset"), name='radioButton4', parent=self, 
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON4)
-
-        self.radioButton5 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON5,
-              label=_("Rising Edge"), name='radioButton5', parent=self, 
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON5)
-
-        self.radioButton6 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON6,
-              label=_("Falling Edge"), name='radioButton6', parent=self, 
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON6)
-
-        self.ElementName = wx.ComboBox(id=ID_LDELEMENTDIALOGNAME,
-              name='Name', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 28), style=wx.CB_READONLY)
-        self.Bind(wx.EVT_COMBOBOX, self.OnNameChanged, id=ID_LDELEMENTDIALOGNAME)
-
-        self.Preview = wx.Panel(id=ID_LDELEMENTDIALOGPREVIEW,
-              name='Preview', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
-        self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
-        setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
-        setattr(self.Preview, "GetScaling", lambda:None)
-        setattr(self.Preview, "IsOfType", ctrler.IsOfType)
-
-        self.Spacer = wx.Panel(id=ID_LDELEMENTDIALOGSPACER,
-              name='Spacer', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
-
-        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
-        
-        if wx.VERSION >= (2, 5, 0):
-            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
-        else:
-            wx.EVT_PAINT(self.Preview, self.OnPaint)
-        
-        self._init_sizers()
-
-    def __init__(self, parent, controler, type):
-        self.Type = type
-        if type == "contact":
-            self._init_ctrls(parent, controler, _("Edit Contact Values"))
-            self.Element = LD_Contact(self.Preview, CONTACT_NORMAL, "")
-            self.radioButton3.Hide()
-            self.radioButton4.Hide()
-        elif type == "coil":
-            self._init_ctrls(parent, controler, _("Edit Coil Values"), 50)
-            self.Element = LD_Coil(self.Preview, COIL_NORMAL, "")
-            
-    
-    def SetPreviewFont(self, font):
-        self.Preview.SetFont(font)
-    
-    def SetElementSize(self, size):
-        min_width, min_height = self.Element.GetMinSize()
-        width, height = max(min_width, size[0]), max(min_height, size[1])
-        self.Element.SetSize(width, height)
-        
-    def SetVariables(self, vars):
-        self.ElementName.Clear()
-        for name in vars:
-            self.ElementName.Append(name)
-        self.ElementName.Enable(self.ElementName.GetCount() > 0)
-
-    def SetValues(self, values):
-        for name, value in values.items():
-            if name == "name":
-                self.Element.SetName(value)
-                self.ElementName.SetStringSelection(value)
-            elif name == "type":
-                self.Element.SetType(value)
-                if self.Type == "contact":
-                    if value == CONTACT_NORMAL:
-                        self.radioButton1.SetValue(True)
-                    elif value == CONTACT_REVERSE:
-                        self.radioButton2.SetValue(True)
-                    elif value == CONTACT_RISING:
-                        self.radioButton5.SetValue(True)
-                    elif value == CONTACT_FALLING:
-                        self.radioButton6.SetValue(True)
-                elif self.Type == "coil":
-                    if value == COIL_NORMAL:
-                        self.radioButton1.SetValue(True)
-                    elif value == COIL_REVERSE:
-                        self.radioButton2.SetValue(True)
-                    elif value == COIL_SET:
-                        self.radioButton3.SetValue(True)
-                    elif value == COIL_RESET:
-                        self.radioButton4.SetValue(True)
-                    elif value == COIL_RISING:
-                        self.radioButton5.SetValue(True)
-                    elif value == COIL_FALLING:
-                        self.radioButton6.SetValue(True)
-
-    def GetValues(self):
-        values = {}
-        values["name"] = self.Element.GetName()
-        values["type"] = self.Element.GetType()
-        values["width"], values["height"] = self.Element.GetSize()
-        return values
-
-    def OnTypeChanged(self, event):
-        if self.Type == "contact":
-            if self.radioButton1.GetValue():
-                self.Element.SetType(CONTACT_NORMAL)
-            elif self.radioButton2.GetValue():
-                self.Element.SetType(CONTACT_REVERSE)
-            elif self.radioButton5.GetValue():
-                self.Element.SetType(CONTACT_RISING)
-            elif self.radioButton6.GetValue():
-                self.Element.SetType(CONTACT_FALLING)
-        elif self.Type == "coil":
-            if self.radioButton1.GetValue():
-                self.Element.SetType(COIL_NORMAL)
-            elif self.radioButton2.GetValue():
-                self.Element.SetType(COIL_REVERSE)
-            elif self.radioButton3.GetValue():
-                self.Element.SetType(COIL_SET)
-            elif self.radioButton4.GetValue():
-                self.Element.SetType(COIL_RESET)
-            elif self.radioButton5.GetValue():
-                self.Element.SetType(COIL_RISING)
-            elif self.radioButton6.GetValue():
-                self.Element.SetType(COIL_FALLING)
-        self.RefreshPreview()
-        event.Skip()
-
-    def OnNameChanged(self, event):
-        self.Element.SetName(self.ElementName.GetStringSelection())
-        self.RefreshPreview()
-        event.Skip()
-
-    def RefreshPreview(self):
-        dc = wx.ClientDC(self.Preview)
-        dc.SetFont(self.Preview.GetFont())
-        dc.Clear()
-        clientsize = self.Preview.GetClientSize()
-        width, height = self.Element.GetSize()
-        self.Element.SetPosition((clientsize.width - width) / 2, (clientsize.height - height) / 2)
-        self.Element.Draw(dc)
-
-    def OnPaint(self, event):
-        self.RefreshPreview()
-        event.Skip()
-
-
-#-------------------------------------------------------------------------------
-#                      Edit Ladder Power Rail Properties Dialog
-#-------------------------------------------------------------------------------
-
-
-[ID_LDPOWERRAILDIALOG, ID_LDPOWERRAILDIALOGSPACER, 
- ID_LDPOWERRAILDIALOGTYPE, ID_LDPOWERRAILDIALOGRADIOBUTTON1, 
- ID_LDPOWERRAILDIALOGRADIOBUTTON2, ID_LDPOWERRAILDIALOGPREVIEW,
- ID_LDPOWERRAILDIALOGSTATICTEXT1, ID_LDPOWERRAILDIALOGSTATICTEXT2, 
- ID_LDPOWERRAILDIALOGSTATICTEXT3, ID_LDPOWERRAILDIALOGPINNUMBER,
-] = [wx.NewId() for _init_ctrls in range(10)]
-
-class LDPowerRailDialog(wx.Dialog):
-    
-    if wx.VERSION < (2, 6, 0):
-        def Bind(self, event, function, id = None):
-            if id is not None:
-                event(self, id, function)
-            else:
-                event(self, function)
-    
-    def _init_coll_flexGridSizer1_Items(self, parent):
-        parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
-        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
-        
-    def _init_coll_flexGridSizer1_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(0)
-    
-    def _init_coll_MainSizer_Items(self, parent):
-        parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT)
-        parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT)
-    
-    def _init_coll_LeftGridSizer_Items(self, parent):
-        parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.PinNumber, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
-    
-    def _init_coll_LeftGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(5)
-            
-    def _init_coll_RightGridSizer_Items(self, parent):
-        parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
-        
-    def _init_coll_RightGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(1)
-
-    def _init_sizers(self):
-        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
-        self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
-        self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5)
-        self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
-
-        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
-        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
-        self._init_coll_MainSizer_Items(self.MainSizer)
-        self._init_coll_LeftGridSizer_Items(self.LeftGridSizer)
-        self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer)
-        self._init_coll_RightGridSizer_Items(self.RightGridSizer)
-        self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
-
-        self.SetSizer(self.flexGridSizer1)
-
-    def _init_ctrls(self, prnt, ctrler):
-        wx.Dialog.__init__(self, id=ID_LDPOWERRAILDIALOG,
-              name='PowerRailDialog', parent=prnt, pos=wx.Point(376, 223),
-              size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE,
-              title=_('Power Rail Properties'))
-        self.SetClientSize(wx.Size(350, 260))
-
-        self.staticText1 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT1,
-              label=_('Type:'), name='staticText1', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.staticText2 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT2,
-              label=_('Pin number:'), name='staticText2', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.staticText3 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT3,
-              label=_('Preview:'), name='staticText3', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.radioButton1 = wx.RadioButton(id=ID_LDPOWERRAILDIALOGRADIOBUTTON1,
-              label=_('Left PowerRail'), name='radioButton1', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP)
-        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDPOWERRAILDIALOGRADIOBUTTON1)
-        self.radioButton1.SetValue(True)
-
-        self.radioButton2 = wx.RadioButton(id=ID_LDPOWERRAILDIALOGRADIOBUTTON2,
-              label=_('Right PowerRail'), name='radioButton2', parent=self, 
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDPOWERRAILDIALOGRADIOBUTTON2)
-
-        self.PinNumber = wx.SpinCtrl(id=ID_LDPOWERRAILDIALOGPINNUMBER,
-              name='PinNumber', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=1, max=50)
-        self.Bind(wx.EVT_SPINCTRL, self.OnPinNumberChanged, id=ID_LDPOWERRAILDIALOGPINNUMBER)
-
-        self.Preview = wx.Panel(id=ID_LDPOWERRAILDIALOGPREVIEW,
-              name='Preview', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
-        self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
-        setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
-        setattr(self.Preview, "GetScaling", lambda:None)
-        setattr(self.Preview, "IsOfType", ctrler.IsOfType)
-
-        self.Spacer = wx.Panel(id=ID_LDELEMENTDIALOGSPACER,
-              name='Spacer', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
-
-        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
-        
-        if wx.VERSION >= (2, 5, 0):
-            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
-        else:
-            wx.EVT_PAINT(self.Preview, self.OnPaint)
-        
-        self._init_sizers()
-
-    def __init__(self, parent, controler, type = LEFTRAIL, number = 1):
-        self._init_ctrls(parent, controler)
-        self.Type = type
-        if type == LEFTRAIL:
-            self.radioButton1.SetValue(True)
-        elif type == RIGHTRAIL:
-            self.radioButton2.SetValue(True)
-        self.PinNumber.SetValue(number)
-        
-        self.PowerRailMinSize = (0, 0)
-        self.PowerRail = None
-
-    def SetPreviewFont(self, font):
-        self.Preview.SetFont(font)
-
-    def SetMinSize(self, size):
-        self.PowerRailMinSize = size
-        self.RefreshPreview()    
-
-    def GetValues(self):
-        values = {}
-        values["type"] = self.Type
-        values["number"] = self.PinNumber.GetValue()
-        values["width"], values["height"] = self.PowerRail.GetSize()
-        return values
-
-    def OnTypeChanged(self, event):
-        if self.radioButton1.GetValue():
-            self.Type = LEFTRAIL
-        elif self.radioButton2.GetValue():
-            self.Type = RIGHTRAIL
-        self.RefreshPreview()
-        event.Skip()
-
-    def OnPinNumberChanged(self, event):
-        self.RefreshPreview()
-        event.Skip()
-
-    def RefreshPreview(self):
-        dc = wx.ClientDC(self.Preview)
-        dc.SetFont(self.Preview.GetFont())
-        dc.Clear()
-        self.PowerRail = LD_PowerRail(self.Preview, self.Type, connectors = [True for i in xrange(self.PinNumber.GetValue())])
-        min_width, min_height = 2, LD_LINE_SIZE * self.PinNumber.GetValue()
-        width, height = max(min_width, self.PowerRailMinSize[0]), max(min_height, self.PowerRailMinSize[1])
-        self.PowerRail.SetSize(width, height)
-        clientsize = self.Preview.GetClientSize()
-        self.PowerRail.SetPosition((clientsize.width - width) / 2, (clientsize.height - height) / 2)
-        self.PowerRail.Draw(dc)
-
-    def OnPaint(self, event):
-        self.RefreshPreview()
-        event.Skip()
-
-
-#-------------------------------------------------------------------------------
-#                          Edit Step Content Dialog
-#-------------------------------------------------------------------------------
-
-[ID_STEPCONTENTDIALOG, ID_STEPCONTENTDIALOGSPACER, 
- ID_STEPCONTENTDIALOGNAME, ID_STEPCONTENTDIALOGPREVIEW, 
- ID_STEPCONTENTDIALOGCHECKBOX1, ID_STEPCONTENTDIALOGCHECKBOX2,
- ID_STEPCONTENTDIALOGCHECKBOX3, ID_STEPCONTENTDIALOGSTATICTEXT1, 
- ID_STEPCONTENTDIALOGSTATICTEXT2, ID_STEPCONTENTDIALOGSTATICTEXT3, 
-] = [wx.NewId() for _init_ctrls in range(10)]
-
-class StepContentDialog(wx.Dialog):
-    
-    if wx.VERSION < (2, 6, 0):
-        def Bind(self, event, function, id = None):
-            if id is not None:
-                event(self, id, function)
-            else:
-                event(self, function)
-    
-    def _init_coll_flexGridSizer1_Items(self, parent):
-        parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
-        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
-        
-    def _init_coll_flexGridSizer1_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(0)
-    
-    def _init_coll_MainSizer_Items(self, parent):
-        parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT)
-        parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT)
-    
-    def _init_coll_LeftGridSizer_Items(self, parent):
-        parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.StepName, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.checkBox1, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.checkBox2, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.checkBox3, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
-        
-    def _init_coll_LeftGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(6)
-            
-    def _init_coll_RightGridSizer_Items(self, parent):
-        parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
-        
-    def _init_coll_RightGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(1)
-
-    def _init_sizers(self):
-        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
-        self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
-        self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=5)
-        self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
-
-        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
-        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
-        self._init_coll_MainSizer_Items(self.MainSizer)
-        self._init_coll_LeftGridSizer_Items(self.LeftGridSizer)
-        self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer)
-        self._init_coll_RightGridSizer_Items(self.RightGridSizer)
-        self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
-
-        self.SetSizer(self.flexGridSizer1)
-
-    def _init_ctrls(self, prnt, ctrler):
-        wx.Dialog.__init__(self, id=ID_STEPCONTENTDIALOG,
-              name='StepContentDialog', parent=prnt, pos=wx.Point(376, 223),
-              size=wx.Size(400, 250), style=wx.DEFAULT_DIALOG_STYLE,
-              title=_('Edit Step'))
-        self.SetClientSize(wx.Size(400, 250))
-
-        self.staticText1 = wx.StaticText(id=ID_STEPCONTENTDIALOGSTATICTEXT1,
-              label=_('Name:'), name='staticText1', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.staticText2 = wx.StaticText(id=ID_STEPCONTENTDIALOGSTATICTEXT2,
-              label=_('Connectors:'), name='staticText2', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.staticText3 = wx.StaticText(id=ID_STEPCONTENTDIALOGSTATICTEXT3,
-              label=_('Preview:'), name='staticText4', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.StepName = wx.TextCtrl(id=ID_STEPCONTENTDIALOGNAME,
-              name='Name', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_TEXT, self.OnNameChanged, id=ID_STEPCONTENTDIALOGNAME)
-
-        self.checkBox1 = wx.CheckBox(id=ID_STEPCONTENTDIALOGCHECKBOX1,
-              label=_("Input"), name='checkBox1', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, id=ID_STEPCONTENTDIALOGCHECKBOX1)
-        
-        self.checkBox2 = wx.CheckBox(id=ID_STEPCONTENTDIALOGCHECKBOX2,
-              label=_("Output"), name='checkBox2', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, id=ID_STEPCONTENTDIALOGCHECKBOX2)
-        
-        self.checkBox3 = wx.CheckBox(id=ID_STEPCONTENTDIALOGCHECKBOX3,
-              label=_("Action"), name='checkBox3', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, id=ID_STEPCONTENTDIALOGCHECKBOX3)
-        
-        self.Spacer = wx.Panel(id=ID_STEPCONTENTDIALOGSPACER,
-              name='Spacer', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
-
-        self.Preview = wx.Panel(id=ID_STEPCONTENTDIALOGPREVIEW,
-              name='Preview', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
-        self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
-        setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
-        setattr(self.Preview, "RefreshStepModel", lambda x:None)
-        setattr(self.Preview, "GetScaling", lambda:None)
-        setattr(self.Preview, "IsOfType", ctrler.IsOfType)
-
-        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
-        if wx.VERSION >= (2, 5, 0):
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
-            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
-        else:
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
-            wx.EVT_PAINT(self.Preview, self.OnPaint)
-        
-        self._init_sizers()
-
-    def __init__(self, parent, controler, initial = False):
-        self._init_ctrls(parent, controler)
-        self.Step = None
-        self.Initial = initial
-        self.MinStepSize = None
-    
-        self.PouNames = []
-        self.Variables = []
-        self.StepNames = []
-    
-    def SetPreviewFont(self, font):
-        self.Preview.SetFont(font)
-    
-    def OnOK(self, event):
-        step_name = self.StepName.GetValue()
-        if step_name == "":
-            message = wx.MessageDialog(self, _("You must type a name!"), _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif not TestIdentifier(step_name):
-            message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif step_name.upper() in IEC_KEYWORDS:
-            message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif step_name.upper() in self.PouNames:
-            message = wx.MessageDialog(self, _("A pou with \"%s\" as name exists!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif step_name.upper() in self.Variables:
-            message = wx.MessageDialog(self, _("A variable with \"%s\" as name already exists in this pou!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif step_name.upper() in self.StepNames:
-            message = wx.MessageDialog(self, _("\"%s\" step already exists!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        else:
-            self.EndModal(wx.ID_OK)
-    
-    def SetMinStepSize(self, size):
-        self.MinStepSize = size
-
-    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]
-
-    def SetValues(self, values):
-        value_name = values.get("name", None)
-        if value_name:
-            self.StepName.SetValue(value_name)
-        else:
-            self.StepName.SetValue("")
-        self.checkBox1.SetValue(values.get("input", False))
-        self.checkBox2.SetValue(values.get("output", False))
-        self.checkBox3.SetValue(values.get("action", False))
-        self.RefreshPreview()
-        
-    def GetValues(self):
-        values = {}
-        values["name"] = self.StepName.GetValue()
-        values["input"] = self.checkBox1.IsChecked()
-        values["output"] = self.checkBox2.IsChecked()
-        values["action"] = self.checkBox3.IsChecked()
-        values["width"], values["height"] = self.Step.GetSize()
-        return values
-    
-    def OnConnectorsChanged(self, event):
-        self.RefreshPreview()
-        event.Skip()
-
-    def OnNameChanged(self, event):
-        self.RefreshPreview()
-        event.Skip()
-    
-    def RefreshPreview(self):
-        dc = wx.ClientDC(self.Preview)
-        dc.SetFont(self.Preview.GetFont())
-        dc.Clear()
-        self.Step = SFC_Step(self.Preview, self.StepName.GetValue(), self.Initial)
-        if self.checkBox1.IsChecked():
-            self.Step.AddInput()
-        else:
-            self.Step.RemoveInput()
-        if self.checkBox2.IsChecked():
-            self.Step.AddOutput()
-        else:
-            self.Step.RemoveOutput()
-        if self.checkBox3.IsChecked():
-            self.Step.AddAction()    
-        else:
-            self.Step.RemoveAction()
-        width, height = self.MinStepSize
-        min_width, min_height = self.Step.GetMinSize()
-        width, height = max(min_width, width), max(min_height, height)
-        self.Step.SetSize(width, height)
-        clientsize = self.Preview.GetClientSize()
-        x = (clientsize.width - width) / 2
-        y = (clientsize.height - height) / 2
-        self.Step.SetPosition(x, y)
-        self.Step.Draw(dc)
-
-    def OnPaint(self, event):
-        self.RefreshPreview()
-        event.Skip()
-
-#-------------------------------------------------------------------------------
-#                          Edit Transition Content Dialog
-#-------------------------------------------------------------------------------
-
-[ID_TRANSITIONCONTENTDIALOG, ID_TRANSITIONCONTENTDIALOGSPACER, 
- ID_TRANSITIONCONTENTDIALOGREFERENCE, ID_TRANSITIONCONTENTDIALOGINLINE, 
- ID_TRANSITIONCONTENTDIALOGPRIORITY, ID_TRANSITIONCONTENTDIALOGPREVIEW, 
- ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, ID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, 
- ID_TRANSITIONCONTENTDIALOGRADIOBUTTON3, ID_TRANSITIONCONTENTDIALOGSTATICTEXT1, 
- ID_TRANSITIONCONTENTDIALOGSTATICTEXT2, ID_TRANSITIONCONTENTDIALOGSTATICTEXT3, 
-] = [wx.NewId() for _init_ctrls in range(12)]
-
-class TransitionContentDialog(wx.Dialog):
-    
-    if wx.VERSION < (2, 6, 0):
-        def Bind(self, event, function, id = None):
-            if id is not None:
-                event(self, id, function)
-            else:
-                event(self, function)
-    
-    def _init_coll_flexGridSizer1_Items(self, parent):
-        parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
-        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
-        
-    def _init_coll_flexGridSizer1_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(0)
-    
-    def _init_coll_MainSizer_Items(self, parent):
-        parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT)
-        parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT)
-    
-    def _init_coll_LeftGridSizer_Items(self, parent):
-        parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Reference, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Inline, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Priority, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
-    
-    def _init_coll_LeftGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(6)
-            
-    def _init_coll_RightGridSizer_Items(self, parent):
-        parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
-        
-    def _init_coll_RightGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(1)
-
-    def _init_sizers(self):
-        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
-        self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
-        self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=9, vgap=5)
-        self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
-
-        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
-        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
-        self._init_coll_MainSizer_Items(self.MainSizer)
-        self._init_coll_LeftGridSizer_Items(self.LeftGridSizer)
-        self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer)
-        self._init_coll_RightGridSizer_Items(self.RightGridSizer)
-        self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
-
-        self.SetSizer(self.flexGridSizer1)
-
-    def _init_ctrls(self, prnt, ctrler):
-        wx.Dialog.__init__(self, id=ID_TRANSITIONCONTENTDIALOG,
-              name='ProjectDialog', parent=prnt, pos=wx.Point(376, 223),
-              size=wx.Size(350, 300), style=wx.DEFAULT_DIALOG_STYLE,
-              title=_('Edit transition'))
-        self.SetClientSize(wx.Size(350, 300))
-
-        self.staticText1 = wx.StaticText(id=ID_TRANSITIONCONTENTDIALOGSTATICTEXT1,
-              label=_('Type:'), name='staticText1', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.staticText2 = wx.StaticText(id=ID_TRANSITIONCONTENTDIALOGSTATICTEXT2,
-              label=_('Preview:'), name='staticText2', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.staticText3 = wx.StaticText(id=ID_TRANSITIONCONTENTDIALOGSTATICTEXT3,
-              label=_('Priority:'), name='staticText3', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-        
-        self.radioButton1 = wx.RadioButton(id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1,
-              label=_('Reference'), name='radioButton1', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP)
-        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1)
-        self.radioButton1.SetValue(True)
-
-        self.Reference = wx.ComboBox(id=ID_TRANSITIONCONTENTDIALOGREFERENCE,
-              name='Reference', parent=self, pos=wx.Point(0, 0), 
-              size=wx.Size(0, 28), style=wx.CB_READONLY)
-        self.Bind(wx.EVT_COMBOBOX, self.OnReferenceChanged, id=ID_TRANSITIONCONTENTDIALOGREFERENCE)
-
-        self.radioButton2 = wx.RadioButton(id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON2,
-              label=_('Inline'), name='radioButton2', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON2)
-        self.radioButton2.SetValue(False)
-
-        self.Inline = wx.TextCtrl(id=ID_TRANSITIONCONTENTDIALOGINLINE,
-              name='Inline', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_TEXT, self.OnInlineChanged, id=ID_TRANSITIONCONTENTDIALOGINLINE)
-        self.Inline.Enable(False)
-        
-        self.radioButton3 = wx.RadioButton(id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON3,
-              label=_('Connection'), name='radioButton3', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON3)
-        self.radioButton3.SetValue(False)
-        if not self.Connection:
-            self.radioButton3.Hide()
-
-        self.Priority = wx.SpinCtrl(id=ID_TRANSITIONCONTENTDIALOGPRIORITY,
-              name='Priority', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0)
-        self.Bind(wx.EVT_TEXT, self.OnPriorityChanged, id=ID_TRANSITIONCONTENTDIALOGPRIORITY)
-
-        self.Preview = wx.Panel(id=ID_TRANSITIONCONTENTDIALOGPREVIEW,
-              name='Preview', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
-        self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
-        setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
-        setattr(self.Preview, "RefreshTransitionModel", lambda x:None)
-        setattr(self.Preview, "GetScaling", lambda:None)
-        setattr(self.Preview, "IsOfType", ctrler.IsOfType)
-
-        self.Spacer = wx.Panel(id=ID_TRANSITIONCONTENTDIALOGSPACER,
-              name='Spacer', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
-
-        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
-        if wx.VERSION >= (2, 5, 0):
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
-            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
-        else:
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
-            wx.EVT_PAINT(self.Preview, self.OnPaint)
-        
-        self._init_sizers()
-
-    def __init__(self, parent, controler, connection):
-        self.Connection = connection
-        self._init_ctrls(parent, controler)
-        self.Transition = None
-        self.MinTransitionSize = None
-        
-        self.Element = SFC_Transition(self.Preview)
-    
-    def SetPreviewFont(self, font):
-        self.Preview.SetFont(font)
-    
-    def SetElementSize(self, size):
-        min_width, min_height = self.Element.GetMinSize()
-        width, height = max(min_width, size[0]), max(min_height, size[1])
-        self.Element.SetSize(width, height)
-    
-    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 = wx.MessageDialog(self, _("Form isn't complete. %s must be filled!")%text, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        else:
-            self.EndModal(wx.ID_OK)
-
-    def OnTypeChanged(self, event):
-        if self.radioButton1.GetValue():
-            self.Element.SetType("reference", self.Reference.GetStringSelection())
-            self.Reference.Enable(True)
-            self.Inline.Enable(False)
-        elif self.radioButton2.GetValue():
-            self.Element.SetType("inline", self.Inline.GetValue())
-            self.Reference.Enable(False)
-            self.Inline.Enable(True)
-        else:
-            self.Element.SetType("connection")
-            self.Reference.Enable(False)
-            self.Inline.Enable(False)
-        self.RefreshPreview()
-        event.Skip()
-
-    def OnReferenceChanged(self, event):
-        self.Element.SetType("reference", self.Reference.GetStringSelection())
-        self.RefreshPreview()
-        event.Skip()
-
-    def OnInlineChanged(self, event):
-        self.Element.SetType("inline", self.Inline.GetValue())
-        self.RefreshPreview()
-        event.Skip()
-
-    def OnPriorityChanged(self, event):
-        self.Element.SetPriority(int(self.Priority.GetValue()))
-        self.RefreshPreview()
-        event.Skip()
-
-    def SetTransitions(self, transitions):
-        self.Reference.Append("")
-        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.radioButton3.SetValue(False)
-            self.Reference.Enable(True)
-            self.Inline.Enable(False)
-            self.Reference.SetStringSelection(values["value"])
-            self.Element.SetType("reference", values["value"])
-        elif values["type"] == "inline":
-            self.radioButton1.SetValue(False)
-            self.radioButton2.SetValue(True)
-            self.radioButton3.SetValue(False)
-            self.Reference.Enable(False)
-            self.Inline.Enable(True)
-            self.Inline.SetValue(values["value"])
-            self.Element.SetType("inline", values["value"])
-        elif values["type"] == "connection" and self.Connection:
-            self.radioButton1.SetValue(False)
-            self.radioButton2.SetValue(False)
-            self.radioButton3.SetValue(True)
-            self.Reference.Enable(False)
-            self.Inline.Enable(False)
-            self.Element.SetType("connection")
-        self.Priority.SetValue(values["priority"])
-        self.Element.SetPriority(values["priority"])
-        self.RefreshPreview()
-        
-    def GetValues(self):
-        values = {"priority" : int(self.Priority.GetValue())}
-        if self.radioButton1.GetValue():
-            values["type"] = "reference"
-            values["value"] = self.Reference.GetStringSelection()
-        elif self.radioButton2.GetValue():
-            values["type"] = "inline"
-            values["value"] = self.Inline.GetValue()
-        else:
-            values["type"] = "connection"
-            values["value"] = None
-        return values
-
-    def RefreshPreview(self):
-        dc = wx.ClientDC(self.Preview)
-        dc.SetFont(self.Preview.GetFont())
-        dc.Clear()
-        clientsize = self.Preview.GetClientSize()
-        posx, posy = self.Element.GetPosition()
-        rect = self.Element.GetBoundingBox()
-        diffx, diffy = posx - rect.x, posy - rect.y
-        self.Element.SetPosition((clientsize.width - rect.width) / 2 + diffx, (clientsize.height - rect.height) / 2 + diffy)
-        self.Element.Draw(dc)
-
-    def OnPaint(self, event):
-        self.RefreshPreview()
-        event.Skip()
-
-#-------------------------------------------------------------------------------
-#                         Create New Divergence Dialog
-#-------------------------------------------------------------------------------
-
-[ID_DIVERGENCECREATEDIALOG, ID_DIVERGENCECREATEDIALOGSPACER, 
- ID_DIVERGENCECREATEDIALOGRADIOBUTTON1, ID_DIVERGENCECREATEDIALOGRADIOBUTTON2,
- ID_DIVERGENCECREATEDIALOGRADIOBUTTON3, ID_DIVERGENCECREATEDIALOGRADIOBUTTON4, 
- ID_DIVERGENCECREATEDIALOGSEQUENCES, ID_DIVERGENCECREATEDIALOGPREVIEW, 
- ID_DIVERGENCECREATEDIALOGSTATICTEXT1, ID_DIVERGENCECREATEDIALOGSTATICTEXT2, 
- ID_DIVERGENCECREATEDIALOGSTATICTEXT3,  
-] = [wx.NewId() for _init_ctrls in range(11)]
-
-class DivergenceCreateDialog(wx.Dialog):
-    
-    if wx.VERSION < (2, 6, 0):
-        def Bind(self, event, function, id = None):
-            if id is not None:
-                event(self, id, function)
-            else:
-                event(self, function)
-    
-    def _init_coll_flexGridSizer1_Items(self, parent):
-        parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
-        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
-        
-    def _init_coll_flexGridSizer1_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(0)
-    
-    def _init_coll_MainSizer_Items(self, parent):
-        parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT)
-        parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT)
-    
-    def _init_coll_LeftGridSizer_Items(self, parent):
-        parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.radioButton4, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Sequences, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
-    
-    def _init_coll_LeftGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(7)
-            
-    def _init_coll_RightGridSizer_Items(self, parent):
-        parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
-        
-    def _init_coll_RightGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(1)
-
-    def _init_sizers(self):
-        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
-        self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
-        self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=8, vgap=5)
-        self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
-
-        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
-        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
-        self._init_coll_MainSizer_Items(self.MainSizer)
-        self._init_coll_LeftGridSizer_Items(self.LeftGridSizer)
-        self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer)
-        self._init_coll_RightGridSizer_Items(self.RightGridSizer)
-        self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
-
-        self.SetSizer(self.flexGridSizer1)
-    
-    def _init_ctrls(self, prnt, ctrler):
-        wx.Dialog.__init__(self, id=ID_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, 300))
-
-        self.staticText1 = wx.StaticText(id=ID_DIVERGENCECREATEDIALOGSTATICTEXT1,
-              label=_('Type:'), name='staticText1', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.radioButton1 = wx.RadioButton(id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON1,
-              label=_('Selection Divergence'), name='radioButton1', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP)
-        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON1)
-        self.radioButton1.SetValue(True)
-
-        self.radioButton2 = wx.RadioButton(id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON2,
-              label=_('Selection Convergence'), name='radioButton2', parent=self, 
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON2)
-        self.radioButton2.SetValue(False)
-
-        self.radioButton3 = wx.RadioButton(id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON3,
-              label=_('Simultaneous Divergence'), name='radioButton3', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON3)
-        self.radioButton3.SetValue(False)
-
-        self.radioButton4 = wx.RadioButton(id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON4,
-              label=_('Simultaneous Convergence'), name='radioButton4', parent=self, 
-              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
-        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON4)
-        self.radioButton4.SetValue(False)
-
-        self.staticText2 = wx.StaticText(id=ID_DIVERGENCECREATEDIALOGSTATICTEXT2,
-              label=_('Number of sequences:'), name='staticText2', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.Sequences = wx.SpinCtrl(id=ID_DIVERGENCECREATEDIALOGSEQUENCES,
-              name='Sequences', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 24), style=0, min=2, max=20)
-        self.Bind(wx.EVT_SPINCTRL, self.OnSequencesChanged, id=ID_DIVERGENCECREATEDIALOGSEQUENCES)
-
-        self.staticText3 = wx.StaticText(id=ID_DIVERGENCECREATEDIALOGSTATICTEXT3,
-              label=_('Preview:'), name='staticText3', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.Preview = wx.Panel(id=ID_DIVERGENCECREATEDIALOGPREVIEW,
-              name='Preview', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
-        self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
-        setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
-        setattr(self.Preview, "IsOfType", ctrler.IsOfType)
-
-        self.Spacer = wx.Panel(id=ID_TRANSITIONCONTENTDIALOGSPACER,
-              name='Spacer', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
-
-        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
-        
-        if wx.VERSION >= (2, 5, 0):
-            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
-        else:
-            wx.EVT_PAINT(self.Preview, self.OnPaint)
-        
-        self._init_sizers()
-
-    def __init__(self, parent, controler):
-        self._init_ctrls(parent, controler)
-        
-        self.Divergence = None
-        self.MinSize = (0, 0)
-    
-    def SetPreviewFont(self, font):
-        self.Preview.SetFont(font)
-    
-    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 SetMinSize(self, size):
-        self.MinSize = size
-
-    def OnTypeChanged(self, event):
-        self.RefreshPreview()
-        event.Skip()
-
-    def OnSequencesChanged(self, event):
-        self.RefreshPreview()
-        event.Skip()
-        
-    def RefreshPreview(self):
-        dc = wx.ClientDC(self.Preview)
-        dc.SetFont(self.Preview.GetFont())
-        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()
-        min_width, min_height = max(width, self.MinSize[0]), max(height, self.MinSize[1])
-        self.Divergence.SetSize(min_width, min_height)
-        clientsize = self.Preview.GetClientSize()
-        x = (clientsize.width - min_width) / 2
-        y = (clientsize.height - min_height) / 2
-        self.Divergence.SetPosition(x, y)
-        self.Divergence.Draw(dc)
-
-    def OnPaint(self, event):
-        self.RefreshPreview()
-        event.Skip()
-
-
-#-------------------------------------------------------------------------------
-#                            Action Block Dialog
-#-------------------------------------------------------------------------------
-
-def GetActionTableColnames():
-    _ = lambda x: x
-    return [_("Qualifier"), _("Duration"), _("Type"), _("Value"), _("Indicator")]
-
-def GetTypeList():
-    _ = lambda x: x
-    return [_("Action"), _("Variable"), _("Inline")]
-
-class ActionTable(wx.grid.PyGridTableBase):
-    
-    """
-    A custom wx.Grid Table using user supplied data
-    """
-    def __init__(self, parent, data, colnames):
-        # The base class must be initialized *first*
-        wx.grid.PyGridTableBase.__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, translate=True):
-        if col < len(self.colnames):
-            colname = self.colnames[col]
-            if translate:
-		return _(colname)
-	    return colname
-
-    def GetRowLabelValues(self, row, translate=True):
-        return row
-
-    def GetValue(self, row, col):
-        if row < self.GetNumberRows():
-            colname = self.GetColLabelValue(col, False)
-            name = str(self.data[row].get(colname, ""))
-            if colname == "Type":
-                return _(name)
-            return name
-    
-    def GetValueByName(self, row, colname):
-        return self.data[row].get(colname)
-
-    def SetValue(self, row, col, value):
-        if col < len(self.colnames):
-            colname = self.GetColLabelValue(col, False)
-            if colname == "Type":
-                value = self.Parent.TranslateType[value]
-            self.data[row][colname] = value
-        
-    def ResetView(self, grid):
-        """
-        (wx.Grid) -> 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(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED),
-            (self._cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED),
-        ]:
-            if new < current:
-                msg = wx.grid.GridTableMessage(self,delmsg,new,current-new)
-                grid.ProcessTableMessage(msg)
-            elif new > current:
-                msg = wx.grid.GridTableMessage(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 = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES)
-        grid.ProcessTableMessage(msg)
-
-    def _updateColAttrs(self, grid):
-        """
-        wx.Grid -> update the column attributes to add the
-        appropriate renderer given the column name.
-
-        Otherwise default to the default renderer.
-        """
-        
-        for row in range(self.GetNumberRows()):
-            for col in range(self.GetNumberCols()):
-                editor = None
-                renderer = None
-                readonly = False
-                colname = self.GetColLabelValue(col, False)
-                if colname == "Qualifier":
-                    editor = wx.grid.GridCellChoiceEditor()
-                    editor.SetParameters(self.Parent.QualifierList)
-                if colname == "Duration":
-                    editor = wx.grid.GridCellTextEditor()
-                    renderer = wx.grid.GridCellStringRenderer()
-                    if self.Parent.DurationList[self.data[row]["Qualifier"]]:
-                        readonly = False
-                    else:
-                        readonly = True
-                        self.data[row]["Duration"] = ""
-                elif colname == "Type":
-                    editor = wx.grid.GridCellChoiceEditor()
-                    editor.SetParameters(self.Parent.TypeList)
-                elif colname == "Value":
-                    type = self.data[row]["Type"]
-                    if type == "Action":
-                        editor = wx.grid.GridCellChoiceEditor()
-                        editor.SetParameters(self.Parent.ActionList)
-                    elif type == "Variable":
-                        editor = wx.grid.GridCellChoiceEditor()
-                        editor.SetParameters(self.Parent.VariableList)
-                    elif type == "Inline":
-                        editor = wx.grid.GridCellTextEditor()
-                        renderer = wx.grid.GridCellStringRenderer()
-                elif colname == "Indicator":
-                    editor = wx.grid.GridCellChoiceEditor()
-                    editor.SetParameters(self.Parent.VariableList)
-                    
-                grid.SetCellEditor(row, col, editor)
-                grid.SetCellRenderer(row, col, renderer)
-                grid.SetReadOnly(row, col, readonly)
-                
-                grid.SetCellBackgroundColour(row, col, wx.WHITE)
-    
-    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 = []
-
-[ID_ACTIONBLOCKDIALOG, ID_ACTIONBLOCKDIALOGVARIABLESGRID, 
- ID_ACTIONBLOCKDIALOGSTATICTEXT1, ID_ACTIONBLOCKDIALOGADDBUTTON,
- ID_ACTIONBLOCKDIALOGDELETEBUTTON, ID_ACTIONBLOCKDIALOGUPBUTTON, 
- ID_ACTIONBLOCKDIALOGDOWNBUTTON, 
-] = [wx.NewId() for _init_ctrls in range(7)]
-
-class ActionBlockDialog(wx.Dialog):
-    
-    if wx.VERSION < (2, 6, 0):
-        def Bind(self, event, function, id = None):
-            if id is not None:
-                event(self, id, function)
-            else:
-                event(self, function)
-    
-    def _init_coll_flexGridSizer1_Items(self, parent):
-        parent.AddSizer(self.TopSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
-        parent.AddSizer(self.GridButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT)
-        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
-        
-    def _init_coll_flexGridSizer1_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(0)
-        
-    def _init_coll_TopSizer_Items(self, parent):
-        parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.ActionsGrid, 0, border=0, flag=wx.GROW)
-    
-    def _init_coll_TopSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(1)
-
-    def _init_coll_GridButtonSizer_Items(self, parent):
-        parent.AddWindow(self.AddButton, 0, border=10, flag=wx.GROW|wx.LEFT)
-        parent.AddWindow(self.DeleteButton, 0, border=10, flag=wx.GROW|wx.LEFT)
-        parent.AddWindow(self.UpButton, 0, border=10, flag=wx.GROW|wx.LEFT)
-        parent.AddWindow(self.DownButton, 0, border=10, flag=wx.GROW|wx.LEFT)
-
-    def _init_sizers(self):
-        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
-        self.TopSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
-        self.GridButtonSizer = wx.BoxSizer(wx.HORIZONTAL)
-        
-        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
-        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
-        self._init_coll_TopSizer_Items(self.TopSizer)
-        self._init_coll_TopSizer_Growables(self.TopSizer)
-        self._init_coll_GridButtonSizer_Items(self.GridButtonSizer)
-        
-        self.SetSizer(self.flexGridSizer1)
-    
-    def _init_ctrls(self, prnt):
-        wx.Dialog.__init__(self, id=ID_ACTIONBLOCKDIALOG,
-              name='ActionBlockDialog', parent=prnt, pos=wx.Point(376, 223),
-              size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
-              title=_('Edit action block properties'))
-        self.SetClientSize(wx.Size(500, 300))
-
-        self.staticText1 = wx.StaticText(id=ID_ACTIONBLOCKDIALOGSTATICTEXT1,
-              label=_('Actions:'), name='staticText1', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
-        self.ActionsGrid = wx.grid.Grid(id=ID_ACTIONBLOCKDIALOGVARIABLESGRID,
-              name='ActionsGrid', parent=self, pos=wx.Point(0, 0), 
-              size=wx.Size(0, 0), style=wx.VSCROLL)
-        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)
-        self.ActionsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnActionsGridCellChange)
-
-        self.AddButton = wx.Button(id=ID_ACTIONBLOCKDIALOGADDBUTTON, label=_('Add'),
-              name='AddButton', parent=self, pos=wx.Point(0, 0),
-              size=wx.DefaultSize, style=0)
-        self.Bind(wx.EVT_BUTTON, self.OnAddButton, id=ID_ACTIONBLOCKDIALOGADDBUTTON)
-
-        self.DeleteButton = wx.Button(id=ID_ACTIONBLOCKDIALOGDELETEBUTTON, label=_('Delete'),
-              name='DeleteButton', parent=self, pos=wx.Point(0, 0),
-              size=wx.DefaultSize, style=0)
-        self.Bind(wx.EVT_BUTTON, self.OnDeleteButton, id=ID_ACTIONBLOCKDIALOGDELETEBUTTON)
-
-        self.UpButton = wx.Button(id=ID_ACTIONBLOCKDIALOGUPBUTTON, label='^',
-              name='UpButton', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(32, 32), style=0)
-        self.Bind(wx.EVT_BUTTON, self.OnUpButton, id=ID_ACTIONBLOCKDIALOGUPBUTTON)
-
-        self.DownButton = wx.Button(id=ID_ACTIONBLOCKDIALOGDOWNBUTTON, label='v',
-              name='DownButton', parent=self, pos=wx.Point(0, 0),
-              size=wx.Size(32, 32), style=0)
-        self.Bind(wx.EVT_BUTTON, self.OnDownButton, id=ID_ACTIONBLOCKDIALOGDOWNBUTTON)
-
-        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
-        if wx.VERSION >= (2, 5, 0):
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
-        else:
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
-        
-        self._init_sizers()
-
-    def __init__(self, parent):
-        self._init_ctrls(parent)
-        
-        self.DefaultValue = {"Qualifier" : "N", "Duration" : "", "Type" : "Action", "Value" : "", "Indicator" : ""}
-        self.Table = ActionTable(self, [], GetActionTableColnames())
-        typelist = GetTypeList()       
-        self.TypeList = ",".join(map(_,typelist))
-        self.TranslateType = dict([(_(value), value) for value in typelist])
-        self.ColSizes = [60, 90, 80, 110, 80]
-        self.ColAlignements = [wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT]
-        
-        self.ActionsGrid.SetTable(self.Table)
-        self.ActionsGrid.SetRowLabelSize(0)
-        
-        for col in range(self.Table.GetNumberCols()):
-            attr = wx.grid.GridCellAttr()
-            attr.SetAlignment(self.ColAlignements[col], wx.ALIGN_CENTRE)
-            self.ActionsGrid.SetColAttr(col, attr)
-            self.ActionsGrid.SetColMinimalWidth(col, self.ColSizes[col])
-            self.ActionsGrid.AutoSizeColumn(col, False)
-        
-        self.Table.ResetView(self.ActionsGrid)
-
-    def OnOK(self, event):
-        self.ActionsGrid.SetGridCursor(0, 0)
-        self.EndModal(wx.ID_OK)
-
-    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 = "," + ",".join(list)
-        self.DurationList = list
-
-    def SetVariableList(self, list):
-        self.VariableList = "," + ",".join([variable["Name"] for variable in list])
-        
-    def SetActionList(self, list):
-        self.ActionList = "," + ",".join(list)
-
-    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():
-            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(wx.TextEntryDialog):
-
-    if wx.VERSION < (2, 6, 0):
-        def Bind(self, event, function, id = None):
-            if id is not None:
-                event(self, id, function)
-            else:
-                event(self, function)
-    
-
-    def __init__(self, parent, message, caption = "Please enter text", defaultValue = "", 
-                       style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition):
-        wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)
-        
-        self.PouNames = []
-        self.Variables = []
-        self.StepNames = []
-        if wx.VERSION >= (2, 8, 0):
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton().GetId())
-        elif wx.VERSION >= (2, 6, 0):
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId())
-        else:
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
-    
-    def OnOK(self, event):
-        step_name = self.GetSizer().GetItem(1).GetWindow().GetValue()
-        if step_name == "":
-            message = wx.MessageDialog(self, _("You must type a name!"), _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif not TestIdentifier(step_name):
-            message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif step_name.upper() in IEC_KEYWORDS:
-            message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif step_name.upper() in self.PouNames:
-            message = wx.MessageDialog(self, _("A pou with \"%s\" as name exists!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif step_name.upper() in self.Variables:
-            message = wx.MessageDialog(self, _("A variable with \"%s\" as name already exists in this pou!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif step_name.upper() in self.StepNames:
-            message = wx.MessageDialog(self, _("\"%s\" step already exists!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        else:
-            self.EndModal(wx.ID_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]
-
-    def GetValue(self):
-        return self.GetSizer().GetItem(1).GetWindow().GetValue()
-
-#-------------------------------------------------------------------------------
-#                                POU Name Dialog
-#-------------------------------------------------------------------------------
-
-class PouNameDialog(wx.TextEntryDialog):
-
-    if wx.VERSION < (2, 6, 0):
-        def Bind(self, event, function, id = None):
-            if id is not None:
-                event(self, id, function)
-            else:
-                event(self, function)
-    
-
-    def __init__(self, parent, message, caption = "Please enter text", defaultValue = "", 
-                       style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition):
-        wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)
-        
-        self.PouNames = []
-        if wx.VERSION >= (2, 8, 0):
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton().GetId())
-        elif wx.VERSION >= (2, 6, 0):
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId())
-        else:
-            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
-    
-    def OnOK(self, event):
-        step_name = self.GetSizer().GetItem(1).GetWindow().GetValue()
-        if step_name == "":
-            message = wx.MessageDialog(self, _("You must type a name!"), _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif not TestIdentifier(step_name):
-            message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif step_name.upper() in IEC_KEYWORDS:
-            message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        elif step_name.upper() in self.PouNames:
-            message = wx.MessageDialog(self, _("A pou with \"%s\" as name exists!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-        else:
-            self.EndModal(wx.ID_OK)
-
-    def SetPouNames(self, pou_names):
-        self.PouNames = [pou_name.upper() for pou_name in pou_names]
-
-    def GetValue(self):
-        return self.GetSizer().GetItem(1).GetWindow().GetValue()