author | laurent |
Sun, 09 Oct 2011 19:51:14 +0200 | |
changeset 566 | 6014ef82a98a |
parent 556 | 69214983dd03 |
child 576 | 3f2024f30553 |
permissions | -rw-r--r-- |
125 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
4 |
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor |
|
5 |
#based on the plcopen standard. |
|
6 |
# |
|
7 |
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
|
8 |
# |
|
9 |
#See COPYING file for copyrights details. |
|
10 |
# |
|
11 |
#This library is free software; you can redistribute it and/or |
|
12 |
#modify it under the terms of the GNU General Public |
|
13 |
#License as published by the Free Software Foundation; either |
|
14 |
#version 2.1 of the License, or (at your option) any later version. |
|
15 |
# |
|
16 |
#This library is distributed in the hope that it will be useful, |
|
17 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
19 |
#General Public License for more details. |
|
20 |
# |
|
21 |
#You should have received a copy of the GNU General Public |
|
22 |
#License along with this library; if not, write to the Free Software |
|
23 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 |
||
25 |
import wx |
|
26 |
import wx.grid |
|
27 |
import wx.gizmos |
|
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
28 |
from plcopen.structures import IEC_KEYWORDS, TestIdentifier |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
29 |
from graphics.GraphicCommons import REFRESH_HIGHLIGHT_PERIOD |
125 | 30 |
|
207 | 31 |
import re |
32 |
||
33 |
DIMENSION_MODEL = re.compile("([0-9]+)\.\.([0-9]+)$") |
|
34 |
||
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
35 |
def AppendMenu(parent, help, id, kind, text): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
36 |
if wx.VERSION >= (2, 6, 0): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
37 |
parent.Append(help=help, id=id, kind=kind, text=text) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
38 |
else: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
39 |
parent.Append(helpString=help, id=id, kind=kind, item=text) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
40 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
41 |
#------------------------------------------------------------------------------- |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
42 |
# Structure Elements Table |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
43 |
#------------------------------------------------------------------------------- |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
44 |
|
391 | 45 |
def GetElementsTableColnames(): |
46 |
_ = lambda x : x |
|
47 |
return ["#", _("Name"), _("Type"), _("Initial Value")] |
|
48 |
||
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
49 |
class ElementsTable(wx.grid.PyGridTableBase): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
50 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
51 |
""" |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
52 |
A custom wx.grid.Grid Table using user supplied data |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
53 |
""" |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
54 |
def __init__(self, parent, data, colnames): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
55 |
# The base class must be initialized *first* |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
56 |
wx.grid.PyGridTableBase.__init__(self) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
57 |
self.data = data |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
58 |
self.old_value = None |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
59 |
self.colnames = colnames |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
60 |
self.Errors = {} |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
61 |
self.Parent = parent |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
62 |
# XXX |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
63 |
# we need to store the row length and collength to |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
64 |
# see if the table has changed size |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
65 |
self._rows = self.GetNumberRows() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
66 |
self._cols = self.GetNumberCols() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
67 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
68 |
def GetNumberCols(self): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
69 |
return len(self.colnames) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
70 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
71 |
def GetNumberRows(self): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
72 |
return len(self.data) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
73 |
|
391 | 74 |
def GetColLabelValue(self, col, translate=True): |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
75 |
if col < len(self.colnames): |
391 | 76 |
if translate: |
77 |
return _(self.colnames[col]) |
|
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
78 |
return self.colnames[col] |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
79 |
|
391 | 80 |
def GetRowLabelValues(self, row, translate=True): |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
81 |
return row |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
82 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
83 |
def GetValue(self, row, col): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
84 |
if row < self.GetNumberRows(): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
85 |
if col == 0: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
86 |
return row + 1 |
391 | 87 |
name = str(self.data[row].get(self.GetColLabelValue(col, False), "")) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
88 |
return name |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
89 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
90 |
def SetValue(self, row, col, value): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
91 |
if col < len(self.colnames): |
391 | 92 |
colname = self.GetColLabelValue(col, False) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
93 |
if colname == "Name": |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
94 |
self.old_value = self.data[row][colname] |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
95 |
self.data[row][colname] = value |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
96 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
97 |
def GetValueByName(self, row, colname): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
98 |
if row < self.GetNumberRows(): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
99 |
return self.data[row].get(colname) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
100 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
101 |
def SetValueByName(self, row, colname, value): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
102 |
if row < self.GetNumberRows(): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
103 |
self.data[row][colname] = value |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
104 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
105 |
def GetOldValue(self): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
106 |
return self.old_value |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
107 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
108 |
def ResetView(self, grid): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
109 |
""" |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
110 |
(wx.grid.Grid) -> Reset the grid view. Call this to |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
111 |
update the grid if rows and columns have been added or deleted |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
112 |
""" |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
113 |
grid.BeginBatch() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
114 |
for current, new, delmsg, addmsg in [ |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
115 |
(self._rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED), |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
116 |
(self._cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED), |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
117 |
]: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
118 |
if new < current: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
119 |
msg = wx.grid.GridTableMessage(self,delmsg,new,current-new) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
120 |
grid.ProcessTableMessage(msg) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
121 |
elif new > current: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
122 |
msg = wx.grid.GridTableMessage(self,addmsg,new-current) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
123 |
grid.ProcessTableMessage(msg) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
124 |
self.UpdateValues(grid) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
125 |
grid.EndBatch() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
126 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
127 |
self._rows = self.GetNumberRows() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
128 |
self._cols = self.GetNumberCols() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
129 |
# update the column rendering scheme |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
130 |
self._updateColAttrs(grid) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
131 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
132 |
# update the scrollbars and the displayed part of the grid |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
133 |
grid.AdjustScrollbars() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
134 |
grid.ForceRefresh() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
135 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
136 |
def UpdateValues(self, grid): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
137 |
"""Update all displayed values""" |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
138 |
# This sends an event to the grid table to update all of the values |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
139 |
msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
140 |
grid.ProcessTableMessage(msg) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
141 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
142 |
def _updateColAttrs(self, grid): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
143 |
""" |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
144 |
wx.grid.Grid -> update the column attributes to add the |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
145 |
appropriate renderer given the column name. |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
146 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
147 |
Otherwise default to the default renderer. |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
148 |
""" |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
149 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
150 |
for row in range(self.GetNumberRows()): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
151 |
for col in range(self.GetNumberCols()): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
152 |
editor = None |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
153 |
renderer = None |
391 | 154 |
colname = self.GetColLabelValue(col, False) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
155 |
if col != 0: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
156 |
grid.SetReadOnly(row, col, False) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
157 |
if colname == "Name": |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
158 |
editor = wx.grid.GridCellTextEditor() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
159 |
renderer = wx.grid.GridCellStringRenderer() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
160 |
elif colname == "Initial Value": |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
161 |
editor = wx.grid.GridCellTextEditor() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
162 |
renderer = wx.grid.GridCellStringRenderer() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
163 |
elif colname == "Type": |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
164 |
editor = wx.grid.GridCellTextEditor() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
165 |
else: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
166 |
grid.SetReadOnly(row, col, True) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
167 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
168 |
grid.SetCellEditor(row, col, editor) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
169 |
grid.SetCellRenderer(row, col, renderer) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
170 |
|
379
e4c26ee9c998
Code rewritten, replacing all list containing tests by dict key defining tests
laurent
parents:
313
diff
changeset
|
171 |
if self.Errors.has_key(row) and self.Errors[row][0] == colname.lower(): |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
172 |
grid.SetCellBackgroundColour(row, col, wx.Colour(255, 255, 0)) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
173 |
grid.SetCellTextColour(row, col, wx.RED) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
174 |
grid.MakeCellVisible(row, col) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
175 |
else: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
176 |
grid.SetCellTextColour(row, col, wx.BLACK) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
177 |
grid.SetCellBackgroundColour(row, col, wx.WHITE) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
178 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
179 |
def SetData(self, data): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
180 |
self.data = data |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
181 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
182 |
def GetData(self): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
183 |
return self.data |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
184 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
185 |
def AppendRow(self, row_content): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
186 |
self.data.append(row_content) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
187 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
188 |
def RemoveRow(self, row_index): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
189 |
self.data.pop(row_index) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
190 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
191 |
def MoveRow(self, idx, move): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
192 |
new_idx = max(0, min(idx + move, len(self.data) - 1)) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
193 |
if new_idx != idx: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
194 |
self.data.insert(new_idx, self.data.pop(idx)) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
195 |
return new_idx |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
196 |
return None |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
197 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
198 |
def GetRow(self, row_index): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
199 |
return self.data[row_index] |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
200 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
201 |
def Empty(self): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
202 |
self.data = [] |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
203 |
self.editors = [] |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
204 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
205 |
def AddError(self, infos): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
206 |
self.Errors[infos[0]] = infos[1:] |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
207 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
208 |
def ClearErrors(self): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
209 |
self.Errors = {} |
125 | 210 |
|
211 |
#------------------------------------------------------------------------------- |
|
379
e4c26ee9c998
Code rewritten, replacing all list containing tests by dict key defining tests
laurent
parents:
313
diff
changeset
|
212 |
# Datatype Editor class |
125 | 213 |
#------------------------------------------------------------------------------- |
214 |
||
215 |
[ID_DATATYPEEDITOR, ID_DATATYPEEDITORSTATICBOX, |
|
216 |
ID_DATATYPEEDITORDERIVATIONTYPE, ID_DATATYPEEDITORDIRECTLYPANEL, |
|
217 |
ID_DATATYPEEDITORSUBRANGEPANEL, ID_DATATYPEEDITORDIRECTLYBASETYPE, |
|
218 |
ID_DATATYPEEDITORSUBRANGEBASETYPE, ID_DATATYPEEDITORSUBRANGEMINIMUM, |
|
219 |
ID_DATATYPEEDITORSUBRANGEMAXIMUM, ID_DATATYPEEDITORDIRECTLYINITIALVALUE, |
|
220 |
ID_DATATYPEEDITORSUBRANGEINITIALVALUE, ID_DATATYPEEDITORENUMERATEDPANEL, |
|
221 |
ID_DATATYPEEDITORENUMERATEDVALUES, ID_DATATYPEEDITORENUMERATEDINITIALVALUE, |
|
222 |
ID_DATATYPEEDITORARRAYPANEL, ID_DATATYPEEDITORARRAYBASETYPE, |
|
223 |
ID_DATATYPEEDITORARRAYDIMENSIONS, ID_DATATYPEEDITORARRAYINITIALVALUE, |
|
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
224 |
ID_DATATYPEEDITORSTRUCTUREPANEL, ID_DATATYPEEDITORSTRUCTUREELEMENTSGRID, |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
225 |
ID_DATATYPEEDITORSTRUCTUREADDBUTTON, ID_DATATYPEEDITORSTRUCTUREDELETEBUTTON, |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
226 |
ID_DATATYPEEDITORSTRUCTUREUPBUTTON, ID_DATATYPEEDITORSTRUCTUREDOWNBUTTON, |
125 | 227 |
ID_DATATYPEEDITORSTATICTEXT1, ID_DATATYPEEDITORSTATICTEXT2, |
228 |
ID_DATATYPEEDITORSTATICTEXT3, ID_DATATYPEEDITORSTATICTEXT4, |
|
229 |
ID_DATATYPEEDITORSTATICTEXT5, ID_DATATYPEEDITORSTATICTEXT6, |
|
230 |
ID_DATATYPEEDITORSTATICTEXT7, ID_DATATYPEEDITORSTATICTEXT8, |
|
231 |
ID_DATATYPEEDITORSTATICTEXT9, ID_DATATYPEEDITORSTATICTEXT10, |
|
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
232 |
ID_DATATYPEEDITORSTATICTEXT11, |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
233 |
] = [wx.NewId() for _init_ctrls in range(35)] |
125 | 234 |
|
391 | 235 |
def GetDatatypeTypes(): |
236 |
_ = lambda x : x |
|
237 |
return [_("Directly"), _("Subrange"), _("Enumerated"), _("Array"), _("Structure")] |
|
238 |
DATATYPE_TYPES_DICT = dict([(_(datatype), datatype) for datatype in GetDatatypeTypes()]) |
|
239 |
||
125 | 240 |
class DataTypeEditor(wx.Panel): |
241 |
||
242 |
def _init_coll_MainSizer_Items(self, parent): |
|
243 |
parent.AddSizer(self.TopSizer, 0, border=5, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
|
244 |
parent.AddSizer(self.TypeInfosSizer, 0, border=5, flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
|
245 |
||
246 |
def _init_coll_MainSizer_Growables(self, parent): |
|
247 |
parent.AddGrowableCol(0) |
|
248 |
parent.AddGrowableRow(1) |
|
249 |
||
250 |
def _init_coll_TopSizer_Items(self, parent): |
|
391 | 251 |
parent.AddWindow(self.staticText1, 0, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT) |
252 |
parent.AddWindow(self.DerivationType, 0, border=5, flag=wx.GROW|wx.RIGHT) |
|
125 | 253 |
|
254 |
def _init_coll_TypeInfosSizer_Items(self, parent): |
|
255 |
parent.AddWindow(self.DirectlyPanel, 1, border=0, flag=wx.ALL) |
|
256 |
parent.AddWindow(self.SubrangePanel, 1, border=0, flag=wx.ALL) |
|
257 |
parent.AddWindow(self.EnumeratedPanel, 1, border=0, flag=wx.GROW|wx.ALL) |
|
258 |
parent.AddWindow(self.ArrayPanel, 1, border=0, flag=wx.ALL) |
|
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
259 |
parent.AddWindow(self.StructurePanel, 1, border=0, flag=wx.GROW|wx.ALL) |
125 | 260 |
|
261 |
def _init_coll_DirectlyPanelSizer_Items(self, parent): |
|
391 | 262 |
parent.AddWindow(self.staticText2, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) |
125 | 263 |
parent.AddWindow(self.DirectlyBaseType, 1, border=5, flag=wx.GROW|wx.ALL) |
391 | 264 |
parent.AddWindow(self.staticText3, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
265 |
parent.AddWindow(self.DirectlyInitialValue, 1, border=5, flag=wx.ALL) |
125 | 266 |
|
267 |
def _init_coll_SubrangePanelSizer_Items(self, parent): |
|
391 | 268 |
parent.AddWindow(self.staticText4, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) |
125 | 269 |
parent.AddWindow(self.SubrangeBaseType, 1, border=5, flag=wx.GROW|wx.ALL) |
391 | 270 |
parent.AddWindow(self.staticText5, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) |
125 | 271 |
parent.AddWindow(self.SubrangeInitialValue, 1, border=5, flag=wx.GROW|wx.ALL) |
391 | 272 |
parent.AddWindow(self.staticText6, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) |
125 | 273 |
parent.AddWindow(self.SubrangeMinimum, 1, border=5, flag=wx.GROW|wx.ALL) |
274 |
parent.AddWindow(wx.Size(0, 0), 1, border=5, flag=wx.GROW|wx.ALL) |
|
275 |
parent.AddWindow(wx.Size(0, 0), 1, border=5, flag=wx.GROW|wx.ALL) |
|
391 | 276 |
parent.AddWindow(self.staticText7, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) |
125 | 277 |
parent.AddWindow(self.SubrangeMaximum, 1, border=5, flag=wx.GROW|wx.ALL) |
278 |
||
279 |
def _init_coll_EnumeratedPanelSizer_Items(self, parent): |
|
391 | 280 |
parent.AddWindow(self.EnumeratedValues, 1, border=5, flag=wx.GROW|wx.ALL) |
281 |
parent.AddSizer(self.EnumeratedPanelRightSizer, 1, border=0, flag=0) |
|
282 |
||
283 |
def _init_coll_EnumeratedPanelRightSizer_Items(self, parent): |
|
284 |
parent.AddWindow(self.staticText8, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) |
|
125 | 285 |
parent.AddWindow(self.EnumeratedInitialValue, 1, border=5, flag=wx.ALL) |
286 |
||
287 |
def _init_coll_ArrayPanelSizer_Items(self, parent): |
|
288 |
parent.AddSizer(self.ArrayPanelLeftSizer, 0, border=0, flag=wx.GROW) |
|
556
69214983dd03
Enabling support for direct array variable declaration
laurent
parents:
507
diff
changeset
|
289 |
parent.AddSizer(self.ArrayPanelRightSizer, 0, border=0, flag=wx.GROW) |
125 | 290 |
parent.AddWindow(self.ArrayDimensions, 0, border=5, flag=wx.GROW|wx.ALL) |
291 |
||
292 |
def _init_coll_ArrayPanelSizer_Growables(self, parent): |
|
293 |
parent.AddGrowableCol(0) |
|
294 |
parent.AddGrowableCol(1) |
|
295 |
parent.AddGrowableRow(1) |
|
296 |
||
297 |
def _init_coll_ArrayPanelLeftSizer_Items(self, parent): |
|
391 | 298 |
parent.AddWindow(self.staticText9, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) |
125 | 299 |
parent.AddWindow(self.ArrayBaseType, 1, border=5, flag=wx.GROW|wx.ALL) |
300 |
||
301 |
def _init_coll_ArrayPanelRightSizer_Items(self, parent): |
|
391 | 302 |
parent.AddWindow(self.staticText10, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
303 |
parent.AddWindow(self.ArrayInitialValue, 1, border=5, flag=wx.ALL) |
125 | 304 |
|
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
305 |
def _init_coll_StructurePanelSizer_Items(self, parent): |
391 | 306 |
parent.AddWindow(self.staticText11, 0, border=5, flag=wx.ALL) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
307 |
parent.AddWindow(self.StructureElementsGrid, 0, border=0, flag=wx.GROW) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
308 |
parent.AddSizer(self.StructurePanelButtonSizer, 0, border=0, flag=wx.ALIGN_RIGHT) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
309 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
310 |
def _init_coll_StructurePanelSizer_Growables(self, parent): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
311 |
parent.AddGrowableCol(0) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
312 |
parent.AddGrowableRow(1) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
313 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
314 |
def _init_coll_StructurePanelButtonSizer_Items(self, parent): |
391 | 315 |
parent.AddWindow(self.StructureAddButton, 0, border=5, flag=wx.ALL) |
316 |
parent.AddWindow(self.StructureDeleteButton, 0, border=5, flag=wx.ALL) |
|
317 |
parent.AddWindow(self.StructureUpButton, 0, border=5, flag=wx.ALL) |
|
318 |
parent.AddWindow(self.StructureDownButton, 0, border=5, flag=wx.ALL) |
|
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
319 |
|
125 | 320 |
def _init_sizers(self): |
321 |
self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
|
322 |
self.TopSizer = wx.BoxSizer(wx.HORIZONTAL) |
|
323 |
self.TypeInfosSizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL) |
|
324 |
self.DirectlyPanelSizer = wx.BoxSizer(wx.HORIZONTAL) |
|
391 | 325 |
self.SubrangePanelSizer = wx.GridSizer(cols=4, hgap=5, rows=3, vgap=0) |
125 | 326 |
self.EnumeratedPanelSizer = wx.BoxSizer(wx.HORIZONTAL) |
391 | 327 |
self.EnumeratedPanelRightSizer = wx.BoxSizer(wx.HORIZONTAL) |
328 |
self.ArrayPanelSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=0) |
|
125 | 329 |
self.ArrayPanelLeftSizer = wx.BoxSizer(wx.HORIZONTAL) |
330 |
self.ArrayPanelRightSizer = wx.BoxSizer(wx.HORIZONTAL) |
|
391 | 331 |
self.StructurePanelSizer = wx.FlexGridSizer(cols=1, hgap=5, rows=3, vgap=0) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
332 |
self.StructurePanelButtonSizer = wx.BoxSizer(wx.HORIZONTAL) |
125 | 333 |
self._init_coll_MainSizer_Items(self.MainSizer) |
334 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
|
335 |
self._init_coll_TopSizer_Items(self.TopSizer) |
|
336 |
self._init_coll_TypeInfosSizer_Items(self.TypeInfosSizer) |
|
337 |
self._init_coll_DirectlyPanelSizer_Items(self.DirectlyPanelSizer) |
|
338 |
self._init_coll_SubrangePanelSizer_Items(self.SubrangePanelSizer) |
|
339 |
self._init_coll_EnumeratedPanelSizer_Items(self.EnumeratedPanelSizer) |
|
391 | 340 |
self._init_coll_EnumeratedPanelRightSizer_Items(self.EnumeratedPanelRightSizer) |
125 | 341 |
self._init_coll_ArrayPanelSizer_Items(self.ArrayPanelSizer) |
342 |
self._init_coll_ArrayPanelSizer_Growables(self.ArrayPanelSizer) |
|
343 |
self._init_coll_ArrayPanelLeftSizer_Items(self.ArrayPanelLeftSizer) |
|
344 |
self._init_coll_ArrayPanelRightSizer_Items(self.ArrayPanelRightSizer) |
|
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
345 |
self._init_coll_StructurePanelSizer_Items(self.StructurePanelSizer) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
346 |
self._init_coll_StructurePanelSizer_Growables(self.StructurePanelSizer) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
347 |
self._init_coll_StructurePanelButtonSizer_Items(self.StructurePanelButtonSizer) |
125 | 348 |
|
349 |
self.SetSizer(self.MainSizer) |
|
350 |
self.DirectlyPanel.SetSizer(self.DirectlyPanelSizer) |
|
351 |
self.SubrangePanel.SetSizer(self.SubrangePanelSizer) |
|
352 |
self.EnumeratedPanel.SetSizer(self.EnumeratedPanelSizer) |
|
353 |
self.ArrayPanel.SetSizer(self.ArrayPanelSizer) |
|
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
354 |
self.StructurePanel.SetSizer(self.StructurePanelSizer) |
125 | 355 |
|
356 |
def _init_ctrls(self, prnt): |
|
357 |
wx.Panel.__init__(self, id=ID_DATATYPEEDITOR, name='', parent=prnt, |
|
358 |
size=wx.Size(0, 0), style=wx.SUNKEN_BORDER) |
|
359 |
||
360 |
self.staticbox = wx.StaticBox(id=ID_DATATYPEEDITORSTATICBOX, |
|
391 | 361 |
label=_('Type infos:'), name='staticBox1', parent=self, |
362 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
|
125 | 363 |
|
364 |
self.staticText1 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT1, |
|
391 | 365 |
label=_('Derivation Type:'), name='staticText1', parent=self, |
366 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
|
125 | 367 |
|
304 | 368 |
self.DerivationType = wx.ComboBox(id=ID_DATATYPEEDITORDERIVATIONTYPE, |
125 | 369 |
name='DerivationType', parent=self, pos=wx.Point(0, 0), |
313 | 370 |
size=wx.Size(200, 28), style=wx.CB_READONLY) |
304 | 371 |
self.Bind(wx.EVT_COMBOBOX, self.OnDerivationTypeChanged, id=ID_DATATYPEEDITORDERIVATIONTYPE) |
125 | 372 |
|
373 |
# Panel for Directly derived data types |
|
374 |
||
375 |
self.DirectlyPanel = wx.Panel(id=ID_DATATYPEEDITORDIRECTLYPANEL, |
|
376 |
name='DirectlyPanel', parent=self, pos=wx.Point(0, 0), |
|
377 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
|
378 |
||
379 |
self.staticText2 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT2, |
|
391 | 380 |
label=_('Base Type:'), name='staticText2', parent=self.DirectlyPanel, |
381 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
|
125 | 382 |
|
304 | 383 |
self.DirectlyBaseType = wx.ComboBox(id=ID_DATATYPEEDITORDIRECTLYBASETYPE, |
125 | 384 |
name='DirectlyBaseType', parent=self.DirectlyPanel, pos=wx.Point(0, 0), |
313 | 385 |
size=wx.Size(0, 28), style=wx.CB_READONLY) |
304 | 386 |
self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, id=ID_DATATYPEEDITORDIRECTLYBASETYPE) |
125 | 387 |
|
388 |
self.staticText3 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT3, |
|
391 | 389 |
label=_('Initial Value:'), name='staticText3', parent=self.DirectlyPanel, |
390 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
|
125 | 391 |
|
392 |
self.DirectlyInitialValue = wx.TextCtrl(id=ID_DATATYPEEDITORDIRECTLYINITIALVALUE, |
|
393 |
name='DirectlyInitialValue', parent=self.DirectlyPanel, pos=wx.Point(0, 0), |
|
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
394 |
size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|wx.TE_MULTILINE|wx.TE_RICH) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
395 |
self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, id=ID_DATATYPEEDITORDIRECTLYINITIALVALUE) |
125 | 396 |
|
397 |
# Panel for Subrange data types |
|
398 |
||
399 |
self.SubrangePanel = wx.Panel(id=ID_DATATYPEEDITORSUBRANGEPANEL, |
|
400 |
name='SubrangePanel', parent=self, pos=wx.Point(0, 0), |
|
401 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
|
402 |
||
403 |
self.staticText4 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT4, |
|
391 | 404 |
label=_('Base Type:'), name='staticText4', parent=self.SubrangePanel, |
405 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
|
125 | 406 |
|
304 | 407 |
self.SubrangeBaseType = wx.ComboBox(id=ID_DATATYPEEDITORSUBRANGEBASETYPE, |
125 | 408 |
name='SubrangeBaseType', parent=self.SubrangePanel, pos=wx.Point(0, 0), |
313 | 409 |
size=wx.Size(0, 28), style=wx.CB_READONLY) |
304 | 410 |
self.Bind(wx.EVT_COMBOBOX, self.OnSubrangeBaseTypeChanged, id=ID_DATATYPEEDITORSUBRANGEBASETYPE) |
125 | 411 |
|
412 |
self.staticText5 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT5, |
|
391 | 413 |
label=_('Initial Value:'), name='staticText5', parent=self.SubrangePanel, |
414 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
|
125 | 415 |
|
416 |
self.SubrangeInitialValue = wx.SpinCtrl(id=ID_DATATYPEEDITORSUBRANGEINITIALVALUE, |
|
417 |
name='SubrangeInitialValue', parent=self.SubrangePanel, pos=wx.Point(0, 0), |
|
418 |
size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL) |
|
419 |
self.Bind(wx.EVT_SPINCTRL, self.OnInfosChanged, id=ID_DATATYPEEDITORSUBRANGEINITIALVALUE) |
|
420 |
||
421 |
self.staticText6 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT6, |
|
391 | 422 |
label=_('Minimum:'), name='staticText6', parent=self.SubrangePanel, |
423 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
|
125 | 424 |
|
425 |
self.SubrangeMinimum = wx.SpinCtrl(id=ID_DATATYPEEDITORSUBRANGEMINIMUM, |
|
426 |
name='SubrangeMinimum', parent=self.SubrangePanel, pos=wx.Point(0, 0), |
|
427 |
size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL) |
|
428 |
self.Bind(wx.EVT_SPINCTRL, self.OnSubrangeMinimumChanged, id=ID_DATATYPEEDITORSUBRANGEMINIMUM) |
|
429 |
||
430 |
self.staticText7 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT7, |
|
391 | 431 |
label=_('Maximum:'), name='staticText7', parent=self.SubrangePanel, |
432 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
|
125 | 433 |
|
434 |
self.SubrangeMaximum = wx.SpinCtrl(id=ID_DATATYPEEDITORSUBRANGEMAXIMUM, |
|
435 |
name='SubrangeMaximum', parent=self.SubrangePanel, pos=wx.Point(0, 0), |
|
436 |
size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL) |
|
437 |
self.Bind(wx.EVT_SPINCTRL, self.OnSubrangeMaximumChanged, id=ID_DATATYPEEDITORSUBRANGEMAXIMUM) |
|
438 |
||
439 |
# Panel for Enumerated data types |
|
440 |
||
441 |
self.EnumeratedPanel = wx.Panel(id=ID_DATATYPEEDITORENUMERATEDPANEL, |
|
442 |
name='EnumeratedPanel', parent=self, pos=wx.Point(0, 0), |
|
443 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
|
444 |
||
445 |
self.EnumeratedValues = wx.gizmos.EditableListBox(id=ID_DATATYPEEDITORENUMERATEDVALUES, |
|
391 | 446 |
name='EnumeratedValues', parent=self.EnumeratedPanel, label=_("Values:"), pos=wx.Point(0, 0), |
125 | 447 |
size=wx.Size(0, 0), style=wx.gizmos.EL_ALLOW_NEW | wx.gizmos.EL_ALLOW_EDIT | wx.gizmos.EL_ALLOW_DELETE) |
448 |
self.EnumeratedValues.GetListCtrl().Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnEnumeratedValueEndEdit) |
|
391 | 449 |
self.EnumeratedValues.GetEditButton().SetToolTipString(_("Edit item")) |
450 |
new_button = self.EnumeratedValues.GetNewButton() |
|
451 |
new_button.SetToolTipString(_("New item")) |
|
452 |
new_button.Bind(wx.EVT_BUTTON, self.OnEnumeratedValuesChanged) |
|
453 |
del_button = self.EnumeratedValues.GetDelButton() |
|
454 |
del_button.SetToolTipString(_("Delete item")) |
|
455 |
del_button.Bind(wx.EVT_BUTTON, self.OnEnumeratedValuesChanged) |
|
456 |
up_button = self.EnumeratedValues.GetUpButton() |
|
457 |
up_button.SetToolTipString(_("Move up")) |
|
458 |
up_button.Bind(wx.EVT_BUTTON, self.OnEnumeratedValuesChanged) |
|
459 |
down_button = self.EnumeratedValues.GetDownButton() |
|
460 |
down_button.SetToolTipString(_("Move down")) |
|
461 |
down_button.Bind(wx.EVT_BUTTON, self.OnEnumeratedValuesChanged) |
|
125 | 462 |
|
463 |
self.staticText8 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT8, |
|
391 | 464 |
label=_('Initial Value:'), name='staticText8', parent=self.EnumeratedPanel, |
465 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
|
125 | 466 |
|
304 | 467 |
self.EnumeratedInitialValue = wx.ComboBox(id=ID_DATATYPEEDITORENUMERATEDINITIALVALUE, |
125 | 468 |
name='EnumeratedInitialValue', parent=self.EnumeratedPanel, pos=wx.Point(0, 0), |
313 | 469 |
size=wx.Size(0, 28), style=wx.CB_READONLY) |
304 | 470 |
self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, id=ID_DATATYPEEDITORENUMERATEDINITIALVALUE) |
125 | 471 |
|
472 |
# Panel for Array data types |
|
473 |
||
474 |
self.ArrayPanel = wx.Panel(id=ID_DATATYPEEDITORARRAYPANEL, |
|
475 |
name='ArrayPanel', parent=self, pos=wx.Point(0, 0), |
|
476 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
|
477 |
||
478 |
self.staticText9 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT9, |
|
391 | 479 |
label=_('Base Type:'), name='staticText9', parent=self.ArrayPanel, |
480 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
|
125 | 481 |
|
304 | 482 |
self.ArrayBaseType = wx.ComboBox(id=ID_DATATYPEEDITORARRAYBASETYPE, |
507
42150e041dbe
Adding support for direct array variable declaration in variable panel (still disable cause matiec doesn't support this feature)
laurent
parents:
494
diff
changeset
|
483 |
name='ArrayBaseType', parent=self.ArrayPanel, pos=wx.Point(0, 0), |
313 | 484 |
size=wx.Size(0, 28), style=wx.CB_READONLY) |
304 | 485 |
self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, id=ID_DATATYPEEDITORARRAYBASETYPE) |
125 | 486 |
|
487 |
self.ArrayDimensions = wx.gizmos.EditableListBox(id=ID_DATATYPEEDITORARRAYDIMENSIONS, |
|
391 | 488 |
name='ArrayDimensions', parent=self.ArrayPanel, label=_("Dimensions:"), pos=wx.Point(0, 0), |
125 | 489 |
size=wx.Size(0, 24), style=wx.gizmos.EL_ALLOW_NEW | wx.gizmos.EL_ALLOW_EDIT | wx.gizmos.EL_ALLOW_DELETE) |
490 |
self.ArrayDimensions.GetListCtrl().Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnDimensionsChanged) |
|
391 | 491 |
self.ArrayDimensions.GetEditButton().SetToolTipString(_("Edit item")) |
492 |
new_button = self.ArrayDimensions.GetNewButton() |
|
493 |
new_button.SetToolTipString(_("New item")) |
|
494 |
new_button.Bind(wx.EVT_BUTTON, self.OnDimensionsChanged) |
|
495 |
del_button = self.ArrayDimensions.GetDelButton() |
|
496 |
del_button.SetToolTipString(_("Delete item")) |
|
497 |
del_button.Bind(wx.EVT_BUTTON, self.OnDimensionsChanged) |
|
498 |
up_button = self.ArrayDimensions.GetUpButton() |
|
499 |
up_button.SetToolTipString(_("Move up")) |
|
500 |
up_button.Bind(wx.EVT_BUTTON, self.OnDimensionsChanged) |
|
501 |
down_button = self.ArrayDimensions.GetDownButton() |
|
502 |
down_button.SetToolTipString(_("Move down")) |
|
503 |
down_button.Bind(wx.EVT_BUTTON, self.OnDimensionsChanged) |
|
125 | 504 |
|
505 |
self.staticText10 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT10, |
|
391 | 506 |
label=_('Initial Value:'), name='staticText10', parent=self.ArrayPanel, |
507 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
|
125 | 508 |
|
509 |
self.ArrayInitialValue = wx.TextCtrl(id=ID_DATATYPEEDITORARRAYINITIALVALUE, |
|
510 |
name='ArrayInitialValue', parent=self.ArrayPanel, pos=wx.Point(0, 0), |
|
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
511 |
size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|wx.TE_MULTILINE|wx.TE_RICH) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
512 |
self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, id=ID_DATATYPEEDITORARRAYINITIALVALUE) |
125 | 513 |
|
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
514 |
# Panel for Structure data types |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
515 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
516 |
self.StructurePanel = wx.Panel(id=ID_DATATYPEEDITORSTRUCTUREPANEL, |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
517 |
name='StructurePanel', parent=self, pos=wx.Point(0, 0), |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
518 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
519 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
520 |
self.staticText11 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT11, |
391 | 521 |
label=_('Elements :'), name='staticText11', parent=self.StructurePanel, |
522 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
|
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
523 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
524 |
self.StructureElementsGrid = wx.grid.Grid(id=ID_DATATYPEEDITORSTRUCTUREELEMENTSGRID, |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
525 |
name='StructureElementsGrid', parent=self.StructurePanel, pos=wx.Point(0, 0), |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
526 |
size=wx.Size(0, 150), style=wx.VSCROLL) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
527 |
self.StructureElementsGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False, |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
528 |
'Sans')) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
529 |
self.StructureElementsGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
530 |
False, 'Sans')) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
531 |
self.StructureElementsGrid.SetSelectionBackground(wx.WHITE) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
532 |
self.StructureElementsGrid.SetSelectionForeground(wx.BLACK) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
533 |
if wx.VERSION >= (2, 6, 0): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
534 |
self.StructureElementsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnStructureElementsGridCellChange) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
535 |
self.StructureElementsGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, self.OnStructureElementsGridEditorShown) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
536 |
else: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
537 |
wx.grid.EVT_GRID_CELL_CHANGE(self.StructureElementsGrid, self.OnStructureElementsGridCellChange) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
538 |
wx.grid.EVT_GRID_EDITOR_SHOWN(self.StructureElementsGrid, self.OnStructureElementsGridEditorShown) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
539 |
|
391 | 540 |
self.StructureAddButton = wx.Button(id=ID_DATATYPEEDITORSTRUCTUREADDBUTTON, label=_('Add'), |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
541 |
name='StructureAddButton', parent=self.StructurePanel, pos=wx.Point(0, 0), |
391 | 542 |
size=wx.DefaultSize, style=0) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
543 |
self.Bind(wx.EVT_BUTTON, self.OnStructureAddButton, id=ID_DATATYPEEDITORSTRUCTUREADDBUTTON) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
544 |
|
391 | 545 |
self.StructureDeleteButton = wx.Button(id=ID_DATATYPEEDITORSTRUCTUREDELETEBUTTON, label=_('Delete'), |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
546 |
name='StructureDeleteButton', parent=self.StructurePanel, pos=wx.Point(0, 0), |
391 | 547 |
size=wx.DefaultSize, style=0) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
548 |
self.Bind(wx.EVT_BUTTON, self.OnStructureDeleteButton, id=ID_DATATYPEEDITORSTRUCTUREDELETEBUTTON) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
549 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
550 |
self.StructureUpButton = wx.Button(id=ID_DATATYPEEDITORSTRUCTUREUPBUTTON, label='^', |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
551 |
name='StructureUpButton', parent=self.StructurePanel, pos=wx.Point(0, 0), |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
552 |
size=wx.Size(32, 32), style=0) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
553 |
self.Bind(wx.EVT_BUTTON, self.OnStructureUpButton, id=ID_DATATYPEEDITORSTRUCTUREUPBUTTON) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
554 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
555 |
self.StructureDownButton = wx.Button(id=ID_DATATYPEEDITORSTRUCTUREDOWNBUTTON, label='v', |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
556 |
name='StructureDownButton', parent=self.StructurePanel, pos=wx.Point(0, 0), |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
557 |
size=wx.Size(32, 32), style=0) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
558 |
self.Bind(wx.EVT_BUTTON, self.OnStructureDownButton, id=ID_DATATYPEEDITORSTRUCTUREDOWNBUTTON) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
559 |
|
125 | 560 |
self._init_sizers() |
561 |
||
562 |
def __init__(self, parent, tagname, window, controler): |
|
563 |
self._init_ctrls(parent) |
|
564 |
||
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
565 |
self.StructureElementDefaultValue = {"Name" : "", "Type" : "INT", "Initial Value" : ""} |
391 | 566 |
self.StructureElementsTable = ElementsTable(self, [], GetElementsTableColnames()) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
567 |
self.StructureColSizes = [40, 150, 100, 250] |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
568 |
self.StructureColAlignements = [wx.ALIGN_CENTER, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT] |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
569 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
570 |
self.StructureElementsGrid.SetTable(self.StructureElementsTable) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
571 |
self.StructureElementsGrid.SetRowLabelSize(0) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
572 |
for col in range(self.StructureElementsTable.GetNumberCols()): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
573 |
attr = wx.grid.GridCellAttr() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
574 |
attr.SetAlignment(self.StructureColAlignements[col], wx.ALIGN_CENTRE) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
575 |
self.StructureElementsGrid.SetColAttr(col, attr) |
391 | 576 |
self.StructureElementsGrid.SetColMinimalWidth(col, self.StructureColSizes[col]) |
577 |
self.StructureElementsGrid.AutoSizeColumn(col, False) |
|
578 |
||
579 |
for datatype in GetDatatypeTypes(): |
|
580 |
self.DerivationType.Append(_(datatype)) |
|
125 | 581 |
self.SubrangePanel.Hide() |
582 |
self.EnumeratedPanel.Hide() |
|
583 |
self.ArrayPanel.Hide() |
|
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
584 |
self.StructurePanel.Hide() |
125 | 585 |
self.CurrentPanel = "Directly" |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
586 |
self.Highlights = [] |
130 | 587 |
self.Initializing = False |
125 | 588 |
|
589 |
self.ParentWindow = window |
|
590 |
self.Controler = controler |
|
591 |
self.TagName = tagname |
|
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
592 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
593 |
self.RefreshHighlightsTimer = wx.Timer(self, -1) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
594 |
self.Bind(wx.EVT_TIMER, self.OnRefreshHighlightsTimer, self.RefreshHighlightsTimer) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
595 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
596 |
def __del__(self): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
597 |
self.RefreshHighlightsTimer.Stop() |
125 | 598 |
|
599 |
def SetTagName(self, tagname): |
|
600 |
self.TagName = tagname |
|
601 |
||
602 |
def GetTagName(self): |
|
603 |
return self.TagName |
|
604 |
||
605 |
def IsViewing(self, tagname): |
|
606 |
return self.TagName == tagname |
|
607 |
||
407
0a324a874981
Adding support for integrating PLCOpenEditor in Beremiz frame
laurent
parents:
391
diff
changeset
|
608 |
def IsDebugging(self): |
0a324a874981
Adding support for integrating PLCOpenEditor in Beremiz frame
laurent
parents:
391
diff
changeset
|
609 |
return False |
0a324a874981
Adding support for integrating PLCOpenEditor in Beremiz frame
laurent
parents:
391
diff
changeset
|
610 |
|
125 | 611 |
def SetMode(self, mode): |
612 |
pass |
|
613 |
||
614 |
def ResetBuffer(self): |
|
615 |
pass |
|
616 |
||
617 |
def RefreshView(self): |
|
130 | 618 |
self.Initializing = True |
125 | 619 |
self.DirectlyBaseType.Clear() |
620 |
self.ArrayBaseType.Clear() |
|
621 |
for datatype in self.Controler.GetDataTypes(self.TagName): |
|
622 |
self.DirectlyBaseType.Append(datatype) |
|
623 |
self.ArrayBaseType.Append(datatype) |
|
624 |
self.DirectlyBaseType.SetSelection(0) |
|
625 |
self.SubrangeBaseType.Clear() |
|
626 |
words = self.TagName.split("::") |
|
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
627 |
for base_type in self.Controler.GetSubrangeBaseTypes(words[1]): |
125 | 628 |
self.SubrangeBaseType.Append(base_type) |
629 |
self.SubrangeBaseType.SetSelection(0) |
|
630 |
self.RefreshBoundsRange() |
|
631 |
type_infos = self.Controler.GetDataTypeInfos(self.TagName) |
|
632 |
if type_infos is not None: |
|
391 | 633 |
datatype = type_infos["type"] |
634 |
self.DerivationType.SetStringSelection(_(datatype)) |
|
125 | 635 |
if type_infos["type"] == "Directly": |
636 |
self.DirectlyBaseType.SetStringSelection(type_infos["base_type"]) |
|
637 |
self.DirectlyInitialValue.SetValue(type_infos["initial"]) |
|
638 |
elif type_infos["type"] == "Subrange": |
|
639 |
self.SubrangeBaseType.SetStringSelection(type_infos["base_type"]) |
|
640 |
self.RefreshBoundsRange() |
|
389 | 641 |
self.SubrangeMinimum.SetValue(int(type_infos["min"])) |
642 |
self.SubrangeMaximum.SetValue(int(type_infos["max"])) |
|
125 | 643 |
self.RefreshSubrangeInitialValueRange() |
644 |
if type_infos["initial"] != "": |
|
645 |
self.SubrangeInitialValue.SetValue(int(type_infos["initial"])) |
|
646 |
else: |
|
647 |
self.SubrangeInitialValue.SetValue(type_infos["min"]) |
|
648 |
elif type_infos["type"] == "Enumerated": |
|
649 |
self.EnumeratedValues.SetStrings(type_infos["values"]) |
|
650 |
self.RefreshEnumeratedValues() |
|
651 |
self.EnumeratedInitialValue.SetStringSelection(type_infos["initial"]) |
|
652 |
elif type_infos["type"] == "Array": |
|
653 |
self.ArrayBaseType.SetStringSelection(type_infos["base_type"]) |
|
389 | 654 |
self.ArrayDimensions.SetStrings(map(lambda x : "..".join(x), type_infos["dimensions"])) |
125 | 655 |
self.ArrayInitialValue.SetValue(type_infos["initial"]) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
656 |
elif type_infos["type"] == "Structure": |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
657 |
self.StructureElementsTable.SetData(type_infos["elements"]) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
658 |
self.StructureElementsTable.ResetView(self.StructureElementsGrid) |
125 | 659 |
self.RefreshDisplayedInfos() |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
660 |
self.ShowErrors() |
130 | 661 |
self.Initializing = False |
125 | 662 |
|
205 | 663 |
def RefreshScaling(self, refresh=True): |
664 |
pass |
|
665 |
||
125 | 666 |
def OnDerivationTypeChanged(self, event): |
667 |
self.RefreshDisplayedInfos() |
|
668 |
self.RefreshTypeInfos() |
|
669 |
event.Skip() |
|
670 |
||
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
671 |
def OnReturnKeyPressed(self, event): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
672 |
self.RefreshTypeInfos() |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
673 |
|
125 | 674 |
def OnInfosChanged(self, event): |
675 |
self.RefreshTypeInfos() |
|
676 |
event.Skip() |
|
677 |
||
678 |
def OnSubrangeBaseTypeChanged(self, event): |
|
679 |
self.RefreshBoundsRange() |
|
680 |
self.RefreshTypeInfos() |
|
681 |
event.Skip() |
|
682 |
||
683 |
def OnSubrangeMinimumChanged(self, event): |
|
215 | 684 |
if not self.Initializing: |
130 | 685 |
wx.CallAfter(self.SubrangeMinimum.SetValue, min(self.SubrangeMaximum.GetValue(), self.SubrangeMinimum.GetValue())) |
686 |
wx.CallAfter(self.RefreshSubrangeInitialValueRange) |
|
687 |
wx.CallAfter(self.RefreshTypeInfos) |
|
125 | 688 |
event.Skip() |
689 |
||
690 |
def OnSubrangeMaximumChanged(self, event): |
|
215 | 691 |
if not self.Initializing: |
130 | 692 |
wx.CallAfter(self.SubrangeMaximum.SetValue, max(self.SubrangeMinimum.GetValue(), self.SubrangeMaximum.GetValue())) |
693 |
wx.CallAfter(self.RefreshSubrangeInitialValueRange) |
|
694 |
wx.CallAfter(self.RefreshTypeInfos) |
|
125 | 695 |
event.Skip() |
696 |
||
697 |
def OnDimensionsChanged(self, event): |
|
698 |
wx.CallAfter(self.RefreshTypeInfos) |
|
699 |
event.Skip() |
|
700 |
||
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
701 |
def OnEnumeratedValueEndEdit(self, event): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
702 |
text = event.GetText() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
703 |
values = self.EnumeratedValues.GetStrings() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
704 |
index = event.GetIndex() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
705 |
if index >= len(values) or values[index].upper() != text.upper(): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
706 |
if text.upper() in [value.upper() for value in values]: |
391 | 707 |
message = wx.MessageDialog(self, _("\"%s\" value already defined!")%text, _("Error"), wx.OK|wx.ICON_ERROR) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
708 |
message.ShowModal() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
709 |
message.Destroy() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
710 |
event.Veto() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
711 |
elif text.upper() in IEC_KEYWORDS: |
391 | 712 |
message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%text, _("Error"), wx.OK|wx.ICON_ERROR) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
713 |
message.ShowModal() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
714 |
message.Destroy() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
715 |
else: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
716 |
wx.CallAfter(self.RefreshEnumeratedValues) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
717 |
wx.CallAfter(self.RefreshTypeInfos) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
718 |
event.Skip() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
719 |
else: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
720 |
wx.CallAfter(self.RefreshEnumeratedValues) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
721 |
wx.CallAfter(self.RefreshTypeInfos) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
722 |
event.Skip() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
723 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
724 |
def OnEnumeratedValuesChanged(self, event): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
725 |
wx.CallAfter(self.RefreshEnumeratedValues) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
726 |
wx.CallAfter(self.RefreshTypeInfos) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
727 |
event.Skip() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
728 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
729 |
def OnStructureAddButton(self, event): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
730 |
new_row = self.StructureElementDefaultValue.copy() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
731 |
self.StructureElementsTable.AppendRow(new_row) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
732 |
self.RefreshTypeInfos() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
733 |
self.StructureElementsTable.ResetView(self.StructureElementsGrid) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
734 |
event.Skip() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
735 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
736 |
def OnStructureDeleteButton(self, event): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
737 |
row = self.StructureElementsGrid.GetGridCursorRow() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
738 |
self.StructureElementsTable.RemoveRow(row) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
739 |
self.RefreshTypeInfos() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
740 |
self.StructureElementsTable.ResetView(self.StructureElementsGrid) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
741 |
event.Skip() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
742 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
743 |
def OnStructureUpButton(self, event): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
744 |
row = self.StructureElementsGrid.GetGridCursorRow() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
745 |
new_index = self.StructureElementsTable.MoveRow(row, -1) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
746 |
if new_index is not None: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
747 |
self.RefreshTypeInfos() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
748 |
self.StructureElementsTable.ResetView(self.StructureElementsGrid) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
749 |
self.StructureElementsGrid.SetGridCursor(new_index, self.StructureElementsGrid.GetGridCursorCol()) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
750 |
event.Skip() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
751 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
752 |
def OnStructureDownButton(self, event): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
753 |
row = self.StructureElementsGrid.GetGridCursorRow() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
754 |
new_index = self.StructureElementsTable.MoveRow(row, 1) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
755 |
if new_index is not None: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
756 |
self.RefreshTypeInfos() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
757 |
self.StructureElementsTable.ResetView(self.StructureElementsGrid) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
758 |
self.StructureElementsGrid.SetGridCursor(new_index, self.StructureElementsGrid.GetGridCursorCol()) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
759 |
event.Skip() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
760 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
761 |
def OnStructureElementsGridCellChange(self, event): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
762 |
row, col = event.GetRow(), event.GetCol() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
763 |
colname = self.StructureElementsTable.GetColLabelValue(col) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
764 |
value = self.StructureElementsTable.GetValue(row, col) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
765 |
if colname == "Name": |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
766 |
if not TestIdentifier(value): |
391 | 767 |
message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%value, _("Error"), wx.OK|wx.ICON_ERROR) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
768 |
message.ShowModal() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
769 |
message.Destroy() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
770 |
event.Veto() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
771 |
elif value.upper() in IEC_KEYWORDS: |
391 | 772 |
message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%value, _("Error"), wx.OK|wx.ICON_ERROR) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
773 |
message.ShowModal() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
774 |
message.Destroy() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
775 |
event.Veto() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
776 |
## elif value.upper() in self.PouNames: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
777 |
## message = wx.MessageDialog(self, "A pou with \"%s\" as name exists!"%value, "Error", wx.OK|wx.ICON_ERROR) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
778 |
## message.ShowModal() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
779 |
## message.Destroy() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
780 |
## event.Veto() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
781 |
elif value.upper() in [var["Name"].upper() for idx, var in enumerate(self.StructureElementsTable.GetData()) if idx != row]: |
427 | 782 |
message = wx.MessageDialog(self, _("An element named \"%s\" already exists in this structure!")%value, _("Error"), wx.OK|wx.ICON_ERROR) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
783 |
message.ShowModal() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
784 |
message.Destroy() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
785 |
event.Veto() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
786 |
else: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
787 |
self.RefreshTypeInfos() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
788 |
self.StructureElementsTable.ResetView(self.StructureElementsGrid) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
789 |
## old_value = self.Table.GetOldValue() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
790 |
## if old_value != "": |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
791 |
## self.Controler.UpdateEditedElementUsedVariable(self.TagName, old_value, value) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
792 |
## self.Controler.BufferProject() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
793 |
event.Skip() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
794 |
else: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
795 |
self.RefreshTypeInfos() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
796 |
self.StructureElementsTable.ResetView(self.StructureElementsGrid) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
797 |
event.Skip() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
798 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
799 |
def OnStructureElementsGridEditorShown(self, event): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
800 |
row, col = event.GetRow(), event.GetCol() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
801 |
if self.StructureElementsTable.GetColLabelValue(col) == "Type": |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
802 |
type_menu = wx.Menu(title='') |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
803 |
base_menu = wx.Menu(title='') |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
804 |
for base_type in self.Controler.GetBaseTypes(): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
805 |
new_id = wx.NewId() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
806 |
AppendMenu(base_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
807 |
self.Bind(wx.EVT_MENU, self.GetElementTypeFunction(base_type), id=new_id) |
391 | 808 |
type_menu.AppendMenu(wx.NewId(), _("Base Types"), base_menu) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
809 |
datatype_menu = wx.Menu(title='') |
462
9abbc90c0263
Bug when trying to choose type of struture datatype element fixed
laurent
parents:
460
diff
changeset
|
810 |
for datatype in self.Controler.GetDataTypes(self.TagName, False): |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
811 |
new_id = wx.NewId() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
812 |
AppendMenu(datatype_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
813 |
self.Bind(wx.EVT_MENU, self.GetElementTypeFunction(datatype), id=new_id) |
391 | 814 |
type_menu.AppendMenu(wx.NewId(), _("User Data Types"), datatype_menu) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
815 |
## functionblock_menu = wx.Menu(title='') |
462
9abbc90c0263
Bug when trying to choose type of struture datatype element fixed
laurent
parents:
460
diff
changeset
|
816 |
## bodytype = self.Controler.GetEditedElementBodyType(self.TagName) |
9abbc90c0263
Bug when trying to choose type of struture datatype element fixed
laurent
parents:
460
diff
changeset
|
817 |
## pouname, poutype = self.Controler.GetEditedElementType(self.TagName) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
818 |
## if classtype in ["Input","Output","InOut","External","Global"] or poutype != "function" and bodytype in ["ST", "IL"]: |
462
9abbc90c0263
Bug when trying to choose type of struture datatype element fixed
laurent
parents:
460
diff
changeset
|
819 |
## for functionblock_type in self.Controler.GetFunctionBlockTypes(self.TagName): |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
820 |
## new_id = wx.NewId() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
821 |
## AppendMenu(functionblock_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=functionblock_type) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
822 |
## self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(functionblock_type), id=new_id) |
391 | 823 |
## type_menu.AppendMenu(wx.NewId(), _("Function Block Types"), functionblock_menu) |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
824 |
rect = self.StructureElementsGrid.BlockToDeviceRect((row, col), (row, col)) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
825 |
self.StructureElementsGrid.PopupMenuXY(type_menu, rect.x + rect.width, rect.y + self.StructureElementsGrid.GetColLabelSize()) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
826 |
event.Veto() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
827 |
else: |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
828 |
event.Skip() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
829 |
|
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
830 |
def GetElementTypeFunction(self, base_type): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
831 |
def ElementTypeFunction(event): |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
832 |
row = self.StructureElementsGrid.GetGridCursorRow() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
833 |
self.StructureElementsTable.SetValueByName(row, "Type", base_type) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
834 |
self.RefreshTypeInfos() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
835 |
self.StructureElementsTable.ResetView(self.StructureElementsGrid) |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
836 |
return ElementTypeFunction |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
837 |
|
125 | 838 |
def RefreshDisplayedInfos(self): |
391 | 839 |
selected = DATATYPE_TYPES_DICT[self.DerivationType.GetStringSelection()] |
125 | 840 |
if selected != self.CurrentPanel: |
841 |
if self.CurrentPanel == "Directly": |
|
842 |
self.DirectlyPanel.Hide() |
|
843 |
elif self.CurrentPanel == "Subrange": |
|
844 |
self.SubrangePanel.Hide() |
|
845 |
elif self.CurrentPanel == "Enumerated": |
|
846 |
self.EnumeratedPanel.Hide() |
|
847 |
elif self.CurrentPanel == "Array": |
|
848 |
self.ArrayPanel.Hide() |
|
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
849 |
elif self.CurrentPanel == "Structure": |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
850 |
self.StructurePanel.Hide() |
125 | 851 |
self.CurrentPanel = selected |
852 |
if selected == "Directly": |
|
853 |
self.DirectlyPanel.Show() |
|
854 |
elif selected == "Subrange": |
|
855 |
self.SubrangePanel.Show() |
|
856 |
elif selected == "Enumerated": |
|
857 |
self.EnumeratedPanel.Show() |
|
858 |
elif selected == "Array": |
|
859 |
self.ArrayPanel.Show() |
|
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
860 |
elif selected == "Structure": |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
861 |
self.StructurePanel.Show() |
125 | 862 |
self.MainSizer.Layout() |
863 |
||
864 |
def RefreshEnumeratedValues(self): |
|
865 |
selected = self.EnumeratedInitialValue.GetStringSelection() |
|
866 |
self.EnumeratedInitialValue.Clear() |
|
867 |
self.EnumeratedInitialValue.Append("") |
|
868 |
for value in self.EnumeratedValues.GetStrings(): |
|
869 |
self.EnumeratedInitialValue.Append(value) |
|
870 |
self.EnumeratedInitialValue.SetStringSelection(selected) |
|
871 |
||
872 |
def RefreshBoundsRange(self): |
|
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
873 |
range = self.Controler.GetDataTypeRange(self.SubrangeBaseType.GetStringSelection()) |
125 | 874 |
if range is not None: |
875 |
min_value, max_value = range |
|
876 |
self.SubrangeMinimum.SetRange(min_value, max_value) |
|
877 |
self.SubrangeMinimum.SetValue(min(max(min_value, self.SubrangeMinimum.GetValue()), max_value)) |
|
878 |
self.SubrangeMaximum.SetRange(min_value, max_value) |
|
879 |
self.SubrangeMaximum.SetValue(min(max(min_value, self.SubrangeMaximum.GetValue()), max_value)) |
|
880 |
||
881 |
def RefreshSubrangeInitialValueRange(self): |
|
882 |
self.SubrangeInitialValue.SetRange(self.SubrangeMinimum.GetValue(), self.SubrangeMaximum.GetValue()) |
|
883 |
||
884 |
def RefreshTypeInfos(self): |
|
391 | 885 |
selected = DATATYPE_TYPES_DICT[self.DerivationType.GetStringSelection()] |
125 | 886 |
infos = {"type" : selected} |
887 |
if selected == "Directly": |
|
888 |
infos["base_type"] = self.DirectlyBaseType.GetStringSelection() |
|
889 |
infos["initial"] = self.DirectlyInitialValue.GetValue() |
|
890 |
elif selected == "Subrange": |
|
891 |
infos["base_type"] = self.SubrangeBaseType.GetStringSelection() |
|
389 | 892 |
infos["min"] = str(self.SubrangeMinimum.GetValue()) |
893 |
infos["max"] = str(self.SubrangeMaximum.GetValue()) |
|
125 | 894 |
initial_value = self.SubrangeInitialValue.GetValue() |
895 |
if initial_value == infos["min"]: |
|
896 |
infos["initial"] = "" |
|
897 |
else: |
|
898 |
infos["initial"] = str(initial_value) |
|
899 |
elif selected == "Enumerated": |
|
900 |
infos["values"] = self.EnumeratedValues.GetStrings() |
|
901 |
infos["initial"] = self.EnumeratedInitialValue.GetStringSelection() |
|
902 |
elif selected == "Array": |
|
903 |
infos["base_type"] = self.ArrayBaseType.GetStringSelection() |
|
207 | 904 |
infos["dimensions"] = [] |
905 |
for dimensions in self.ArrayDimensions.GetStrings(): |
|
906 |
result = DIMENSION_MODEL.match(dimensions) |
|
907 |
if result is None: |
|
391 | 908 |
message = wx.MessageDialog(self, _("\"%s\" value isn't a valid array dimension!")%dimensions, _("Error"), wx.OK|wx.ICON_ERROR) |
207 | 909 |
message.ShowModal() |
910 |
message.Destroy() |
|
911 |
self.RefreshView() |
|
912 |
return |
|
913 |
bounds = result.groups() |
|
460 | 914 |
if int(bounds[0]) >= int(bounds[1]): |
391 | 915 |
message = wx.MessageDialog(self, _("\"%s\" value isn't a valid array dimension!\nRight value must be greater than left value.")%dimensions, _("Error"), wx.OK|wx.ICON_ERROR) |
207 | 916 |
message.ShowModal() |
917 |
message.Destroy() |
|
918 |
self.RefreshView() |
|
919 |
return |
|
389 | 920 |
infos["dimensions"].append(bounds) |
125 | 921 |
infos["initial"] = self.ArrayInitialValue.GetValue() |
295
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
922 |
elif selected == "Structure": |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
923 |
infos["elements"] = self.StructureElementsTable.GetData() |
c6ef6d92ce16
Adding support for editing and using struct data types
lbessard
parents:
235
diff
changeset
|
924 |
infos["initial"] = "" |
125 | 925 |
self.Controler.SetDataTypeInfos(self.TagName, infos) |
926 |
self.ParentWindow.RefreshTitle() |
|
494
c91644c2bfa7
Bug on FileMenu not refreshed when modifications fixed
laurent
parents:
462
diff
changeset
|
927 |
self.ParentWindow.RefreshFileMenu() |
125 | 928 |
self.ParentWindow.RefreshEditMenu() |
929 |
||
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
930 |
#------------------------------------------------------------------------------- |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
931 |
# Highlights showing functions |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
932 |
#------------------------------------------------------------------------------- |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
933 |
|
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
934 |
def OnRefreshHighlightsTimer(self, event): |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
935 |
self.RefreshView() |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
936 |
event.Skip() |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
937 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
938 |
def ClearHighlights(self, highlight_type=None): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
939 |
if highlight_type is None: |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
940 |
self.Highlights = [] |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
941 |
else: |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
942 |
self.Highlights = [(infos, start, end, highlight) for (infos, start, end, highlight) in self.Highlights if highlight != highlight_type] |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
943 |
self.RefreshView() |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
944 |
|
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
945 |
def AddHighlight(self, infos, start, end ,highlight_type): |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
946 |
self.Highlights.append((infos, start, end, highlight_type)) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
947 |
self.RefreshHighlightsTimer.Start(int(REFRESH_HIGHLIGHT_PERIOD * 1000), oneShot=True) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
948 |
|
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
949 |
def ShowErrors(self): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
950 |
type_infos = self.Controler.GetDataTypeInfos(self.TagName) |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
951 |
for infos, start, end, highlight_type in self.Highlights: |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
952 |
if infos[0] == "base": |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
953 |
if type_infos["type"] == "Directly": |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
954 |
self.DirectlyBaseType.SetBackgroundColour(highlight_type[0]) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
955 |
self.DirectlyBaseType.SetForegroundColour(highlight_type[1]) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
956 |
elif type_infos["type"] == "Subrange": |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
957 |
self.SubrangeBaseType.SetBackgroundColour(highlight_type[0]) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
958 |
self.SubrangeBaseType.SetForegroundColour(highlight_type[1]) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
959 |
elif type_infos["type"] == "Array": |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
960 |
self.ArrayBaseType.SetBackgroundColour(highlight_type[0]) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
961 |
self.ArrayBaseType.SetForegroundColour(highlight_type[1]) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
962 |
elif infos[0] == "lower": |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
963 |
self.SubrangeMinimum.SetBackgroundColour(highlight_type[0]) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
964 |
self.SubrangeMaximum.SetForegroundColour(highlight_type[1]) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
965 |
elif infos[0] == "upper": |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
966 |
self.SubrangeMinimum.SetBackgroundColour(highlight_type[0]) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
967 |
self.SubrangeMaximum.SetForegroundColour(highlight_type[1]) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
968 |
elif infos[0] == "value": |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
969 |
listctrl = self.EnumeratedValues.GetListCtrl() |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
970 |
listctrl.SetItemBackgroundColour(infos[1], highlight_type[0]) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
971 |
listctrl.SetItemTextColour(infos[1], highlight_type[1]) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
972 |
listctrl.Select(listctrl.FocusedItem, False) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
973 |
elif infos[0] == "range": |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
974 |
listctrl = self.EnumeratedValues.GetListCtrl() |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
975 |
listctrl.SetItemBackgroundColour(infos[1], highlight_type[0]) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
976 |
listctrl.SetItemTextColour(infos[1], highlight_type[1]) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
977 |
listctrl.SetStringSelection("") |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
978 |
elif infos[0] == "initial": |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
979 |
if type_infos["type"] == "Directly": |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
980 |
self.DirectlyInitialValue.SetStyle(start[1], end[1] + 1, wx.TextAttr(highlight_type[1], highlight_type[0])) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
981 |
elif type_infos["type"] == "Subrange": |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
982 |
self.SubrangeInitialValue.SetBackgroundColour(highlight_type[0]) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
983 |
self.SubrangeInitialValue.SetForegroundColour(highlight_type[1]) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
984 |
elif type_infos["type"] == "Enumerated": |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
985 |
self.EnumeratedInitialValue.SetBackgroundColour(highlight_type[0]) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
986 |
self.EnumeratedInitialValue.SetForegroundColour(highlight_type[1]) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
215
diff
changeset
|
987 |
elif type_infos["type"] == "Array": |
566
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
988 |
self.ArrayInitialValue.SetStyle(start[1], end[1] + 1, wx.TextAttr(highlight_type[1], highlight_type[0])) |
6014ef82a98a
Adding support for searching text or regular expression in whole project
laurent
parents:
556
diff
changeset
|
989 |