Corrections for wx version 2.8.4 and Windows
authorlbessard
Tue, 18 Sep 2007 18:05:52 +0200
changeset 95 ee66a9a1748b
parent 94 e7f5a251f251
child 96 d178cfa9e77f
Corrections for wx version 2.8.4 and Windows
Dialogs.py
PLCOpenEditor.py
Viewer.py
--- a/Dialogs.py	Mon Sep 17 17:51:05 2007 +0200
+++ b/Dialogs.py	Tue Sep 18 18:05:52 2007 +0200
@@ -69,7 +69,7 @@
     def _init_coll_RightUpGridSizer_Items(self, parent):
         parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW|wx.ALIGN_BOTTOM)
         parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW|wx.ALIGN_BOTTOM)
-        parent.AddWindow(self.Name, 0, border=0, flag=wx.GROW)
+        parent.AddWindow(self.BlockName, 0, border=0, flag=wx.GROW)
         parent.AddWindow(self.Inputs, 0, border=0, flag=wx.GROW)
 
     def _init_sizers(self):
@@ -112,9 +112,13 @@
               label='Preview:', name='staticText4', parent=self,
               pos=wx.Point(0, 0), size=wx.Size(0, 17), 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=wx.TR_HAS_BUTTONS|wx.TR_HIDE_ROOT|wx.TR_SINGLE|wx.SUNKEN_BORDER)
+              size=wx.Size(0, 0), style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER)
         self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnTypeTreeItemSelected,
               id=ID_BLOCKPROPERTIESDIALOGTYPETREE)
 
@@ -122,8 +126,8 @@
               name='TypeDesc', parent=self, pos=wx.Point(0, 0),
               size=wx.Size(0, 0), style=wx.TE_READONLY|wx.TE_MULTILINE)
 
-        self.Name = wx.TextCtrl(id=ID_BLOCKPROPERTIESDIALOGNAME, value='',
-              name='Name', parent=self, pos=wx.Point(0, 0),
+        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)
 
@@ -147,8 +151,8 @@
 
     def __init__(self, parent):
         self._init_ctrls(parent)
-        self.Name.SetValue("")
-        self.Name.Enable(False)
+        self.BlockName.SetValue("")
+        self.BlockName.Enable(False)
         self.Inputs.Enable(False)
         self.Block = None
         self.MinBlockSize = None
@@ -177,8 +181,8 @@
     def OnOK(self, event):
         error = []
         selected = self.TypeTree.GetSelection()
-        block_name = self.Name.GetValue()
-        name_enabled = self.Name.IsEnabled()
+        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()
@@ -207,7 +211,10 @@
             self.EndModal(wx.ID_OK)
 
     def SetBlockList(self, blocktypes):
-        root = self.TypeTree.AddRoot("")
+        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_item = self.TypeTree.AppendItem(root, category["name"])
@@ -215,6 +222,8 @@
             for blocktype in category["list"]:
                 blocktype_item = self.TypeTree.AppendItem(category_item, blocktype["name"])
                 self.TypeTree.SetPyData(blocktype_item, {"type" : BLOCK, "inputs" : tuple([type for name, type, modifier in blocktype["inputs"]])})
+        if wx.Platform == '__WXMSW__':
+            self.TypeTree.Expand(root)
 
     def SetMinBlockSize(self, size):
         self.MinBlockSize = size
@@ -235,7 +244,7 @@
                 if item:
                     self.TypeTree.SelectItem(item)
             elif name == "name":
-                self.Name.SetValue(value)
+                self.BlockName.SetValue(value)
             elif name == "extension":
                 self.Inputs.SetValue(value)
         self.RefreshPreview()
@@ -245,14 +254,14 @@
         item = self.TypeTree.GetSelection()
         values["type"] = self.TypeTree.GetItemText(item)
         values["inputs"] = self.TypeTree.GetPyData(item)["inputs"]
-        if self.Name.GetValue() != "":
-            values["name"] = self.Name.GetValue()
+        if self.BlockName.GetValue() != "":
+            values["name"] = self.BlockName.GetValue()
         values["width"], values["height"] = self.Block.GetSize()
         values["extension"] = self.Inputs.GetValue()
         return values
 
     def OnTypeTreeItemSelected(self, event):
-        self.Name.SetValue("")
+        self.BlockName.SetValue("")
         selected = event.GetItem()
         pydata = self.TypeTree.GetPyData(selected)
         if pydata["type"] != CATEGORY:
