PLCOpenEditor.py
changeset 203 76c407fb33fe
parent 190 f37abf3ee358
child 210 17ce08b81775
equal deleted inserted replaced
202:e219803fdd11 203:76c407fb33fe
   158               "add_contact.png", "Create a new contact")],
   158               "add_contact.png", "Create a new contact")],
   159     "ST"  : [],
   159     "ST"  : [],
   160     "IL"  : []
   160     "IL"  : []
   161 }
   161 }
   162 
   162 
       
   163 def GenerateBitmap(icon1_name, icon2_name = None):
       
   164     if icon2_name is None:
       
   165         return wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name))
       
   166     else:
       
   167         icon1 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name))
       
   168         icon2 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon2_name))
       
   169         width = icon1.GetWidth() + icon2.GetWidth() - 1
       
   170         height = max(icon1.GetHeight(), icon2.GetHeight())
       
   171         tmp_bitmap = wx.EmptyBitmap(width, height)
       
   172         dc = wx.MemoryDC()
       
   173         dc.SelectObject(tmp_bitmap)
       
   174         dc.Clear()
       
   175         dc.DrawBitmap(icon1, 0, 0)
       
   176         dc.DrawBitmap(icon2, icon1.GetWidth() - 1, 0)
       
   177         return tmp_bitmap
       
   178 
   163 def AppendMenu(parent, help, id, kind, text):
   179 def AppendMenu(parent, help, id, kind, text):
   164     if wx.VERSION >= (2, 6, 0):
   180     if wx.VERSION >= (2, 6, 0):
   165         parent.Append(help=help, id=id, kind=kind, text=text)
   181         parent.Append(help=help, id=id, kind=kind, text=text)
   166     else:
   182     else:
   167         parent.Append(helpString=help, id=id, kind=kind, item=text)
   183         parent.Append(helpString=help, id=id, kind=kind, item=text)
   607             notebook = self.GetNotebook()
   623             notebook = self.GetNotebook()
   608             if notebook is not None:
   624             if notebook is not None:
   609                 return notebook.SetPageText(idx, text)
   625                 return notebook.SetPageText(idx, text)
   610         else:
   626         else:
   611             return self.TabsOpened.SetPageText(idx, text)
   627             return self.TabsOpened.SetPageText(idx, text)
       
   628 
       
   629     def SetPageBitmap(self, idx, bitmap):
       
   630         if wx.VERSION >= (2, 8, 0):
       
   631             notebook = self.GetNotebook()
       
   632             if notebook is not None:
       
   633                 return notebook.SetPageBitmap(idx, bitmap)
       
   634         else:
       
   635             return self.TabsOpened.SetPageImage(idx, bitmap)
   612 
   636 
   613     def GetPageText(self, idx):
   637     def GetPageText(self, idx):
   614         if wx.VERSION >= (2, 8, 0):
   638         if wx.VERSION >= (2, 8, 0):
   615             notebook = self.GetNotebook()
   639             notebook = self.GetNotebook()
   616             if notebook is not None:
   640             if notebook is not None:
  1028 
  1052 
  1029     def RefreshPageTitles(self):
  1053     def RefreshPageTitles(self):
  1030         for idx in xrange(self.GetPageCount()):
  1054         for idx in xrange(self.GetPageCount()):
  1031             window = self.GetPage(idx)
  1055             window = self.GetPage(idx)
  1032             words = window.GetTagName().split("::")
  1056             words = window.GetTagName().split("::")
       
  1057             if words[0] == "P":
       
  1058                 pou_type = self.Controler.GetEditedElementType(window.GetTagName())[1].upper()
       
  1059                 pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName())
       
  1060                 self.SetPageBitmap(idx, GenerateBitmap(pou_type, pou_body_type))
       
  1061             elif words[0] == "T":
       
  1062                 pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName())
       
  1063                 self.SetPageBitmap(idx, GenerateBitmap("TRANSITION", pou_body_type))
       
  1064             elif words[0] == "A":
       
  1065                 pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName())
       
  1066                 self.SetPageBitmap(idx, GenerateBitmap("ACTION", pou_body_type))
       
  1067             elif words[0] == "C":
       
  1068                 self.SetPageBitmap(idx, GenerateBitmap("CONFIGURATION"))
       
  1069             elif words[0] == "R":
       
  1070                 self.SetPageBitmap(idx, GenerateBitmap("RESOURCE"))
       
  1071             elif words[0] == "D":
       
  1072                 self.SetPageBitmap(idx, GenerateBitmap("DATATYPE"))
  1033             self.SetPageText(idx, "-".join(words[1:]))
  1073             self.SetPageText(idx, "-".join(words[1:]))
  1034 
  1074 
  1035 
  1075 
  1036 #-------------------------------------------------------------------------------
  1076 #-------------------------------------------------------------------------------
  1037 #                         Project Tree Management Functions
  1077 #                         Project Tree Management Functions