Adding support support for using PLCOpenEditor with Beremiz
authorlbessard
Mon, 10 Sep 2007 18:16:07 +0200
changeset 90 2245e8776086
parent 89 a6ff2b3fcc25
child 91 e8e9ddeed76c
Adding support support for using PLCOpenEditor with Beremiz
Modify code for wxPython 2.8.4
LDViewer.py
PLCControler.py
PLCOpenEditor.py
RessourceEditor.py
SFCViewer.py
TextViewer.py
Viewer.py
graphics/FBD_Objects.py
graphics/GraphicCommons.py
xmlclass/xmlclass.py
--- a/LDViewer.py	Mon Sep 10 16:12:29 2007 +0200
+++ b/LDViewer.py	Mon Sep 10 18:16:07 2007 +0200
@@ -448,7 +448,7 @@
 #-------------------------------------------------------------------------------
 
     def AddLadderRung(self):
-        dialog = LDElementDialog(self.Parent, "coil")
+        dialog = LDElementDialog(self.ParentWindow, "coil")
         varlist = []
         vars = self.Controler.GetCurrentElementEditingInterfaceVars()
         if vars:
@@ -537,7 +537,7 @@
                 for element in self.SelectedElement.GetElements():
                     wires.append(element)
         if len(wires) > 0:
-            dialog = LDElementDialog(self.Parent, "contact")
+            dialog = LDElementDialog(self.ParentWindow, "contact")
             varlist = []
             vars = self.Controler.GetCurrentElementEditingInterfaceVars()
             if vars:
@@ -758,7 +758,7 @@
                             new_wire.ConnectEndPoint(None, connectors[index + 1])
                         right_elements.reverse()
                     elif right_powerrail:
-                        dialog = LDElementDialog(self.Parent, "coil")
+                        dialog = LDElementDialog(self.ParentWindow, "coil")
                         varlist = []
                         vars = self.Controler.GetCurrentElementEditingInterfaceVars()
                         if vars:
@@ -1179,7 +1179,7 @@
         if self.GetDrawingMode() == FREEDRAWING_MODE:
             Viewer.EditContactContent(self, contact)
         else:
-            dialog = LDElementDialog(self.Parent, "contact")
+            dialog = LDElementDialog(self.ParentWindow, "contact")
             varlist = []
             vars = self.Controler.GetCurrentElementEditingInterfaceVars()
             if vars:
@@ -1202,7 +1202,7 @@
         if self.GetDrawingMode() == FREEDRAWING_MODE:
             Viewer.EditCoilContent(self, coil)
         else:
-            dialog = LDElementDialog(self.Parent, "coil")
+            dialog = LDElementDialog(self.ParentWindow, "coil")
             varlist = []
             vars = self.Controler.GetCurrentElementEditingInterfaceVars()
             if vars:
--- a/PLCControler.py	Mon Sep 10 16:12:29 2007 +0200
+++ b/PLCControler.py	Mon Sep 10 18:16:07 2007 +0200
@@ -1213,6 +1213,7 @@
                 infos["connectors"] = {"inputs":[],"outputs":[]}
                 for variable in instance.inputVariables.getVariable():
                     connector = {}
+                    connector["name"] = variable.getFormalParameter()
                     connector["position"] = variable.connectionPointIn.getRelPosition()
                     connector["negated"] = variable.getNegated()
                     connector["edge"] = variable.getConnectorEdge()
@@ -1225,6 +1226,7 @@
                     infos["connectors"]["inputs"].append(connector)
                 for variable in instance.outputVariables.getVariable():
                     connector = {}
+                    connector["name"] = variable.getFormalParameter()
                     connector["position"] = variable.connectionPointOut.getRelPosition()
                     connector["negated"] = variable.getNegated()
                     connector["edge"] = variable.getConnectorEdge()
--- a/PLCOpenEditor.py	Mon Sep 10 16:12:29 2007 +0200
+++ b/PLCOpenEditor.py	Mon Sep 10 18:16:07 2007 +0200
@@ -346,6 +346,10 @@
         self.SetClientSize(wx.Size(1000, 600))
         self.SetMenuBar(self.menuBar1)
         self.Bind(wx.EVT_CLOSE, self.OnCloseFrame, id=ID_PLCOPENEDITOR)
+        if not self.ModeSolo:
+            self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=ID_PLCOPENEDITORFILEMENUITEMS5)
+            accel = wx.AcceleratorTable([wx.AcceleratorEntry(wx.ACCEL_CTRL, 83, ID_PLCOPENEDITORFILEMENUITEMS5)])
+            self.SetAcceleratorTable(accel)
         
         self.MainSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORMAINSPLITTER,
               name='MainSplitter', parent=self, point=wx.Point(0, 0),