@@ -260,17 +269,17 @@
             if blocktype:
                 self.Inputs.SetValue(len(blocktype["inputs"]))
                 self.Inputs.Enable(blocktype["extensible"])
-                self.Name.Enable(blocktype["type"] != "function")
+                self.BlockName.Enable(blocktype["type"] != "function")
                 self.TypeDesc.SetValue(blocktype["comment"])
                 wx.CallAfter(self.RefreshPreview)
             else:
-                self.Name.Enable(False)
+                self.BlockName.Enable(False)
                 self.Inputs.Enable(False)
                 self.Inputs.SetValue(2)
                 self.TypeDesc.SetValue("")
                 wx.CallAfter(self.ErasePreview)
         else:
-            self.Name.Enable(False)
+            self.BlockName.Enable(False)
             self.Inputs.Enable(False)
             self.Inputs.SetValue(2)
             self.TypeDesc.SetValue("")
@@ -278,7 +287,7 @@
         event.Skip()
 
     def OnNameChanged(self, event):
-        if self.Name.IsEnabled():
+        if self.BlockName.IsEnabled():
             self.RefreshPreview()
         event.Skip()
     
@@ -303,7 +312,7 @@
             else:
                 blocktype = self.TypeTree.GetItemText(item)
                 if blocktype:
-                    self.Block = FBD_Block(self.Preview, blocktype, self.Name.GetValue(), extension = self.Inputs.GetValue(), inputs = pydata["inputs"])
+                    self.Block = FBD_Block(self.Preview, blocktype, self.BlockName.GetValue(), extension = self.Inputs.GetValue(), inputs = pydata["inputs"])
                     width, height = self.MinBlockSize
                     min_width, min_height = self.Block.GetMinSize()
                     width, height = max(min_width, width), max(min_height, height)
@@ -319,7 +328,7 @@
     def OnPaint(self, event):
         if self.Block:
             self.RefreshPreview()
-
+        event.Skip()
 
 #-------------------------------------------------------------------------------
 #                          Create New Variable Dialog
@@ -367,7 +376,7 @@
             
     def _init_coll_RightGridSizer_Items(self, parent):
         parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Name, 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)
@@ -420,7 +429,7 @@
               size=wx.Size(0, 24), style=0)
         self.Bind(wx.EVT_CHOICE, self.OnClassChanged, id=ID_VARIABLEPROPERTIESDIALOGCLASS)
         
-        self.Name = wx.ListBox(id=ID_VARIABLEPROPERTIESDIALOGNAME,
+        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)
         self.Bind(wx.EVT_LISTBOX, self.OnNameChanged, id=ID_VARIABLEPROPERTIESDIALOGNAME)
@@ -458,23 +467,23 @@
         self.Class.SetStringSelection("Input")
 
     def RefreshNameList(self):
-        selected = self.Name.GetStringSelection()
-        self.Name.Clear()
-        self.Name.Append("")
+        selected = self.VariableName.GetStringSelection()
+        self.VariableName.Clear()
+        self.VariableName.Append("")
         for name, var_type, value_type in self.VarList:
             if var_type in ["Local","Temp","Global","External"]:
-                self.Name.Append(name)
+                self.VariableName.Append(name)
             elif var_type == "Input" and self.Class.GetStringSelection() == "Input":
-                self.Name.Append(name)
+                self.VariableName.Append(name)
             elif var_type == "Output" and self.Class.GetStringSelection() == "Output":
-                self.Name.Append(name)
+                self.VariableName.Append(name)
             elif var_type == "InOut" and self.Class.GetStringSelection() == "InOut":
-                self.Name.Append(name)
-        if self.Name.FindString(selected) != wx.NOT_FOUND:
-            self.Name.SetStringSelection(selected)
+                self.VariableName.Append(name)
+        if self.VariableName.FindString(selected) != wx.NOT_FOUND:
+            self.VariableName.SetStringSelection(selected)
         else:
-            self.Name.SetStringSelection("")
-        self.Name.Enable(self.Name.GetCount() > 0)
+            self.VariableName.SetStringSelection("")
+        self.VariableName.Enable(self.VariableName.GetCount() > 0)
             
     def SetMinVariableSize(self, size):
         self.MinVariableSize = size
@@ -495,12 +504,12 @@
                 self.Class.SetStringSelection("InOut")
             self.RefreshNameList()
         if value_name:
