163 wx.Panel.__init__(self, id=ID_DATATYPEEDITOR, name='', parent=prnt, |
163 wx.Panel.__init__(self, id=ID_DATATYPEEDITOR, name='', parent=prnt, |
164 size=wx.Size(0, 0), style=wx.SUNKEN_BORDER) |
164 size=wx.Size(0, 0), style=wx.SUNKEN_BORDER) |
165 |
165 |
166 self.staticbox = wx.StaticBox(id=ID_DATATYPEEDITORSTATICBOX, |
166 self.staticbox = wx.StaticBox(id=ID_DATATYPEEDITORSTATICBOX, |
167 label='Type infos:', name='staticBox1', parent=self, |
167 label='Type infos:', name='staticBox1', parent=self, |
168 pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0) |
168 pos=wx.Point(0, 0), size=wx.Size(10, 0), style=0) |
169 |
169 |
170 self.staticText1 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT1, |
170 self.staticText1 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT1, |
171 label='Derivation Type:', name='staticText1', parent=self, |
171 label='Derivation Type:', name='staticText1', parent=self, |
172 pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0) |
172 pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0) |
173 |
173 |
195 label='Initial Value:', name='staticText3', parent=self.DirectlyPanel, |
195 label='Initial Value:', name='staticText3', parent=self.DirectlyPanel, |
196 pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0) |
196 pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0) |
197 |
197 |
198 self.DirectlyInitialValue = wx.TextCtrl(id=ID_DATATYPEEDITORDIRECTLYINITIALVALUE, |
198 self.DirectlyInitialValue = wx.TextCtrl(id=ID_DATATYPEEDITORDIRECTLYINITIALVALUE, |
199 name='DirectlyInitialValue', parent=self.DirectlyPanel, pos=wx.Point(0, 0), |
199 name='DirectlyInitialValue', parent=self.DirectlyPanel, pos=wx.Point(0, 0), |
200 size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER) |
200 size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|wx.TE_MULTILINE|wx.TE_RICH) |
201 self.Bind(wx.EVT_TEXT_ENTER, self.OnInfosChanged, id=ID_DATATYPEEDITORDIRECTLYINITIALVALUE) |
201 self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, id=ID_DATATYPEEDITORDIRECTLYINITIALVALUE) |
202 |
202 |
203 # Panel for Subrange data types |
203 # Panel for Subrange data types |
204 |
204 |
205 self.SubrangePanel = wx.Panel(id=ID_DATATYPEEDITORSUBRANGEPANEL, |
205 self.SubrangePanel = wx.Panel(id=ID_DATATYPEEDITORSUBRANGEPANEL, |
206 name='SubrangePanel', parent=self, pos=wx.Point(0, 0), |
206 name='SubrangePanel', parent=self, pos=wx.Point(0, 0), |
294 label='Initial Value:', name='staticText10', parent=self.ArrayPanel, |
294 label='Initial Value:', name='staticText10', parent=self.ArrayPanel, |
295 pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0) |
295 pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0) |
296 |
296 |
297 self.ArrayInitialValue = wx.TextCtrl(id=ID_DATATYPEEDITORARRAYINITIALVALUE, |
297 self.ArrayInitialValue = wx.TextCtrl(id=ID_DATATYPEEDITORARRAYINITIALVALUE, |
298 name='ArrayInitialValue', parent=self.ArrayPanel, pos=wx.Point(0, 0), |
298 name='ArrayInitialValue', parent=self.ArrayPanel, pos=wx.Point(0, 0), |
299 size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER) |
299 size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|wx.TE_MULTILINE|wx.TE_RICH) |
300 self.Bind(wx.EVT_TEXT_ENTER, self.OnInfosChanged, id=ID_DATATYPEEDITORARRAYINITIALVALUE) |
300 self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, id=ID_DATATYPEEDITORARRAYINITIALVALUE) |
301 |
301 |
302 self._init_sizers() |
302 self._init_sizers() |
303 |
303 |
304 def __init__(self, parent, tagname, window, controler): |
304 def __init__(self, parent, tagname, window, controler): |
305 self._init_ctrls(parent) |
305 self._init_ctrls(parent) |
369 self.DirectlyBaseType.Append(datatype) |
370 self.DirectlyBaseType.Append(datatype) |
370 self.ArrayBaseType.Append(datatype) |
371 self.ArrayBaseType.Append(datatype) |
371 self.DirectlyBaseType.SetSelection(0) |
372 self.DirectlyBaseType.SetSelection(0) |
372 self.SubrangeBaseType.Clear() |
373 self.SubrangeBaseType.Clear() |
373 words = self.TagName.split("::") |
374 words = self.TagName.split("::") |
374 for base_type in self.Controler.GetSubrangeTypes(): |
375 for base_type in self.Controler.GetSubrangeBaseTypes(words[1]): |
375 self.SubrangeBaseType.Append(base_type) |
376 self.SubrangeBaseType.Append(base_type) |
376 self.SubrangeBaseType.SetSelection(0) |
377 self.SubrangeBaseType.SetSelection(0) |
377 self.RefreshBoundsRange() |
378 self.RefreshBoundsRange() |
378 type_infos = self.Controler.GetDataTypeInfos(self.TagName) |
379 type_infos = self.Controler.GetDataTypeInfos(self.TagName) |
379 if type_infos is not None: |
380 if type_infos is not None: |
398 elif type_infos["type"] == "Array": |
399 elif type_infos["type"] == "Array": |
399 self.ArrayBaseType.SetStringSelection(type_infos["base_type"]) |
400 self.ArrayBaseType.SetStringSelection(type_infos["base_type"]) |
400 self.ArrayDimensions.SetStrings(map(lambda x : "..".join(map(str, x)), type_infos["dimensions"])) |
401 self.ArrayDimensions.SetStrings(map(lambda x : "..".join(map(str, x)), type_infos["dimensions"])) |
401 self.ArrayInitialValue.SetValue(type_infos["initial"]) |
402 self.ArrayInitialValue.SetValue(type_infos["initial"]) |
402 self.RefreshDisplayedInfos() |
403 self.RefreshDisplayedInfos() |
|
404 self.ShowErrors() |
403 self.Initializing = False |
405 self.Initializing = False |
404 |
406 |
405 def RefreshScaling(self, refresh=True): |
407 def RefreshScaling(self, refresh=True): |
406 pass |
408 pass |
407 |
409 |
408 def OnDerivationTypeChanged(self, event): |
410 def OnDerivationTypeChanged(self, event): |
409 self.RefreshDisplayedInfos() |
411 self.RefreshDisplayedInfos() |
410 self.RefreshTypeInfos() |
412 self.RefreshTypeInfos() |
411 event.Skip() |
413 event.Skip() |
412 |
414 |
|
415 def OnReturnKeyPressed(self, event): |
|
416 self.RefreshTypeInfos() |
|
417 |
413 def OnInfosChanged(self, event): |
418 def OnInfosChanged(self, event): |
414 self.RefreshTypeInfos() |
419 self.RefreshTypeInfos() |
415 event.Skip() |
420 event.Skip() |
416 |
421 |
417 def OnSubrangeBaseTypeChanged(self, event): |
422 def OnSubrangeBaseTypeChanged(self, event): |
466 for value in self.EnumeratedValues.GetStrings(): |
471 for value in self.EnumeratedValues.GetStrings(): |
467 self.EnumeratedInitialValue.Append(value) |
472 self.EnumeratedInitialValue.Append(value) |
468 self.EnumeratedInitialValue.SetStringSelection(selected) |
473 self.EnumeratedInitialValue.SetStringSelection(selected) |
469 |
474 |
470 def RefreshBoundsRange(self): |
475 def RefreshBoundsRange(self): |
471 range = GetDataTypeRange(self.SubrangeBaseType.GetStringSelection()) |
476 range = self.Controler.GetDataTypeRange(self.SubrangeBaseType.GetStringSelection()) |
472 if range is not None: |
477 if range is not None: |
473 min_value, max_value = range |
478 min_value, max_value = range |
474 self.SubrangeMinimum.SetRange(min_value, max_value) |
479 self.SubrangeMinimum.SetRange(min_value, max_value) |
475 self.SubrangeMinimum.SetValue(min(max(min_value, self.SubrangeMinimum.GetValue()), max_value)) |
480 self.SubrangeMinimum.SetValue(min(max(min_value, self.SubrangeMinimum.GetValue()), max_value)) |
476 self.SubrangeMaximum.SetRange(min_value, max_value) |
481 self.SubrangeMaximum.SetRange(min_value, max_value) |
519 infos["initial"] = self.ArrayInitialValue.GetValue() |
524 infos["initial"] = self.ArrayInitialValue.GetValue() |
520 self.Controler.SetDataTypeInfos(self.TagName, infos) |
525 self.Controler.SetDataTypeInfos(self.TagName, infos) |
521 self.ParentWindow.RefreshTitle() |
526 self.ParentWindow.RefreshTitle() |
522 self.ParentWindow.RefreshEditMenu() |
527 self.ParentWindow.RefreshEditMenu() |
523 |
528 |
|
529 #------------------------------------------------------------------------------- |
|
530 # Errors showing functions |
|
531 #------------------------------------------------------------------------------- |
|
532 |
|
533 def ClearErrors(self): |
|
534 self.Errors = [] |
|
535 self.RefreshView() |
|
536 |
|
537 def AddShownError(self, infos, start, end): |
|
538 self.Errors.append((infos, start, end)) |
|
539 |
|
540 def ShowErrors(self): |
|
541 type_infos = self.Controler.GetDataTypeInfos(self.TagName) |
|
542 for infos, start, end in self.Errors: |
|
543 if infos[0] == "base": |
|
544 if type_infos["type"] == "Directly": |
|
545 self.DirectlyBaseType.SetBackgroundColour(wx.Colour(255, 255, 0)) |
|
546 self.DirectlyBaseType.SetForegroundColour(wx.RED) |
|
547 elif type_infos["type"] == "Subrange": |
|
548 self.SubrangeBaseType.SetBackgroundColour(wx.Colour(255, 255, 0)) |
|
549 self.SubrangeBaseType.SetForegroundColour(wx.RED) |
|
550 elif type_infos["type"] == "Array": |
|
551 self.ArrayBaseType.SetBackgroundColour(wx.Colour(255, 255, 0)) |
|
552 self.ArrayBaseType.SetForegroundColour(wx.RED) |
|
553 elif infos[0] == "lower": |
|
554 self.SubrangeMinimum.SetBackgroundColour(wx.Colour(255, 255, 0)) |
|
555 self.SubrangeMaximum.SetForegroundColour(wx.RED) |
|
556 elif infos[0] == "upper": |
|
557 self.SubrangeMinimum.SetBackgroundColour(wx.Colour(255, 255, 0)) |
|
558 self.SubrangeMaximum.SetForegroundColour(wx.RED) |
|
559 elif infos[0] == "value": |
|
560 listctrl = self.EnumeratedValues.GetListCtrl() |
|
561 listctrl.SetItemBackgroundColour(infos[1], wx.Colour(255, 255, 0)) |
|
562 listctrl.SetItemTextColour(infos[1], wx.RED) |
|
563 listctrl.Select(listctrl.FocusedItem, False) |
|
564 elif infos[0] == "range": |
|
565 listctrl = self.EnumeratedValues.GetListCtrl() |
|
566 listctrl.SetItemBackgroundColour(infos[1], wx.Colour(255, 255, 0)) |
|
567 listctrl.SetItemTextColour(infos[1], wx.RED) |
|
568 listctrl.SetStringSelection("") |
|
569 elif infos[0] == "initial": |
|
570 if type_infos["type"] == "Directly": |
|
571 text = self.DirectlyInitialValue.GetValue() |
|
572 self.DirectlyInitialValue.SetValue(text[:start[1]]) |
|
573 self.DirectlyInitialValue.SetDefaultStyle(wx.TextAttr(wx.RED, wx.Colour(255, 255, 0))) |
|
574 self.DirectlyInitialValue.AppendText(text[start[1]:end[1] + 1]) |
|
575 self.DirectlyInitialValue.SetDefaultStyle(wx.TextAttr(wx.BLACK, wx.WHITE)) |
|
576 self.DirectlyInitialValue.AppendText(text[end[1] + 1:]) |
|
577 elif type_infos["type"] == "Subrange": |
|
578 self.SubrangeInitialValue.SetBackgroundColour(wx.Colour(255, 255, 0)) |
|
579 self.SubrangeInitialValue.SetForegroundColour(wx.RED) |
|
580 elif type_infos["type"] == "Enumerated": |
|
581 self.EnumeratedInitialValue.SetBackgroundColour(wx.Colour(255, 255, 0)) |
|
582 self.EnumeratedInitialValue.SetForegroundColour(wx.RED) |
|
583 elif type_infos["type"] == "Array": |
|
584 text = self.ArrayInitialValue.GetValue() |
|
585 self.ArrayInitialValue.SetValue(text[:start[1]]) |
|
586 self.ArrayInitialValue.SetDefaultStyle(wx.TextAttr(wx.RED, wx.Colour(255, 255, 0))) |
|
587 self.ArrayInitialValue.AppendText(text[start[1]:end[1] + 1]) |
|
588 self.ArrayInitialValue.SetDefaultStyle(wx.TextAttr(wx.BLACK, wx.WHITE)) |
|
589 self.ArrayInitialValue.AppendText(text[end[1] + 1:]) |