@@ -365,7 +369,7 @@
 
         self.ToolBar = wx.ToolBar(id=ID_PLCOPENEDITORTOOLBAR, name='ToolBar',
               parent=self.EditorPanel, pos=wx.Point(0, 0), size=wx.Size(0, 40),
-              style=wx.TB_HORIZONTAL | wx.NO_BORDER)
+              style=wx.TB_HORIZONTAL|wx.NO_BORDER)
         self.ToolBar.AddRadioTool(ID_PLCOPENEDITORTOOLBARSELECTION, 
               wx.Bitmap(os.path.join(CWD, 'Images/select.png')), wx.NullBitmap, "Select an object")
         self.Bind(wx.EVT_TOOL, self.OnSelectionTool, 
@@ -496,7 +500,10 @@
         dialog.Destroy()
 
     def OnCloseFrame(self, event):
-        if not self.Controler.ProjectIsSaved():
+        if not self.ModeSolo and getattr(self, "_onclose", None) != None:
+            self._onclose()
+            event.Skip()
+        elif not self.Controler.ProjectIsSaved():
             dialog = wx.MessageDialog(self, "There are changes, do you want to save?", "Close Application", wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
             answer = dialog.ShowModal()
             dialog.Destroy()
@@ -570,7 +577,10 @@
         event.Skip()
 
     def OnSaveProjectMenu(self, event):
-        self.SaveProject()
+        if not self.ModeSolo and getattr(self, "_onsave", None) != None:
+            self._onsave()
+        else:
+            self.SaveProject()
         event.Skip()
 
     def OnSaveProjectAsMenu(self, event):
@@ -1015,26 +1025,25 @@
     def RefreshProjectTree(self):
         infos = self.Controler.GetProjectInfos()
         root = self.ProjectTree.GetRootItem()
+        if not root.IsOk():
+            root = self.ProjectTree.AddRoot(infos["name"])
         self.GenerateTreeBranch(root, infos)
         self.ProjectTree.Expand(self.ProjectTree.GetRootItem())
 
     def GenerateTreeBranch(self, root, infos):
         to_delete = []
-        if root.IsOk():
-            self.ProjectTree.SetItemText(root, infos["name"])
-        else:
-            root = self.ProjectTree.AddRoot(infos["name"])
+        self.ProjectTree.SetItemText(root, infos["name"])
         self.ProjectTree.SetPyData(root, infos["type"])
         if infos["type"] == ITEM_POU:
             self.ProjectTree.SetItemImage(root, LANGUAGES.index(self.Controler.GetPouBodyType(infos["name"])))
         item, root_cookie = self.ProjectTree.GetFirstChild(root)
-        if len(infos["values"]) > 0:
-            for values in infos["values"]:
-                if not item.IsOk():
-                    item = self.ProjectTree.AppendItem(root, "")
+        for values in infos["values"]:
+            if not item.IsOk():
+                item = self.ProjectTree.AppendItem(root, "")
+                if wx.VERSION < (2, 7, 0):
                     item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
-                self.GenerateTreeBranch(item, values)
-                item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
+            self.GenerateTreeBranch(item, values)
+            item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
         while item.IsOk():
             to_delete.append(item)
             item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
@@ -2187,20 +2196,20 @@
     
     def __init__(self, parent):
         wx.TextDropTarget.__init__(self)
-        self.Parent = parent
+        self.ParentWindow = parent
     
     def OnDropText(self, x, y, data):
-        col = self.Parent.VariablesGrid.XToCol(x)
-        row = self.Parent.VariablesGrid.YToRow(y)
+        col = self.ParentWindow.VariablesGrid.XToCol(x)
+        row = self.ParentWindow.VariablesGrid.YToRow(y)
         if col != wx.NOT_FOUND and row != wx.NOT_FOUND:
-            if self.Parent.Table.GetColLabelValue(col) != "Location":
+            if self.ParentWindow.Table.GetColLabelValue(col) != "Location":
                 return
             try:
                 values = eval(data)    
             except:
                 values = None
             if values and values[1] == "location":
-                dialog = wx.SingleChoiceDialog(self.Parent, "Select a variable class:", "Variable class", ["Input", "Output", "Memory"], wx.OK|wx.CANCEL)
+                dialog = wx.SingleChoiceDialog(self.ParentWindow, "Select a variable class:", "Variable class", ["Input", "Output", "Memory"], wx.OK|wx.CANCEL)
                 if dialog.ShowModal() == wx.ID_OK:
                     selected = dialog.GetSelection()
                     if selected == 0:
@@ -2209,9 +2218,9 @@
                         location = "%Q" + values[0]
                     else:
                         location = "%M" + values[0]
-                    self.Parent.Table.SetValue(row - 1, col, location)
-                    self.Parent.Table.ResetView(self.Parent.VariablesGrid)
-                    self.Parent.SaveValues()
+                    self.ParentWindow.Table.SetValue(row - 1, col, location)
+                    self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid)
+                    self.ParentWindow.SaveValues()
                 dialog.Destroy()    
 
 [ID_POUEDITORPANEL, ID_POUEDITORPANELVIEWER, 
@@ -2290,15 +2299,15 @@
             self.Viewer.ResetBuffer = lambda: None
             self.Viewer.RefreshView = lambda: None
         elif element_type == "resource":
-            self.Viewer = ResourceEditor(self, self.Parent, self.Controler)
+            self.Viewer = ResourceEditor(self, self.ParentWindow, self.Controler)
         elif element_type == "FBD":
-            self.Viewer = Viewer(self, self.Parent, self.Controler)
+            self.Viewer = Viewer(self, self.ParentWindow, self.Controler)
         elif element_type == "LD":
-            self.Viewer = LD_Viewer(self, self.Parent, self.Controler)
+            self.Viewer = LD_Viewer(self, self.ParentWindow, self.Controler)
         elif element_type == "SFC":
-            self.Viewer = SFC_Viewer(self, self.Parent, self.Controler)
+            self.Viewer = SFC_Viewer(self, self.ParentWindow, self.Controler)
         else:
-            self.Viewer = TextViewer(self, self.Parent, self.Controler)
+            self.Viewer = TextViewer(self, self.ParentWindow, self.Controler)
             self.Viewer.SetTextSyntax(element_type)
             if element_type == "IL":
                 self.Viewer.SetKeywords(IL_KEYWORDS)
@@ -2365,7 +2374,7 @@
         self._init_sizers()
 
     def __init__(self, parent, window, controler, element_type, pou_name = None, transition_name = None, action_name = None, config_name = None, resource_name = None):
-        self.Parent = window
+        self.ParentWindow = window
         self.Controler = controler
         self.ElementType = element_type
         self.PouName = pou_name
@@ -2496,8 +2505,8 @@
     def OnReturnTypeChanged(self, event):
         self.Controler.SetPouInterfaceReturnType(self.PouName, self.ReturnType.GetStringSelection())
         self.Controler.BufferProject()
-        self.Parent.RefreshTitle()
-        self.Parent.RefreshEditMenu()
+        self.ParentWindow.RefreshTitle()
+        self.ParentWindow.RefreshEditMenu()
         event.Skip()
     
     def OnClassFilter(self, event):
@@ -2590,8 +2599,8 @@
                 if old_value != "":
                     self.Controler.UpdateCurrentPouEditingUsedVariable(old_value, value)
                 self.Controler.BufferProject()
-                self.Parent.RefreshTitle()
-                self.Parent.RefreshEditMenu()
+                self.ParentWindow.RefreshTitle()
+                self.ParentWindow.RefreshEditMenu()
                 self.RefreshViewerVarList()
                 self.Viewer.RefreshView()
                 event.Skip()
@@ -2690,8 +2699,8 @@
             self.Controler.SetPouInterfaceVars(self.PouName, self.Values)
         if buffer:
             self.Controler.BufferProject()
-            self.Parent.RefreshTitle()
-            self.Parent.RefreshEditMenu()
+            self.ParentWindow.RefreshTitle()
+            self.ParentWindow.RefreshEditMenu()
 
 #-------------------------------------------------------------------------------
 #                               Exception Handler
--- a/RessourceEditor.py	Mon Sep 10 16:12:29 2007 +0200
+++ b/RessourceEditor.py	Mon Sep 10 18:16:07 2007 +0200
@@ -351,7 +351,7 @@
     def __init__(self, parent, window, controler):
         self._init_ctrls(parent)
         
-        self.Parent = window
+        self.ParentWindow = window
         self.Controler = controler
         
         self.TasksDefaultValue = {"Name" : "", "Single" : "", "Interval" : "", "Priority" : 0}
@@ -399,8 +399,8 @@
     # Buffer the last model state
     def RefreshBuffer(self):
         self.Controler.BufferProject()
-        self.Parent.RefreshTitle()
-        self.Parent.RefreshEditMenu()
+        self.ParentWindow.RefreshTitle()
+        self.ParentWindow.RefreshEditMenu()
 
     def RefreshView(self):
         tasks, instances = self.Controler.GetCurrentResourceEditingInfos()
--- a/SFCViewer.py	Mon Sep 10 16:12:29 2007 +0200
+++ b/SFCViewer.py	Mon Sep 10 18:16:07 2007 +0200
@@ -369,7 +369,7 @@
 #-------------------------------------------------------------------------------
 
     def AddInitialStep(self, pos):
-        dialog = StepNameDialog(self.Parent, "Add a new initial step", "Please enter step name", "", wx.OK|wx.CANCEL)
+        dialog = StepNameDialog(self.ParentWindow, "Add a new initial step", "Please enter step name", "", wx.OK|wx.CANCEL)
         dialog.SetPouNames(self.Controler.GetProjectPouNames())
         dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
         dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
@@ -391,7 +391,7 @@
 
     def AddStep(self):
         if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, SFC_Step):
-            dialog = StepNameDialog(self.Parent, "Add a new step", "Please enter step name", "", wx.OK|wx.CANCEL)
+            dialog = StepNameDialog(self.ParentWindow, "Add a new step", "Please enter step name", "", wx.OK|wx.CANCEL)
             dialog.SetPouNames(self.Controler.GetProjectPouNames())
             dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
@@ -447,7 +447,7 @@
         if isinstance(self.SelectedElement, SFC_Step):
             connectors = self.SelectedElement.GetConnectors()
             if not connectors["action"]:
-                dialog = ActionBlockDialog(self.Parent)
+                dialog = ActionBlockDialog(self.ParentWindow)
                 dialog.SetQualifierList(self.Controler.GetQualifierTypes())
                 dialog.SetActionList(self.Controler.GetCurrentElementEditingActions())
                 dialog.SetVariableList(self.Controler.GetCurrentElementEditingInterfaceVars())
@@ -474,7 +474,7 @@
     
     def AddDivergence(self):
         if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, Graphic_Group) or isinstance(self.SelectedElement, SFC_Step):        