-            if self.Name.FindString(value_name) != wx.NOT_FOUND:
-                self.Name.SetStringSelection(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.Name.Enable(False)
+                self.VariableName.Enable(False)
         self.RefreshPreview()
         
     def GetValues(self):
@@ -516,7 +525,7 @@
         if self.Expression.IsEnabled() and expression != "":
             values["name"] = expression
         else:
-            values["name"] = self.Name.GetStringSelection()
+            values["name"] = self.VariableName.GetStringSelection()
         values["value_type"] = ""
         for var_name, var_type, value_type in self.VarList:
             if var_name == values["name"]:
@@ -534,7 +543,7 @@
         event.Skip()
 
     def OnNameChanged(self, event):
-        if self.Name.GetStringSelection() != "":
+        if self.VariableName.GetStringSelection() != "":
             self.Expression.Enable(False)
         elif self.Class.GetStringSelection() == "Input":
             self.Expression.Enable(True)
@@ -543,9 +552,9 @@
     
     def OnExpressionChanged(self, event):
         if self.Expression.GetValue() != "":
-            self.Name.Enable(False)
+            self.VariableName.Enable(False)
         else:
-            self.Name.Enable(True)
+            self.VariableName.Enable(True)
         self.RefreshPreview()
         event.Skip()
     
@@ -556,7 +565,7 @@
         if self.Expression.IsEnabled() and expression != "":
             name = expression
         else:
-            name = self.Name.GetStringSelection()
+            name = self.VariableName.GetStringSelection()
         type = ""
         for var_name, var_type, value_type in self.VarList:
             if var_name == name:
@@ -580,6 +589,7 @@
 
     def OnPaint(self, event):
         self.RefreshPreview()
+        event.Skip()
 
 #-------------------------------------------------------------------------------
 #                          Create New Connection Dialog
@@ -610,7 +620,7 @@
         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.Name, 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):
@@ -672,7 +682,7 @@
         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2)
         self.radioButton2.SetValue(False)
         
-        self.Name = wx.TextCtrl(id=ID_CONNECTIONPROPERTIESDIALOGNAME,
+        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)
@@ -709,7 +719,7 @@
                 elif value == CONTINUATION:
                     self.radioButton2.SetValue(True)
             elif name == "name":
-                self.Name.SetValue(value)
+                self.ConnectionName.SetValue(value)
         self.RefreshPreview()
     
     def GetValues(self):
@@ -718,7 +728,7 @@
             values["type"] = CONNECTOR
         else:
             values["type"] = CONTINUATION
-        values["name"] = self.Name.GetValue()
+        values["name"] = self.ConnectionName.GetValue()
         values["width"], values["height"] = self.Connection.GetSize()
         return values
 
@@ -734,9 +744,9 @@
         dc = wx.ClientDC(self.Preview)
         dc.Clear()
         if self.radioButton1.GetValue():
-            self.Connection = FBD_Connector(self.Preview, CONNECTOR, self.Name.GetValue())
+            self.Connection = FBD_Connector(self.Preview, CONNECTOR, self.ConnectionName.GetValue())
         else:
-            self.Connection = FBD_Connector(self.Preview, CONTINUATION, self.Name.GetValue())
+            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)
@@ -749,7 +759,7 @@
 
     def OnPaint(self, event):
         self.RefreshPreview()
-
+        event.Skip()
 
 #-------------------------------------------------------------------------------
 #                        Edit Ladder Element Properties Dialog
@@ -784,7 +794,7 @@
         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.Name, 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):
@@ -855,7 +865,7 @@
               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON4)
 
