281 remove_function(self.Controler, name) |
281 remove_function(self.Controler, name) |
282 else: |
282 else: |
283 self.ShowErrorMessage(_("\"%s\" is used by one or more POUs. It can't be removed!")%name) |
283 self.ShowErrorMessage(_("\"%s\" is used by one or more POUs. It can't be removed!")%name) |
284 return DeleteElementFunction |
284 return DeleteElementFunction |
285 |
285 |
|
286 |
286 #------------------------------------------------------------------------------- |
287 #------------------------------------------------------------------------------- |
287 # PLCOpenEditor Main Class |
288 # PLCOpenEditor Main Class |
288 #------------------------------------------------------------------------------- |
289 #------------------------------------------------------------------------------- |
289 |
290 |
290 UNEDITABLE_NAMES_DICT = dict([(_(name), name) for name in UNEDITABLE_NAMES]) |
291 UNEDITABLE_NAMES_DICT = dict([(_(name), name) for name in UNEDITABLE_NAMES]) |
543 self.InstancesTree = wx.TreeCtrl(id=ID_PLCOPENEDITORINSTANCESTREE, |
544 self.InstancesTree = wx.TreeCtrl(id=ID_PLCOPENEDITORINSTANCESTREE, |
544 name='InstancesTree', parent=self.TreeNoteBook, |
545 name='InstancesTree', parent=self.TreeNoteBook, |
545 pos=wx.Point(0, 0), size=wx.Size(0, 0), |
546 pos=wx.Point(0, 0), size=wx.Size(0, 0), |
546 style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER) |
547 style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER) |
547 |
548 |
548 self.TabsImageList = wx.ImageList(16, 31) |
549 self.TabsImageList = wx.ImageList(31, 16) |
549 self.TabsImageListIndexes = {} |
550 self.TabsImageListIndexes = {} |
550 |
551 |
551 if self.Debug: |
552 if self.Debug: |
552 if wx.VERSION >= (2, 6, 0): |
553 if wx.VERSION >= (2, 6, 0): |
553 self.InstancesTree.Bind(wx.EVT_RIGHT_UP, self.OnInstancesTreeRightUp) |
554 self.InstancesTree.Bind(wx.EVT_RIGHT_UP, self.OnInstancesTreeRightUp) |
890 return self.TabsImageList.GetBitmap(index) |
891 return self.TabsImageList.GetBitmap(index) |
891 else: |
892 else: |
892 return index |
893 return index |
893 if icon2_name is None: |
894 if icon2_name is None: |
894 # Bitmap with only one icon |
895 # Bitmap with only one icon |
895 tmp_bitmap = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name)) |
896 bitmap = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name)) |
896 else: |
897 else: |
897 # Bitmap with two icon |
898 # Bitmap with two icon |
898 icon1 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name)) |
899 icon1 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name)) |
899 icon2 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon2_name)) |
900 icon2 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon2_name)) |
|
901 |
900 # Calculate bitmap size |
902 # Calculate bitmap size |
901 width = icon1.GetWidth() + icon2.GetWidth() - 1 |
903 width = icon1.GetWidth() + icon2.GetWidth() - 1 |
902 height = max(icon1.GetHeight(), icon2.GetHeight()) |
904 height = max(icon1.GetHeight(), icon2.GetHeight()) |
903 # Create bitmap with both icons |
905 # Create bitmap with both icons |
904 tmp_bitmap = wx.EmptyBitmap(width, height) |
906 bitmap = wx.EmptyBitmap(width, height) |
905 dc = wx.MemoryDC() |
907 dc = wx.MemoryDC() |
906 dc.SelectObject(tmp_bitmap) |
908 dc.SelectObject(bitmap) |
907 dc.Clear() |
909 dc.Clear() |
908 dc.DrawBitmap(icon1, 0, 0) |
910 dc.DrawBitmap(icon1, 0, 0) |
909 dc.DrawBitmap(icon2, icon1.GetWidth() - 1, 0) |
911 dc.DrawBitmap(icon2, icon1.GetWidth() - 1, 0) |
910 if wx.Platform != '__WXMSW__': |
912 dc.Destroy() |
|
913 |
911 # Store bitmap in ImageList |
914 # Store bitmap in ImageList |
912 index = self.TabsImageList.Add(tmp_bitmap) |
915 index = self.TabsImageList.Add(bitmap) |
913 # Save bitmap index in ImageList in dictionary |
916 # Save bitmap index in ImageList in dictionary |
914 self.TabsImageListIndexes[(icon1_name, icon2_name)] = index |
917 self.TabsImageListIndexes[(icon1_name, icon2_name)] = index |
915 if USE_AUI: |
918 if USE_AUI: |
916 return tmp_bitmap |
919 return bitmap |
917 else: |
920 else: |
918 return index |
921 return index |
919 |
922 |
920 ## Function that add a tab in Notebook, calling refresh for tab DClick event |
923 ## Function that add a tab in Notebook, calling refresh for tab DClick event |
921 # for wx.aui.AUINotebook. |
924 # for wx.aui.AUINotebook. |