Added plugins creation helpstrings, changed GUI layout (more compact), solved staticbitmap issues on win32, re-designed some icons...
authoretisserant
Fri, 22 Feb 2008 12:20:21 +0100
changeset 106 9810689febb0
parent 105 434aed8dc58d
child 107 65fe90d49bf7
Added plugins creation helpstrings, changed GUI layout (more compact), solved staticbitmap issues on win32, re-designed some icons...
Beremiz.py
images/Add16x16.png
images/Delete16x16.png
images/Disabled.png
images/Enabled.png
images/HideVars.png
images/Maximize.png
images/Minimize.png
images/ShowVars.png
images/Stop24x24.png
images/empty.png
plugger.py
plugins/__init__.py
plugins/c_ext/README
plugins/c_ext/c_ext.py
plugins/canfestival/README
plugins/canfestival/canfestival.py
plugins/svgui/README
--- a/Beremiz.py	Thu Feb 21 11:42:33 2008 +0100
+++ b/Beremiz.py	Fri Feb 22 12:20:21 2008 +0100
@@ -26,6 +26,7 @@
 
 import wx
 import wx.lib.buttons
+import wx.lib.statbmp
 
 import types
 
@@ -39,6 +40,7 @@
 
 SCROLLBAR_UNIT = 10
 WINDOW_COLOUR = wx.Colour(240,240,240)
+TITLE_COLOUR = wx.Colour(200,200,220)
 
 if wx.Platform == '__WXMSW__':
     faces = { 'times': 'Times New Roman',
@@ -57,17 +59,50 @@
 
 CWD = os.path.split(os.path.realpath(__file__))[0]
 
-gen_mini_GetBackgroundBrush = lambda obj:lambda dc: wx.Brush(obj.faceDnClr, wx.SOLID)
+gen_mini_GetBackgroundBrush = lambda obj:lambda dc: wx.Brush(obj.GetParent().GetBackgroundColour(), wx.SOLID)
 gen_mini_GetLabelSize = lambda obj:lambda:(wx.lib.buttons.GenBitmapTextButton._GetLabelSize(obj)[:-1] + (False,))
 gen_textbutton_GetLabelSize = lambda obj:lambda:(wx.lib.buttons.GenButton._GetLabelSize(obj)[:-1] + (False,))
 
-def GenerateEmptyBitmap(width, height):
-    bitmap = wx.EmptyBitmap(width, height)
-    dc = wx.MemoryDC(bitmap)
-    dc.SetPen(wx.Pen(WINDOW_COLOUR))
-    dc.SetBrush(wx.Brush(WINDOW_COLOUR))
-    dc.DrawRectangle(0, 0, width, height)
-    return bitmap
+def make_genbitmaptogglebutton_flat(button):
+    button.GetBackgroundBrush = gen_mini_GetBackgroundBrush(button)
+    button.labelDelta = 0
+    button.SetBezelWidth(0)
+    button.SetUseFocusIndicator(False)
+
+def GenerateEmptyBitmap(width, height, color):
+#    bitmap = wx.EmptyBitmap(width, height)
+#    dc = wx.MemoryDC(bitmap)
+#    dc.SetPen(wx.Pen(color))
+#    dc.SetBrush(wx.Brush(color))
+#    dc.DrawRectangle(0, 0, width, height)
+#    return bitmap
+    return wx.Bitmap(os.path.join(CWD, "images", "empty.png"))
+
+class GenStaticBitmap(wx.lib.statbmp.GenStaticBitmap):
+    def __init__(self, parent, ID, bitmapname,
+                 pos = wx.DefaultPosition, size = wx.DefaultSize,
+                 style = 0,
+                 name = "genstatbmp"):
+        
+        bitmappath = os.path.join(CWD, "images", bitmapname)
+        if os.path.isfile(bitmappath):
+            bitmap = wx.Bitmap(bitmappath)
+        else:
+            bitmap = None
+        wx.lib.statbmp.GenStaticBitmap.__init__(self, parent, ID, bitmap,
+                 pos, size,
+                 style,
+                 name)
+        
+    def OnPaint(self, event):
+        dc = wx.PaintDC(self)
+        colour = self.GetParent().GetBackgroundColour()
+        dc.SetPen(wx.Pen(colour))
+        dc.SetBrush(wx.Brush(colour ))
+        dc.DrawRectangle(0, 0, *dc.GetSizeTuple())
+        if self._bitmap:
+            dc.DrawBitmap(self._bitmap, 0, 0, True)
+
                         
 class LogPseudoFile:
     """ Base class for file like objects to facilitate StdOut for the Shell."""
@@ -265,7 +300,8 @@
     def _init_sizers(self):
         self.PLCConfigMainSizer = wx.FlexGridSizer(cols=1, hgap=2, rows=2, vgap=2)
         self.PLCParamsSizer = wx.BoxSizer(wx.VERTICAL)
-        self.PluginTreeSizer = wx.FlexGridSizer(cols=3, hgap=0, rows=0, vgap=2)
+        #self.PluginTreeSizer = wx.FlexGridSizer(cols=3, hgap=0, rows=0, vgap=2)
+        self.PluginTreeSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=0, vgap=2)
         
         self._init_coll_PLCConfigMainSizer_Items(self.PLCConfigMainSizer)
         self._init_coll_PLCConfigMainSizer_Growables(self.PLCConfigMainSizer)
@@ -375,7 +411,7 @@
         
         if self.PluginRoot.HasProjectOpened():
             plcwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