-        self.Name = wx.Choice(id=ID_LDELEMENTDIALOGNAME,
+        self.ElementName = wx.Choice(id=ID_LDELEMENTDIALOGNAME,
               name='Name', parent=self, pos=wx.Point(0, 0),
               size=wx.Size(0, 24), style=0)
         self.Bind(wx.EVT_CHOICE, self.OnNameChanged, id=ID_LDELEMENTDIALOGNAME)
@@ -891,16 +901,16 @@
         self.Element.SetSize(width, height)
         
     def SetVariables(self, vars):
-        self.Name.Clear()
+        self.ElementName.Clear()
         for name in vars:
-            self.Name.Append(name)
-        self.Name.Enable(self.Name.GetCount() > 0)
+            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.Name.SetStringSelection(value)
+                self.ElementName.SetStringSelection(value)
             elif name == "type":
                 self.Element.SetType(value)
                 if self.Type == "contact":
@@ -952,7 +962,7 @@
         event.Skip()
 
     def OnNameChanged(self, event):
-        self.Element.SetName(self.Name.GetStringSelection())
+        self.Element.SetName(self.ElementName.GetStringSelection())
         self.RefreshPreview()
         event.Skip()
 
@@ -1158,7 +1168,7 @@
     
     def _init_coll_LeftGridSizer_Items(self, parent):
         parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
-        parent.AddWindow(self.Name, 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)
@@ -1212,7 +1222,7 @@
               label='Preview:', name='staticText4', parent=self,
               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
 
-        self.Name = wx.TextCtrl(id=ID_STEPCONTENTDIALOGNAME,
+        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)
@@ -1261,7 +1271,7 @@
         self.StepNames = []
     
     def OnOK(self, event):
-        step_name = self.Name.GetValue()
+        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()
@@ -1304,9 +1314,9 @@
     def SetValues(self, values):
         value_name = values.get("name", None)
         if value_name:
-            self.Name.SetValue(value_name)
+            self.StepName.SetValue(value_name)
         else:
-            self.Name.SetValue("")
+            self.StepName.SetValue("")
         self.checkBox1.SetValue(values.get("input", False))
         self.checkBox2.SetValue(values.get("output", False))
         self.checkBox3.SetValue(values.get("action", False))
@@ -1314,7 +1324,7 @@
         
     def GetValues(self):
         values = {}
-        values["name"] = self.Name.GetValue()
+        values["name"] = self.StepName.GetValue()
         values["input"] = self.checkBox1.IsChecked()
         values["output"] = self.checkBox2.IsChecked()
         values["action"] = self.checkBox3.IsChecked()
@@ -1332,7 +1342,7 @@
     def RefreshPreview(self):
         dc = wx.ClientDC(self.Preview)
         dc.Clear()
-        self.Step = SFC_Step(self.Preview, self.Name.GetValue(), self.Initial)
+        self.Step = SFC_Step(self.Preview, self.StepName.GetValue(), self.Initial)
         if self.checkBox1.IsChecked():
             self.Step.AddInput()
         else:
@@ -1357,6 +1367,7 @@
 
     def OnPaint(self, event):
         self.RefreshPreview()
+        event.Skip()
 
 #-------------------------------------------------------------------------------
 #                          Edit Transition Content Dialog
@@ -1616,6 +1627,7 @@
 
     def OnPaint(self, event):
         self.RefreshPreview()
+        event.Skip()
 
 #-------------------------------------------------------------------------------
 #                         Create New Divergence Dialog
@@ -1796,6 +1808,7 @@
 
     def OnPaint(self, event):
         self.RefreshPreview()
+        event.Skip()
 
 
 #-------------------------------------------------------------------------------
--- a/PLCOpenEditor.py	Mon Sep 17 17:51:05 2007 +0200
+++ b/PLCOpenEditor.py	Tue Sep 18 18:05:52 2007 +0200
@@ -98,34 +98,34 @@
 ] = [wx.NewId() for _init_coll_DefaultToolBar_Items in range(17)]
 
 ToolBarItems = {
-    "FBD" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool", "Images/comment.png", "Create a new comment"),
-             (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool", "Images/variable.png", "Create a new variable"),
-             (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool", "Images/block.png", "Create a new block"),
-             (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool", "Images/connection.png", "Create a new connection"),
-             (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARWIRE, "OnWireTool", "Images/wire.png", "Create a new wire")],
-    "LD"  : [(True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool", "Images/comment.png", "Create a new comment"),
-             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARPOWERRAIL, "OnPowerRailTool", "Images/powerrail.png", "Create a new power rail"),
-             (False, DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARRUNG, "OnRungTool", "Images/rung.png", "Create a new rung"),
-             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCOIL, "OnCoilTool", "Images/coil.png", "Create a new coil"),
-             (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCONTACT, "OnContactTool", "Images/contact.png", "Create a new contact"),
-             (False, DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARBRANCH, "OnBranchTool", "Images/branch.png", "Create a new branch"),
-             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool", "Images/variable.png", "Create a new variable"),
-             (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool", "Images/block.png", "Create a new block"),
-             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool", "Images/connection.png", "Create a new connection"),
-             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARWIRE, "OnWireTool", "Images/wire.png", "Create a new wire")],
-    "SFC" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool", "Images/comment.png", "Create a new comment"),
-             (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARINITIALSTEP, "OnInitialStepTool", "Images/initial_step.png", "Create a new initial step"),
-             (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARSTEP, "OnStepTool", "Images/step.png", "Create a new step"),
-             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARTRANSITION, "OnTransitionTool", "Images/transition.png", "Create a new transition"),
-             (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARACTIONBLOCK, "OnActionBlockTool", "Images/action.png", "Create a new action block"),
-             (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARDIVERGENCE, "OnDivergenceTool", "Images/divergence.png", "Create a new divergence"),
-             (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARJUMP, "OnJumpTool", "Images/jump.png", "Create a new jump"),
-             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool", "Images/variable.png", "Create a new variable"),
-             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool", "Images/block.png", "Create a new block"),
-             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool", "Images/connection.png", "Create a new connection"),
-             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARPOWERRAIL, "OnPowerRailTool", "Images/powerrail.png", "Create a new power rail"),
-             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCONTACT, "OnContactTool", "Images/contact.png", "Create a new contact"),
-             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARWIRE, "OnWireTool", "Images/wire.png", "Create a new wire")],
+    "FBD" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool", "comment.png", "Create a new comment"),
+             (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool", "variable.png", "Create a new variable"),
+             (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool", "block.png", "Create a new block"),
+             (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool", "connection.png", "Create a new connection"),
+             (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARWIRE, "OnWireTool", "wire.png", "Create a new wire")],
+    "LD"  : [(True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool", "comment.png", "Create a new comment"),
+             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARPOWERRAIL, "OnPowerRailTool", "powerrail.png", "Create a new power rail"),
+             (False, DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARRUNG, "OnRungTool", "rung.png", "Create a new rung"),
+             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCOIL, "OnCoilTool", "coil.png", "Create a new coil"),
+             (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCONTACT, "OnContactTool", "contact.png", "Create a new contact"),
+             (False, DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARBRANCH, "OnBranchTool", "branch.png", "Create a new branch"),
+             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool", "variable.png", "Create a new variable"),
+             (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool", "block.png", "Create a new block"),
+             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool", "connection.png", "Create a new connection"),
+             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARWIRE, "OnWireTool", "wire.png", "Create a new wire")],
+    "SFC" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool", "comment.png", "Create a new comment"),
+             (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARINITIALSTEP, "OnInitialStepTool", "initial_step.png", "Create a new initial step"),
+             (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARSTEP, "OnStepTool", "step.png", "Create a new step"),
+             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARTRANSITION, "OnTransitionTool", "transition.png", "Create a new transition"),
+             (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARACTIONBLOCK, "OnActionBlockTool", "action.png", "Create a new action block"),
+             (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARDIVERGENCE, "OnDivergenceTool", "divergence.png", "Create a new divergence"),
+             (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITORTOOLBARJUMP, "OnJumpTool", "jump.png", "Create a new jump"),
+             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool", "variable.png", "Create a new variable"),
+             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool", "block.png", "Create a new block"),
+             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool", "connection.png", "Create a new connection"),
+             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARPOWERRAIL, "OnPowerRailTool", "powerrail.png", "Create a new power rail"),
+             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARCONTACT, "OnContactTool", "contact.png", "Create a new contact"),
+             (True, FREEDRAWING_MODE, ID_PLCOPENEDITORTOOLBARWIRE, "OnWireTool", "wire.png", "Create a new wire")],
     "ST"  : [],
     "IL"  : []
 }
