laurent@586: #!/usr/bin/env python laurent@586: # -*- coding: utf-8 -*- laurent@586: laurent@586: #This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor laurent@586: #based on the plcopen standard. laurent@586: # laurent@586: #Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD laurent@586: # laurent@586: #See COPYING file for copyrights details. laurent@586: # laurent@586: #This library is free software; you can redistribute it and/or laurent@586: #modify it under the terms of the GNU General Public laurent@586: #License as published by the Free Software Foundation; either laurent@586: #version 2.1 of the License, or (at your option) any later version. laurent@586: # laurent@586: #This library is distributed in the hope that it will be useful, laurent@586: #but WITHOUT ANY WARRANTY; without even the implied warranty of laurent@586: #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU laurent@586: #General Public License for more details. laurent@586: # laurent@586: #You should have received a copy of the GNU General Public laurent@586: #License along with this library; if not, write to the Free Software laurent@586: #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA laurent@586: laurent@586: import wx laurent@586: laurent@586: from VariablePanel import VariablePanel laurent@586: laurent@586: class EditorPanel(wx.SplitterWindow): laurent@586: laurent@586: VARIABLE_PANEL_TYPE = None laurent@586: laurent@586: def _init_Editor(self, prnt): laurent@586: self.Editor = None laurent@635: laurent@635: def _init_MenuItems(self): laurent@635: self.MenuItems = [] laurent@635: Laurent@714: def _init_ctrls(self, parent): Laurent@714: wx.SplitterWindow.__init__(self, parent, Laurent@714: style=wx.SUNKEN_BORDER|wx.SP_3D) laurent@586: self.SetNeedUpdating(True) laurent@586: self.SetMinimumPaneSize(1) laurent@586: laurent@635: self._init_MenuItems() laurent@586: laurent@586: if self.VARIABLE_PANEL_TYPE is not None: laurent@600: self.VariableEditor = VariablePanel(self, self, self.Controler, self.VARIABLE_PANEL_TYPE, self.Debug) laurent@586: self.VariableEditor.SetTagName(self.TagName) laurent@586: else: laurent@586: self.VariableEditor = None laurent@586: laurent@655: self._init_Editor(self) laurent@655: laurent@655: if self.Editor is not None and self.VariableEditor is not None: laurent@655: self.SplitHorizontally(self.VariableEditor, self.Editor, 200) laurent@655: elif self.VariableEditor is not None: laurent@655: self.Initialize(self.VariableEditor) laurent@655: elif self.Editor is not None: laurent@687: self.Initialize(self.Editor) laurent@586: laurent@600: def __init__(self, parent, tagname, window, controler, debug=False): laurent@586: self.ParentWindow = window laurent@586: self.Controler = controler laurent@586: self.TagName = tagname laurent@586: self.Icon = None laurent@600: self.Debug = debug laurent@586: laurent@586: self._init_ctrls(parent) laurent@586: laurent@586: def SetTagName(self, tagname): laurent@586: self.TagName = tagname laurent@586: if self.VARIABLE_PANEL_TYPE is not None: laurent@586: self.VariableEditor.SetTagName(tagname) laurent@586: laurent@586: def GetTagName(self): laurent@586: return self.TagName laurent@586: laurent@586: def GetTitle(self): laurent@586: return "-".join(self.TagName.split("::")[1:]) laurent@586: laurent@586: def GetIcon(self): laurent@586: return self.Icon laurent@586: laurent@586: def SetIcon(self, icon): laurent@586: self.Icon = icon laurent@586: laurent@675: def GetState(self): laurent@675: return None laurent@675: laurent@675: def SetState(self, state): laurent@675: pass laurent@675: laurent@586: def IsViewing(self, tagname): Laurent@718: return self.GetTagName() == tagname laurent@586: laurent@586: def IsDebugging(self): laurent@613: return self.Debug laurent@586: laurent@586: def SetMode(self, mode): laurent@586: pass laurent@586: laurent@586: def ResetBuffer(self): laurent@586: pass laurent@586: Laurent@719: def IsModified(self): Laurent@719: return False Laurent@719: Laurent@733: def CheckSaveBeforeClosing(self): Laurent@733: return True Laurent@733: Laurent@719: def Save(self): Laurent@719: pass Laurent@719: Laurent@719: def SaveAs(self): Laurent@719: pass Laurent@719: laurent@586: def GetBufferState(self): laurent@586: if self.Controler is not None: laurent@586: return self.Controler.GetBufferState() laurent@586: return False, False laurent@586: laurent@586: def Undo(self): laurent@586: if self.Controler is not None: laurent@586: self.Controler.LoadPrevious() laurent@586: self.RefreshView() laurent@586: laurent@586: def Redo(self): laurent@586: if self.Controler is not None: laurent@586: self.Controler.LoadNext() laurent@586: self.RefreshView() laurent@586: laurent@586: def HasNoModel(self): laurent@586: return False laurent@586: laurent@586: def RefreshView(self, variablepanel=True): laurent@586: if variablepanel: laurent@586: self.RefreshVariablePanel() laurent@586: laurent@586: def RefreshVariablePanel(self): laurent@586: if self.VariableEditor is not None: laurent@586: self.VariableEditor.RefreshView() laurent@586: Edouard@681: def GetConfNodeMenuItems(self): laurent@635: return self.MenuItems laurent@635: Edouard@681: def RefreshConfNodeMenu(self, confnode_menu): laurent@635: pass laurent@635: laurent@586: def _Refresh(self, *args): laurent@586: self.ParentWindow._Refresh(*args) laurent@586: laurent@586: def RefreshScaling(self, refresh=True): laurent@586: pass laurent@586: laurent@617: def AddHighlight(self, infos, start, end, highlight_type): laurent@617: if self.VariableEditor is not None and infos[0] in ["var_local", "var_input", "var_output", "var_inout"]: laurent@617: self.VariableEditor.AddVariableHighlight(infos[1:], highlight_type) laurent@617: laurent@586: def ClearHighlights(self, highlight_type=None): laurent@586: if self.VariableEditor is not None: laurent@586: self.VariableEditor.ClearHighlights(highlight_type)