author | Edouard Tisserant 7BB06627 <edouard.tisserant@gmail.com> |
Tue, 24 Jan 2017 01:09:54 +0100 | |
branch | 1.2 |
changeset 1641 | 24168e52fc2b |
parent 1615 | af9b0ccb418e |
child 1735 | c02818d7e29f |
permissions | -rw-r--r-- |
814 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
814 | 6 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
7 |
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
814 | 8 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
9 |
# See COPYING file for copyrights details. |
814 | 10 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
11 |
# This program is free software; you can redistribute it and/or |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
12 |
# modify it under the terms of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
13 |
# as published by the Free Software Foundation; either version 2 |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
14 |
# of the License, or (at your option) any later version. |
814 | 15 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
16 |
# This program is distributed in the hope that it will be useful, |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
19 |
# GNU General Public License for more details. |
814 | 20 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
21 |
# You should have received a copy of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
22 |
# along with this program; if not, write to the Free Software |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
23 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
814 | 24 |
|
25 |
import wx |
|
26 |
||
27 |
from controls import VariablePanel |
|
28 |
||
29 |
class EditorPanel(wx.SplitterWindow): |
|
30 |
||
31 |
VARIABLE_PANEL_TYPE = None |
|
32 |
||
33 |
def _init_Editor(self, prnt): |
|
34 |
self.Editor = None |
|
35 |
||
36 |
def _init_MenuItems(self): |
|
37 |
self.MenuItems = [] |
|
38 |
||
39 |
def _init_ctrls(self, parent): |
|
40 |
wx.SplitterWindow.__init__(self, parent, |
|
41 |
style=wx.SUNKEN_BORDER|wx.SP_3D) |
|
42 |
self.SetMinimumPaneSize(1) |
|
43 |
||
44 |
self._init_MenuItems() |
|
45 |
||
46 |
if self.VARIABLE_PANEL_TYPE is not None: |
|
47 |
self.VariableEditor = VariablePanel(self, self, self.Controler, self.VARIABLE_PANEL_TYPE, self.Debug) |
|
48 |
self.VariableEditor.SetTagName(self.TagName) |
|
49 |
else: |
|
50 |
self.VariableEditor = None |
|
51 |
||
52 |
self._init_Editor(self) |
|
53 |
||
54 |
if self.Editor is not None and self.VariableEditor is not None: |
|
55 |
self.SplitHorizontally(self.VariableEditor, self.Editor, 200) |
|
56 |
elif self.VariableEditor is not None: |
|
57 |
self.Initialize(self.VariableEditor) |
|
58 |
elif self.Editor is not None: |
|
59 |
self.Initialize(self.Editor) |
|
60 |
||
61 |
def __init__(self, parent, tagname, window, controler, debug=False): |
|
62 |
self.ParentWindow = window |
|
63 |
self.Controler = controler |
|
64 |
self.TagName = tagname |
|
65 |
self.Icon = None |
|
66 |
self.Debug = debug |
|
67 |
||
68 |
self._init_ctrls(parent) |
|
69 |
||
70 |
def SetTagName(self, tagname): |
|
71 |
self.TagName = tagname |
|
72 |
if self.VARIABLE_PANEL_TYPE is not None: |
|
73 |
self.VariableEditor.SetTagName(tagname) |
|
74 |
||
75 |
def GetTagName(self): |
|
76 |
return self.TagName |
|
77 |
||
78 |
def Select(self): |
|
79 |
self.ParentWindow.EditProjectElement(None, self.GetTagName(), True) |
|
80 |
||
81 |
def GetTitle(self): |
|
1615
af9b0ccb418e
replace '-' with '.' in resource tab and transition/action SFC code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
82 |
return ".".join(self.TagName.split("::")[1:]) |
814 | 83 |
|
84 |
def GetIcon(self): |
|
85 |
return self.Icon |
|
86 |
||
87 |
def SetIcon(self, icon): |
|
88 |
self.Icon = icon |
|
89 |
||
90 |
def IsViewing(self, tagname): |
|
91 |
return self.GetTagName() == tagname |
|
92 |
||
93 |
def IsDebugging(self): |
|
94 |
return self.Debug |
|
95 |
||
96 |
def SetMode(self, mode): |
|
97 |
pass |
|
98 |
||
99 |
def ResetBuffer(self): |
|
100 |
pass |
|
101 |
||
102 |
def IsModified(self): |
|
103 |
return False |
|
104 |
||
105 |
def CheckSaveBeforeClosing(self): |
|
106 |
return True |
|
107 |
||
108 |
def Save(self): |
|
109 |
pass |
|
110 |
||
111 |
def SaveAs(self): |
|
112 |
pass |
|
113 |
||
114 |
def GetBufferState(self): |
|
115 |
if self.Controler is not None: |
|
116 |
return self.Controler.GetBufferState() |
|
117 |
return False, False |
|
118 |
||
119 |
def Undo(self): |
|
120 |
if self.Controler is not None: |
|
121 |
self.Controler.LoadPrevious() |
|
122 |
self.RefreshView() |
|
123 |
||
124 |
def Redo(self): |
|
125 |
if self.Controler is not None: |
|
126 |
self.Controler.LoadNext() |
|
127 |
self.RefreshView() |
|
128 |
||
129 |
def Find(self, direction, search_params): |
|
130 |
pass |
|
131 |
||
132 |
def HasNoModel(self): |
|
133 |
return False |
|
134 |
||
135 |
def RefreshView(self, variablepanel=True): |
|
136 |
if variablepanel: |
|
137 |
self.RefreshVariablePanel() |
|
138 |
||
139 |
def RefreshVariablePanel(self): |
|
140 |
if self.VariableEditor is not None: |
|
141 |
self.VariableEditor.RefreshView() |
|
142 |
||
143 |
def GetConfNodeMenuItems(self): |
|
144 |
return self.MenuItems |
|
145 |
||
146 |
def RefreshConfNodeMenu(self, confnode_menu): |
|
147 |
pass |
|
148 |
||
149 |
def _Refresh(self, *args): |
|
150 |
self.ParentWindow._Refresh(*args) |
|
151 |
||
152 |
def RefreshScaling(self, refresh=True): |
|
153 |
pass |
|
154 |
||
155 |
def AddHighlight(self, infos, start, end, highlight_type): |
|
156 |
if self.VariableEditor is not None and infos[0] in ["var_local", "var_input", "var_output", "var_inout"]: |
|
157 |
self.VariableEditor.AddVariableHighlight(infos[1:], highlight_type) |
|
158 |
||
159 |
def RemoveHighlight(self, infos, start, end, highlight_type): |
|
160 |
if self.VariableEditor is not None and infos[0] in ["var_local", "var_input", "var_output", "var_inout"]: |
|
161 |
self.VariableEditor.RemoveVariableHighlight(infos[1:], highlight_type) |
|
162 |
||
163 |
def ClearHighlights(self, highlight_type=None): |
|
164 |
if self.VariableEditor is not None: |
|
165 |
self.VariableEditor.ClearHighlights(highlight_type) |