--- a/PLCOpenEditor.py Tue Mar 27 23:55:10 2012 +0200
+++ b/PLCOpenEditor.py Tue Mar 27 23:57:51 2012 +0200
@@ -124,10 +124,8 @@
ID_PLCOPENEDITORTHIRDSPLITTER, ID_PLCOPENEDITORLIBRARYPANEL,
ID_PLCOPENEDITORLIBRARYTREE, ID_PLCOPENEDITORLIBRARYCOMMENT,
ID_PLCOPENEDITORTABSOPENED, ID_PLCOPENEDITORTABSOPENED,
- ID_PLCOPENEDITORTOOLBAR, ID_PLCOPENEDITORDEFAULTTOOLBAR,
- ID_PLCOPENEDITORSFCTOOLBAR, ID_PLCOPENEDITORFBDTOOLBAR,
- ID_PLCOPENEDITORLDTOOLBAR,
-] = [wx.NewId() for _init_ctrls in range(19)]
+ ID_PLCOPENEDITOREDITORMENUTOOLBAR, ID_PLCOPENEDITOREDITORTOOLBAR,
+] = [wx.NewId() for _init_ctrls in range(16)]
# Define PLCOpenEditor FileMenu extra items id
[ID_PLCOPENEDITORFILEMENUGENERATE,
@@ -142,20 +140,20 @@
#-------------------------------------------------------------------------------
-# ToolBars definitions
+# EditorToolBar definitions
#-------------------------------------------------------------------------------
# Define PLCOpenEditor Toolbar items id
-[ID_PLCOPENEDITORTOOLBARSELECTION, ID_PLCOPENEDITORTOOLBARCOMMENT,
- ID_PLCOPENEDITORTOOLBARVARIABLE, ID_PLCOPENEDITORTOOLBARBLOCK,
- ID_PLCOPENEDITORTOOLBARCONNECTION, ID_PLCOPENEDITORTOOLBARWIRE,
- ID_PLCOPENEDITORTOOLBARPOWERRAIL, ID_PLCOPENEDITORTOOLBARRUNG,
- ID_PLCOPENEDITORTOOLBARCOIL, ID_PLCOPENEDITORTOOLBARCONTACT,
- ID_PLCOPENEDITORTOOLBARBRANCH, ID_PLCOPENEDITORTOOLBARINITIALSTEP,
- ID_PLCOPENEDITORTOOLBARSTEP, ID_PLCOPENEDITORTOOLBARTRANSITION,
- ID_PLCOPENEDITORTOOLBARACTIONBLOCK, ID_PLCOPENEDITORTOOLBARDIVERGENCE,
- ID_PLCOPENEDITORTOOLBARJUMP, ID_PLCOPENEDITORTOOLBARMOTION,
-] = [wx.NewId() for _init_coll_DefaultToolBar_Items in range(18)]
+[ID_PLCOPENEDITOREDITORTOOLBARSELECTION, ID_PLCOPENEDITOREDITORTOOLBARCOMMENT,
+ ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, ID_PLCOPENEDITOREDITORTOOLBARBLOCK,
+ ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, ID_PLCOPENEDITOREDITORTOOLBARWIRE,
+ ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, ID_PLCOPENEDITOREDITORTOOLBARRUNG,
+ ID_PLCOPENEDITOREDITORTOOLBARCOIL, ID_PLCOPENEDITOREDITORTOOLBARCONTACT,
+ ID_PLCOPENEDITOREDITORTOOLBARBRANCH, ID_PLCOPENEDITOREDITORTOOLBARINITIALSTEP,
+ ID_PLCOPENEDITOREDITORTOOLBARSTEP, ID_PLCOPENEDITOREDITORTOOLBARTRANSITION,
+ ID_PLCOPENEDITOREDITORTOOLBARACTIONBLOCK, ID_PLCOPENEDITOREDITORTOOLBARDIVERGENCE,
+ ID_PLCOPENEDITOREDITORTOOLBARJUMP, ID_PLCOPENEDITOREDITORTOOLBARMOTION,
+] = [wx.NewId() for _init_coll_DefaultEditorToolBar_Items in range(18)]
# Define behaviour of each Toolbar item according to current POU body type
# Informations meaning are in this order:
@@ -165,93 +163,96 @@
# - Item callback function name
# - Item icon filename
# - Item tooltip text
-ToolBarItems = {
+EditorToolBarItems = {
"FBD" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARMOTION, "OnMotionTool",
+ ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool",
"move.png", _("Move the view")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool",
+ ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool",
"add_comment.png", _("Create a new comment")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool",
+ ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool",
"add_variable.png", _("Create a new variable")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool",
+ ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool",
"add_block.png", _("Create a new block")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool",
+ ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool",
"add_connection.png", _("Create a new connection"))],
"LD" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARMOTION, "OnMotionTool",
+ ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool",
"move.png", _("Move the view")),
(True, FREEDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool",
+ ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool",
"add_comment.png", _("Create a new comment")),
(True, FREEDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARPOWERRAIL, "OnPowerRailTool",
+ ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool",
"add_powerrail.png", _("Create a new power rail")),
(False, DRIVENDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARRUNG, "OnRungTool",
+ ID_PLCOPENEDITOREDITORTOOLBARRUNG, "OnRungTool",
"add_rung.png", _("Create a new rung")),
(True, FREEDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARCOIL, "OnCoilTool",
+ ID_PLCOPENEDITOREDITORTOOLBARCOIL, "OnCoilTool",
"add_coil.png", _("Create a new coil")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARCONTACT, "OnContactTool",
+ ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool",
"add_contact.png", _("Create a new contact")),
(False, DRIVENDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARBRANCH, "OnBranchTool",
+ ID_PLCOPENEDITOREDITORTOOLBARBRANCH, "OnBranchTool",
"add_branch.png", _("Create a new branch")),
(True, FREEDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool",
+ ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool",
"add_variable.png", _("Create a new variable")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool",
+ ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool",
"add_block.png", _("Create a new block")),
(True, FREEDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool",
+ ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool",
"add_connection.png", _("Create a new connection"))],
"SFC" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARMOTION, "OnMotionTool",
+ ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool",
"move.png", _("Move the view")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool",
+ ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool",
"add_comment.png", _("Create a new comment")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARINITIALSTEP, "OnInitialStepTool",
+ ID_PLCOPENEDITOREDITORTOOLBARINITIALSTEP, "OnInitialStepTool",
"add_initial_step.png", _("Create a new initial step")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARSTEP, "OnStepTool",
+ ID_PLCOPENEDITOREDITORTOOLBARSTEP, "OnStepTool",
"add_step.png", _("Create a new step")),
(True, FREEDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARTRANSITION, "OnTransitionTool",
+ ID_PLCOPENEDITOREDITORTOOLBARTRANSITION, "OnTransitionTool",
"add_transition.png", _("Create a new transition")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARACTIONBLOCK, "OnActionBlockTool",
+ ID_PLCOPENEDITOREDITORTOOLBARACTIONBLOCK, "OnActionBlockTool",
"add_action.png", _("Create a new action block")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARDIVERGENCE, "OnDivergenceTool",
+ ID_PLCOPENEDITOREDITORTOOLBARDIVERGENCE, "OnDivergenceTool",
"add_divergence.png", _("Create a new divergence")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARJUMP, "OnJumpTool",
+ ID_PLCOPENEDITOREDITORTOOLBARJUMP, "OnJumpTool",
"add_jump.png", _("Create a new jump")),
(True, FREEDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool",
+ ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool",
"add_variable.png", _("Create a new variable")),
(True, FREEDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool",
+ ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool",
"add_block.png", _("Create a new block")),
(True, FREEDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool",
+ ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool",
"add_connection.png", _("Create a new connection")),
(True, FREEDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARPOWERRAIL, "OnPowerRailTool",
+ ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool",
"add_powerrail.png", _("Create a new power rail")),
(True, FREEDRAWING_MODE,
- ID_PLCOPENEDITORTOOLBARCONTACT, "OnContactTool",
+ ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool",
"add_contact.png", _("Create a new contact"))],
"ST" : [],
- "IL" : []
+ "IL" : [],
+ "debug": [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool",
+ "move.png", _("Move the view"))],
}
#-------------------------------------------------------------------------------
@@ -265,7 +266,7 @@
else:
parent.Append(helpString=help, id=id, kind=kind, item=text)
-[TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, TYPESTREE,
+[TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, TYPESTREE,
INSTANCESTREE, LIBRARYTREE, SCALING, PAGETITLES
] = range(10)
@@ -382,6 +383,13 @@
id=ID_PLCOPENEDITOREDITMENUADDCONFIGURATION)
self.Bind(wx.EVT_MENU, self.OnSelectAllMenu, id=wx.ID_SELECTALL)
self.Bind(wx.EVT_MENU, self.OnDeleteMenu, id=wx.ID_DELETE)
+
+ self.AddToMenuToolBar([(wx.ID_UNDO, wx.ART_UNDO, _(u'Undo'), None),
+ (wx.ID_REDO, wx.ART_REDO, _(u'Redo'), None),
+ None,
+ (wx.ID_CUT, wx.ART_CUT, _(u'Cut'), None),
+ (wx.ID_COPY, wx.ART_COPY, _(u'Copy'), None),
+ (wx.ID_PASTE, wx.ART_PASTE, _(u'Paste'), None)])
def _init_coll_DisplayMenu_Items(self, parent):
AppendMenu(parent, help='', id=wx.ID_REFRESH,
@@ -438,9 +446,7 @@
wx.Frame.__init__(self, id=ID_PLCOPENEDITOR, name='IDEFrame',
parent=prnt, pos=wx.DefaultPosition, size=wx.Size(1000, 600),
style=wx.DEFAULT_FRAME_STYLE)
- self._init_utils()
self.SetClientSize(wx.Size(1000, 600))
- self.SetMenuBar(self.MenuBar)
self.TabsImageList = wx.ImageList(31, 16)
self.TabsImageListIndexes = {}
@@ -599,27 +605,38 @@
#-----------------------------------------------------------------------
if USE_AUI:
- ToolBar = wx.ToolBar(self, ID_PLCOPENEDITORTOOLBAR, wx.DefaultPosition, wx.DefaultSize,
+ EditorToolBar = wx.ToolBar(self, ID_PLCOPENEDITOREDITORTOOLBAR, wx.DefaultPosition, wx.DefaultSize,
wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER)
- ToolBar.SetToolBitmapSize(wx.Size(25, 25))
- ToolBar.AddRadioTool(ID_PLCOPENEDITORTOOLBARSELECTION,
+ EditorToolBar.SetToolBitmapSize(wx.Size(25, 25))
+ EditorToolBar.AddRadioTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION,
wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, _("Select an object"))
- ToolBar.Realize()
- self.Panes["ToolBar"] = ToolBar
- self.AUIManager.AddPane(ToolBar, wx.aui.AuiPaneInfo().
- Name("ToolBar").Caption(_("Toolbar")).
+ EditorToolBar.Realize()
+ self.Panes["EditorToolBar"] = EditorToolBar
+ self.AUIManager.AddPane(EditorToolBar, wx.aui.AuiPaneInfo().
+ Name("EditorToolBar").Caption(_("Editor ToolBar")).
ToolbarPane().Top().
LeftDockable(False).RightDockable(False))
- else:
- self.ToolBar = self.CreateToolBar(wx.TB_HORIZONTAL|wx.TB_FLAT|wx.NO_BORDER,
- ID_PLCOPENEDITORTOOLBAR, 'ToolBar')
- self.ToolBar.SetToolBitmapSize(wx.Size(25, 25))
- self.ToolBar.AddRadioTool(ID_PLCOPENEDITORTOOLBARSELECTION,
+
+ MenuToolBar = wx.ToolBar(self, ID_PLCOPENEDITOREDITORMENUTOOLBAR, wx.DefaultPosition, wx.DefaultSize,
+ wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER)
+ MenuToolBar.SetToolBitmapSize(wx.Size(25, 25))
+ MenuToolBar.Realize()
+ self.Panes["MenuToolBar"] = MenuToolBar
+ self.AUIManager.AddPane(MenuToolBar, wx.aui.AuiPaneInfo().
+ Name("MenuToolBar").Caption(_("Menu ToolBar")).
+ ToolbarPane().Top().
+ LeftDockable(False).RightDockable(False))
+
+ else:
+ self.EditorToolBar = self.CreateToolBar(wx.TB_HORIZONTAL|wx.TB_FLAT|wx.NO_BORDER,
+ ID_PLCOPENEDITOREDITORTOOLBAR, 'EditorToolBar')
+ self.EditorToolBar.SetToolBitmapSize(wx.Size(25, 25))
+ self.EditorToolBar.AddRadioTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION,
wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, _("Select an object"))
- self.ToolBar.Realize()
+ self.EditorToolBar.Realize()
- self.Bind(wx.EVT_TOOL, self.OnSelectionTool,
- id=ID_PLCOPENEDITORTOOLBARSELECTION)
+ self.Bind(wx.EVT_MENU, self.OnSelectionTool,
+ id=ID_PLCOPENEDITOREDITORTOOLBARSELECTION)
self.SearchResultPanel = SearchResultPanel(self.BottomNoteBook, self)
self.BottomNoteBook.AddPage(self.SearchResultPanel, _("Search"))
@@ -643,6 +660,9 @@
pos=wx.Point(0, 0), size=wx.Size(0, 160),
style=wx.TE_READONLY|wx.TE_MULTILINE)
+ self._init_utils()
+ self.SetMenuBar(self.MenuBar)
+
self._init_sizers()
if self.EnableDebug:
@@ -706,8 +726,8 @@
self.TypesTree.SetImageList(self.TreeImageList)
self.InstancesTree.SetImageList(self.TreeImageList)
- self.CurrentToolBar = []
- self.CurrentLanguage = ""
+ self.CurrentEditorToolBar = []
+ self.CurrentMenu = None
self.SelectedItem = None
self.Highlights = {}
self.DrawingMode = FREEDRAWING_MODE
@@ -753,7 +773,7 @@
def SetRefreshFunctions(self):
self.RefreshFunctions = {
TITLE : self.RefreshTitle,
- TOOLBAR : self.RefreshToolBar,
+ EDITORTOOLBAR : self.RefreshEditorToolBar,
FILEMENU : self.RefreshFileMenu,
EDITMENU : self.RefreshEditMenu,
DISPLAYMENU : self.RefreshDisplayMenu,
@@ -773,7 +793,7 @@
# @param event AUINotebook Event.
def OnPageClose(self, event):
# Refresh all window elements that have changed
- wx.CallAfter(self._Refresh, TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
+ wx.CallAfter(self._Refresh, TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
wx.CallAfter(self.RefreshTabCtrlEvent)
event.Skip()
@@ -814,7 +834,7 @@
new_values["creationDateTime"] = old_values["creationDateTime"]
if new_values != old_values:
self.Controler.SetProjectProperties(None, new_values)
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU,
+ self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU,
TYPESTREE, INSTANCESTREE, SCALING)
dialog.Destroy()
@@ -950,7 +970,7 @@
new_index = min(selected, self.TabsOpened.GetPageCount() - 1)
self.TabsOpened.SetSelection(new_index)
# Refresh all window elements that have changed
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
+ self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
self.RefreshTabCtrlEvent()
def OnPageSetupMenu(self, event):
@@ -1010,6 +1030,7 @@
#-------------------------------------------------------------------------------
def RefreshEditMenu(self):
+ MenuToolBar = self.Panes["MenuToolBar"]
if self.Controler is not None:
selected = self.TabsOpened.GetSelection()
if selected > -1:
@@ -1018,7 +1039,9 @@
else:
undo, redo = self.Controler.GetBufferState()
self.EditMenu.Enable(wx.ID_UNDO, undo)
+ MenuToolBar.EnableTool(wx.ID_UNDO, undo)
self.EditMenu.Enable(wx.ID_REDO, redo)
+ MenuToolBar.EnableTool(wx.ID_REDO, redo)
#self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO, True)
#self.EditMenu.Check(ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO,
# self.Controler.IsProjectBufferEnabled())
@@ -1027,24 +1050,36 @@
self.EditMenu.Enable(wx.ID_DELETE, True)
if self.TabsOpened.GetPageCount() > 0:
self.EditMenu.Enable(wx.ID_CUT, True)
+ MenuToolBar.EnableTool(wx.ID_CUT, True)
self.EditMenu.Enable(wx.ID_COPY, True)
+ MenuToolBar.EnableTool(wx.ID_COPY, True)
if self.GetCopyBuffer() is not None:
self.EditMenu.Enable(wx.ID_PASTE, True)
+ MenuToolBar.EnableTool(wx.ID_PASTE, True)
else:
self.EditMenu.Enable(wx.ID_PASTE, False)
+ MenuToolBar.EnableTool(wx.ID_PASTE, False)
self.EditMenu.Enable(wx.ID_SELECTALL, True)
else:
self.EditMenu.Enable(wx.ID_CUT, False)
+ MenuToolBar.EnableTool(wx.ID_CUT, False)
self.EditMenu.Enable(wx.ID_COPY, False)
+ MenuToolBar.EnableTool(wx.ID_COPY, False)
self.EditMenu.Enable(wx.ID_PASTE, False)
+ MenuToolBar.EnableTool(wx.ID_PASTE, False)
self.EditMenu.Enable(wx.ID_SELECTALL, False)
else:
self.EditMenu.Enable(wx.ID_UNDO, False)
+ MenuToolBar.EnableTool(wx.ID_UNDO, False)
self.EditMenu.Enable(wx.ID_REDO, False)
+ MenuToolBar.EnableTool(wx.ID_REDO, False)
#self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO, False)
self.EditMenu.Enable(wx.ID_CUT, False)
+ MenuToolBar.EnableTool(wx.ID_CUT, False)
self.EditMenu.Enable(wx.ID_COPY, False)
+ MenuToolBar.EnableTool(wx.ID_COPY, False)
self.EditMenu.Enable(wx.ID_PASTE, False)
+ MenuToolBar.EnableTool(wx.ID_PASTE, False)
self.EditMenu.Enable(wx.ID_SELECTALL, False)
self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, False)
self.EditMenu.Enable(wx.ID_ADD, False)
@@ -1118,7 +1153,7 @@
if function is not None:
function(self, selected)
self.CloseTabsWithoutModel()
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, TYPESTREE,
+ self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, TYPESTREE,
INSTANCESTREE, LIBRARYTREE)
elif isinstance(window, (Viewer, TextViewer)):
event = wx.KeyEvent(wx.EVT_CHAR._getEvtType())
@@ -1226,7 +1261,7 @@
window.RefreshView()
else:
wx.CallAfter(self.SelectInstancesTreeItem, window.GetInstancePath())
- wx.CallAfter(self._Refresh, FILEMENU, EDITMENU, DISPLAYMENU, TOOLBAR)
+ wx.CallAfter(self._Refresh, FILEMENU, EDITMENU, DISPLAYMENU, EDITORTOOLBAR)
event.Skip()
def RefreshEditor(self):
@@ -1563,7 +1598,7 @@
if old_selected >= 0:
self.TabsOpened.GetPage(old_selected).ResetBuffer()
self.TabsOpened.SetSelection(openedidx)
- self._Refresh(FILEMENU, EDITMENU, TOOLBAR, PAGETITLES)
+ self._Refresh(FILEMENU, EDITMENU, EDITORTOOLBAR, PAGETITLES)
elif not onlyopened:
new_window = None
if element == ITEM_CONFIGURATION:
@@ -1956,7 +1991,7 @@
if item is None:
self.TabsOpened.DeletePage(idx)
elif isinstance(editor, GraphicViewer):
- editor.ResetView()
+ editor.ResetView(True)
else:
editor.RefreshView()
self.DebugVariablePanel.UnregisterObsoleteData()
@@ -2047,66 +2082,86 @@
dragSource.DoDragDrop()
#-------------------------------------------------------------------------------
-# ToolBar Management Functions
-#-------------------------------------------------------------------------------
-
- def ResetToolBar(self):
+# ToolBars Management Functions
+#-------------------------------------------------------------------------------
+
+ def AddToMenuToolBar(self, items):
+ MenuToolBar = self.Panes["MenuToolBar"]
+ if MenuToolBar.GetToolsCount() > 0:
+ MenuToolBar.AddSeparator()
+ for toolbar_item in items:
+ if toolbar_item is None:
+ MenuToolBar.AddSeparator()
+ else:
+ id, bitmap, help, callback = toolbar_item
+ if not isinstance(bitmap, wx.Bitmap):
+ bitmap = wx.ArtProvider.GetBitmap(bitmap, wx.ART_TOOLBAR, (24, 24))
+ MenuToolBar.AddSimpleTool(id=id, shortHelpString=help, bitmap=bitmap)
+ if callback is not None:
+ self.Bind(wx.EVT_TOOL, callback, id=id)
+ MenuToolBar.Realize()
if USE_AUI:
- ToolBar = self.Panes["ToolBar"]
- else:
- ToolBar = self.ToolBar
-
- for item in self.CurrentToolBar:
+ self.AUIManager.GetPane("MenuToolBar").BestSize(MenuToolBar.GetBestSize())
+
+ def ResetEditorToolBar(self):
+ if USE_AUI:
+ EditorToolBar = self.Panes["EditorToolBar"]
+ else:
+ EditorToolBar = self.EditorToolBar
+
+ for item in self.CurrentEditorToolBar:
if wx.VERSION >= (2, 6, 0):
self.Unbind(wx.EVT_MENU, id=item)
else:
self.Disconnect(id=item, eventType=wx.wxEVT_COMMAND_MENU_SELECTED)
- if ToolBar:
- ToolBar.DeleteTool(item)
-
- if ToolBar:
- ToolBar.Realize()
+ if EditorToolBar:
+ EditorToolBar.DeleteTool(item)
+
+ if EditorToolBar:
+ EditorToolBar.Realize()
if USE_AUI:
- self.AUIManager.GetPane("ToolBar").BestSize(ToolBar.GetBestSize())
+ self.AUIManager.GetPane("EditorToolBar").BestSize(EditorToolBar.GetBestSize())
self.AUIManager.Update()
- def RefreshToolBar(self):
+ def RefreshEditorToolBar(self):
selected = self.TabsOpened.GetSelection()
- language = None
+ menu = None
if selected != -1:
window = self.TabsOpened.GetPage(selected)
if not window.IsDebugging():
- language = self.Controler.GetEditedElementBodyType(window.GetTagName())
- if language is not None and language != self.CurrentLanguage:
- self.ResetToolBar()
- self.CurrentLanguage = language
- self.CurrentToolBar = []
+ menu = self.Controler.GetEditedElementBodyType(window.GetTagName())
+ else:
+ menu = "debug"
+ if menu is not None and menu != self.CurrentMenu:
+ self.ResetEditorToolBar()
+ self.CurrentMenu = menu
+ self.CurrentEditorToolBar = []
if USE_AUI:
- ToolBar = self.Panes["ToolBar"]
+ EditorToolBar = self.Panes["EditorToolBar"]
else:
- ToolBar = self.ToolBar
- if ToolBar:
- for radio, modes, id, method, picture, help in ToolBarItems[language]:
+ EditorToolBar = self.EditorToolBar
+ if EditorToolBar:
+ for radio, modes, id, method, picture, help in EditorToolBarItems[menu]:
if modes & self.DrawingMode:
if radio or self.DrawingMode == FREEDRAWING_MODE:
- ToolBar.AddRadioTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), wx.NullBitmap, help)
+ EditorToolBar.AddRadioTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), wx.NullBitmap, help)
else:
- ToolBar.AddSimpleTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), help)
- self.Bind(wx.EVT_TOOL, getattr(self, method), id=id)
- self.CurrentToolBar.append(id)
- ToolBar.Realize()
+ EditorToolBar.AddSimpleTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), help)
+ self.Bind(wx.EVT_MENU, getattr(self, method), id=id)
+ self.CurrentEditorToolBar.append(id)
+ EditorToolBar.Realize()
if USE_AUI:
- self.AUIManager.GetPane("ToolBar").BestSize(ToolBar.GetBestSize())
+ self.AUIManager.GetPane("EditorToolBar").BestSize(EditorToolBar.GetBestSize())
self.AUIManager.Update()
- elif not language:
- self.ResetToolBar()
- self.CurrentLanguage = language
+ elif not menu:
+ self.ResetEditorToolBar()
+ self.CurrentMenu = menu
self.ResetCurrentMode()
#-------------------------------------------------------------------------------
-# ToolBar Items Functions
+# EditorToolBar Items Functions
#-------------------------------------------------------------------------------
def ResetCurrentMode(self):
@@ -2115,18 +2170,18 @@
window = self.TabsOpened.GetPage(selected)
window.SetMode(MODE_SELECTION)
if USE_AUI:
- ToolBar = self.Panes["ToolBar"]
- else:
- ToolBar = self.ToolBar
- if ToolBar:
- ToolBar.ToggleTool(ID_PLCOPENEDITORTOOLBARSELECTION, False)
- ToolBar.ToggleTool(ID_PLCOPENEDITORTOOLBARSELECTION, True)
+ EditorToolBar = self.Panes["EditorToolBar"]
+ else:
+ EditorToolBar = self.EditorToolBar
+ if EditorToolBar:
+ EditorToolBar.ToggleTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION, False)
+ EditorToolBar.ToggleTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION, True)
def ResetToolToggle(self, id):
if USE_AUI:
- tool = self.Panes["ToolBar"].FindById(id)
- else:
- tool = self.ToolBar.FindById(id)
+ tool = self.Panes["EditorToolBar"].FindById(id)
+ else:
+ tool = self.EditorToolBar.FindById(id)
tool.SetToggle(False)
def OnSelectionTool(self, event):
@@ -2140,31 +2195,31 @@
self.TabsOpened.GetPage(selected).SetMode(MODE_MOTION)
def OnCommentTool(self, event):
- self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARCOMMENT)
+ self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARCOMMENT)
selected = self.TabsOpened.GetSelection()
if selected != -1:
self.TabsOpened.GetPage(selected).SetMode(MODE_COMMENT)
def OnVariableTool(self, event):
- self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARVARIABLE)
+ self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARVARIABLE)
selected = self.TabsOpened.GetSelection()
if selected != -1:
self.TabsOpened.GetPage(selected).SetMode(MODE_VARIABLE)
def OnBlockTool(self, event):
- self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARBLOCK)
+ self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARBLOCK)
selected = self.TabsOpened.GetSelection()
if selected != -1:
self.TabsOpened.GetPage(selected).SetMode(MODE_BLOCK)
def OnConnectionTool(self, event):
- self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARCONNECTION)
+ self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARCONNECTION)
selected = self.TabsOpened.GetSelection()
if selected != -1:
self.TabsOpened.GetPage(selected).SetMode(MODE_CONNECTION)
def OnPowerRailTool(self, event):
- self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARPOWERRAIL)
+ self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL)
selected = self.TabsOpened.GetSelection()
if selected != -1:
self.TabsOpened.GetPage(selected).SetMode(MODE_POWERRAIL)
@@ -2176,7 +2231,7 @@
event.Skip()
def OnCoilTool(self, event):
- self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARCOIL)
+ self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARCOIL)
selected = self.TabsOpened.GetSelection()
if selected != -1:
self.TabsOpened.GetPage(selected).SetMode(MODE_COIL)
@@ -2184,7 +2239,7 @@
def OnContactTool(self, event):
if self.DrawingMode == FREEDRAWING_MODE:
- self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARCONTACT)
+ self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARCONTACT)
selected = self.TabsOpened.GetSelection()
if selected != -1:
if self.DrawingMode == FREEDRAWING_MODE:
@@ -2198,14 +2253,14 @@
self.TabsOpened.GetPage(selected).AddLadderBranch()
def OnInitialStepTool(self, event):
- self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARINITIALSTEP)
+ self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARINITIALSTEP)
selected = self.TabsOpened.GetSelection()
if selected != -1:
self.TabsOpened.GetPage(selected).SetMode(MODE_INITIALSTEP)
def OnStepTool(self, event):
if self.GetDrawingMode() == FREEDRAWING_MODE:
- self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARSTEP)
+ self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARSTEP)
selected = self.TabsOpened.GetSelection()
if selected != -1:
if self.GetDrawingMode() == FREEDRAWING_MODE:
@@ -2215,7 +2270,7 @@
def OnActionBlockTool(self, event):
if self.GetDrawingMode() == FREEDRAWING_MODE:
- self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARACTIONBLOCK)
+ self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARACTIONBLOCK)
selected = self.TabsOpened.GetSelection()
if selected != -1:
if self.GetDrawingMode() == FREEDRAWING_MODE:
@@ -2224,14 +2279,14 @@
self.TabsOpened.GetPage(selected).AddStepAction()
def OnTransitionTool(self, event):
- self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARTRANSITION)
+ self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARTRANSITION)
selected = self.TabsOpened.GetSelection()
if selected != -1:
self.TabsOpened.GetPage(selected).SetMode(MODE_TRANSITION)
def OnDivergenceTool(self, event):
if self.GetDrawingMode() == FREEDRAWING_MODE:
- self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARDIVERGENCE)
+ self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARDIVERGENCE)
selected = self.TabsOpened.GetSelection()
if selected != -1:
if self.GetDrawingMode() == FREEDRAWING_MODE:
@@ -2241,7 +2296,7 @@
def OnJumpTool(self, event):
if self.GetDrawingMode() == FREEDRAWING_MODE:
- self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARJUMP)
+ self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARJUMP)
selected = self.TabsOpened.GetSelection()
if selected != -1:
if self.GetDrawingMode() == FREEDRAWING_MODE:
@@ -2337,7 +2392,7 @@
selected = self.TypesTree.GetSelection()
if self.TypesTree.GetPyData(selected) == ITEM_POU:
self.Controler.ProjectChangePouType(name, new_type)
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, TYPESTREE, LIBRARYTREE)
+ self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, TYPESTREE, LIBRARYTREE)
return OnChangePouTypeMenu
def OnCopyPou(self, event):
@@ -2365,7 +2420,7 @@
message.ShowModal()
message.Destroy()
else:
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, TYPESTREE, LIBRARYTREE)
+ self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, TYPESTREE, LIBRARYTREE)
#-------------------------------------------------------------------------------
# Remove Project Elements Functions
@@ -2381,7 +2436,7 @@
idx = self.IsOpened(tagname)
if idx is not None:
self.TabsOpened.DeletePage(idx)
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, TYPESTREE)
+ self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, TYPESTREE)
else:
self.ShowErrorMessage(_("\"%s\" is used by one or more POUs. It can't be removed!"))
@@ -2400,7 +2455,7 @@
idx = self.IsOpened(tagname)
if idx is not None:
self.TabsOpened.DeletePage(idx)
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, TYPESTREE, INSTANCESTREE, LIBRARYTREE)
+ self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, TYPESTREE, INSTANCESTREE, LIBRARYTREE)
else:
self.ShowErrorMessage(_("\"%s\" is used by one or more POUs. It can't be removed!"))
@@ -2572,7 +2627,13 @@
self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT)
self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES)
self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT)
-
+
+ self.AddToMenuToolBar([(wx.ID_NEW, wx.ART_NEW, _(u'New'), None),
+ (wx.ID_OPEN, wx.ART_FILE_OPEN, _(u'Open'), None),
+ (wx.ID_SAVE, wx.ART_FILE_SAVE, _(u'Save'), None),
+ (wx.ID_SAVEAS, wx.ART_FILE_SAVE_AS, _(u'Save As...'), None),
+ (wx.ID_PRINT, wx.ART_PRINT, _(u'Print'), None)])
+
def _init_coll_HelpMenu_Items(self, parent):
AppendMenu(parent, help='', id=wx.ID_HELP,
kind=wx.ITEM_NORMAL, text=_(u'PLCOpenEditor\tF1'))
@@ -2609,7 +2670,7 @@
self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
+ self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
if result is not None:
self.ShowErrorMessage(result)
@@ -2637,6 +2698,7 @@
#-------------------------------------------------------------------------------
def RefreshFileMenu(self):
+ MenuToolBar = self.Panes["MenuToolBar"]
if self.Controler is not None:
selected = self.TabsOpened.GetSelection()
if selected >= 0:
@@ -2648,28 +2710,37 @@
if graphic_viewer:
self.FileMenu.Enable(wx.ID_PREVIEW, True)
self.FileMenu.Enable(wx.ID_PRINT, True)
+ MenuToolBar.EnableTool(wx.ID_PRINT, True)
else:
self.FileMenu.Enable(wx.ID_PREVIEW, False)
self.FileMenu.Enable(wx.ID_PRINT, False)
+ MenuToolBar.EnableTool(wx.ID_PRINT, False)
else:
self.FileMenu.Enable(wx.ID_CLOSE, False)
self.FileMenu.Enable(wx.ID_PREVIEW, False)
self.FileMenu.Enable(wx.ID_PRINT, False)
+ MenuToolBar.EnableTool(wx.ID_PRINT, False)
self.FileMenu.Enable(wx.ID_PAGE_SETUP, True)
- self.FileMenu.Enable(wx.ID_SAVE, True)
+ project_modified = not self.Controler.ProjectIsSaved()
+ self.FileMenu.Enable(wx.ID_SAVE, project_modified)
+ MenuToolBar.EnableTool(wx.ID_SAVE, project_modified)
self.FileMenu.Enable(wx.ID_PROPERTIES, True)
self.FileMenu.Enable(wx.ID_CLOSE_ALL, True)
self.FileMenu.Enable(wx.ID_SAVEAS, True)
+ MenuToolBar.EnableTool(wx.ID_SAVEAS, True)
self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATE, True)
else:
self.FileMenu.Enable(wx.ID_CLOSE, False)
self.FileMenu.Enable(wx.ID_PAGE_SETUP, False)
self.FileMenu.Enable(wx.ID_PREVIEW, False)
self.FileMenu.Enable(wx.ID_PRINT, False)
+ MenuToolBar.EnableTool(wx.ID_PRINT, False)
self.FileMenu.Enable(wx.ID_SAVE, False)
+ MenuToolBar.EnableTool(wx.ID_SAVE, False)
self.FileMenu.Enable(wx.ID_PROPERTIES, False)
self.FileMenu.Enable(wx.ID_CLOSE_ALL, False)
self.FileMenu.Enable(wx.ID_SAVEAS, False)
+ MenuToolBar.EnableTool(wx.ID_SAVEAS, False)
self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATE, False)
def OnNewProjectMenu(self, event):
@@ -2706,7 +2777,7 @@
result = self.Controler.OpenXMLFile(filepath)
if result is None:
self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE)
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
+ self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU)
dialog.Destroy()
if result is not None:
@@ -2716,7 +2787,7 @@
if not self.CheckSaveBeforeClosing():
return
self.ResetView()
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
+ self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU)
def OnSaveProjectMenu(self, event):
self.SaveProject()