@@ -286,32 +286,22 @@
         self._init_coll_SFCMenu_Items(self.SFCMenu)
         self._init_coll_ConfigMenu_Items(self.ConfigMenu)
 
-    def _init_coll_MainGridSizer_Items(self, parent):
-        parent.AddWindow(self.MainSplitter, 0, border=0, flag=wx.GROW)
-
     def _init_coll_EditorGridSizer_Items(self, parent):
         parent.AddWindow(self.ToolBar, 0, border=0, flag=wx.GROW)
         parent.AddWindow(self.TabsOpened, 0, border=0, flag=wx.GROW)
 
-    def _init_coll_MainGridSizer_Growables(self, parent):
-        parent.AddGrowableCol(0)
-        parent.AddGrowableRow(0)
-
     def _init_coll_EditorGridSizer_Growables(self, parent):
         parent.AddGrowableCol(0)
         parent.AddGrowableRow(1)
 
     def _init_sizers(self):
-        self.MainGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=1, vgap=0)
-        self.EditorGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
-
-        self._init_coll_MainGridSizer_Growables(self.MainGridSizer)
-        self._init_coll_MainGridSizer_Items(self.MainGridSizer)
-        self._init_coll_EditorGridSizer_Growables(self.EditorGridSizer)
-        self._init_coll_EditorGridSizer_Items(self.EditorGridSizer)
-        
-        self.SetSizer(self.MainGridSizer)
-        self.EditorPanel.SetSizer(self.EditorGridSizer)
+        if wx.Platform != '__WXMSW__':
+            self.EditorGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
+        
+            self._init_coll_EditorGridSizer_Growables(self.EditorGridSizer)
+            self._init_coll_EditorGridSizer_Items(self.EditorGridSizer)
+        
+            self.EditorPanel.SetSizer(self.EditorGridSizer)
 
     def _init_ctrls(self, prnt):
         wx.Frame.__init__(self, id=ID_PLCOPENEDITOR, name=u'PLCOpenEditor',
@@ -333,24 +323,6 @@
         self.MainSplitter.SetNeedUpdating(True)
         self.MainSplitter.SetMinimumPaneSize(1)
         
-        self.EditorPanel = wx.Panel(id=ID_PLCOPENEDITOREDITORPANEL, 
-              name='TabPanel', parent=self.MainSplitter, pos=wx.Point(0, 0),
-              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
-        
-        self.TabsOpened = wx.Notebook(id=ID_PLCOPENEDITORTABSOPENED,
-              name='TabsOpened', parent=self.EditorPanel, pos=wx.Point(0,
-              0), size=wx.Size(0, 0), style=0)
-        self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
-              self.OnPouSelectedChanged, id=ID_PLCOPENEDITORTABSOPENED)
-
-        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)
-        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, 
-              id=ID_PLCOPENEDITORTOOLBARSELECTION)
-        
         self.ProjectTree = wx.TreeCtrl(id=ID_PLCOPENEDITORPROJECTTREE,
               name='treeCtrl1', parent=self.MainSplitter, pos=wx.Point(0, 0),
               size=wx.Size(-1, -1),
@@ -366,8 +338,46 @@
               id=ID_PLCOPENEDITORPROJECTTREE)
         self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnProjectTreeItemSelected,
               id=ID_PLCOPENEDITORPROJECTTREE)