-            plcwindow.SetBackgroundColour(WINDOW_COLOUR)
+            plcwindow.SetBackgroundColour(TITLE_COLOUR)
             self.PLCParamsSizer.AddWindow(plcwindow, 0, border=0, flag=wx.GROW)
             
             plcwindowsizer = wx.BoxSizer(wx.HORIZONTAL)
@@ -386,6 +422,14 @@
             st.SetLabel(self.PluginRoot.GetProjectName())
             plcwindowsizer.AddWindow(st, 0, border=5, flag=wx.ALL|wx.ALIGN_CENTER)
             
+            addbutton_id = wx.NewId()
+            addbutton = wx.lib.buttons.GenBitmapButton(id=addbutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Add16x16.png')),
+                  name='AddBusButton', parent=plcwindow, pos=wx.Point(0, 0),
+                  size=wx.Size(16, 16), style=wx.NO_BORDER)
+            addbutton.SetToolTipString("Add a sub plugin")
+            addbutton.Bind(wx.EVT_BUTTON, self.Gen_AddPluginMenu(self.PluginRoot), id=addbutton_id)
+            plcwindowsizer.AddWindow(addbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER)
+    
             plcwindowmainsizer = wx.BoxSizer(wx.VERTICAL)
             plcwindowsizer.AddSizer(plcwindowmainsizer, 0, border=5, flag=wx.ALL)
             
@@ -396,7 +440,7 @@
             plcwindowbuttonsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW)
             
             paramswindow = wx.Panel(plcwindow, -1, size=wx.Size(-1, -1))
-            paramswindow.SetBackgroundColour(WINDOW_COLOUR)
+            paramswindow.SetBackgroundColour(TITLE_COLOUR)
             plcwindowbuttonsizer.AddWindow(paramswindow, 0, border=0, flag=0)
             
             psizer = wx.BoxSizer(wx.HORIZONTAL)
@@ -411,31 +455,27 @@
             minimizebutton = wx.lib.buttons.GenBitmapToggleButton(id=minimizebutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Maximize.png')),
                   name='MinimizeButton', parent=plcwindow, pos=wx.Point(0, 0),
                   size=wx.Size(24, 24), style=wx.NO_BORDER)
-            minimizebutton.GetBackgroundBrush = gen_mini_GetBackgroundBrush(minimizebutton)
-            minimizebutton.SetBackgroundColour(wx.Colour(208, 208, 208))
-            minimizebutton.labelDelta = 0
-            minimizebutton.SetBezelWidth(0)
-            minimizebutton.SetUseFocusIndicator(False)
+            make_genbitmaptogglebutton_flat(minimizebutton)
             minimizebutton.SetBitmapSelected(wx.Bitmap(os.path.join(CWD, 'images', 'Minimize.png')))
             plcwindowbuttonsizer.AddWindow(minimizebutton, 0, border=5, flag=wx.ALL)
             
-            if len(self.PluginRoot.PlugChildsTypes) > 0:
-                addsizer = self.GenerateAddButtonSizer(self.PluginRoot, plcwindow)
-                plcwindowbuttonsizer.AddSizer(addsizer, 0, border=0, flag=0)
-            else:
-                addsizer = None
+#            if len(self.PluginRoot.PlugChildsTypes) > 0:
+#                addsizer = self.GenerateAddButtonSizer(self.PluginRoot, plcwindow)
+#                plcwindowbuttonsizer.AddSizer(addsizer, 0, border=0, flag=0)
+#            else:
+#                addsizer = None
 
             def togglewindow(event):
                 if minimizebutton.GetToggle():
                     paramswindow.Show()
                     msizer.SetCols(1)
-                    if addsizer is not None:
-                        addsizer.SetCols(1)
+#                    if addsizer is not None:
+#                        addsizer.SetCols(1)
                 else:
                     paramswindow.Hide()
                     msizer.SetCols(len(self.PluginRoot.PluginMethods))
-                    if addsizer is not None:
-                        addsizer.SetCols(len(self.PluginRoot.PlugChildsTypes))
+#                    if addsizer is not None:
+#                        addsizer.SetCols(len(self.PluginRoot.PlugChildsTypes))
                 self.PLCConfigMainSizer.Layout()
                 self.RefreshScrollBars()
                 event.Skip()
@@ -444,25 +484,25 @@
         self.PLCConfigMainSizer.Layout()
         self.RefreshScrollBars()
 
