44 # ------------------------------------------------------------------------------- |
44 # ------------------------------------------------------------------------------- |
45 |
45 |
46 DIMENSION_MODEL = re.compile(r"([0-9]+)\.\.([0-9]+)$") |
46 DIMENSION_MODEL = re.compile(r"([0-9]+)\.\.([0-9]+)$") |
47 |
47 |
48 |
48 |
49 def AppendMenu(parent, help, id, kind, text): |
49 def AppendMenu(parent, help, kind, text): |
50 parent.Append(help=help, id=id, kind=kind, text=text) |
50 return parent.Append(help=help, id=wx.ID_ANY, kind=kind, text=text) |
51 |
51 |
52 |
52 |
53 def GetElementsTableColnames(): |
53 def GetElementsTableColnames(): |
54 _ = NoTranslate |
54 _ = NoTranslate |
55 return ["#", _("Name"), _("Type"), _("Initial Value")] |
55 return ["#", _("Name"), _("Type"), _("Initial Value")] |
631 if self.StructureElementsTable.GetColLabelValue(col, False) == "Type": |
631 if self.StructureElementsTable.GetColLabelValue(col, False) == "Type": |
632 type_menu = wx.Menu(title='') |
632 type_menu = wx.Menu(title='') |
633 |
633 |
634 base_menu = wx.Menu(title='') |
634 base_menu = wx.Menu(title='') |
635 for base_type in self.Controler.GetBaseTypes(): |
635 for base_type in self.Controler.GetBaseTypes(): |
636 new_id = wx.NewId() |
636 new_entry = AppendMenu(base_menu, help='', kind=wx.ITEM_NORMAL, text=base_type) |
637 AppendMenu(base_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type) |
637 self.Bind(wx.EVT_MENU, self.GetElementTypeFunction(base_type), new_entry) |
638 self.Bind(wx.EVT_MENU, self.GetElementTypeFunction(base_type), id=new_id) |
638 type_menu.AppendMenu(wx.ID_ANY, _("Base Types"), base_menu) |
639 type_menu.AppendMenu(wx.NewId(), _("Base Types"), base_menu) |
|
640 |
639 |
641 datatype_menu = wx.Menu(title='') |
640 datatype_menu = wx.Menu(title='') |
642 for datatype in self.Controler.GetDataTypes(self.TagName, False): |
641 for datatype in self.Controler.GetDataTypes(self.TagName, False): |
643 new_id = wx.NewId() |
642 new_entry = AppendMenu(datatype_menu, help='', kind=wx.ITEM_NORMAL, text=datatype) |
644 AppendMenu(datatype_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype) |
643 self.Bind(wx.EVT_MENU, self.GetElementTypeFunction(datatype), new_entry) |
645 self.Bind(wx.EVT_MENU, self.GetElementTypeFunction(datatype), id=new_id) |
644 type_menu.AppendMenu(wx.ID_ANY, _("User Data Types"), datatype_menu) |
646 type_menu.AppendMenu(wx.NewId(), _("User Data Types"), datatype_menu) |
645 |
647 |
646 new_entry = AppendMenu(type_menu, help='', kind=wx.ITEM_NORMAL, text=_("Array")) |
648 new_id = wx.NewId() |
647 self.Bind(wx.EVT_MENU, self.ElementArrayTypeFunction, new_entry) |
649 AppendMenu(type_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Array")) |
|
650 self.Bind(wx.EVT_MENU, self.ElementArrayTypeFunction, id=new_id) |
|
651 |
|
652 # functionblock_menu = wx.Menu(title='') |
|
653 # bodytype = self.Controler.GetEditedElementBodyType(self.TagName) |
|
654 # pouname, poutype = self.Controler.GetEditedElementType(self.TagName) |
|
655 # if classtype in ["Input","Output","InOut","External","Global"] or poutype != "function" and bodytype in ["ST", "IL"]: |
|
656 # for functionblock_type in self.Controler.GetFunctionBlockTypes(self.TagName): |
|
657 # new_id = wx.NewId() |
|
658 # AppendMenu(functionblock_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=functionblock_type) |
|
659 # self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(functionblock_type), id=new_id) |
|
660 # type_menu.AppendMenu(wx.NewId(), _("Function Block Types"), functionblock_menu) |
|
661 |
648 |
662 rect = self.StructureElementsGrid.BlockToDeviceRect((row, col), (row, col)) |
649 rect = self.StructureElementsGrid.BlockToDeviceRect((row, col), (row, col)) |
663 self.StructureElementsGrid.PopupMenuXY(type_menu, rect.x + rect.width, rect.y + self.StructureElementsGrid.GetColLabelSize()) |
650 self.StructureElementsGrid.PopupMenuXY(type_menu, rect.x + rect.width, rect.y + self.StructureElementsGrid.GetColLabelSize()) |
664 type_menu.Destroy() |
651 type_menu.Destroy() |
665 event.Veto() |
652 event.Veto() |