-        self.MainSplitter.SplitVertically(self.ProjectTree, self.EditorPanel,
-              200)
+        
+        if wx.Platform == '__WXMSW__':
+            self.ToolBar = self.CreateToolBar(wx.TB_HORIZONTAL|wx.TB_FLAT|wx.NO_BORDER, 
+                  ID_PLCOPENEDITORTOOLBAR, 'ToolBar')
+            self.ToolBar.SetToolBitmapSize(wx.Size(25, 25))
+            self.ToolBar.AddRadioTool(ID_PLCOPENEDITORTOOLBARSELECTION, 
+                  wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, "Select an object")
+            self.ToolBar.Realize()
+            self.Bind(wx.EVT_TOOL, self.OnSelectionTool, 
+                  id=ID_PLCOPENEDITORTOOLBARSELECTION)
+        
+            self.TabsOpened = wx.Notebook(id=ID_PLCOPENEDITORTABSOPENED,
+                  name='TabsOpened', parent=self.MainSplitter, pos=wx.Point(0,
+                  0), size=wx.Size(0, 0), style=0)
+            self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
+                  self.OnPouSelectedChanged, id=ID_PLCOPENEDITORTABSOPENED)
+        
+            self.MainSplitter.SplitVertically(self.ProjectTree, self.TabsOpened, 200)
+        
+        else:
+            self.EditorPanel = wx.Panel(id=ID_PLCOPENEDITOREDITORPANEL, 
+                  name='TabPanel', parent=self.MainSplitter, pos=wx.Point(0, 0),
+                  size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
+        
+            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)
+            self.ToolBar.AddRadioTool(ID_PLCOPENEDITORTOOLBARSELECTION, 
+                  wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, "Select an object")
+            self.ToolBar.Realize()
+            self.Bind(wx.EVT_TOOL, self.OnSelectionTool, 
+                  id=ID_PLCOPENEDITORTOOLBARSELECTION)
+        
+            self.TabsOpened = wx.Notebook(id=ID_PLCOPENEDITORTABSOPENED,
+                  name='TabsOpened', parent=self.EditorPanel, pos=wx.Point(0,
+                  0), size=wx.Size(0, 0), style=0)
+            self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
+                  self.OnPouSelectedChanged, id=ID_PLCOPENEDITORTABSOPENED)
+        
+            self.MainSplitter.SplitVertically(self.ProjectTree, self.EditorPanel, 200)
         
         self._init_sizers()
 