-    def GenerateAddButtonSizer(self, plugin, parent, horizontal = True):
-        if horizontal:
-            addsizer = wx.FlexGridSizer(cols=len(plugin.PluginMethods))
-        else:
-            addsizer = wx.FlexGridSizer(cols=1)
-        for name, XSDClass in plugin.PlugChildsTypes:
-            addbutton_id = wx.NewId()
-            addbutton = wx.lib.buttons.GenButton(id=addbutton_id, label="Add %s"%name,
-                  name='AddBusButton', parent=parent, pos=wx.Point(0, 0),
-                  style=wx.NO_BORDER)
-            font = addbutton.GetFont()
-            font.SetUnderlined(True)
-            addbutton.SetFont(font)
-            addbutton._GetLabelSize = gen_textbutton_GetLabelSize(addbutton)
-            addbutton.SetForegroundColour(wx.BLUE)
-            addbutton.SetToolTipString("Add a %s plugin to this one"%name)
-            addbutton.Bind(wx.EVT_BUTTON, self._GetAddPluginFunction(name, plugin), id=addbutton_id)
-            addsizer.AddWindow(addbutton, 0, border=0, flag=0)
-        return addsizer
+#    def GenerateAddButtonSizer(self, plugin, parent, horizontal = True):
+#        if horizontal:
+#            addsizer = wx.FlexGridSizer(cols=len(plugin.PluginMethods))
+#        else:
+#            addsizer = wx.FlexGridSizer(cols=1)
+#        for name, XSDClass, help in plugin.PlugChildsTypes:
+#            addbutton_id = wx.NewId()
+#            addbutton = wx.lib.buttons.GenButton(id=addbutton_id, label="Add %s"%help,
+#                  name='AddBusButton', parent=parent, pos=wx.Point(0, 0),
+#                  style=wx.NO_BORDER)
+#            font = addbutton.GetFont()
+#            font.SetUnderlined(True)
+#            addbutton.SetFont(font)
+#            addbutton._GetLabelSize = gen_textbutton_GetLabelSize(addbutton)
+#            addbutton.SetForegroundColour(wx.BLUE)
+#            addbutton.SetToolTipString("Add a \"%s\" plugin to this one"%name)
+#            addbutton.Bind(wx.EVT_BUTTON, self._GetAddPluginFunction(name, plugin), id=addbutton_id)
+#            addsizer.AddWindow(addbutton, 0, border=0, flag=0)
+#        return addsizer
 
     def GenerateMethodButtonSizer(self, plugin, parent, horizontal = True):
         if horizontal:
@@ -498,7 +538,7 @@
         for child in self.PluginInfos[plugin]["children"]:
             self.PluginTreeSizer.Show(self.PluginInfos[child]["left"])
             self.PluginTreeSizer.Show(self.PluginInfos[child]["middle"])
-            self.PluginTreeSizer.Show(self.PluginInfos[child]["right"])
+#            self.PluginTreeSizer.Show(self.PluginInfos[child]["right"])
             if force or not self.PluginInfos[child]["expanded"]:
                 self.ExpandPlugin(child, force)
                 if force:
@@ -508,7 +548,7 @@
         for child in self.PluginInfos[plugin]["children"]:
             self.PluginTreeSizer.Hide(self.PluginInfos[child]["left"])
             self.PluginTreeSizer.Hide(self.PluginInfos[child]["middle"])
-            self.PluginTreeSizer.Hide(self.PluginInfos[child]["right"])
+#            self.PluginTreeSizer.Hide(self.PluginInfos[child]["right"])
             if force or self.PluginInfos[child]["expanded"]:
                 self.CollapsePlugin(child, force)
                 if force:
@@ -525,47 +565,91 @@
         
         self.PluginTreeSizer.AddWindow(leftwindow, 0, border=0, flag=wx.GROW)
         
-        leftwindowsizer = wx.FlexGridSizer(cols=1, rows=2)
+        leftwindowsizer = wx.FlexGridSizer(cols=1, rows=3)
         leftwindowsizer.AddGrowableCol(0)
-        leftwindowsizer.AddGrowableRow(1)
+        leftwindowsizer.AddGrowableRow(2)
         leftwindow.SetSizer(leftwindowsizer)
         
         leftbuttonmainsizer = wx.FlexGridSizer(cols=3, rows=1)
         leftbuttonmainsizer.AddGrowableCol(0)
-        leftwindowsizer.AddSizer(leftbuttonmainsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.TOP)
+        leftwindowsizer.AddSizer(leftbuttonmainsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT) #|wx.TOP
         
         leftbuttonsizer = wx.BoxSizer(wx.HORIZONTAL)