-            dialog = DivergenceCreateDialog(self.Parent)
+            dialog = DivergenceCreateDialog(self.ParentWindow)
             if dialog.ShowModal() == wx.ID_OK:
                 value = dialog.GetValues()
                 if value["type"] == SELECTION_DIVERGENCE:
@@ -702,7 +702,7 @@
             for block in self.Blocks:
                 if isinstance(block, SFC_Step):
                     choices.append(block.GetName())
-            dialog = wx.SingleChoiceDialog(self.Parent, "Add a new jump", "Please choose a target", choices, wx.OK|wx.CANCEL)
+            dialog = wx.SingleChoiceDialog(self.ParentWindow, "Add a new jump", "Please choose a target", choices, wx.OK|wx.CANCEL)
             if dialog.ShowModal() == wx.ID_OK:
                 value = dialog.GetStringSelection()
                 self.SelectedElement.AddOutput()
@@ -730,7 +730,7 @@
         if self.GetDrawingMode() == FREEDRAWING_MODE:
             Viewer.EditStepContent(self, step)
         else:
-            dialog = StepNameDialog(self.Parent, "Edit step name", "Please enter step name", step.GetName(), wx.OK|wx.CANCEL)
+            dialog = StepNameDialog(self.ParentWindow, "Edit step name", "Please enter step name", step.GetName(), wx.OK|wx.CANCEL)
             dialog.SetPouNames(self.Controler.GetProjectPouNames())
             dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()])
--- a/TextViewer.py	Mon Sep 10 16:12:29 2007 +0200
+++ b/TextViewer.py	Mon Sep 10 18:16:07 2007 +0200
@@ -118,7 +118,10 @@
         
         # Indicators styles
         self.IndicatorSetStyle(0, wx.stc.STC_INDIC_SQUIGGLE)
-        self.IndicatorSetForeground(0, wx.RED)
+        if window and controler:
+            self.IndicatorSetForeground(0, wx.RED)
+        else:
+            self.IndicatorSetForeground(0, wx.WHITE)
         
         # Line numbers in the margin
         self.SetMarginType(1, wx.stc.STC_MARGIN_NUMBER)
@@ -137,13 +140,13 @@
         self.TextSyntax = "ST"
         self.CurrentAction = None
         
-        self.Parent = window
+        self.ParentWindow = window
         self.Controler = controler
 
         self.SetModEventMask(wx.stc.STC_MOD_BEFOREINSERT|wx.stc.STC_MOD_BEFOREDELETE)
 
         self.Bind(wx.stc.EVT_STC_STYLENEEDED, self.OnStyleNeeded, id=ID_TEXTVIEWER)
-        if window and controler :
+        if window and controler:
             self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
             self.Bind(wx.stc.EVT_STC_DO_DROP, self.OnDoDrop, id=ID_TEXTVIEWER)
             self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
@@ -207,13 +210,13 @@
     # Buffer the last model state
     def RefreshBuffer(self):
         self.Controler.BufferProject()
-        self.Parent.RefreshTitle()
-        self.Parent.RefreshEditMenu()
+        self.ParentWindow.RefreshTitle()
+        self.ParentWindow.RefreshEditMenu()
     
     def StartBuffering(self):
         self.Controler.StartBuffering()
-        self.Parent.RefreshTitle()
-        self.Parent.RefreshEditMenu()
+        self.ParentWindow.RefreshTitle()
+        self.ParentWindow.RefreshEditMenu()
     
     def ResetBuffer(self):
         if self.CurrentAction != None:
--- a/Viewer.py	Mon Sep 10 16:12:29 2007 +0200
+++ b/Viewer.py	Mon Sep 10 18:16:07 2007 +0200
@@ -49,38 +49,38 @@
     
     def __init__(self, parent):
         wx.TextDropTarget.__init__(self)