@@ -375,10 +385,11 @@
         self.ModeSolo = controler == None
         self._init_ctrls(parent)
         
-        self.TreeImageList = wx.ImageList(16, 16)
-        for language in LANGUAGES:
-            self.TreeImageList.Add(wx.Bitmap(os.path.join(CWD, 'Images/%s.png'%language)))
-        self.ProjectTree.SetImageList(self.TreeImageList)
+        if wx.Platform != '__WXMSW__':
+            self.TreeImageList = wx.ImageList(16, 16)
+            for language in LANGUAGES:
+                self.TreeImageList.Add(wx.Bitmap(os.path.join(CWD, 'Images','%s.png'%language)))
+            self.ProjectTree.AssignImageList(self.TreeImageList)
         
         if self.ModeSolo:
             self.Controler = PLCControler()
@@ -1017,7 +1028,7 @@
         to_delete = []
         self.ProjectTree.SetItemText(root, infos["name"])
         self.ProjectTree.SetPyData(root, infos["type"])
-        if infos["type"] == ITEM_POU:
+        if infos["type"] == ITEM_POU and wx.Platform != '__WXMSW__':
             self.ProjectTree.SetItemImage(root, LANGUAGES.index(self.Controler.GetPouBodyType(infos["name"])))
         item, root_cookie = self.ProjectTree.GetFirstChild(root)
         for values in infos["values"]:
@@ -1047,11 +1058,15 @@
             for radio, modes, id, method, picture, help in ToolBarItems[language]:
                 if modes & self.DrawingMode:
                     if radio or self.DrawingMode == FREEDRAWING_MODE:
-                        self.ToolBar.AddRadioTool(id, wx.Bitmap(os.path.join(CWD, picture)), wx.NullBitmap, help)
+                        self.ToolBar.AddRadioTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), wx.NullBitmap, help)
                     else:
-                        self.ToolBar.AddSimpleTool(id, wx.Bitmap(os.path.join(CWD, picture)), help)
+                        self.ToolBar.AddSimpleTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), help)
                     self.Bind(wx.EVT_TOOL, getattr(self, method), id=id)
                     self.CurrentToolBar.append(id)
+            self.ToolBar.Realize()
+        elif not language:
+            self.ResetToolBar()
+            self.CurrentLanguage = language
         self.ResetCurrentMode()
 
     def RefreshTabsOpenedTitles(self):
--- a/Viewer.py	Mon Sep 17 17:51:05 2007 +0200
+++ b/Viewer.py	Tue Sep 18 18:05:52 2007 +0200
@@ -192,7 +192,8 @@
             dc = wx.BufferedPaintDC(self)
         else:
             dc = wx.ClientDC(self)
-        dc.SetFont(wx.NORMAL_FONT)
+        if wx.Platform != '__WXMSW__':
+            dc.SetFont(wx.NORMAL_FONT)
         self.DoPrepareDC(dc)
         return dc
 
@@ -305,6 +306,10 @@
         self.RefreshScrollBars()
         self.Refresh(False)
     
+    def Scroll(self, x, y):
+        print "Scroll to (%d, %d)"%(x, y)
+        wx.ScrolledWindow.Scroll(self, x, y)
+    
     def RefreshScrollBars(self):
         xstart, ystart = self.GetViewStart()
         window_size = self.GetClientSize()
@@ -321,8 +326,8 @@
             maxx = max(maxx, extent.x + extent.width)
             maxy = max(maxy, extent.y + extent.height)
         self.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, 
-            maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, xstart, ystart)
-    
+            maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, xstart, ystart, True)
+        
     # Load instance from given informations
     def loadInstance(self, instance, ids):
         ids.append(instance["id"])
@@ -926,6 +931,7 @@
                 self.SelectedElement.OnMotion(event, dc, self.Scaling)
                 self.SelectedElement.GeneratePoints()
                 self.Refresh(False)
+        self.UpdateScrollPos(event)
         event.Skip()
 
     def UpdateScrollPos(self, event):