-        leftbuttonmainsizer.AddSizer(leftbuttonsizer, 0, border=15, flag=wx.GROW|wx.RIGHT)
-        
-        ieccsizer = wx.BoxSizer(wx.VERTICAL)
-        leftbuttonsizer.AddSizer(ieccsizer, 0, border=15, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
+        leftbuttonmainsizer.AddSizer(leftbuttonsizer, 0, border=5, flag=wx.GROW|wx.RIGHT)
+        
+        leftsizer = wx.BoxSizer(wx.VERTICAL)
+        leftbuttonsizer.AddSizer(leftsizer, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
+
+        rolesizer = wx.BoxSizer(wx.HORIZONTAL)
+        leftsizer.AddSizer(rolesizer, 0, border=0, flag=wx.GROW|wx.RIGHT)
+
+        roletext = wx.StaticText(leftwindow, -1)
+        roletext.SetLabel(plugin.PlugHelp)
+        rolesizer.AddWindow(roletext, 0, border=5, flag=wx.RIGHT|wx.ALIGN_LEFT)
+
+        enablebutton_id = wx.NewId()
+        enablebutton = wx.lib.buttons.GenBitmapToggleButton(id=enablebutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Disabled.png')),
+              name='EnableButton', parent=leftwindow, size=wx.Size(16, 16), pos=wx.Point(0, 0), style=0)#wx.NO_BORDER)
+        enablebutton.SetToolTipString("Enable/Disable this plugin")
+        make_genbitmaptogglebutton_flat(enablebutton)
+        enablebutton.SetBitmapSelected(wx.Bitmap(os.path.join(CWD, 'images', 'Enabled.png')))
+        enablebutton.SetToggle(plugin.MandatoryParams[1].getEnabled())
+        def toggleenablebutton(event):
+            res, StructChanged = plugin.SetParamsAttribute("BaseParams.Enabled", enablebutton.GetToggle(), self.Log)
+            if StructChanged: wx.CallAfter(self.RefreshPluginTree)
+            enablebutton.SetToggle(res)
+            event.Skip()
+        enablebutton.Bind(wx.EVT_BUTTON, toggleenablebutton, id=enablebutton_id)
+        rolesizer.AddWindow(enablebutton, 0, border=0, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
+
         
         plugin_IECChannel = plugin.BaseParams.getIEC_Channel()
         
+        iecsizer = wx.BoxSizer(wx.HORIZONTAL)
+        leftsizer.AddSizer(iecsizer, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
+
+        st = wx.StaticText(leftwindow, -1)
+        st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"]))
+        st.SetLabel(plugin.GetFullIEC_Channel())
+        iecsizer.AddWindow(st, 0, border=0, flag=0)
+
+        updownsizer = wx.BoxSizer(wx.VERTICAL)
+        iecsizer.AddSizer(updownsizer, 0, border=5, flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL)
+
         if plugin_IECChannel > 0:
             ieccdownbutton_id = wx.NewId()
             ieccdownbutton = wx.lib.buttons.GenBitmapButton(id=ieccdownbutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'IECCDown.png')),
                   name='IECCDownButton', parent=leftwindow, pos=wx.Point(0, 0),
                   size=wx.Size(16, 16), style=wx.NO_BORDER)
             ieccdownbutton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(plugin, plugin_IECChannel - 1), id=ieccdownbutton_id)
-            ieccsizer.AddWindow(ieccdownbutton, 0, border=0, flag=wx.ALIGN_CENTER)
-        else:
-            staticbitmap = wx.StaticBitmap(id=-1, bitmap=GenerateEmptyBitmap(16, 16),
-                  name="staticBitmap", parent=leftwindow,
-                  pos=wx.Point(0, 0), size=wx.Size(16, 16), style=0)
-            ieccsizer.AddWindow(staticbitmap, 0, border=0, flag=wx.ALIGN_CENTER)
-        
-        st = wx.StaticText(leftwindow, -1)
-        st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"]))
-        st.SetLabel(plugin.GetFullIEC_Channel())
-        ieccsizer.AddWindow(st, 0, border=0, flag=0)
-        
+            updownsizer.AddWindow(ieccdownbutton, 0, border=0, flag=wx.ALIGN_LEFT)
+
         ieccupbutton_id = wx.NewId()
         ieccupbutton = wx.lib.buttons.GenBitmapTextButton(id=ieccupbutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'IECCUp.png')),
               name='IECCUpButton', parent=leftwindow, pos=wx.Point(0, 0),
               size=wx.Size(16, 16), style=wx.NO_BORDER)
         ieccupbutton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(plugin, plugin_IECChannel + 1), id=ieccupbutton_id)
-        ieccsizer.AddWindow(ieccupbutton, 0, border=0, flag=wx.ALIGN_CENTER)
+        updownsizer.AddWindow(ieccupbutton, 0, border=0, flag=wx.ALIGN_LEFT)
+
+        adddeletesizer = wx.BoxSizer(wx.VERTICAL)
+        iecsizer.AddSizer(adddeletesizer, 0, border=5, flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL)
+
+        deletebutton_id = wx.NewId()
+        deletebutton = wx.lib.buttons.GenBitmapButton(id=deletebutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Delete16x16.png')),
+              name='DeleteBusButton', parent=leftwindow, pos=wx.Point(0, 0),
+              size=wx.Size(16, 16), style=wx.NO_BORDER)
+        deletebutton.SetToolTipString("Delete this plugin")
+        deletebutton.Bind(wx.EVT_BUTTON, self.GetDeleteButtonFunction(plugin), id=deletebutton_id)
+        adddeletesizer.AddWindow(deletebutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER)
+
+        if len(plugin.PlugChildsTypes) > 0:
+            addbutton_id = wx.NewId()
+            addbutton = wx.lib.buttons.GenBitmapButton(id=addbutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Add16x16.png')),
+                  name='AddBusButton', parent=leftwindow, pos=wx.Point(0, 0),
+                  size=wx.Size(16, 16), style=wx.NO_BORDER)
+            addbutton.SetToolTipString("Add a sub plugin")
+            addbutton.Bind(wx.EVT_BUTTON, self.Gen_AddPluginMenu(plugin), id=addbutton_id)
+            adddeletesizer.AddWindow(addbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER)
         
         if len(self.PluginInfos[plugin]["children"]) > 0:
             expandbutton_id = wx.NewId()
