615 # Creating Tool Bar |
615 # Creating Tool Bar |
616 # ----------------------------------------------------------------------- |
616 # ----------------------------------------------------------------------- |
617 |
617 |
618 MenuToolBar = wx.ToolBar(self, ID_PLCOPENEDITOREDITORMENUTOOLBAR, |
618 MenuToolBar = wx.ToolBar(self, ID_PLCOPENEDITOREDITORMENUTOOLBAR, |
619 wx.DefaultPosition, wx.DefaultSize, |
619 wx.DefaultPosition, wx.DefaultSize, |
620 wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER) |
620 wx.TB_FLAT | wx.TB_HORIZONTAL | wx.NO_BORDER) |
621 MenuToolBar.SetToolBitmapSize(wx.Size(25, 25)) |
621 MenuToolBar.SetToolBitmapSize(wx.Size(25, 25)) |
622 MenuToolBar.Realize() |
622 MenuToolBar.Realize() |
623 self.Panes["MenuToolBar"] = MenuToolBar |
623 self.Panes["MenuToolBar"] = MenuToolBar |
624 self.AUIManager.AddPane(MenuToolBar, wx.aui.AuiPaneInfo(). |
624 self.AUIManager.AddPane(MenuToolBar, wx.aui.AuiPaneInfo(). |
625 Name("MenuToolBar").Caption(_("Menu ToolBar")). |
625 Name("MenuToolBar").Caption(_("Menu ToolBar")). |
626 ToolbarPane().Top(). |
626 ToolbarPane().Top(). |
627 LeftDockable(False).RightDockable(False)) |
627 LeftDockable(False).RightDockable(False)) |
628 |
628 |
629 EditorToolBar = wx.ToolBar(self, ID_PLCOPENEDITOREDITORTOOLBAR, |
629 EditorToolBar = wx.ToolBar(self, ID_PLCOPENEDITOREDITORTOOLBAR, |
630 wx.DefaultPosition, wx.DefaultSize, |
630 wx.DefaultPosition, wx.DefaultSize, |
631 wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER) |
631 wx.TB_FLAT | wx.TB_HORIZONTAL | wx.NO_BORDER) |
632 EditorToolBar.SetToolBitmapSize(wx.Size(25, 25)) |
632 EditorToolBar.SetToolBitmapSize(wx.Size(25, 25)) |
633 EditorToolBar.AddRadioTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION, |
633 EditorToolBar.AddRadioTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION, |
634 _("Select an object"), |
634 _("Select"), |
635 GetBitmap("select"), |
635 GetBitmap("select"), |
636 wx.NullBitmap) |
636 wx.NullBitmap, |
|
637 _("Select an object")) |
637 EditorToolBar.Realize() |
638 EditorToolBar.Realize() |
638 self.Panes["EditorToolBar"] = EditorToolBar |
639 self.Panes["EditorToolBar"] = EditorToolBar |
639 self.AUIManager.AddPane(EditorToolBar, wx.aui.AuiPaneInfo(). |
640 self.AUIManager.AddPane(EditorToolBar, wx.aui.AuiPaneInfo(). |
640 Name("EditorToolBar").Caption(_("Editor ToolBar")). |
641 Name("EditorToolBar").Caption(_("Editor ToolBar")). |
641 ToolbarPane().Top().Position(1). |
642 ToolbarPane().Top().Position(1). |
2119 for toolbar_item in items: |
2120 for toolbar_item in items: |
2120 if toolbar_item is None: |
2121 if toolbar_item is None: |
2121 MenuToolBar.AddSeparator() |
2122 MenuToolBar.AddSeparator() |
2122 else: |
2123 else: |
2123 id, bitmap, help, callback = toolbar_item |
2124 id, bitmap, help, callback = toolbar_item |
2124 MenuToolBar.AddTool(id, help, GetBitmap(bitmap)) |
2125 MenuToolBar.AddTool(id, help, GetBitmap(bitmap), help) |
2125 if callback is not None: |
2126 if callback is not None: |
2126 self.Bind(wx.EVT_TOOL, callback, id=id) |
2127 self.Bind(wx.EVT_TOOL, callback, id=id) |
2127 MenuToolBar.Realize() |
2128 MenuToolBar.Realize() |
2128 self.AUIManager.GetPane("MenuToolBar").BestSize(MenuToolBar.GetBestSize()) |
2129 self.AUIManager.GetPane("MenuToolBar").BestSize(MenuToolBar.GetBestSize()) |
2129 |
2130 |
2156 self.ResetEditorToolBar() |
2157 self.ResetEditorToolBar() |
2157 self.CurrentMenu = menu |
2158 self.CurrentMenu = menu |
2158 self.CurrentEditorToolBar = [] |
2159 self.CurrentEditorToolBar = [] |
2159 EditorToolBar = self.Panes["EditorToolBar"] |
2160 EditorToolBar = self.Panes["EditorToolBar"] |
2160 if EditorToolBar: |
2161 if EditorToolBar: |
2161 for radio, modes, id, method, picture, help in self.EditorToolBarItems[menu]: |
2162 for radio, modes, id, method_name, picture, help in self.EditorToolBarItems[menu]: |
2162 if modes & self.DrawingMode: |
2163 if modes & self.DrawingMode: |
2163 if radio or self.DrawingMode == FREEDRAWING_MODE: |
2164 if radio or self.DrawingMode == FREEDRAWING_MODE: |
2164 EditorToolBar.AddRadioTool(id, help, GetBitmap(picture), wx.NullBitmap) |
2165 EditorToolBar.AddRadioTool(id, method_name, GetBitmap(picture), wx.NullBitmap, help) |
2165 else: |
2166 else: |
2166 EditorToolBar.AddTool(id, help, GetBitmap(picture)) |
2167 EditorToolBar.AddTool(id, method_name, GetBitmap(picture), help) |
2167 self.Bind(wx.EVT_MENU, getattr(self, method), id=id) |
2168 self.Bind(wx.EVT_MENU, getattr(self, method_name), id=id) |
2168 self.CurrentEditorToolBar.append(id) |
2169 self.CurrentEditorToolBar.append(id) |
2169 EditorToolBar.Realize() |
2170 EditorToolBar.Realize() |
2170 self.AUIManager.GetPane("EditorToolBar").Show() |
2171 self.AUIManager.GetPane("EditorToolBar").Show() |
2171 self.AUIManager.Update() |
2172 self.AUIManager.Update() |
2172 self.AUIManager.GetPane("EditorToolBar").BestSize(EditorToolBar.GetBestSize()) |
2173 self.AUIManager.GetPane("EditorToolBar").BestSize(EditorToolBar.GetBestSize()) |