481 addbutton_id = wx.NewId() |
481 addbutton_id = wx.NewId() |
482 addbutton = wx.lib.buttons.GenBitmapButton(id=addbutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Add24x24.png')), |
482 addbutton = wx.lib.buttons.GenBitmapButton(id=addbutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Add24x24.png')), |
483 name='AddBusButton', parent=window, pos=wx.Point(0, 0), |
483 name='AddBusButton', parent=window, pos=wx.Point(0, 0), |
484 size=wx.Size(24, 24), style=wx.NO_BORDER) |
484 size=wx.Size(24, 24), style=wx.NO_BORDER) |
485 addbutton.SetToolTipString("Add a plugin to this one") |
485 addbutton.SetToolTipString("Add a plugin to this one") |
486 addbutton.Bind(wx.EVT_BUTTON, self.GetAddButtonFunction(root), id=addbutton_id) |
486 addbutton.Bind(wx.EVT_BUTTON, self.GetAddButtonFunction(root, window), id=addbutton_id) |
487 tcsizer.AddWindow(addbutton, 0, border=5, flag=wx.LEFT|wx.RIGHT|wx.TOP|wx.BOTTOM|wx.ALIGN_CENTER) |
487 tcsizer.AddWindow(addbutton, 0, border=5, flag=wx.LEFT|wx.RIGHT|wx.TOP|wx.BOTTOM|wx.ALIGN_CENTER) |
488 |
488 |
489 if plugin != self.PluginRoot: |
489 if plugin != self.PluginRoot: |
490 deletebutton_id = wx.NewId() |
490 deletebutton_id = wx.NewId() |
491 deletebutton = wx.lib.buttons.GenBitmapButton(id=deletebutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Delete24x24.png')), |
491 deletebutton = wx.lib.buttons.GenBitmapButton(id=deletebutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Delete24x24.png')), |
661 toolbar = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, |
661 toolbar = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, |
662 wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER | wx.TB_TEXT) |
662 wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER | wx.TB_TEXT) |
663 toolbar.SetToolBitmapSize(wx.Size(48, 48)) |
663 toolbar.SetToolBitmapSize(wx.Size(48, 48)) |
664 else: |
664 else: |
665 boxsizer = wx.BoxSizer(wx.HORIZONTAL) |
665 boxsizer = wx.BoxSizer(wx.HORIZONTAL) |
|
666 width = 0 |
666 for plugin_infos in self.PluginRoot.PluginMethods: |
667 for plugin_infos in self.PluginRoot.PluginMethods: |
667 if "method" in plugin_infos: |
668 if "method" in plugin_infos: |
668 id = wx.NewId() |
669 id = wx.NewId() |
669 if "bitmap" in plugin_infos: |
670 if "bitmap" in plugin_infos: |
670 if wx.VERSION < (2, 8, 0): |
671 if wx.VERSION < (2, 8, 0): |
685 button = wx.Button(id=id, label=plugin_infos["name"], |
686 button = wx.Button(id=id, label=plugin_infos["name"], |
686 name=plugin_infos["name"], parent=toolbar, |
687 name=plugin_infos["name"], parent=toolbar, |
687 pos=wx.Point(0, 0), size=(-1, 48), style=wx.BU_EXACTFIT) |
688 pos=wx.Point(0, 0), size=(-1, 48), style=wx.BU_EXACTFIT) |
688 button.SetToolTipString(plugin_infos["tooltip"]) |
689 button.SetToolTipString(plugin_infos["tooltip"]) |
689 button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(self.PluginRoot, plugin_infos["method"]), id=id) |
690 button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(self.PluginRoot, plugin_infos["method"]), id=id) |
|
691 width += button.GetSize()[0] |
690 if wx.VERSION < (2, 8, 0): |
692 if wx.VERSION < (2, 8, 0): |
691 boxsizer.AddWindow(button, 0, border=5, flag=wx.GROW|wx.RIGHT) |
693 boxsizer.AddWindow(button, 0, border=5, flag=wx.GROW|wx.RIGHT) |
692 else: |
694 else: |
693 toolbar.AddControl(button) |
695 toolbar.AddControl(button) |
694 if wx.VERSION < (2, 8, 0): |
696 if wx.VERSION < (2, 8, 0): |
699 self.Panes["ToolBar"] = toolbar |
701 self.Panes["ToolBar"] = toolbar |
700 self.AUIManager.AddPane(toolbar, wx.aui.AuiPaneInfo(). |
702 self.AUIManager.AddPane(toolbar, wx.aui.AuiPaneInfo(). |
701 Name("ToolBar").Caption("Toolbar"). |
703 Name("ToolBar").Caption("Toolbar"). |
702 ToolbarPane().Top(). |
704 ToolbarPane().Top(). |
703 LeftDockable(False).RightDockable(False)) |
705 LeftDockable(False).RightDockable(False)) |
|
706 if wx.Platform == '__WXMSW__': |
|
707 self.AUIManagerGetPane("ToolBar").BestSize(wx.Size(width + 3, 55)) |
704 self.AUIManager.Update() |
708 self.AUIManager.Update() |
705 |
709 |
706 def RefreshPluginParams(self): |
710 def RefreshPluginParams(self): |
707 plugin = self.GetSelectedPlugin() |
711 plugin = self.GetSelectedPlugin() |
708 if not plugin: |
712 if not plugin: |
1065 |
1069 |
1066 def CloseEditor(self, bus_id): |
1070 def CloseEditor(self, bus_id): |
1067 if self.BusManagers.get(bus_id, None) != None: |
1071 if self.BusManagers.get(bus_id, None) != None: |
1068 self.BusManagers[bus_id]["Editor"] = None |
1072 self.BusManagers[bus_id]["Editor"] = None |
1069 |
1073 |
1070 def GetAddButtonFunction(self, item): |
1074 def GetAddButtonFunction(self, item, window): |
1071 def AddButtonFunction(event): |
1075 def AddButtonFunction(event): |
1072 plugin = self.GetSelectedPlugin(item) |
1076 plugin = self.GetSelectedPlugin(item) |
1073 if plugin and len(plugin.PlugChildsTypes) > 0: |
1077 if plugin and len(plugin.PlugChildsTypes) > 0: |
1074 plugin_menu = wx.Menu(title='') |
1078 plugin_menu = wx.Menu(title='') |
1075 for name, XSDClass in plugin.PlugChildsTypes: |
1079 for name, XSDClass in plugin.PlugChildsTypes: |
1076 new_id = wx.NewId() |
1080 new_id = wx.NewId() |
1077 plugin_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=name) |
1081 plugin_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=name) |
1078 self.Bind(wx.EVT_MENU, self._GetAddPluginFunction(name, item), id=new_id) |
1082 self.Bind(wx.EVT_MENU, self._GetAddPluginFunction(name, item), id=new_id) |
1079 rect = self.PluginTree.GetBoundingRect(item, True) |
1083 window_pos = window.GetPosition() |
1080 wx.CallAfter(self.PluginTree.PopupMenuXY, plugin_menu, rect.x + rect.width, rect.y) |
1084 button = event.GetButtonObj() |
|
1085 button_pos, button_size = button.GetPosition(), button.GetSize() |
|
1086 wx.CallAfter(self.PluginTree.PopupMenuXY, plugin_menu, |
|
1087 window_pos.x + button_pos.x + button_size.width, |
|
1088 window_pos.y + button_pos.y) |
1081 event.Skip() |
1089 event.Skip() |
1082 return AddButtonFunction |
1090 return AddButtonFunction |
1083 |
1091 |
1084 def GetDeleteButtonFunction(self, item): |
1092 def GetDeleteButtonFunction(self, item): |
1085 def DeleteButtonFunction(event): |
1093 def DeleteButtonFunction(event): |