@@ -596,36 +680,14 @@
         tc.SetValue(plugin.MandatoryParams[1].getName())
         tc.Bind(wx.EVT_TEXT_ENTER, self.GetTextCtrlCallBackFunction(tc, plugin, "BaseParams.Name"), id=tc_id)
         leftbuttonsizer.AddWindow(tc, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
-        
-        enablebutton_id = wx.NewId()
-        enablebutton = wx.lib.buttons.GenBitmapToggleButton(id=enablebutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Disabled.png')),
-              name='EnableButton', parent=leftwindow, pos=wx.Point(0, 0), style=wx.NO_BORDER)
-        enablebutton.SetToolTipString("Enable/Disable this plugin")
-        enablebutton.GetBackgroundBrush = gen_mini_GetBackgroundBrush(enablebutton)
-        enablebutton.SetBackgroundColour(wx.Colour(208, 208, 208))
-        enablebutton.labelDelta = 0
-        enablebutton.SetBezelWidth(0)
-        enablebutton.SetUseFocusIndicator(False)
-        enablebutton.SetBitmapSelected(wx.Bitmap(os.path.join(CWD, 'images', 'Enabled.png')))
-        enablebutton.SetToggle(plugin.MandatoryParams[1].getEnabled())
-        def toggleenablebutton(event):
-            res, StructChanged = plugin.SetParamsAttribute("BaseParams.Enabled", enablebutton.GetToggle(), self.Log)
-            if StructChanged: wx.CallAfter(self.RefreshPluginTree)
-            enablebutton.SetToggle(res)
-            event.Skip()
-        enablebutton.Bind(wx.EVT_BUTTON, toggleenablebutton, id=enablebutton_id)
-        leftbuttonsizer.AddWindow(enablebutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
+       
 
         leftminimizebutton_id = wx.NewId()
-        leftminimizebutton = wx.lib.buttons.GenBitmapToggleButton(id=leftminimizebutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Maximize.png')),
+        leftminimizebutton = wx.lib.buttons.GenBitmapToggleButton(id=leftminimizebutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'ShowVars.png')),
               name='MinimizeButton', parent=leftwindow, pos=wx.Point(0, 0),
               size=wx.Size(24, 24), style=wx.NO_BORDER)
-        leftminimizebutton.GetBackgroundBrush = gen_mini_GetBackgroundBrush(leftminimizebutton)
-        leftminimizebutton.SetBackgroundColour(wx.Colour(208, 208, 208))
-        leftminimizebutton.labelDelta = 0
-        leftminimizebutton.SetBezelWidth(0)
-        leftminimizebutton.SetUseFocusIndicator(False)
-        leftminimizebutton.SetBitmapSelected(wx.Bitmap(os.path.join(CWD, 'images', 'Minimize.png')))
+        make_genbitmaptogglebutton_flat(leftminimizebutton)
+        leftminimizebutton.SetBitmapSelected(wx.Bitmap(os.path.join(CWD, 'images', 'HideVars.png')))
         leftminimizebutton.SetToggle(self.PluginInfos[plugin]["left_visible"])
         def toggleleftwindow(event):
             if leftminimizebutton.GetToggle():
@@ -639,14 +701,6 @@
         leftminimizebutton.Bind(wx.EVT_BUTTON, toggleleftwindow, id=leftminimizebutton_id)
         leftbuttonmainsizer.AddWindow(leftminimizebutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER)
 
-        deletebutton_id = wx.NewId()
-        deletebutton = wx.lib.buttons.GenBitmapButton(id=deletebutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Delete24x24.png')),
-              name='DeleteBusButton', parent=leftwindow, pos=wx.Point(0, 0),
-              size=wx.Size(24, 24), style=wx.NO_BORDER)
-        deletebutton.SetToolTipString("Delete this plugin")
-        deletebutton.Bind(wx.EVT_BUTTON, self.GetDeleteButtonFunction(plugin), id=deletebutton_id)
-        leftbuttonmainsizer.AddWindow(deletebutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER)
-
         locations = plugin.GetLocations()
         lb = wx.ListBox(leftwindow, -1, size=wx.Size(-1, max(1, min(len(locations), 4)) * 25), style=wx.NO_BORDER)
         for location in locations:
@@ -667,7 +721,7 @@
         middlewindowsizer = wx.FlexGridSizer(cols=2, rows=1)
         middlewindowsizer.AddGrowableCol(1)
         middlewindowsizer.AddGrowableRow(0)
-        middlewindowmainsizer.AddSizer(middlewindowsizer, 0, border=17, flag=wx.TOP|wx.GROW)
+        middlewindowmainsizer.AddSizer(middlewindowsizer, 0, border=8, flag=wx.TOP|wx.GROW)
         
         msizer = self.GenerateMethodButtonSizer(plugin, middlewindow, not self.PluginInfos[plugin]["middle_visible"])
         middlewindowsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW)
@@ -693,43 +747,39 @@
         middleminimizebutton = wx.lib.buttons.GenBitmapToggleButton(id=middleminimizebutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Maximize.png')),
               name='MinimizeButton', parent=middlewindow, pos=wx.Point(0, 0),
               size=wx.Size(24, 24), style=wx.NO_BORDER)
-        middleminimizebutton.GetBackgroundBrush = gen_mini_GetBackgroundBrush(middleminimizebutton)
-        middleminimizebutton.SetBackgroundColour(wx.Colour(208, 208, 208))
-        middleminimizebutton.labelDelta = 0
-        middleminimizebutton.SetBezelWidth(0)
-        middleminimizebutton.SetUseFocusIndicator(False)
+        make_genbitmaptogglebutton_flat(middleminimizebutton)
         middleminimizebutton.SetBitmapSelected(wx.Bitmap(os.path.join(CWD, 'images', 'Minimize.png')))
         middleminimizebutton.SetToggle(self.PluginInfos[plugin]["middle_visible"])
         middleparamssizer.AddWindow(middleminimizebutton, 0, border=5, flag=wx.ALL)
         
