19 # |
19 # |
20 #You should have received a copy of the GNU Lesser General Public |
20 #You should have received a copy of the GNU Lesser General Public |
21 #License along with this library; if not, write to the Free Software |
21 #License along with this library; if not, write to the Free Software |
22 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 |
23 |
24 from wxPython.wx import * |
|
25 from wxPython.grid import * |
|
26 import wx |
24 import wx |
27 import wx.grid |
25 import wx.grid |
28 |
26 |
29 from types import * |
27 from types import * |
30 |
28 |
31 from node import OD_Subindex, OD_MultipleSubindexes, OD_IdenticalSubindexes, OD_IdenticalIndexes |
29 from node import OD_Subindex, OD_MultipleSubindexes, OD_IdenticalSubindexes, OD_IdenticalIndexes |
32 |
30 |
33 ColSizes = [75, 250, 150, 125, 100, 60, 250] |
31 ColSizes = [75, 250, 150, 125, 100, 60, 250] |
34 ColAlignements = [wxALIGN_CENTER, wxALIGN_LEFT, wxALIGN_CENTER, wxALIGN_RIGHT, wxALIGN_CENTER, wxALIGN_CENTER, wxALIGN_LEFT] |
32 ColAlignements = [wx.ALIGN_CENTER, wx.ALIGN_LEFT, wx.ALIGN_CENTER, wx.ALIGN_RIGHT, wx.ALIGN_CENTER, wx.ALIGN_CENTER, wx.ALIGN_LEFT] |
35 AccessList = "Read Only,Write Only,Read/Write" |
33 AccessList = "Read Only,Write Only,Read/Write" |
36 RAccessList = "Read Only,Read/Write" |
34 RAccessList = "Read Only,Read/Write" |
37 BoolList = "True,False" |
35 BoolList = "True,False" |
38 OptionList = "Yes,No" |
36 OptionList = "Yes,No" |
39 |
37 |
110 if col < len(self.colnames): |
108 if col < len(self.colnames): |
111 self.data[row][self.GetColLabelValue(col)] = value |
109 self.data[row][self.GetColLabelValue(col)] = value |
112 |
110 |
113 def ResetView(self, grid): |
111 def ResetView(self, grid): |
114 """ |
112 """ |
115 (wxGrid) -> Reset the grid view. Call this to |
113 (wx.grid.Grid) -> Reset the grid view. Call this to |
116 update the grid if rows and columns have been added or deleted |
114 update the grid if rows and columns have been added or deleted |
117 """ |
115 """ |
118 grid.BeginBatch() |
116 grid.BeginBatch() |
119 for current, new, delmsg, addmsg in [ |
117 for current, new, delmsg, addmsg in [ |
120 (self._rows, self.GetNumberRows(), wxGRIDTABLE_NOTIFY_ROWS_DELETED, wxGRIDTABLE_NOTIFY_ROWS_APPENDED), |
118 (self._rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED), |
121 (self._cols, self.GetNumberCols(), wxGRIDTABLE_NOTIFY_COLS_DELETED, wxGRIDTABLE_NOTIFY_COLS_APPENDED), |
119 (self._cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED), |
122 ]: |
120 ]: |
123 if new < current: |
121 if new < current: |
124 msg = wxGridTableMessage(self,delmsg,new,current-new) |
122 msg = wx.grid.GridTableMessage(self,delmsg,new,current-new) |
125 grid.ProcessTableMessage(msg) |
123 grid.ProcessTableMessage(msg) |
126 elif new > current: |
124 elif new > current: |
127 msg = wxGridTableMessage(self,addmsg,new-current) |
125 msg = wx.grid.GridTableMessage(self,addmsg,new-current) |
128 grid.ProcessTableMessage(msg) |
126 grid.ProcessTableMessage(msg) |
129 self.UpdateValues(grid) |
127 self.UpdateValues(grid) |
130 grid.EndBatch() |
128 grid.EndBatch() |
131 |
129 |
132 self._rows = self.GetNumberRows() |
130 self._rows = self.GetNumberRows() |
170 colname = self.GetColLabelValue(col) |
168 colname = self.GetColLabelValue(col) |
171 editortype = editors[colname] |
169 editortype = editors[colname] |
172 if editortype and self.Editable: |
170 if editortype and self.Editable: |
173 grid.SetReadOnly(row, col, False) |
171 grid.SetReadOnly(row, col, False) |
174 if editortype == "string": |
172 if editortype == "string": |
175 editor = wxGridCellTextEditor() |
173 editor = wx.grid.GridCellTextEditor() |
176 renderer = wxGridCellStringRenderer() |
174 renderer = wx.grid.GridCellStringRenderer() |
177 if colname == "value" and "length" in editors: |
175 if colname == "value" and "length" in editors: |
178 editor.SetParameters(editors["length"]) |
176 editor.SetParameters(editors["length"]) |
179 elif editortype == "number": |
177 elif editortype == "number": |
180 editor = wxGridCellNumberEditor() |
178 editor = wx.grid.GridCellNumberEditor() |
181 renderer = wxGridCellNumberRenderer() |
179 renderer = wx.grid.GridCellNumberRenderer() |
182 if colname == "value" and "min" in editors and "max" in editors: |
180 if colname == "value" and "min" in editors and "max" in editors: |
183 editor.SetParameters("%s,%s"%(editors["min"],editors["max"])) |
181 editor.SetParameters("%s,%s"%(editors["min"],editors["max"])) |
184 elif editortype == "real": |
182 elif editortype == "real": |
185 editor = wxGridCellFloatEditor() |
183 editor = wx.grid.GridCellFloatEditor() |
186 renderer = wxGridCellFloatRenderer() |
184 renderer = wx.grid.GridCellFloatRenderer() |
187 if colname == "value" and "min" in editors and "max" in editors: |
185 if colname == "value" and "min" in editors and "max" in editors: |
188 editor.SetParameters("%s,%s"%(editors["min"],editors["max"])) |
186 editor.SetParameters("%s,%s"%(editors["min"],editors["max"])) |
189 elif editortype == "bool": |
187 elif editortype == "bool": |
190 editor = wxGridCellChoiceEditor() |
188 editor = wx.grid.GridCellChoiceEditor() |
191 editor.SetParameters(BoolList) |
189 editor.SetParameters(BoolList) |
192 elif editortype == "access": |
190 elif editortype == "access": |
193 editor = wxGridCellChoiceEditor() |
191 editor = wx.grid.GridCellChoiceEditor() |
194 editor.SetParameters(AccessList) |
192 editor.SetParameters(AccessList) |
195 elif editortype == "raccess": |
193 elif editortype == "raccess": |
196 editor = wxGridCellChoiceEditor() |
194 editor = wx.grid.GridCellChoiceEditor() |
197 editor.SetParameters(RAccessList) |
195 editor.SetParameters(RAccessList) |
198 elif editortype == "option": |
196 elif editortype == "option": |
199 editor = wxGridCellChoiceEditor() |
197 editor = wx.grid.GridCellChoiceEditor() |
200 editor.SetParameters(OptionList) |
198 editor.SetParameters(OptionList) |
201 elif editortype == "type": |
199 elif editortype == "type": |
202 editor = wxGridCellChoiceEditor() |
200 editor = wx.grid.GridCellChoiceEditor() |
203 if typelist == None: |
201 if typelist == None: |
204 typelist = self.Parent.Manager.GetCurrentTypeList() |
202 typelist = self.Parent.Manager.GetCurrentTypeList() |
205 editor.SetParameters(typelist) |
203 editor.SetParameters(typelist) |
206 elif editortype == "map": |
204 elif editortype == "map": |
207 editor = wxGridCellChoiceEditor() |
205 editor = wx.grid.GridCellChoiceEditor() |
208 if maplist == None: |
206 if maplist == None: |
209 maplist = self.Parent.Manager.GetCurrentMapList() |
207 maplist = self.Parent.Manager.GetCurrentMapList() |
210 editor.SetParameters(maplist) |
208 editor.SetParameters(maplist) |
211 elif editortype == "time": |
209 elif editortype == "time": |
212 editor = wxGridCellTextEditor() |
210 editor = wx.grid.GridCellTextEditor() |
213 renderer = wxGridCellStringRenderer() |
211 renderer = wx.grid.GridCellStringRenderer() |
214 elif editortype == "domain": |
212 elif editortype == "domain": |
215 editor = wxGridCellTextEditor() |
213 editor = wx.grid.GridCellTextEditor() |
216 renderer = wxGridCellStringRenderer() |
214 renderer = wx.grid.GridCellStringRenderer() |
217 else: |
215 else: |
218 grid.SetReadOnly(row, col, True) |
216 grid.SetReadOnly(row, col, True) |
219 |
217 |
220 grid.SetCellEditor(row, col, editor) |
218 grid.SetCellEditor(row, col, editor) |
221 grid.SetCellRenderer(row, col, renderer) |
219 grid.SetCellRenderer(row, col, renderer) |
222 |
220 |
223 grid.SetCellBackgroundColour(row, col, wxWHITE) |
221 grid.SetCellBackgroundColour(row, col, wx.WHITE) |
224 |
222 |
225 def SetData(self, data): |
223 def SetData(self, data): |
226 self.data = data |
224 self.data = data |
227 |
225 |
228 def SetEditors(self, editors): |
226 def SetEditors(self, editors): |
239 |
237 |
240 def Empty(self): |
238 def Empty(self): |
241 self.data = [] |
239 self.data = [] |
242 self.editors = [] |
240 self.editors = [] |
243 |
241 |
244 [wxID_EDITINGPANEL, wxID_EDITINGPANELADDBUTTON, wxID_EDITINGPANELINDEXCHOICE, |
242 [ID_EDITINGPANEL, ID_EDITINGPANELADDBUTTON, ID_EDITINGPANELINDEXCHOICE, |
245 wxID_EDITINGPANELINDEXLIST, wxID_EDITINGPANELINDEXLISTPANEL, wxID_EDITINGPANELPARTLIST, |
243 ID_EDITINGPANELINDEXLIST, ID_EDITINGPANELINDEXLISTPANEL, ID_EDITINGPANELPARTLIST, |
246 wxID_EDITINGPANELSECONDSPLITTER, wxID_EDITINGPANELSUBINDEXGRID, |
244 ID_EDITINGPANELSECONDSPLITTER, ID_EDITINGPANELSUBINDEXGRID, |
247 wxID_EDITINGPANELSUBINDEXGRIDPANEL, wxID_EDITINGPANELCALLBACKCHECK, |
245 ID_EDITINGPANELSUBINDEXGRIDPANEL, ID_EDITINGPANELCALLBACKCHECK, |
248 ] = [wx.NewId() for _init_ctrls in range(10)] |
246 ] = [wx.NewId() for _init_ctrls in range(10)] |
249 |
247 |
250 [wxID_EDITINGPANELINDEXLISTMENUITEMS0, wxID_EDITINGPANELINDEXLISTMENUITEMS1, |
248 [ID_EDITINGPANELINDEXLISTMENUITEMS0, ID_EDITINGPANELINDEXLISTMENUITEMS1, |
251 wxID_EDITINGPANELINDEXLISTMENUITEMS2, |
249 ID_EDITINGPANELINDEXLISTMENUITEMS2, |
252 ] = [wx.NewId() for _init_coll_IndexListMenu_Items in range(3)] |
250 ] = [wx.NewId() for _init_coll_IndexListMenu_Items in range(3)] |
253 |
251 |
254 [wxID_EDITINGPANELMENU1ITEMS0, wxID_EDITINGPANELMENU1ITEMS1, |
252 [ID_EDITINGPANELMENU1ITEMS0, ID_EDITINGPANELMENU1ITEMS1, |
255 ] = [wx.NewId() for _init_coll_SubindexGridMenu_Items in range(2)] |
253 ] = [wx.NewId() for _init_coll_SubindexGridMenu_Items in range(2)] |
256 |
254 |
257 class EditingPanel(wx.SplitterWindow): |
255 class EditingPanel(wx.SplitterWindow): |
258 def _init_coll_AddToListSizer_Items(self, parent): |
256 def _init_coll_AddToListSizer_Items(self, parent): |
259 # generated method, don't edit |
|
260 |
|
261 parent.AddWindow(self.AddButton, 0, border=0, flag=0) |
257 parent.AddWindow(self.AddButton, 0, border=0, flag=0) |
262 parent.AddWindow(self.IndexChoice, 0, border=0, flag=wxGROW) |
258 parent.AddWindow(self.IndexChoice, 0, border=0, flag=wx.GROW) |
263 |
259 |
264 def _init_coll_SubindexGridSizer_Items(self, parent): |
260 def _init_coll_SubindexGridSizer_Items(self, parent): |
265 # generated method, don't edit |
|
266 |
|
267 parent.AddWindow(self.CallbackCheck, 0, border=0, flag=0) |
261 parent.AddWindow(self.CallbackCheck, 0, border=0, flag=0) |
268 parent.AddWindow(self.SubindexGrid, 0, border=0, flag=wxGROW) |
262 parent.AddWindow(self.SubindexGrid, 0, border=0, flag=wx.GROW) |
269 |
263 |
270 def _init_coll_IndexListSizer_Items(self, parent): |
264 def _init_coll_IndexListSizer_Items(self, parent): |
271 # generated method, don't edit |
265 parent.AddWindow(self.IndexList, 0, border=0, flag=wx.GROW) |
272 |
266 parent.AddSizer(self.AddToListSizer, 0, border=0, flag=wx.GROW) |
273 parent.AddWindow(self.IndexList, 0, border=0, flag=wxGROW) |
|
274 parent.AddSizer(self.AddToListSizer, 0, border=0, flag=wxGROW) |
|
275 |
267 |
276 def _init_coll_AddToListSizer_Growables(self, parent): |
268 def _init_coll_AddToListSizer_Growables(self, parent): |
277 # generated method, don't edit |
|
278 |
|
279 parent.AddGrowableCol(1) |
269 parent.AddGrowableCol(1) |
280 |
270 |
281 def _init_coll_SubindexGridSizer_Growables(self, parent): |
271 def _init_coll_SubindexGridSizer_Growables(self, parent): |
282 # generated method, don't edit |
|
283 |
|
284 parent.AddGrowableCol(0) |
272 parent.AddGrowableCol(0) |
285 parent.AddGrowableRow(1) |
273 parent.AddGrowableRow(1) |
286 |
274 |
287 def _init_coll_IndexListSizer_Growables(self, parent): |
275 def _init_coll_IndexListSizer_Growables(self, parent): |
288 # generated method, don't edit |
|
289 |
|
290 parent.AddGrowableCol(0) |
276 parent.AddGrowableCol(0) |
291 parent.AddGrowableRow(0) |
277 parent.AddGrowableRow(0) |
292 |
278 |
293 def _init_coll_SubindexGridMenu_Items(self, parent): |
279 def _init_coll_SubindexGridMenu_Items(self, parent): |
294 # generated method, don't edit |
280 parent.Append(help='', id=ID_EDITINGPANELMENU1ITEMS0, |
295 |
|
296 parent.Append(help='', id=wxID_EDITINGPANELMENU1ITEMS0, |
|
297 kind=wx.ITEM_NORMAL, text='Add') |
281 kind=wx.ITEM_NORMAL, text='Add') |
298 parent.Append(help='', id=wxID_EDITINGPANELMENU1ITEMS1, |
282 parent.Append(help='', id=ID_EDITINGPANELMENU1ITEMS1, |
299 kind=wx.ITEM_NORMAL, text='Delete') |
283 kind=wx.ITEM_NORMAL, text='Delete') |
300 self.Bind(wx.EVT_MENU, self.OnAddSubindexMenu, |
284 self.Bind(wx.EVT_MENU, self.OnAddSubindexMenu, |
301 id=wxID_EDITINGPANELMENU1ITEMS0) |
285 id=ID_EDITINGPANELMENU1ITEMS0) |
302 self.Bind(wx.EVT_MENU, self.OnDeleteSubindexMenu, |
286 self.Bind(wx.EVT_MENU, self.OnDeleteSubindexMenu, |
303 id=wxID_EDITINGPANELMENU1ITEMS1) |
287 id=ID_EDITINGPANELMENU1ITEMS1) |
304 |
288 |
305 def _init_coll_IndexListMenu_Items(self, parent): |
289 def _init_coll_IndexListMenu_Items(self, parent): |
306 # generated method, don't edit |
290 parent.Append(help='', id=ID_EDITINGPANELINDEXLISTMENUITEMS0, |
307 |
|
308 parent.Append(help='', id=wxID_EDITINGPANELINDEXLISTMENUITEMS0, |
|
309 kind=wx.ITEM_NORMAL, text='Rename') |
291 kind=wx.ITEM_NORMAL, text='Rename') |
310 parent.Append(help='', id=wxID_EDITINGPANELINDEXLISTMENUITEMS2, |
292 parent.Append(help='', id=ID_EDITINGPANELINDEXLISTMENUITEMS2, |
311 kind=wx.ITEM_NORMAL, text='Modify') |
293 kind=wx.ITEM_NORMAL, text='Modify') |
312 parent.Append(help='', id=wxID_EDITINGPANELINDEXLISTMENUITEMS1, |
294 parent.Append(help='', id=ID_EDITINGPANELINDEXLISTMENUITEMS1, |
313 kind=wx.ITEM_NORMAL, text='Delete') |
295 kind=wx.ITEM_NORMAL, text='Delete') |
314 self.Bind(wx.EVT_MENU, self.OnRenameIndexMenu, |
296 self.Bind(wx.EVT_MENU, self.OnRenameIndexMenu, |
315 id=wxID_EDITINGPANELINDEXLISTMENUITEMS0) |
297 id=ID_EDITINGPANELINDEXLISTMENUITEMS0) |
316 self.Bind(wx.EVT_MENU, self.OnDeleteIndexMenu, |
298 self.Bind(wx.EVT_MENU, self.OnDeleteIndexMenu, |
317 id=wxID_EDITINGPANELINDEXLISTMENUITEMS1) |
299 id=ID_EDITINGPANELINDEXLISTMENUITEMS1) |
318 self.Bind(wx.EVT_MENU, self.OnModifyIndexMenu, |
300 self.Bind(wx.EVT_MENU, self.OnModifyIndexMenu, |
319 id=wxID_EDITINGPANELINDEXLISTMENUITEMS2) |
301 id=ID_EDITINGPANELINDEXLISTMENUITEMS2) |
320 |
302 |
321 def _init_utils(self): |
303 def _init_utils(self): |
322 # generated method, don't edit |
|
323 self.IndexListMenu = wx.Menu(title='') |
304 self.IndexListMenu = wx.Menu(title='') |
324 |
|
325 self.SubindexGridMenu = wx.Menu(title='') |
305 self.SubindexGridMenu = wx.Menu(title='') |
326 |
306 |
327 self._init_coll_IndexListMenu_Items(self.IndexListMenu) |
307 self._init_coll_IndexListMenu_Items(self.IndexListMenu) |
328 self._init_coll_SubindexGridMenu_Items(self.SubindexGridMenu) |
308 self._init_coll_SubindexGridMenu_Items(self.SubindexGridMenu) |
329 |
309 |
330 def _init_sizers(self): |
310 def _init_sizers(self): |
331 # generated method, don't edit |
|
332 self.IndexListSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
311 self.IndexListSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
333 |
|
334 self.SubindexGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
312 self.SubindexGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
335 |
|
336 self.AddToListSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0) |
313 self.AddToListSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0) |
337 |
314 |
338 self._init_coll_IndexListSizer_Growables(self.IndexListSizer) |
315 self._init_coll_IndexListSizer_Growables(self.IndexListSizer) |
339 self._init_coll_IndexListSizer_Items(self.IndexListSizer) |
316 self._init_coll_IndexListSizer_Items(self.IndexListSizer) |
340 self._init_coll_SubindexGridSizer_Growables(self.SubindexGridSizer) |
317 self._init_coll_SubindexGridSizer_Growables(self.SubindexGridSizer) |
344 |
321 |
345 self.SubindexGridPanel.SetSizer(self.SubindexGridSizer) |
322 self.SubindexGridPanel.SetSizer(self.SubindexGridSizer) |
346 self.IndexListPanel.SetSizer(self.IndexListSizer) |
323 self.IndexListPanel.SetSizer(self.IndexListSizer) |
347 |
324 |
348 def _init_ctrls(self, prnt): |
325 def _init_ctrls(self, prnt): |
349 wx.SplitterWindow.__init__(self, id=wxID_EDITINGPANEL, |
326 wx.SplitterWindow.__init__(self, id=ID_EDITINGPANEL, |
350 name='MainSplitter', parent=prnt, point=wx.Point(0, 0), |
327 name='MainSplitter', parent=prnt, point=wx.Point(0, 0), |
351 size=wx.Size(-1, -1), style=wx.SP_3D) |
328 size=wx.Size(-1, -1), style=wx.SP_3D) |
352 self._init_utils() |
329 self._init_utils() |
353 self.SetNeedUpdating(True) |
330 self.SetNeedUpdating(True) |
354 self.SetMinimumPaneSize(1) |
331 self.SetMinimumPaneSize(1) |
355 |
332 |
356 self.PartList = wx.ListBox(choices=[], id=wxID_EDITINGPANELPARTLIST, |
333 self.PartList = wx.ListBox(choices=[], id=ID_EDITINGPANELPARTLIST, |
357 name='PartList', parent=self, pos=wx.Point(0, 0), |
334 name='PartList', parent=self, pos=wx.Point(0, 0), |
358 size=wx.Size(-1, -1), style=0) |
335 size=wx.Size(-1, -1), style=0) |
359 self.PartList.Bind(wx.EVT_LISTBOX, self.OnPartListBoxClick, |
336 self.PartList.Bind(wx.EVT_LISTBOX, self.OnPartListBoxClick, |
360 id=wxID_EDITINGPANELPARTLIST) |
337 id=ID_EDITINGPANELPARTLIST) |
361 |
338 |
362 self.SecondSplitter = wx.SplitterWindow(id=wxID_EDITINGPANELSECONDSPLITTER, |
339 self.SecondSplitter = wx.SplitterWindow(id=ID_EDITINGPANELSECONDSPLITTER, |
363 name='SecondSplitter', parent=self, point=wx.Point(0, |
340 name='SecondSplitter', parent=self, point=wx.Point(0, 0), |
364 0), size=wx.Size(-1, -1), style=wx.SP_3D) |
341 size=wx.Size(-1, -1), style=wx.SP_3D) |
365 self.SecondSplitter.SetMinimumPaneSize(1) |
342 self.SecondSplitter.SetMinimumPaneSize(1) |
366 self.SplitHorizontally(self.PartList, self.SecondSplitter, |
343 self.SplitHorizontally(self.PartList, self.SecondSplitter, |
367 110) |
344 110) |
368 |
345 |
369 self.SubindexGridPanel = wx.Panel(id=wxID_EDITINGPANELSUBINDEXGRIDPANEL, |
346 self.SubindexGridPanel = wx.Panel(id=ID_EDITINGPANELSUBINDEXGRIDPANEL, |
370 name='SubindexGridPanel', parent=self.SecondSplitter, pos=wx.Point(0, |
347 name='SubindexGridPanel', parent=self.SecondSplitter, |
371 0), size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL) |
348 pos=wx.Point(0, 0), size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL) |
372 |
349 |
373 self.IndexListPanel = wx.Panel(id=wxID_EDITINGPANELINDEXLISTPANEL, |
350 self.IndexListPanel = wx.Panel(id=ID_EDITINGPANELINDEXLISTPANEL, |
374 name='IndexListPanel', parent=self.SecondSplitter, pos=wx.Point(0, |
351 name='IndexListPanel', parent=self.SecondSplitter, |
375 0), size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL) |
352 pos=wx.Point(0, 0), size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL) |
376 self.SecondSplitter.SplitVertically(self.IndexListPanel, |
353 self.SecondSplitter.SplitVertically(self.IndexListPanel, |
377 self.SubindexGridPanel, 280) |
354 self.SubindexGridPanel, 280) |
378 |
355 |
379 self.SubindexGrid = wx.grid.Grid(id=wxID_EDITINGPANELSUBINDEXGRID, |
356 self.SubindexGrid = wx.grid.Grid(id=ID_EDITINGPANELSUBINDEXGRID, |
380 name='SubindexGrid', parent=self.SubindexGridPanel, pos=wx.Point(0, |
357 name='SubindexGrid', parent=self.SubindexGridPanel, pos=wx.Point(0, |
381 0), size=wx.Size(-1, -1), style=0) |
358 0), size=wx.Size(-1, -1), style=0) |
382 self.SubindexGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False, |
359 self.SubindexGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False, |
383 'Sans')) |
360 'Sans')) |
384 self.SubindexGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, |
361 self.SubindexGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, |
389 self.OnSubindexGridRightClick) |
366 self.OnSubindexGridRightClick) |
390 self.SubindexGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, |
367 self.SubindexGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, |
391 self.OnSubindexGridSelectCell) |
368 self.OnSubindexGridSelectCell) |
392 self.SubindexGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnSubindexGridCellLeftClick) |
369 self.SubindexGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnSubindexGridCellLeftClick) |
393 |
370 |
394 self.CallbackCheck = wx.CheckBox(id=wxID_EDITINGPANELCALLBACKCHECK, |
371 self.CallbackCheck = wx.CheckBox(id=ID_EDITINGPANELCALLBACKCHECK, |
395 label='Have Callbacks', name='CallbackCheck', |
372 label='Have Callbacks', name='CallbackCheck', |
396 parent=self.SubindexGridPanel, pos=wx.Point(0, 0), size=wx.Size(152, |
373 parent=self.SubindexGridPanel, pos=wx.Point(0, 0), size=wx.Size(152, |
397 24), style=0) |
374 24), style=0) |
398 self.CallbackCheck.Bind(wx.EVT_CHECKBOX, self.OnCallbackCheck, |
375 self.CallbackCheck.Bind(wx.EVT_CHECKBOX, self.OnCallbackCheck, |
399 id=wxID_EDITINGPANELCALLBACKCHECK) |
376 id=ID_EDITINGPANELCALLBACKCHECK) |
400 |
377 |
401 self.IndexList = wx.ListBox(choices=[], id=wxID_EDITINGPANELINDEXLIST, |
378 self.IndexList = wx.ListBox(choices=[], id=ID_EDITINGPANELINDEXLIST, |
402 name='IndexList', parent=self.IndexListPanel, pos=wx.Point(0, 0), |
379 name='IndexList', parent=self.IndexListPanel, pos=wx.Point(0, 0), |
403 size=wx.Size(-1, -1), style=0) |
380 size=wx.Size(-1, -1), style=0) |
404 self.IndexList.Bind(wx.EVT_LISTBOX, self.OnIndexListClick, |
381 self.IndexList.Bind(wx.EVT_LISTBOX, self.OnIndexListClick, |
405 id=wxID_EDITINGPANELINDEXLIST) |
382 id=ID_EDITINGPANELINDEXLIST) |
406 self.IndexList.Bind(wx.EVT_RIGHT_UP, self.OnIndexListRightUp) |
383 self.IndexList.Bind(wx.EVT_RIGHT_UP, self.OnIndexListRightUp) |
407 |
384 |
408 self.AddButton = wx.Button(id=wxID_EDITINGPANELADDBUTTON, label='Add', |
385 self.AddButton = wx.Button(id=ID_EDITINGPANELADDBUTTON, label='Add', |
409 name='AddButton', parent=self.IndexListPanel, pos=wx.Point(0, 0), |
386 name='AddButton', parent=self.IndexListPanel, pos=wx.Point(0, 0), |
410 size=wx.Size(50, 30), style=0) |
387 size=wx.Size(50, 30), style=0) |
411 self.AddButton.Bind(wx.EVT_BUTTON, self.OnAddButtonClick, |
388 self.AddButton.Bind(wx.EVT_BUTTON, self.OnAddButtonClick, |
412 id=wxID_EDITINGPANELADDBUTTON) |
389 id=ID_EDITINGPANELADDBUTTON) |
413 |
390 |
414 self.IndexChoice = wx.Choice(choices=[], id=wxID_EDITINGPANELINDEXCHOICE, |
391 self.IndexChoice = wx.Choice(choices=[], id=ID_EDITINGPANELINDEXCHOICE, |
415 name='IndexChoice', parent=self.IndexListPanel, pos=wx.Point(50, |
392 name='IndexChoice', parent=self.IndexListPanel, pos=wx.Point(50, |
416 0), size=wx.Size(-1, 30), style=0) |
393 0), size=wx.Size(-1, 30), style=0) |
417 |
394 |
418 self._init_sizers() |
395 self._init_sizers() |
419 |
396 |
495 self.SubindexGrid.SetGridCursor(0, 0) |
472 self.SubindexGrid.SetGridCursor(0, 0) |
496 self.RefreshTable() |
473 self.RefreshTable() |
497 event.Skip() |
474 event.Skip() |
498 |
475 |
499 def OnSubindexGridSelectCell(self, event): |
476 def OnSubindexGridSelectCell(self, event): |
500 wxCallAfter(self.BeginDrag) |
477 wx.CallAfter(self.BeginDrag) |
501 wxCallAfter(self.Parent.RefreshStatusBar) |
478 wx.CallAfter(self.Parent.RefreshStatusBar) |
502 event.Skip() |
479 event.Skip() |
503 |
480 |
504 def BeginDrag(self): |
481 def BeginDrag(self): |
505 if not self.Parent.ModeSolo: |
482 if not self.Parent.ModeSolo: |
506 row = self.SubindexGrid.GetGridCursorRow() |
483 row = self.SubindexGrid.GetGridCursorRow() |
507 col = self.SubindexGrid.GetGridCursorCol() |
484 col = self.SubindexGrid.GetGridCursorCol() |
508 if not self.Editable and col == 0: |
485 if not self.Editable and col == 0: |
509 selected = self.IndexList.GetSelection() |
486 selected = self.IndexList.GetSelection() |
510 if selected != wxNOT_FOUND: |
487 if selected != wx.NOT_FOUND: |
511 index = self.ListIndex[selected] |
488 index = self.ListIndex[selected] |
512 subindex = self.SubindexGrid.GetGridCursorRow() |
489 subindex = self.SubindexGrid.GetGridCursorRow() |
513 entry_infos = self.Manager.GetEntryInfos(index) |
490 entry_infos = self.Manager.GetEntryInfos(index) |
514 if not entry_infos["struct"] & OD_MultipleSubindexes or row != 0: |
491 if not entry_infos["struct"] & OD_MultipleSubindexes or row != 0: |
515 subentry_infos = self.Manager.GetSubentryInfos(index, subindex) |
492 subentry_infos = self.Manager.GetSubentryInfos(index, subindex) |
516 typeinfos = self.Manager.GetEntryInfos(subentry_infos["type"]) |
493 typeinfos = self.Manager.GetEntryInfos(subentry_infos["type"]) |
517 if subentry_infos["pdo"] and typeinfos: |
494 if subentry_infos["pdo"] and typeinfos: |
518 bus_id = self.Parent.GetBusId() |
495 bus_id = self.Parent.GetBusId() |
519 node_id = self.Parent.GetCurrentNodeId() |
496 node_id = self.Parent.GetCurrentNodeId() |
520 size = typeinfos["size"] |
497 size = typeinfos["size"] |
521 data = wxTextDataObject(str(("%s%d.%d.%d.%d"%(SizeConversion[size], bus_id, node_id, index, subindex), "location"))) |
498 data = wx.TextDataObject(str(("%s%d.%d.%d.%d"%(SizeConversion[size], bus_id, node_id, index, subindex), "location"))) |
522 dragSource = wxDropSource(self.SubindexGrid) |
499 dragSource = wx.DropSource(self.SubindexGrid) |
523 dragSource.SetData(data) |
500 dragSource.SetData(data) |
524 dragSource.DoDragDrop() |
501 dragSource.DoDragDrop() |
525 |
502 |
526 #------------------------------------------------------------------------------- |
503 #------------------------------------------------------------------------------- |
527 # Refresh Functions |
504 # Refresh Functions |
656 event.Skip() |
633 event.Skip() |
657 |
634 |
658 def OnSubindexGridRightClick(self, event): |
635 def OnSubindexGridRightClick(self, event): |
659 if self.Editable: |
636 if self.Editable: |
660 selected = self.IndexList.GetSelection() |
637 selected = self.IndexList.GetSelection() |
661 if selected != wxNOT_FOUND: |
638 if selected != wx.NOT_FOUND: |
662 index = self.ListIndex[selected] |
639 index = self.ListIndex[selected] |
663 if self.Manager.IsCurrentEntry(index): |
640 if self.Manager.IsCurrentEntry(index): |
664 infos = self.Manager.GetEntryInfos(index) |
641 infos = self.Manager.GetEntryInfos(index) |
665 if index >= 0x2000 and infos["struct"] & OD_MultipleSubindexes or infos["struct"] & OD_IdenticalSubindexes: |
642 if index >= 0x2000 and infos["struct"] & OD_MultipleSubindexes or infos["struct"] & OD_IdenticalSubindexes: |
666 self.PopupMenu(self.SubindexGridMenu) |
643 self.PopupMenu(self.SubindexGridMenu) |
667 event.Skip() |
644 event.Skip() |
668 |
645 |
669 def OnRenameIndexMenu(self, event): |
646 def OnRenameIndexMenu(self, event): |
670 if self.Editable: |
647 if self.Editable: |
671 selected = self.IndexList.GetSelection() |
648 selected = self.IndexList.GetSelection() |
672 if selected != wxNOT_FOUND: |
649 if selected != wx.NOT_FOUND: |
673 index = self.ListIndex[selected] |
650 index = self.ListIndex[selected] |
674 if self.Manager.IsCurrentEntry(index): |
651 if self.Manager.IsCurrentEntry(index): |
675 infos = self.Manager.GetEntryInfos(index) |
652 infos = self.Manager.GetEntryInfos(index) |
676 dialog = wxTextEntryDialog(self, "Give a new name for index 0x%04X"%index, |
653 dialog = wx.TextEntryDialog(self, "Give a new name for index 0x%04X"%index, |
677 "Rename an index", infos["name"], wxOK|wxCANCEL) |
654 "Rename an index", infos["name"], wx.OK|wx.CANCEL) |
678 if dialog.ShowModal() == wxID_OK: |
655 if dialog.ShowModal() == wx.ID_OK: |
679 self.Manager.SetCurrentEntryName(index, dialog.GetValue()) |
656 self.Manager.SetCurrentEntryName(index, dialog.GetValue()) |
680 self.Parent.RefreshBufferState() |
657 self.Parent.RefreshBufferState() |
681 self.RefreshIndexList() |
658 self.RefreshIndexList() |
682 dialog.Destroy() |
659 dialog.Destroy() |
683 event.Skip() |
660 event.Skip() |
684 |
661 |
685 def OnModifyIndexMenu(self, event): |
662 def OnModifyIndexMenu(self, event): |
686 if self.Editable: |
663 if self.Editable: |
687 selected = self.IndexList.GetSelection() |
664 selected = self.IndexList.GetSelection() |
688 if selected != wxNOT_FOUND: |
665 if selected != wx.NOT_FOUND: |
689 index = self.ListIndex[selected] |
666 index = self.ListIndex[selected] |
690 if self.Manager.IsCurrentEntry(index) and index < 0x260: |
667 if self.Manager.IsCurrentEntry(index) and index < 0x260: |
691 values, valuetype = self.Manager.GetCustomisedTypeValues(index) |
668 values, valuetype = self.Manager.GetCustomisedTypeValues(index) |
692 dialog = UserTypeDialog(self) |
669 dialog = UserTypeDialog(self) |
693 dialog.SetTypeList(self.Manager.GetCustomisableTypes(), values[1]) |
670 dialog.SetTypeList(self.Manager.GetCustomisableTypes(), values[1]) |
694 if valuetype == 0: |
671 if valuetype == 0: |
695 dialog.SetValues(min = values[2], max = values[3]) |
672 dialog.SetValues(min = values[2], max = values[3]) |
696 elif valuetype == 1: |
673 elif valuetype == 1: |
697 dialog.SetValues(length = values[2]) |
674 dialog.SetValues(length = values[2]) |
698 if dialog.ShowModal() == wxID_OK: |
675 if dialog.ShowModal() == wx.ID_OK: |
699 type, min, max, length = dialog.GetValues() |
676 type, min, max, length = dialog.GetValues() |
700 self.Manager.SetCurrentUserType(index, type, min, max, length) |
677 self.Manager.SetCurrentUserType(index, type, min, max, length) |
701 self.Parent.RefreshBufferState() |
678 self.Parent.RefreshBufferState() |
702 self.RefreshIndexList() |
679 self.RefreshIndexList() |
703 event.Skip() |
680 event.Skip() |
704 |
681 |
705 def OnDeleteIndexMenu(self, event): |
682 def OnDeleteIndexMenu(self, event): |
706 if self.Editable: |
683 if self.Editable: |
707 selected = self.IndexList.GetSelection() |
684 selected = self.IndexList.GetSelection() |
708 if selected != wxNOT_FOUND: |
685 if selected != wx.NOT_FOUND: |
709 index = self.ListIndex[selected] |
686 index = self.ListIndex[selected] |
710 if self.Manager.IsCurrentEntry(index): |
687 if self.Manager.IsCurrentEntry(index): |
711 self.Manager.ManageEntriesOfCurrent([],[index]) |
688 self.Manager.ManageEntriesOfCurrent([],[index]) |
712 self.Parent.RefreshBufferState() |
689 self.Parent.RefreshBufferState() |
713 self.RefreshIndexList() |
690 self.RefreshIndexList() |
714 event.Skip() |
691 event.Skip() |
715 |
692 |
716 def OnAddSubindexMenu(self, event): |
693 def OnAddSubindexMenu(self, event): |
717 if self.Editable: |
694 if self.Editable: |
718 selected = self.IndexList.GetSelection() |
695 selected = self.IndexList.GetSelection() |
719 if selected != wxNOT_FOUND: |
696 if selected != wx.NOT_FOUND: |
720 index = self.ListIndex[selected] |
697 index = self.ListIndex[selected] |
721 if self.Manager.IsCurrentEntry(index): |
698 if self.Manager.IsCurrentEntry(index): |
722 dialog = wxTextEntryDialog(self, "Number of subindexes to add:", |
699 dialog = wx.TextEntryDialog(self, "Number of subindexes to add:", |
723 "Add subindexes", "1", wxOK|wxCANCEL) |
700 "Add subindexes", "1", wx.OK|wx.CANCEL) |
724 if dialog.ShowModal() == wxID_OK: |
701 if dialog.ShowModal() == wx.ID_OK: |
725 try: |
702 try: |
726 number = int(dialog.GetValue()) |
703 number = int(dialog.GetValue()) |
727 self.Manager.AddSubentriesToCurrent(index, number) |
704 self.Manager.AddSubentriesToCurrent(index, number) |
728 self.Parent.RefreshBufferState() |
705 self.Parent.RefreshBufferState() |
729 self.RefreshIndexList() |
706 self.RefreshIndexList() |
730 except: |
707 except: |
731 message = wxMessageDialog(self, "An integer is required!", "ERROR", wxOK|wxICON_ERROR) |
708 message = wx.MessageDialog(self, "An integer is required!", "ERROR", wx.OK|wx.ICON_ERROR) |
732 message.ShowModal() |
709 message.ShowModal() |
733 message.Destroy() |
710 message.Destroy() |
734 dialog.Destroy() |
711 dialog.Destroy() |
735 event.Skip() |
712 event.Skip() |
736 |
713 |
737 def OnDeleteSubindexMenu(self, event): |
714 def OnDeleteSubindexMenu(self, event): |
738 if self.Editable: |
715 if self.Editable: |
739 selected = self.IndexList.GetSelection() |
716 selected = self.IndexList.GetSelection() |
740 if selected != wxNOT_FOUND: |
717 if selected != wx.NOT_FOUND: |
741 index = self.ListIndex[selected] |
718 index = self.ListIndex[selected] |
742 if self.Manager.IsCurrentEntry(index): |
719 if self.Manager.IsCurrentEntry(index): |
743 dialog = wxTextEntryDialog(self, "Number of subindexes to delete:", |
720 dialog = wx.TextEntryDialog(self, "Number of subindexes to delete:", |
744 "Delete subindexes", "1", wxOK|wxCANCEL) |
721 "Delete subindexes", "1", wx.OK|wx.CANCEL) |
745 if dialog.ShowModal() == wxID_OK: |
722 if dialog.ShowModal() == wx.ID_OK: |
746 try: |
723 try: |
747 number = int(dialog.GetValue()) |
724 number = int(dialog.GetValue()) |
748 self.Manager.RemoveSubentriesFromCurrent(index, number) |
725 self.Manager.RemoveSubentriesFromCurrent(index, number) |
749 self.Parent.RefreshBufferState() |
726 self.Parent.RefreshBufferState() |
750 self.RefreshIndexList() |
727 self.RefreshIndexList() |
751 except: |
728 except: |
752 message = wxMessageDialog(self, "An integer is required!", "ERROR", wxOK|wxICON_ERROR) |
729 message = wx.MessageDialog(self, "An integer is required!", "ERROR", wx.OK|wx.ICON_ERROR) |
753 message.ShowModal() |
730 message.ShowModal() |
754 message.Destroy() |
731 message.Destroy() |
755 dialog.Destroy() |
732 dialog.Destroy() |
756 event.Skip() |
733 event.Skip() |
757 |
734 |