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: ID = wx.NewId() laurent@586: VARIABLE_PANEL_TYPE = None laurent@586: laurent@586: if wx.VERSION < (2, 6, 0): laurent@586: def Bind(self, event, function, id = None): laurent@586: if id is not None: laurent@586: event(self, id, function) laurent@586: else: laurent@586: event(self, function) laurent@586: laurent@586: def _init_Editor(self, prnt): laurent@586: self.Editor = None laurent@586: laurent@586: def _init_ctrls(self, prnt): laurent@586: wx.SplitterWindow.__init__(self, id=self.ID, name='MainSplitter', parent=prnt, laurent@586: size=wx.Size(0, 0), style=wx.SUNKEN_BORDER|wx.SP_3D) laurent@586: self.SetNeedUpdating(True) laurent@586: self.SetMinimumPaneSize(1) laurent@586: laurent@586: self._init_Editor(self) 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: laurent@586: if self.Editor is not None: laurent@586: self.SplitHorizontally(self.VariableEditor, self.Editor, 200) laurent@586: else: laurent@586: self.Initialize(self.VariableEditor) laurent@586: laurent@586: else: laurent@586: self.VariableEditor = None laurent@586: laurent@586: if self.Editor is not None: laurent@586: 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@586: def IsViewing(self, tagname): laurent@586: return self.TagName == 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@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: 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@586: def ClearHighlights(self, highlight_type=None): laurent@586: if self.VariableEditor is not None: laurent@586: self.VariableEditor.ClearHighlights(highlight_type)