-        rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
-        rightwindow.SetBackgroundColour(wx.Colour(240,240,240))
-        
-        self.PluginTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW)
-        
-        rightsizer = wx.BoxSizer(wx.VERTICAL)
-        rightwindow.SetSizer(rightsizer)
-        
-        rightmainsizer = wx.BoxSizer(wx.VERTICAL)
-        rightsizer.AddSizer(rightmainsizer, 0, border=5, flag=wx.ALL)
-        
-        if len(plugin.PlugChildsTypes) > 0:
-            addsizer = self.GenerateAddButtonSizer(plugin, rightwindow)
-            rightmainsizer.AddSizer(addsizer, 0, border=12, flag=wx.TOP)
-        else:
-            addsizer = None
+#        rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
+#        rightwindow.SetBackgroundColour(wx.Colour(240,240,240))
+#        
+#        self.PluginTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW)
+#        
+#        rightsizer = wx.BoxSizer(wx.VERTICAL)
+#        rightwindow.SetSizer(rightsizer)
+#        
+#        rightmainsizer = wx.BoxSizer(wx.VERTICAL)
+#        rightsizer.AddSizer(rightmainsizer, 0, border=5, flag=wx.ALL)
+#        
+#        if len(plugin.PlugChildsTypes) > 0:
+#            addsizer = self.GenerateAddButtonSizer(plugin, rightwindow)
+#            rightmainsizer.AddSizer(addsizer, 0, border=4, flag=wx.TOP)
+#        else:
+#            addsizer = None
             
         def togglemiddlerightwindow(event):
             if middleminimizebutton.GetToggle():
                 middleparamssizer.Show(0)
                 msizer.SetCols(1)
-                if addsizer is not None:
-                    addsizer.SetCols(1)
+#                if addsizer is not None:
+#                    addsizer.SetCols(1)
             else:
                 middleparamssizer.Hide(0)
                 msizer.SetCols(len(plugin.PluginMethods))
-                if addsizer is not None:
-                    addsizer.SetCols(len(plugin.PlugChildsTypes))
+#                if addsizer is not None:
+#                    addsizer.SetCols(len(plugin.PlugChildsTypes))
             self.PluginInfos[plugin]["middle_visible"] = middleminimizebutton.GetToggle()
             self.PLCConfigMainSizer.Layout()
             self.RefreshScrollBars()
@@ -738,8 +788,9 @@
         
         self.PluginInfos[plugin]["left"] = index[0]
         self.PluginInfos[plugin]["middle"] = index[0] + 1
-        self.PluginInfos[plugin]["right"] = index[0] + 2
-        index[0] += 3
+#        self.PluginInfos[plugin]["right"] = index[0] + 2
+#        index[0] += 3
+        index[0] += 2
         for child in self.PluginInfos[plugin]["children"]:
             self.GenerateTreeBranch(child, index)
             if not self.PluginInfos[child]["expanded"]:
@@ -768,23 +819,17 @@
             event.Skip()
         return OnPluginMenu
     
-    def OnPluginTreeRightUp(self, event):
-        plugin = self.GetSelectedPlugin()
-        if plugin:
+    def Gen_AddPluginMenu(self, plugin):
+        def AddPluginMenu(event):
             main_menu = wx.Menu(title='')
             if len(plugin.PlugChildsTypes) > 0:
-                plugin_menu = wx.Menu(title='')
-                for name, XSDClass in plugin.PlugChildsTypes:
+                for name, XSDClass, help in plugin.PlugChildsTypes:
                     new_id = wx.NewId()
-                    plugin_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=name)
-                    self.Bind(wx.EVT_MENU, self._GetAddPluginFunction(name), id=new_id)
-                main_menu.AppendMenu(-1, "Add", plugin_menu, '')
-            new_id = wx.NewId()
-            main_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text="Delete")
-            self.Bind(wx.EVT_MENU, self.OnDeleteButton, id=new_id)
-            pos_x, pos_y = event.GetPosition()
-            self.PluginTree.PopupMenuXY(main_menu, pos_x, pos_y)
-        event.Skip()
+                    main_menu.Append(help=help, id=new_id, kind=wx.ITEM_NORMAL, text="Append "+help)
+                    self.Bind(wx.EVT_MENU, self._GetAddPluginFunction(name, plugin), id=new_id)
+            self.PopupMenuXY(main_menu)
+            event.Skip()
+        return AddPluginMenu
     
     def GetButtonCallBackFunction(self, plugin, method):
         def OnButtonClick(event):
@@ -866,17 +911,10 @@
                     sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL)
                 else:
                     sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
-                bitmappath = os.path.join("images", "%s.png"%element_infos["name"])
-                if os.path.isfile(bitmappath):
-                    staticbitmap = wx.StaticBitmap(id=-1, bitmap=wx.Bitmap(bitmappath),
-                        name="%s_bitmap"%element_infos["name"], parent=parent,
-                        pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
-                    boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT)
-                else:
-                    staticbitmap = wx.StaticBitmap(id=-1, bitmap=GenerateEmptyBitmap(24, 24),
-                        name="%s_bitmap"%element_infos["name"], parent=parent,
-                        pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
-                    boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT)
+                staticbitmap = GenStaticBitmap(ID=-1, bitmapname="%s.png"%element_infos["name"],
+                    name="%s_bitmap"%element_infos["name"], parent=parent,
+                    pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
+                boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT)
                 statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"], 
                     name="%s_label"%element_infos["name"], parent=parent, 
                     pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0)
@@ -909,17 +947,10 @@
                     sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL)
                 else:
                     sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
-                bitmappath = os.path.join("images", "%s.png"%element_infos["name"])
-                if os.path.isfile(bitmappath):
-                    staticbitmap = wx.StaticBitmap(id=-1, bitmap=wx.Bitmap(bitmappath),
-                        name="%s_bitmap"%element_infos["name"], parent=parent,
-                        pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
-                    boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT)
-                else:
-                    staticbitmap = wx.StaticBitmap(id=-1, bitmap=GenerateEmptyBitmap(24, 24),
-                        name="%s_bitmap"%element_infos["name"], parent=parent,
-                        pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
-                    boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT)
+                staticbitmap = GenStaticBitmap(ID=-1, bitmapname="%s.png"%element_infos["name"],
+                    name="%s_bitmap"%element_infos["name"], parent=parent,
+                    pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
+                boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT)
                 statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"], 
                     name="%s_label"%element_infos["name"], parent=parent, 
                     pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0)
