742 dialog.Destroy() |
736 dialog.Destroy() |
743 event.Veto() |
737 event.Veto() |
744 else: |
738 else: |
745 event.Skip() |
739 event.Skip() |
746 |
740 |
747 def OnVariablesGridEditorShown(self, event): |
741 def BuildStdIECTypesMenu(self,type_menu): |
748 row, col = event.GetRow(), event.GetCol() |
|
749 |
|
750 label_value = self.Table.GetColLabelValue(col, False) |
|
751 if label_value == "Type": |
|
752 type_menu = wx.Menu(title='') # the root menu |
|
753 |
|
754 # build a submenu containing standard IEC types |
742 # build a submenu containing standard IEC types |
755 base_menu = wx.Menu(title='') |
743 base_menu = wx.Menu(title='') |
756 for base_type in self.Controler.GetBaseTypes(): |
744 for base_type in self.Controler.GetBaseTypes(): |
757 new_id = wx.NewId() |
745 new_id = wx.NewId() |
758 AppendMenu(base_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type) |
746 base_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type) |
759 self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(base_type), id=new_id) |
747 self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(base_type), id=new_id) |
760 |
748 |
761 type_menu.AppendMenu(wx.NewId(), _("Base Types"), base_menu) |
749 type_menu.AppendMenu(wx.NewId(), _("Base Types"), base_menu) |
762 |
750 |
|
751 def BuildUserTypesMenu(self,type_menu): |
763 # build a submenu containing user-defined types |
752 # build a submenu containing user-defined types |
764 datatype_menu = wx.Menu(title='') |
753 datatype_menu = wx.Menu(title='') |
765 datatypes = self.Controler.GetDataTypes(basetypes = False, confnodetypes = False) |
754 datatypes = self.Controler.GetDataTypes(basetypes = False, confnodetypes = False) |
766 for datatype in datatypes: |
755 for datatype in datatypes: |
767 new_id = wx.NewId() |
756 new_id = wx.NewId() |
768 AppendMenu(datatype_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype) |
757 datatype_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype) |
769 self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id) |
758 self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id) |
770 |
759 |
771 type_menu.AppendMenu(wx.NewId(), _("User Data Types"), datatype_menu) |
760 type_menu.AppendMenu(wx.NewId(), _("User Data Types"), datatype_menu) |
772 |
761 |
773 for category in self.Controler.GetConfNodeDataTypes(): |
762 def BuildLibsTypesMenu(self, type_menu): |
774 |
763 for category in self.Controler.GetConfNodeDataTypes(): |
775 if len(category["list"]) > 0: |
764 if len(category["list"]) > 0: |
776 # build a submenu containing confnode types |
765 # build a submenu containing confnode types |
777 confnode_datatype_menu = wx.Menu(title='') |
766 confnode_datatype_menu = wx.Menu(title='') |
778 for datatype in category["list"]: |
767 for datatype in category["list"]: |
779 new_id = wx.NewId() |
768 new_id = wx.NewId() |
780 AppendMenu(confnode_datatype_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype) |
769 confnode_datatype_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype) |
781 self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id) |
770 self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id) |
782 |
771 |
783 type_menu.AppendMenu(wx.NewId(), category["name"], confnode_datatype_menu) |
772 type_menu.AppendMenu(wx.NewId(), category["name"], confnode_datatype_menu) |
784 |
773 |
785 # build a submenu containing function block types |
774 def BuildProjectTypesMenu(self, type_menu, classtype): |
786 bodytype = self.Controler.GetEditedElementBodyType(self.TagName) |
775 # build a submenu containing function block types |
787 pouname, poutype = self.Controler.GetEditedElementType(self.TagName) |
776 bodytype = self.Controler.GetEditedElementBodyType(self.TagName) |
|
777 pouname, poutype = self.Controler.GetEditedElementType(self.TagName) |
|
778 if classtype in ["Input", "Output", "InOut", "External", "Global"] or \ |
|
779 poutype != "function" and bodytype in ["ST", "IL"]: |
|
780 functionblock_menu = wx.Menu(title='') |
|
781 fbtypes = self.Controler.GetFunctionBlockTypes(self.TagName) |
|
782 for functionblock_type in fbtypes: |
|
783 new_id = wx.NewId() |
|
784 functionblock_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=functionblock_type) |
|
785 self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(functionblock_type), id=new_id) |
|
786 |
|
787 type_menu.AppendMenu(wx.NewId(), _("Function Block Types"), functionblock_menu) |
|
788 |
|
789 def BuildArrayTypesMenu(self, type_menu): |
|
790 new_id = wx.NewId() |
|
791 type_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Array")) |
|
792 self.Bind(wx.EVT_MENU, self.VariableArrayTypeFunction, id=new_id) |
|
793 |
|
794 def OnVariablesGridEditorShown(self, event): |
|
795 row, col = event.GetRow(), event.GetCol() |
|
796 |
|
797 label_value = self.Table.GetColLabelValue(col, False) |
|
798 if label_value == "Type": |
788 classtype = self.Table.GetValueByName(row, "Class") |
799 classtype = self.Table.GetValueByName(row, "Class") |
789 |
800 type_menu = wx.Menu(title='') # the root menu |
790 new_id = wx.NewId() |
801 |
791 AppendMenu(type_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Array")) |
802 self.BuildStdIECTypesMenu(type_menu) |
792 self.Bind(wx.EVT_MENU, self.VariableArrayTypeFunction, id=new_id) |
803 |
793 |
804 self.BuildUserTypesMenu(type_menu) |
794 if classtype in ["Input", "Output", "InOut", "External", "Global"] or \ |
805 |
795 poutype != "function" and bodytype in ["ST", "IL"]: |
806 self.BuildLibsTypesMenu(type_menu) |
796 functionblock_menu = wx.Menu(title='') |
807 |
797 fbtypes = self.Controler.GetFunctionBlockTypes(self.TagName) |
808 self.BuildProjectTypesMenu(type_menu,classtype) |
798 for functionblock_type in fbtypes: |
809 |
799 new_id = wx.NewId() |
810 self.BuildArrayTypesMenu(type_menu) |
800 AppendMenu(functionblock_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=functionblock_type) |
|
801 self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(functionblock_type), id=new_id) |
|
802 |
|
803 type_menu.AppendMenu(wx.NewId(), _("Function Block Types"), functionblock_menu) |
|
804 |
811 |
805 rect = self.VariablesGrid.BlockToDeviceRect((row, col), (row, col)) |
812 rect = self.VariablesGrid.BlockToDeviceRect((row, col), (row, col)) |
806 corner_x = rect.x + rect.width |
813 corner_x = rect.x + rect.width |
807 corner_y = rect.y + self.VariablesGrid.GetColLabelSize() |
814 corner_y = rect.y + self.VariablesGrid.GetColLabelSize() |
808 |
815 |