editors/DataTypeEditor.py
branchpython3
changeset 3750 f62625418bff
parent 3449 6279ec06df98
child 3752 9f6f46dbe3ae
equal deleted inserted replaced
3749:fda6c1a37662 3750:f62625418bff
    22 # You should have received a copy of the GNU General Public License
    22 # You should have received a copy of the GNU General Public License
    23 # along with this program; if not, write to the Free Software
    23 # along with this program; if not, write to the Free Software
    24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    25 
    25 
    26 
    26 
    27 from __future__ import absolute_import
    27 
    28 import re
    28 import re
    29 from six.moves import xrange
    29 from six.moves import xrange
    30 
    30 
    31 import wx
    31 import wx
    32 import wx.grid
    32 import wx.grid
   237         self.SubrangeMinimum = CustomIntCtrl(self.SubrangePanel, style=wx.TAB_TRAVERSAL)
   237         self.SubrangeMinimum = CustomIntCtrl(self.SubrangePanel, style=wx.TAB_TRAVERSAL)
   238         self.SubrangeMinimum.Bind(CustomIntCtrl.EVT_CUSTOM_INT, self.OnSubrangeMinimumChanged)
   238         self.SubrangeMinimum.Bind(CustomIntCtrl.EVT_CUSTOM_INT, self.OnSubrangeMinimumChanged)
   239         subrange_panel_sizer.Add(self.SubrangeMinimum, 1, border=5,
   239         subrange_panel_sizer.Add(self.SubrangeMinimum, 1, border=5,
   240                                        flag=wx.GROW | wx.ALL)
   240                                        flag=wx.GROW | wx.ALL)
   241 
   241 
   242         for dummy in xrange(2):
   242         for dummy in range(2):
   243             subrange_panel_sizer.Add(wx.Size(0, 0), 1)
   243             subrange_panel_sizer.Add(wx.Size(0, 0), 1)
   244 
   244 
   245         subrange_maximum_label = wx.StaticText(self.SubrangePanel,
   245         subrange_maximum_label = wx.StaticText(self.SubrangePanel,
   246                                                label=_('Maximum:'))
   246                                                label=_('Maximum:'))
   247         subrange_panel_sizer.Add(subrange_maximum_label, 1, border=5,
   247         subrange_panel_sizer.Add(subrange_maximum_label, 1, border=5,
   510                 self.EnumeratedValues.SetStrings(type_infos["values"])
   510                 self.EnumeratedValues.SetStrings(type_infos["values"])
   511                 self.RefreshEnumeratedValues()
   511                 self.RefreshEnumeratedValues()
   512                 self.EnumeratedInitialValue.SetStringSelection(type_infos["initial"])
   512                 self.EnumeratedInitialValue.SetStringSelection(type_infos["initial"])
   513             elif type_infos["type"] == "Array":
   513             elif type_infos["type"] == "Array":
   514                 self.ArrayBaseType.SetStringSelection(type_infos["base_type"])
   514                 self.ArrayBaseType.SetStringSelection(type_infos["base_type"])
   515                 self.ArrayDimensions.SetStrings(map("..".join, type_infos["dimensions"]))
   515                 self.ArrayDimensions.SetStrings(list(map("..".join, type_infos["dimensions"])))
   516                 self.ArrayInitialValue.SetValue(type_infos["initial"])
   516                 self.ArrayInitialValue.SetValue(type_infos["initial"])
   517             elif type_infos["type"] == "Structure":
   517             elif type_infos["type"] == "Structure":
   518                 self.StructureElementsTable.SetData(type_infos["elements"])
   518                 self.StructureElementsTable.SetData(type_infos["elements"])
   519             self.RefreshDisplayedInfos()
   519             self.RefreshDisplayedInfos()
   520         self.ShowHighlights()
   520         self.ShowHighlights()
   776     def ClearHighlights(self, highlight_type=None):
   776     def ClearHighlights(self, highlight_type=None):
   777         if highlight_type is None:
   777         if highlight_type is None:
   778             self.Highlights = []
   778             self.Highlights = []
   779         else:
   779         else:
   780             self.Highlights = [(infos, start, end, highlight) for (infos, start, end, highlight) in self.Highlights if highlight != highlight_type]
   780             self.Highlights = [(infos, start, end, highlight) for (infos, start, end, highlight) in self.Highlights if highlight != highlight_type]
   781         for control in self.HighlightControls.itervalues():
   781         for control in self.HighlightControls.values():
   782             if isinstance(control, (wx.ComboBox, wx.SpinCtrl)):
   782             if isinstance(control, (wx.ComboBox, wx.SpinCtrl)):
   783                 control.SetBackgroundColour(wx.NullColour)
   783                 control.SetBackgroundColour(wx.NullColour)
   784                 control.SetForegroundColour(wx.NullColour)
   784                 control.SetForegroundColour(wx.NullColour)
   785             elif isinstance(control, wx.TextCtrl):
   785             elif isinstance(control, wx.TextCtrl):
   786                 value = control.GetValueStr() if isinstance(control, CustomIntCtrl) else \
   786                 value = control.GetValueStr() if isinstance(control, CustomIntCtrl) else \
   787                         control.GetValue()
   787                         control.GetValue()
   788                 control.SetStyle(0, len(value), wx.TextAttr(wx.NullColour))
   788                 control.SetStyle(0, len(value), wx.TextAttr(wx.NullColour))
   789             elif isinstance(control, wx.adv.EditableListBox):
   789             elif isinstance(control, wx.adv.EditableListBox):
   790                 listctrl = control.GetListCtrl()
   790                 listctrl = control.GetListCtrl()
   791                 for i in xrange(listctrl.GetItemCount()):
   791                 for i in range(listctrl.GetItemCount()):
   792                     listctrl.SetItemBackgroundColour(i, wx.NullColour)
   792                     listctrl.SetItemBackgroundColour(i, wx.NullColour)
   793                     listctrl.SetItemTextColour(i, wx.NullColour)
   793                     listctrl.SetItemTextColour(i, wx.NullColour)
   794         self.StructureElementsTable.ClearHighlights(highlight_type)
   794         self.StructureElementsTable.ClearHighlights(highlight_type)
   795         self.RefreshView()
   795         self.RefreshView()
   796 
   796