@@ -953,17 +984,10 @@
                     sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL)
                 else:
                     sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
-                bitmappath = os.path.join("images", "%s.png"%element_infos["name"])
-                if os.path.isfile(bitmappath):
-                    staticbitmap = wx.StaticBitmap(id=-1, bitmap=wx.Bitmap(bitmappath),
-                        name="%s_bitmap"%element_infos["name"], parent=parent,
-                        pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
-                    boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT)
-                else:
-                    staticbitmap = wx.StaticBitmap(id=-1, bitmap=GenerateEmptyBitmap(24, 24),
-                        name="%s_bitmap"%element_infos["name"], parent=parent,
-                        pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
-                    boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT)
+                staticbitmap = GenStaticBitmap(ID=-1, bitmapname="%s.png"%element_infos["name"],
+                    name="%s_bitmap"%element_infos["name"], parent=parent,
+                    pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
+                boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT)
 
                 statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"], 
                     name="%s_label"%element_infos["name"], parent=parent, 
@@ -1104,9 +1128,9 @@
         def AddButtonFunction(event):
             if plugin and len(plugin.PlugChildsTypes) > 0:
                 plugin_menu = wx.Menu(title='')
-                for name, XSDClass in plugin.PlugChildsTypes:
+                for name, XSDClass, help in plugin.PlugChildsTypes:
                     new_id = wx.NewId()
-                    plugin_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=name)
+                    plugin_menu.Append(help=help, id=new_id, kind=wx.ITEM_NORMAL, text=name)
                     self.Bind(wx.EVT_MENU, self._GetAddPluginFunction(name, plugin), id=new_id)
                 window_pos = window.GetPosition()
                 wx.CallAfter(self.PLCConfig.PopupMenu, plugin_menu)
Binary file images/Add16x16.png has changed
Binary file images/Delete16x16.png has changed
Binary file images/Disabled.png has changed
Binary file images/Enabled.png has changed
Binary file images/HideVars.png has changed
Binary file images/Maximize.png has changed
Binary file images/Minimize.png has changed
Binary file images/ShowVars.png has changed
Binary file images/Stop24x24.png has changed
Binary file images/empty.png has changed
--- a/plugger.py	Thu Feb 21 11:42:33 2008 +0100
+++ b/plugger.py	Fri Feb 22 12:20:21 2008 +0100
@@ -94,6 +94,8 @@
         self.MandatoryParams = ("BaseParams", self.BaseParams)
         self._AddParamsMembers()
         self.PluggedChilds = {}
+        # copy PluginMethods so that it can be later customized
+        self.PluginMethods = [dic.copy() for dic in self.PluginMethods]
 
     def PluginBaseXmlFilePath(self, PlugName=None):
         return os.path.join(self.PlugPath(PlugName), "baseplugin.xml")
@@ -415,10 +417,13 @@
         @param PlugType: string desining the plugin class name (get name from PlugChildsTypes)
         @param PlugName: string for the name of the plugin instance
         """
-        PlugChildsTypes = dict(self.PlugChildsTypes)
+        # reorgabize self.PlugChildsTypes tuples from (name, PlugClass, Help)
+        # to ( name, (PlugClass, Help)), an make a dict
+        transpose = zip(*self.PlugChildsTypes)
+        PlugChildsTypes = dict(zip(transpose[0],zip(transpose[1],transpose[2])))
         # Check that adding this plugin is allowed
         try:
-            PlugClass = PlugChildsTypes[PlugType]
+            PlugClass, PlugHelp = PlugChildsTypes[PlugType]
         except KeyError:
             raise Exception, "Cannot create child %s of type %s "%(PlugName, PlugType)
         
@@ -444,6 +449,8 @@
                 _self.PlugParent = self
                 # Keep track of the plugin type name
                 _self.PlugType = PlugType
+                # remind the help string, for more fancy display
+                _self.PlugHelp = PlugHelp
                 # Call the base plugin template init - change XSD into class members
                 PlugTemplate.__init__(_self)
                 # check name is unique
@@ -451,7 +458,7 @@
                 # If dir have already be made, and file exist
                 if os.path.isdir(_self.PlugPath(NewPlugName)): #and os.path.isfile(_self.PluginXmlFilePath(PlugName)):
                     #Load the plugin.xml file into parameters members
-                    _self.LoadXMLParams(NewPlugName)
+                    _self.LoadXMLParams(logger, NewPlugName)
                     # Basic check. Better to fail immediately.
                     if (_self.BaseParams.getName() != NewPlugName):
                         raise Exception, "Project tree layout do not match plugin.xml %s!=%s "%(NewPlugName, _self.BaseParams.getName())
@@ -486,24 +493,32 @@
         return newPluginOpj
             
 
-    def LoadXMLParams(self, PlugName = None):
+    def LoadXMLParams(self, logger, PlugName = None):
         methode_name = os.path.join(self.PlugPath(PlugName), "methods.py")
         if os.path.isfile(methode_name):
+            logger.write("Info: %s plugin as some special methods in methods.py\n" % (PlugName or "Root"))
             execfile(methode_name)
 
         # Get the base xml tree
         if self.MandatoryParams:
-            basexmlfile = open(self.PluginBaseXmlFilePath(PlugName), 'r')
-            basetree = minidom.parse(basexmlfile)
-            self.MandatoryParams[1].loadXMLTree(basetree.childNodes[0])
-            basexmlfile.close()
+            #try:
+                basexmlfile = open(self.PluginBaseXmlFilePath(PlugName), 'r')
+                basetree = minidom.parse(basexmlfile)
+                self.MandatoryParams[1].loadXMLTree(basetree.childNodes[0])
+                basexmlfile.close()
+            #except Exception, e:
+            #    logger.write_error("Couldn't load plugin base parameters %s :\n %s" % (PlugName, str(e)))
+                
         
         # Get the xml tree
         if self.PlugParams:
-            xmlfile = open(self.PluginXmlFilePath(PlugName), 'r')
-            tree = minidom.parse(xmlfile)
-            self.PlugParams[1].loadXMLTree(tree.childNodes[0])
-            xmlfile.close()
+            #try:
+                xmlfile = open(self.PluginXmlFilePath(PlugName), 'r')
+                tree = minidom.parse(xmlfile)
+                self.PlugParams[1].loadXMLTree(tree.childNodes[0])
+                xmlfile.close()
+            #except Exception, e:
+            #    logger.write_error("Couldn't load plugin parameters %s :\n %s" % (PlugName, str(e)))
         
     def LoadChilds(self, logger):
         # Iterate over all PlugName@PlugType in plugin directory, and try to open them
@@ -562,7 +577,7 @@
     """
 
     # For root object, available Childs Types are modules of the plugin packages.