-        self.Parent = parent
+        self.ParentWindow = parent
     
     def OnDropText(self, x, y, data):
         values = eval(data)
         if values[1] in ["function", "functionBlock", "program"]:
-            id = self.Parent.GetNewId()
-            block = FBD_Block(self.Parent, values[0], values[2], id)
+            id = self.ParentWindow.GetNewId()
+            block = FBD_Block(self.ParentWindow, values[0], values[2], id)
             block.SetPosition(x, y)
             width, height = block.GetMinSize()
             block.SetSize(width, height)
-            self.Parent.AddBlock(block)
-            self.Parent.Controler.AddCurrentElementEditingBlock(id)
-            self.Parent.RefreshBlockModel(block)
-            self.Parent.RefreshScrollBars()
-            self.Parent.Refresh()
+            self.ParentWindow.AddBlock(block)
+            self.ParentWindow.Controler.AddCurrentElementEditingBlock(id)
+            self.ParentWindow.RefreshBlockModel(block)
+            self.ParentWindow.RefreshScrollBars()
+            self.ParentWindow.Update()
         elif values[1] != "location":
-            id = self.Parent.GetNewId()
+            id = self.ParentWindow.GetNewId()
             if values[1] == "Output":
                 var_type = OUTPUT
             elif values[1] == "InOut":
                 var_type = INPUT
             else:
                 var_type = INPUT
-            variable = FBD_Variable(self.Parent, var_type, values[0], values[2], id)
+            variable = FBD_Variable(self.ParentWindow, var_type, values[0], values[2], id)
             variable.SetPosition(x, y)
             width, height = variable.GetMinSize()
             variable.SetSize(width, height)
