Fixed LPCManager according to newer version of Beremiz
authorLaurent Bessard
Wed, 25 Sep 2013 19:04:38 +0200
changeset 53 d92a0c3040a4
parent 52 7fc0928030b6
child 54 eb068364ccfa
Fixed LPCManager according to newer version of Beremiz
LPCManager.py
LPCtarget/toolchain_makefile.py
--- a/LPCManager.py	Wed Jul 03 11:28:12 2013 +0200
+++ b/LPCManager.py	Wed Sep 25 19:04:38 2013 +0200
@@ -136,85 +136,7 @@
               'size' : 18,
              }
 
-# Some helpers to tweak GenBitmapTextButtons
-# TODO: declare customized classes instead.
-gen_mini_GetBackgroundBrush = lambda obj:lambda dc: wx.Brush(obj.GetParent().GetBackgroundColour(), wx.SOLID)
-gen_textbutton_GetLabelSize = lambda obj:lambda:(wx.lib.buttons.GenButton._GetLabelSize(obj)[:-1] + (False,))
-
-def make_genbitmaptogglebutton_flat(button):
-    button.GetBackgroundBrush = gen_mini_GetBackgroundBrush(button)
-    button.labelDelta = 0
-    button.SetBezelWidth(0)
-    button.SetUseFocusIndicator(False)
-
-# Patch wx.lib.imageutils so that gray is supported on alpha images
-import wx.lib.imageutils
-from wx.lib.imageutils import grayOut as old_grayOut
-def grayOut(anImage):
-    if anImage.HasAlpha():
-        AlphaData = anImage.GetAlphaData()
-    else :
-        AlphaData = None
-
-    old_grayOut(anImage)
-
-    if AlphaData is not None:
-        anImage.SetAlphaData(AlphaData)
-
-wx.lib.imageutils.grayOut = grayOut
-
-class GenBitmapTextButton(wx.lib.buttons.GenBitmapTextButton):
-    def _GetLabelSize(self):
-        """ used internally """
-        w, h = self.GetTextExtent(self.GetLabel())
-        if not self.bmpLabel:
-            return w, h, False       # if there isn't a bitmap use the size of the text
-
-        w_bmp = self.bmpLabel.GetWidth()+2
-        h_bmp = self.bmpLabel.GetHeight()+2
-        height = h + h_bmp
-        if w_bmp > w:
-            width = w_bmp
-        else:
-            width = w
-        return width, height, False
-
-    def DrawLabel(self, dc, width, height, dw=0, dy=0):
-        bmp = self.bmpLabel
-        if bmp != None:     # if the bitmap is used
-            if self.bmpDisabled and not self.IsEnabled():
-                bmp = self.bmpDisabled
-            if self.bmpFocus and self.hasFocus:
-                bmp = self.bmpFocus
-            if self.bmpSelected and not self.up:
-                bmp = self.bmpSelected
-            bw,bh = bmp.GetWidth(), bmp.GetHeight()
-            if not self.up:
-                dw = dy = self.labelDelta
-            hasMask = bmp.GetMask() != None
-        else:
-            bw = bh = 0     # no bitmap -> size is zero
-
-        dc.SetFont(self.GetFont())
-        if self.IsEnabled():
-            dc.SetTextForeground(self.GetForegroundColour())
-        else:
-            dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT))
-
-        label = self.GetLabel()
-        tw, th = dc.GetTextExtent(label)        # size of text
-        if not self.up:
-            dw = dy = self.labelDelta
-
-        pos_x = (width-bw)/2+dw      # adjust for bitmap and text to centre
-        pos_y = (height-bh-th)/2+dy
-        if bmp !=None:
-            dc.DrawBitmap(bmp, pos_x, pos_y, hasMask) # draw bitmap if available
-            pos_x = (width-tw)/2+dw      # adjust for bitmap and text to centre
-            pos_y += bh + 2
-
-        dc.DrawText(label, pos_x, pos_y)      # draw the text
-
+from editors.ConfTreeNodeEditor import GenBitmapTextButton
 
 #-------------------------------------------------------------------------------
 #                          CANFESTIVAL CONFNODE HACK
@@ -729,7 +651,7 @@
     def GetTarget(self):
         target = ProjectController.GetTarget(self)
         if self.CurrentMode != SIMULATION_MODE:
-            target.getcontent()["value"].setBuildPath(self.BuildPath)
+            target.getcontent().setBuildPath(self.BuildPath)
         return target
     
     def _getBuildPath(self):
@@ -1331,7 +1253,7 @@
     def _init_ctrls(self, prnt):
         Beremiz._init_ctrls(self, prnt)
         
-        self.PLCConfig = wx.ScrolledWindow(id=ID_BEREMIZPLCCONFIG,
+        self.PLCConfig = wx.ScrolledWindow(
               name='PLCConfig', parent=self.LeftNoteBook, pos=wx.Point(0, 0),
               size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER|wx.HSCROLL|wx.VSCROLL)
         self.PLCConfig.SetBackgroundColour(wx.WHITE)
@@ -2236,7 +2158,7 @@
     if projectOpen is not None:
         projectOpen = DecodeFileSystemPath(projectOpen, False)
     
-    CTR = LPCProjectController(None, Log, buildpath)
+    CTR = LPCProjectController(None, Log, DecodeFileSystemPath(buildpath))
     if projectOpen is not None and os.path.isdir(projectOpen):
         result = CTR.LoadProject(projectOpen)
         if result:
--- a/LPCtarget/toolchain_makefile.py	Wed Jul 03 11:28:12 2013 +0200
+++ b/LPCtarget/toolchain_makefile.py	Wed Sep 25 19:04:38 2013 +0200
@@ -88,7 +88,7 @@
                               "md5": '"'+self.md5key+'"'
                              }
             
-            target = self.CTRInstance.GetTarget().getcontent()["value"]
+            target = self.CTRInstance.GetTarget().getcontent()
             command = target.getCommand().split(' ') +\
                       [target.getBuildPath()] +\
                       [arg % beremizcommand for arg in target.getArguments().split(' ')] +\