-    PlugChildsTypes = [(name, _GetClassFunction(name)) for name in plugins.__all__]
+    PlugChildsTypes = [(name, _GetClassFunction(name), help) for name, help in zip(plugins.__all__,plugins.helps)]
 
     XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
@@ -602,6 +617,18 @@
                 </xsd:choice>
               </xsd:complexType>
             </xsd:element>
+            <xsd:element name="Connection">
+              <xsd:complexType>
+                <xsd:choice>
+                  <xsd:element name="Local"/>
+                  <xsd:element name="TCP_IP">
+                    <xsd:complexType>
+                      <xsd:attribute name="Host" type="xsd:string" use="required"/>
+                    </xsd:complexType>
+                  </xsd:element>
+                </xsd:choice>
+              </xsd:complexType>
+            </xsd:element>
           </xsd:sequence>
           <xsd:attribute name="Compiler" type="xsd:string" use="optional" default="gcc"/>
           <xsd:attribute name="CFLAGS" type="xsd:string" use="required"/>
@@ -632,6 +659,9 @@
         # After __init__ root plugin is not valid
         self.ProjectPath = None
         self.PLCEditor = None
+        
+        # copy PluginMethods so that it can be later customized
+        self.PluginMethods = [dic.copy() for dic in self.PluginMethods]
     
     def HasProjectOpened(self):
         """
@@ -714,7 +744,7 @@
         # If dir have already be made, and file exist
         if os.path.isdir(self.PlugPath()) and os.path.isfile(self.PluginXmlFilePath()):
             #Load the plugin.xml file into parameters members
-            result = self.LoadXMLParams()
+            result = self.LoadXMLParams(logger)
             if result:
                 return result
             #Load and init all the childs
--- a/plugins/__init__.py	Thu Feb 21 11:42:33 2008 +0100
+++ b/plugins/__init__.py	Fri Feb 22 12:20:21 2008 +0100
@@ -3,3 +3,11 @@
 _base_path = path.split(__file__)[0]
 
 __all__ = [name for name in listdir(_base_path) if path.isdir(path.join(_base_path, name)) and name.upper() != "CVS" or name.endswith(".py") and not name.startswith("__")]
+
+helps = []
+for name in __all__:
+    helpfilename = path.join(_base_path, name, "README")
+    if path.isfile(helpfilename):
+        helps.append(open(helpfilename).readline().strip())
+    else:
+        helps.append(name)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/c_ext/README	Fri Feb 22 12:20:21 2008 +0100
@@ -0,0 +1,1 @@
+C extension
\ No newline at end of file
--- a/plugins/c_ext/c_ext.py	Thu Feb 21 11:42:33 2008 +0100
+++ b/plugins/c_ext/c_ext.py	Fri Feb 22 12:20:21 2008 +0100
@@ -157,7 +157,7 @@
     
 class RootClass:
 
-    PlugChildsTypes = [("C_File",_Cfile)]
+    PlugChildsTypes = [("C_File",_Cfile, "C file")]
     
     def PlugGenerate_C(self, buildpath, locations, logger):
         return [],"",False
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/canfestival/README	Fri Feb 22 12:20:21 2008 +0100
@@ -0,0 +1,1 @@
+CANOpen
\ No newline at end of file
--- a/plugins/canfestival/canfestival.py	Thu Feb 21 11:42:33 2008 +0100
+++ b/plugins/canfestival/canfestival.py	Fri Feb 22 12:20:21 2008 +0100
@@ -132,7 +132,7 @@
       </xsd:element>
     </xsd:schema>
     """
-    PlugChildsTypes = [("CanOpenNode",_NodeListPlug)]
+    PlugChildsTypes = [("CanOpenNode",_NodeListPlug, "CanOpen node")]
     def GetParamsAttributes(self, path = None):
         infos = PlugTemplate.GetParamsAttributes(self, path = None)
         for element in infos:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/svgui/README	Fri Feb 22 12:20:21 2008 +0100
@@ -0,0 +1,1 @@
+SVGUI HMI
\ No newline at end of file