-            self.Parent.AddBlock(variable)
-            self.Parent.Controler.AddCurrentElementEditingVariable(id, var_type)
-            self.Parent.RefreshVariableModel(variable)
-            self.Parent.RefreshScrollBars()
-            self.Parent.Refresh()
+            self.ParentWindow.AddBlock(variable)
+            self.ParentWindow.Controler.AddCurrentElementEditingVariable(id, var_type)
+            self.ParentWindow.RefreshVariableModel(variable)
+            self.ParentWindow.RefreshScrollBars()
+            self.ParentWindow.Update()
             
 
 """
@@ -161,7 +161,7 @@
         self.Mode = MODE_SELECTION
         self.SavedMode = False
         
-        self.Parent = window
+        self.ParentWindow = window
         self.Controler = controler
         
         self.SetDropTarget(ViewerDropTarget(self))
@@ -174,8 +174,9 @@
         self.Bind(wx.EVT_RIGHT_UP, self.OnViewerRightUp)
         self.Bind(wx.EVT_MOTION, self.OnViewerMotion)
         self.Bind(wx.EVT_CHAR, self.OnChar)
-        self.Bind(wx.EVT_SCROLLWIN, self.OnMoveWindow)
-        self.Bind(wx.EVT_SIZE, self.OnMoveWindow)
+        if wx.VERSION < (2, 7, 0):
+            self.Bind(wx.EVT_SCROLLWIN, self.OnMoveWindow)
+            self.Bind(wx.EVT_SIZE, self.OnMoveWindow)
     
     # Returns a new id
     def GetNewId(self):
@@ -186,8 +187,12 @@
     def __del__(self):
         self.ResetView()
 
-    def GetLogicalDC(self):
-        dc = wx.ClientDC(self)
+    def GetLogicalDC(self, buffered=False):
+        if buffered:
+            dc = wx.BufferedPaintDC(self)
+        else:
+            dc = wx.ClientDC(self)
+        dc.SetFont(wx.NORMAL_FONT)
         self.DoPrepareDC(dc)
         return dc
 
@@ -265,17 +270,17 @@
         if self.Mode != MODE_SELECTION and self.SelectedElement:
             self.SelectedElement.SetSelected(False)
             self.SelectedElement = None
-            self.Refresh()
+            self.Refresh(False)
     
     # Return current drawing mode
     def GetDrawingMode(self):
-        return self.Parent.GetDrawingMode()
+        return self.ParentWindow.GetDrawingMode()
     
     # Buffer the last model state
     def RefreshBuffer(self):
         self.Controler.BufferProject()
-        self.Parent.RefreshTitle()
-        self.Parent.RefreshEditMenu()
+        self.ParentWindow.RefreshTitle()
+        self.ParentWindow.RefreshEditMenu()
 
 #-------------------------------------------------------------------------------
 #                          Refresh functions
@@ -298,7 +303,7 @@
             if instance:
                 self.loadInstance(instance, ids)
         self.RefreshScrollBars()
-        self.Refresh()
+        self.Refresh(False)
     
     def RefreshScrollBars(self):
         xstart, ystart = self.GetViewStart()
@@ -518,10 +523,25 @@
             connector.SetPosition(wx.Point(*instance["connector"]["position"]))
             self.CreateWires(connector, instance["connector"]["links"], ids)
         else:
+            connectors = {"inputs" : [], "outputs" : []}
+            for input in instance["connectors"]["inputs"]:
+                if input["negated"]:
+                    connectors["inputs"].append((input["name"], None, "negated"))
+                elif input["edge"]:
+                    connectors["inputs"].append((input["name"], None, input["edge"]))
+                else:
+                    connectors["inputs"].append((input["name"], None, "none"))
+            for output in instance["connectors"]["outputs"]:
+                if output["negated"]:
+                    connectors["outputs"].append((output["name"], None, "negated"))
+                elif output["edge"]:
+                    connectors["outputs"].append((output["name"], None, output["edge"]))
+                else:
+                    connectors["outputs"].append((output["name"], None, "none"))
             if instance["name"] != None:
-                block = FBD_Block(self, instance["type"], instance["name"], instance["id"], len(instance["connectors"]["inputs"]))
-            else:
-                block = FBD_Block(self, instance["type"], "", instance["id"], len(instance["connectors"]["inputs"]))
+                block = FBD_Block(self, instance["type"], instance["name"], instance["id"], len(instance["connectors"]["inputs"]), connectors=connectors)
+            else:
+                block = FBD_Block(self, instance["type"], "", instance["id"], len(instance["connectors"]["inputs"]), connectors=connectors)
             block.SetPosition(instance["x"], instance["y"])
             block.SetSize(instance["width"], instance["height"])
             self.AddBlock(block)
@@ -685,17 +705,6 @@
         self.ContextualMenu.FindItemByPosition(9).Enable(False)
         self.PopupMenu(self.ContextualMenu)
 
-    def EditCommentContent(self, comment):
-        dialog = wx.TextEntryDialog(self.Parent, "Edit comment", "Please enter comment text", comment.GetContent(), wx.OK|wx.CANCEL|wx.TE_MULTILINE)
-        if dialog.ShowModal() == wx.ID_OK:
-            value = dialog.GetValue()
-            comment.SetContent(value)
-            infos = {"content" : value}
-            infos["width"], infos["height"] = comment.GetSize()
-            self.Controler.SetCurrentElementEditingCommentInfos(comment.GetId(), infos)
-            self.Refresh()
-        dialog.Destroy()
-
 #-------------------------------------------------------------------------------
 #                            Menu items functions
 #-------------------------------------------------------------------------------
@@ -783,11 +792,11 @@
                 if self.SelectedElement and self.SelectedElement != element:
                     self.SelectedElement.SetSelected(False)
                     self.SelectedElement = None
-                    self.Refresh()
+                    self.Refresh(False)
                 if element:
                     self.SelectedElement = element
                     self.SelectedElement.OnLeftDown(event, dc, self.Scaling)
-                    self.Refresh()
+                    self.Refresh(False)
                 else:
                     self.rubberBand.Reset()
                     self.rubberBand.OnLeftDown(event, dc, self.Scaling)
@@ -815,7 +824,7 @@
             elif self.SelectedElement:
                 self.SelectedElement.SetSelected(False)
                 self.SelectedElement = None
-            self.Refresh()
+            self.Refresh(False)
         event.Skip()
 
     def OnViewerLeftUp(self, event):
@@ -826,12 +835,12 @@
                 if len(elements) == 1:
                     self.SelectedElement = elements[0]
                     self.SelectedElement.SetSelected(True)
-                    self.Refresh()
+                    self.Refresh(False)
                 elif len(elements) > 1:
                     self.SelectedElement = Graphic_Group(self)
                     self.SelectedElement.SetElements(elements)
                     self.SelectedElement.SetSelected(True)
-                    self.Refresh()
+                    self.Refresh(False)
             else:
                 bbox = self.rubberBand.GetCurrentExtent()
                 self.rubberBand.OnLeftUp(event, self.GetLogicalDC(), self.Scaling)                
@@ -864,8 +873,7 @@
         elif self.Mode == MODE_SELECTION and self.SelectedElement:
             self.SelectedElement.OnLeftUp(event, self.GetLogicalDC(), self.Scaling)
             wx.CallAfter(self.SetCursor, wx.NullCursor)
-            self.ReleaseMouse()
-            self.Refresh()
+            self.Refresh(False)
         elif self.Mode == MODE_WIRE and self.SelectedElement:
             if self.SelectedElement.EndConnected != None:
                 self.SelectedElement.ResetPoints()
@@ -877,9 +885,9 @@
             else:
                 self.SelectedElement.Delete()
                 self.SelectedElement = None
-            self.Refresh()
+            self.Refresh(False)
         if not self.SavedMode:
-            wx.CallAfter(self.Parent.ResetCurrentMode)
+            wx.CallAfter(self.ParentWindow.ResetCurrentMode)
         event.Skip()
     
     def OnViewerRightUp(self, event):
@@ -894,21 +902,21 @@
             self.SelectedElement.OnRightUp(event, self.GetLogicalDC(), self.Scaling)
             wx.CallAfter(self.SetCursor, wx.NullCursor)
             self.ReleaseMouse()
-            self.Refresh()
+            self.Refresh(False)
         event.Skip()
     
     def OnViewerLeftDClick(self, event):
         if self.Mode == MODE_SELECTION and self.SelectedElement:
             self.SelectedElement.OnLeftDClick(event, self.GetLogicalDC(), self.Scaling)
-            self.Refresh()
+            self.Refresh(False)
         event.Skip()
     
     def OnViewerMotion(self, event):
         if self.rubberBand.IsShown():
             self.rubberBand.OnMotion(event, self.GetLogicalDC(), self.Scaling)
         elif self.Mode == MODE_SELECTION and self.SelectedElement:
-            self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling)
-            self.Refresh()
+            if self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling):
+                self.Refresh(False)
         elif self.Mode == MODE_WIRE and self.SelectedElement:
             dc = self.GetLogicalDC()
             pos = GetScaledEventPosition(event, dc, self.Scaling)
@@ -917,7 +925,7 @@
                 self.SelectedElement.ResetPoints()
                 self.SelectedElement.OnMotion(event, dc, self.Scaling)
                 self.SelectedElement.GeneratePoints()
-                self.Refresh()
+                self.Refresh(False)
         event.Skip()
 
     def UpdateScrollPos(self, event):
@@ -957,7 +965,7 @@
             self.SelectedElement = None
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         elif keycode == wx.WXK_LEFT:
             if event.ControlDown() and event.ShiftDown():
                 self.Scroll(0, ypos)
@@ -968,7 +976,7 @@
                 self.SelectedElement.RefreshModel()
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.Refresh()
+                self.Refresh(False)
         elif keycode == wx.WXK_RIGHT:
             if event.ControlDown() and event.ShiftDown():
                 self.Scroll(xmax, ypos)
@@ -979,7 +987,7 @@
                 self.SelectedElement.RefreshModel()
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.Refresh()
+                self.Refresh(False)
         elif keycode == wx.WXK_UP:
             if event.ControlDown() and event.ShiftDown():
                 self.Scroll(xpos, 0)
@@ -990,7 +998,7 @@
                 self.SelectedElement.RefreshModel()
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.Refresh()
+                self.Refresh(False)
         elif keycode == wx.WXK_DOWN:
             if event.ControlDown() and event.ShiftDown():
                 self.Scroll(xpos, ymax)
@@ -1001,14 +1009,14 @@
                 self.SelectedElement.RefreshModel()
                 self.RefreshBuffer()
                 self.RefreshScrollBars()
-                self.Refresh()
+                self.Refresh(False)
 
 #-------------------------------------------------------------------------------
 #                          Model adding functions
 #-------------------------------------------------------------------------------
 
     def AddNewBlock(self, bbox):
-        dialog = BlockPropertiesDialog(self.Parent)
+        dialog = BlockPropertiesDialog(self.ParentWindow)
         dialog.SetBlockList(self.Controler.GetBlockTypes())
         dialog.SetPouNames(self.Controler.GetProjectPouNames())
         dialog.SetPouElementNames(self.Controler.GetCurrentElementEditingVariables())
@@ -1027,12 +1035,12 @@
             self.RefreshBlockModel(block)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Parent.RefreshEditor()
-            self.Refresh()
+            self.ParentWindow.RefreshEditor()
+            self.Refresh(False)
         dialog.Destroy()
     
     def AddNewVariable(self, bbox):
-        dialog = VariablePropertiesDialog(self.Parent)
+        dialog = VariablePropertiesDialog(self.ParentWindow)
         dialog.SetMinVariableSize((bbox.width, bbox.height))
         varlist = []
         vars = self.Controler.GetCurrentElementEditingInterfaceVars()
@@ -1055,11 +1063,11 @@
             self.RefreshVariableModel(variable)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
     def AddNewConnection(self, bbox):
-        dialog = ConnectionPropertiesDialog(self.Parent)
+        dialog = ConnectionPropertiesDialog(self.ParentWindow)
         dialog.SetMinConnectionSize((bbox.width, bbox.height))
         if dialog.ShowModal() == wx.ID_OK:
             id = self.GetNewId()
@@ -1072,11 +1080,11 @@
             self.RefreshConnectionModel(connection)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
     def AddNewComment(self, bbox):
-        dialog = wx.TextEntryDialog(self.Parent, "Add a new comment", "Please enter comment text", "", wx.OK|wx.CANCEL|wx.TE_MULTILINE)
+        dialog = wx.TextEntryDialog(self.ParentWindow, "Add a new comment", "Please enter comment text", "", wx.OK|wx.CANCEL|wx.TE_MULTILINE)
         if dialog.ShowModal() == wx.ID_OK:
             value = dialog.GetValue()
             id = self.GetNewId()
@@ -1089,11 +1097,11 @@
             self.RefreshCommentModel(comment)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
     def AddNewContact(self, bbox):
-        dialog = LDElementDialog(self.Parent, "contact")
+        dialog = LDElementDialog(self.ParentWindow, "contact")
         varlist = []
         vars = self.Controler.GetCurrentElementEditingInterfaceVars()
         if vars:
@@ -1114,11 +1122,11 @@
             self.RefreshContactModel(contact)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
     def AddNewCoil(self, bbox):
-        dialog = LDElementDialog(self.Parent, "coil")
+        dialog = LDElementDialog(self.ParentWindow, "coil")
         varlist = []
         vars = self.Controler.GetCurrentElementEditingInterfaceVars()
         if vars:
@@ -1142,11 +1150,11 @@
             self.RefreshCoilModel(coil)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
     def AddNewPowerRail(self, bbox):
-        dialog = LDPowerRailDialog(self.Parent)
+        dialog = LDPowerRailDialog(self.ParentWindow)
         dialog.SetMinSize((bbox.width, bbox.height))
         if dialog.ShowModal() == wx.ID_OK:
             id = self.GetNewId()
@@ -1159,11 +1167,11 @@
             self.RefreshPowerRailModel(powerrail)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
     def AddNewStep(self, bbox, initial = False):
-        dialog = StepContentDialog(self.Parent, initial)
+        dialog = StepContentDialog(self.ParentWindow, initial)
         dialog.SetPouNames(self.Controler.GetProjectPouNames())
         dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
         dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
@@ -1192,11 +1200,11 @@
             self.RefreshStepModel(step)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
     def AddNewTransition(self, bbox):
-        dialog = TransitionContentDialog(self.Parent, self.GetDrawingMode() == FREEDRAWING_MODE)
+        dialog = TransitionContentDialog(self.ParentWindow, self.GetDrawingMode() == FREEDRAWING_MODE)
         dialog.SetTransitions(self.Controler.GetCurrentElementEditingTransitions())
         if dialog.ShowModal() == wx.ID_OK:
             id = self.GetNewId()
@@ -1210,11 +1218,11 @@
             self.RefreshTransitionModel(transition)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
     def AddNewDivergence(self, bbox):
-        dialog = DivergenceCreateDialog(self.Parent)
+        dialog = DivergenceCreateDialog(self.ParentWindow)
         dialog.SetMinSize((bbox.width, bbox.height))
         if dialog.ShowModal() == wx.ID_OK:
             id = self.GetNewId()
@@ -1228,7 +1236,7 @@
             self.RefreshDivergenceModel(divergence)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
 
@@ -1237,7 +1245,7 @@
 #-------------------------------------------------------------------------------
 
     def EditBlockContent(self, block):
-        dialog = BlockPropertiesDialog(self.Parent)
+        dialog = BlockPropertiesDialog(self.ParentWindow)
         dialog.SetBlockList(self.Controler.GetBlockTypes())
         dialog.SetPouNames(self.Controler.GetProjectPouNames())
         dialog.SetPouElementNames(self.Controler.GetCurrentElementEditingVariables())
@@ -1254,11 +1262,11 @@
             self.RefreshBlockModel(block)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
     def EditVariableContent(self, variable):
-        dialog = VariablePropertiesDialog(self.Parent)
+        dialog = VariablePropertiesDialog(self.ParentWindow)
         dialog.SetMinVariableSize(variable.GetSize())
         varlist = []
         vars = self.Controler.GetCurrentElementEditingInterfaceVars()
@@ -1285,11 +1293,11 @@
             self.RefreshVariableModel(variable)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
     def EditConnectionContent(self, connection):
-        dialog = ConnectionPropertiesDialog(self.Parent)
+        dialog = ConnectionPropertiesDialog(self.ParentWindow)
         dialog.SetMinConnectionSize(connection.GetSize())
         values = {"name" : connection.GetName(), "type" : connection.GetType()}
         dialog.SetValues(values)
@@ -1306,11 +1314,11 @@
             self.RefreshConnectionModel(connection)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
     def EditContactContent(self, contact):
-        dialog = LDElementDialog(self.Parent, "contact")
+        dialog = LDElementDialog(self.ParentWindow, "contact")
         varlist = []
         vars = self.Controler.GetCurrentElementEditingInterfaceVars()
         if vars:
@@ -1329,11 +1337,11 @@
             self.RefreshContactModel(contact)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
     def EditCoilContent(self, coil):
-        dialog = LDElementDialog(self.Parent, "coil")
+        dialog = LDElementDialog(self.ParentWindow, "coil")
         varlist = []
         vars = self.Controler.GetCurrentElementEditingInterfaceVars()
         if vars:
@@ -1355,11 +1363,11 @@
             self.RefreshCoilModel(coil)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
     def EditPowerRailContent(self, powerrail):
-        dialog = LDPowerRailDialog(self.Parent, powerrail.GetType(), len(powerrail.GetConnectors()))
+        dialog = LDPowerRailDialog(self.ParentWindow, powerrail.GetType(), len(powerrail.GetConnectors()))
         dialog.SetMinSize(powerrail.GetSize())
         if dialog.ShowModal() == wx.ID_OK:
             old_type = powerrail.GetType()
@@ -1373,11 +1381,11 @@
             self.RefreshPowerRailModel(powerrail)
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
     def EditStepContent(self, step):
-        dialog = StepContentDialog(self.Parent, step.GetInitial())
+        dialog = StepContentDialog(self.ParentWindow, step.GetInitial())
         dialog.SetPouNames(self.Controler.GetProjectPouNames())
         dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
         dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()])
@@ -1407,10 +1415,10 @@
             step.RefreshModel()
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         
     def EditTransitionContent(self, transition):
-        dialog = TransitionContentDialog(self.Parent, self.GetDrawingMode() == FREEDRAWING_MODE)
+        dialog = TransitionContentDialog(self.ParentWindow, self.GetDrawingMode() == FREEDRAWING_MODE)
         dialog.SetTransitions(self.Controler.GetCurrentElementEditingTransitions())
         dialog.SetValues({"type":transition.GetType(),"value":transition.GetCondition(), "priority":transition.GetPriority()})
         dialog.SetElementSize(transition.GetSize())
@@ -1421,7 +1429,7 @@
             transition.RefreshModel()
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
     def EditJumpContent(self, jump):
@@ -1429,7 +1437,7 @@
         for block in self.Blocks:
             if isinstance(block, SFC_Step):
                 choices.append(block.GetName())
-        dialog = wx.SingleChoiceDialog(self.Parent, "Edit jump target", "Please choose a target", choices, wx.OK|wx.CANCEL)
+        dialog = wx.SingleChoiceDialog(self.ParentWindow, "Edit jump target", "Please choose a target", choices, wx.OK|wx.CANCEL)
         dialog.SetSelection(choices.index(jump.GetTarget()))
         if dialog.ShowModal() == wx.ID_OK:
             value = dialog.GetStringSelection()
@@ -1437,11 +1445,11 @@
             jump.RefreshModel()
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
         dialog.Destroy()
 
     def EditActionBlockContent(self, actionblock):
-        dialog = ActionBlockDialog(self.Parent)
+        dialog = ActionBlockDialog(self.ParentWindow)
         dialog.SetQualifierList(self.Controler.GetQualifierTypes())
         dialog.SetActionList(self.Controler.GetCurrentElementEditingActions())
         dialog.SetVariableList(self.Controler.GetCurrentElementEditingInterfaceVars())
@@ -1452,7 +1460,18 @@
             actionblock.RefreshModel()
             self.RefreshBuffer()
             self.RefreshScrollBars()
-            self.Refresh()
+            self.Refresh(False)
+        dialog.Destroy()
+
+    def EditCommentContent(self, comment):
+        dialog = wx.TextEntryDialog(self.ParentWindow, "Edit comment", "Please enter comment text", comment.GetContent(), wx.OK|wx.CANCEL|wx.TE_MULTILINE)
+        if dialog.ShowModal() == wx.ID_OK:
+            value = dialog.GetValue()
+            comment.SetContent(value)
+            comment.RefreshModel()
+            self.RefreshBuffer()
+            self.RefreshScrollBars()
+            self.Refresh(False)
         dialog.Destroy()
 
 #-------------------------------------------------------------------------------
@@ -1587,7 +1606,7 @@
         self.Controler.RemoveCurrentElementEditingInstance(block.GetId())
         for element in elements:
             element.RefreshModel()
-        wx.CallAfter(self.Parent.RefreshEditor)
+        wx.CallAfter(self.ParentWindow.RefreshEditor)
 
     def DeleteVariable(self, variable):
         connectors = variable.GetConnectors()
@@ -1732,9 +1751,10 @@
         event.Skip()
 
     def OnPaint(self, event):
-        dc = self.GetLogicalDC()
+        dc = self.GetLogicalDC(True)
         dc.Clear()
         dc.SetPen(wx.Pen(wx.Colour(230, 230, 230)))
+        dc.BeginDrawing()
         if self.Scaling and self.DrawGrid:
             width, height = dc.GetSize()
             for i in xrange(1, width / self.Scaling[0] + 1):
@@ -1753,7 +1773,8 @@
         if self.SelectedElement:
             self.SelectedElement.Draw(dc)
         if self.rubberBand.IsShown():
-            self.rubberBand.Draw()
+            self.rubberBand.Draw(dc)
+        dc.EndDrawing()
         event.Skip()
 
 
--- a/graphics/FBD_Objects.py	Mon Sep 10 16:12:29 2007 +0200
+++ b/graphics/FBD_Objects.py	Mon Sep 10 18:16:07 2007 +0200
@@ -39,7 +39,7 @@
 class FBD_Block(Graphic_Element):
     
     # Create a new block
-    def __init__(self, parent, type, name, id = None, extension = 0, inputs = None):
+    def __init__(self, parent, type, name, id = None, extension = 0, inputs = None, connectors = {}):
         Graphic_Element.__init__(self, parent)
         self.Type = None
         self.Extension = None
@@ -48,7 +48,9 @@
         self.Inputs = []
         self.Outputs = []
         self.RefreshNameSize()
-        self.SetType(type, extension, inputs)
+        self.Colour = wx.BLACK
+        self.Pen = wx.BLACK_PEN
+        self.SetType(type, extension, inputs, connectors)
     
     # Destructor
     def __del__(self):
@@ -153,7 +155,7 @@
         return None
     
     # Changes the block type
-    def SetType(self, type, extension, inputs = None):
+    def SetType(self, type, extension, inputs = None, connectors = {}):
         if type != self.Type or self.Extension != extension: 
             if type != self.Type:
                 self.Type = type
@@ -164,6 +166,7 @@
             # inputs and outputs
             blocktype = GetBlockType(type, inputs)
             if blocktype:
+                self.Colour = wx.BLACK
                 inputs = [input for input in blocktype["inputs"]]
                 outputs = [output for output in blocktype["outputs"]]
                 if blocktype["extensible"]:
@@ -172,7 +175,16 @@
                         start += 1
                         inputs.append(("IN%d"%start, inputs[-1][1], inputs[-1][2]))
             else:
-                raise ValueError, "This block type isn't defined"
+                self.Colour = wx.RED
+                if "inputs" in connectors:
+                    inputs = connectors["inputs"]
+                else:
+                    inputs = []
+                if "outputs" in connectors:
+                    outputs = connectors["outputs"]
+                else:
+                    outputs = []
+            self.Pen = wx.Pen(self.Colour)
             self.Clean()
             # Extract the inputs properties and create the corresponding connector
             self.Inputs = []
@@ -277,8 +289,9 @@
     
     # Draws block
     def Draw(self, dc):
-        dc.SetPen(wx.BLACK_PEN)
+        dc.SetPen(self.Pen)
         dc.SetBrush(wx.WHITE_BRUSH)
+        dc.SetTextForeground(self.Colour)
         # Draw a rectangle with the block size
         dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
         # Draw block name and block type
@@ -292,6 +305,7 @@
         for output in self.Outputs:
             output.Draw(dc)
         Graphic_Element.Draw(self, dc)
+        dc.SetTextForeground(wx.BLACK)
 
 
 #-------------------------------------------------------------------------------
--- a/graphics/GraphicCommons.py	Mon Sep 10 16:12:29 2007 +0200
+++ b/graphics/GraphicCommons.py	Mon Sep 10 18:16:07 2007 +0200
@@ -229,8 +229,9 @@
         self.Redraw()
 
     # Method that erase the last box and draw the new box
-    def Redraw(self):
-        dc = self.drawingSurface.GetLogicalDC()
+    def Redraw(self, dc = None):
+        if not dc:
+            dc = self.drawingSurface.GetLogicalDC()
         dc.SetPen(wx.Pen(wx.WHITE, 1, wx.DOT))
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
         dc.SetLogicalFunction(wx.XOR)
@@ -242,20 +243,22 @@
             # Draw current box
             dc.DrawRectangle(self.currentBox.x, self.currentBox.y, self.currentBox.width,
                 self.currentBox.height)
-
+    
     # Erase last box
-    def Erase(self):
-        dc = self.drawingSurface.GetLogicalDC()
+    def Erase(self, dc = None):
+        if not dc:
+            dc = self.drawingSurface.GetLogicalDC()
         dc.SetPen(wx.Pen(wx.WHITE, 1, wx.DOT))
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
         dc.SetLogicalFunction(wx.XOR)
         if self.lastBox:
             dc.DrawRectangle(self.lastBox.x, self.lastBox.y, self.lastBox.width,
                 self.lastBox.height)
-        
+    
     # Draw current box
-    def Draw(self):
-        dc = self.drawingSurface.GetLogicalDC()
+    def Draw(self, dc = None):
+        if not dc:
+            dc = self.drawingSurface.GetLogicalDC()
         dc.SetPen(wx.Pen(wx.WHITE, 1, wx.DOT))
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
         dc.SetLogicalFunction(wx.XOR)
@@ -264,7 +267,6 @@
             dc.DrawRectangle(self.currentBox.x, self.currentBox.y, self.currentBox.width,
                 self.currentBox.height)
 
-
 #-------------------------------------------------------------------------------
 #                           Graphic element base class
 #-------------------------------------------------------------------------------
@@ -451,6 +453,7 @@
             if self.Dragging:
                 self.oldPos = pos
                 self.ProcessDragging(movex, movey)
+            return True
         # If cursor just pass over the element, changes the cursor if it is on a handle
         else:
             pos = event.GetLogicalPosition(dc)
@@ -461,6 +464,7 @@
             if cursor != self.CurrentCursor:
                 self.Parent.SetCursor(CURSORS[cursor])
                 self.CurrentCursor = cursor
+            return False
 
     # Moves the element
     def Move(self, dx, dy, exclude = []):
@@ -1578,6 +1582,7 @@
                     if self.CurrentCursor != 5:
                         self.CurrentCursor = 5
                         wx.CallAfter(self.Parent.SetCursor, CURSORS[5])
+                return False
             else:
                 # Test if a point has been handled
                 #result = self.TestPoint(pos)
@@ -1590,10 +1595,10 @@
                 #    self.OverStart = False
                 #    self.OverEnd = False
                 # Execute the default method for a graphic element
-                Graphic_Element.OnMotion(self, event, dc, scaling)
+                return Graphic_Element.OnMotion(self, event, dc, scaling)
         else:
             # Execute the default method for a graphic element
-            Graphic_Element.OnMotion(self, event, dc, scaling)
+            return Graphic_Element.OnMotion(self, event, dc, scaling)
     
     # Refreshes the wire state according to move defined and handle selected
     def ProcessDragging(self, movex, movey):
--- a/xmlclass/xmlclass.py	Mon Sep 10 16:12:29 2007 +0200
+++ b/xmlclass/xmlclass.py	Mon Sep 10 18:16:07 2007 +0200
@@ -42,6 +42,12 @@
 date_model = re.compile('([0-9]{4})-([0-9]{2})-([0-9]{2})')
 datetime_model = re.compile('([0-9]{4})-([0-9]{2})-([0-9]{2})[ T]([0-9]{2}):([0-9]{2}):([0-9]{2}(?:.[0-9]*)?)')
 
+XSD_INTEGER_TYPES = ["integer","nonPositiveInteger","negativeInteger","long",
+    "int","short","byte","nonNegativeInteger","unsignedLong","unsignedInt",
+    "unsignedShort","unsignedByte","positiveInteger"]
+
+XSD_STRING_TYPES = ["string","normalizedString","token","anyURI","NMTOKEN","language"]
+
 """
 This function calculates the number of whitespace for indentation
 """
@@ -88,14 +94,14 @@
              return False
          else:
             raise ValueError, "\"%s\" is not a valid boolean!"%value
-    elif type_compute in ["unsignedLong","long","integer"]:
+    elif type_compute in XSD_INTEGER_TYPES:
         return int(value)
-    elif type_compute == "decimal":
+    elif type_compute in ["decimal", "float", "double"]:
         computed_value = float(value)
         if computed_value % 1 == 0:
             return int(computed_value)
         return computed_value
-    elif type_compute in ["string","anyURI","NMTOKEN","language"]:
+    elif type_compute in XSD_STRING_TYPES:
         return value
     elif type_compute == "time":
         result = time_model.match(value)