VariablePanel.py
changeset 424 d19c4a6460ab
parent 422 31c3dc45cfab
child 425 dbc4a66190a6
equal deleted inserted replaced
423:53aa0c334f2f 424:d19c4a6460ab
    33 #-------------------------------------------------------------------------------
    33 #-------------------------------------------------------------------------------
    34 
    34 
    35 def GetVariableTableColnames(location):
    35 def GetVariableTableColnames(location):
    36     _ = lambda x : x
    36     _ = lambda x : x
    37     if location:
    37     if location:
    38     	return ["#", _("Name"), _("Class"), _("Type"), _("Location"), _("Initial Value"), _("Retain"), _("Constant")]
    38     	return ["#", _("Name"), _("Class"), _("Type"), _("Location"), _("Initial Value"), _("Retain"), _("Constant"), _("Documentation")]
    39     return ["#", _("Name"), _("Class"), _("Type"), _("Initial Value"), _("Retain"), _("Constant")]
    39     return ["#", _("Name"), _("Class"), _("Type"), _("Initial Value"), _("Retain"), _("Constant"), _("Documentation")]
    40 
    40 
    41 def GetAlternativeOptions():
    41 def GetAlternativeOptions():
    42     _ = lambda x : x
    42     _ = lambda x : x
    43     return [_("Yes"), _("No")]
    43     return [_("Yes"), _("No")]
    44 ALTERNATIVE_OPTIONS_DICT = dict([(_(option), option) for option in GetAlternativeOptions()])
    44 ALTERNATIVE_OPTIONS_DICT = dict([(_(option), option) for option in GetAlternativeOptions()])
   470         
   470         
   471         self.Filter = "All"
   471         self.Filter = "All"
   472         self.FilterChoices = []
   472         self.FilterChoices = []
   473         self.FilterChoiceTransfer = GetFilterChoiceTransfer()
   473         self.FilterChoiceTransfer = GetFilterChoiceTransfer()
   474         
   474         
       
   475         self.DefaultValue = {   "Name" : "", "Class" : "", "Type" : "INT", "Location" : "",
       
   476                                 "Initial Value" : "", "Retain" : "No", "Constant" : "No",
       
   477                                 "Documentation" : "", "Edit" : True
       
   478                             }
       
   479 
   475         if element_type in ["config", "resource"]:
   480         if element_type in ["config", "resource"]:
   476             self.DefaultTypes = {"All" : "Global"}
   481             self.DefaultTypes = {"All" : "Global"}
   477             self.DefaultValue = {"Name" : "", "Class" : "", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No", "Edit" : True}
       
   478         else:
   482         else:
   479             self.DefaultTypes = {"All" : "Local", "Interface" : "Input", "Variables" : "Local"}
   483             self.DefaultTypes = {"All" : "Local", "Interface" : "Input", "Variables" : "Local"}
   480             self.DefaultValue = {"Name" : "", "Class" : "", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No", "Edit" : True}
   484 
   481         if element_type in ["config", "resource"] or element_type in ["program", "transition", "action"]:
   485         if element_type in ["config", "resource"] \
       
   486         or element_type in ["program", "transition", "action"]:
       
   487             # this is an element that can have located variables
   482             self.Table = VariableTable(self, [], GetVariableTableColnames(True))
   488             self.Table = VariableTable(self, [], GetVariableTableColnames(True))
   483             if element_type not in ["config", "resource"]:
   489 
   484                 self.FilterChoices = ["All", "Interface", "   Input", "   Output", "   InOut", "   External", "Variables", "   Local", "   Temp"]#,"Access"]
   490             if element_type in ["config", "resource"]:
       
   491                 self.FilterChoices = ["All", "Global"]#,"Access"]
   485             else:
   492             else:
   486                 self.FilterChoices = ["All", "Global"]#,"Access"]
   493                 self.FilterChoices = ["All",
   487             self.ColSizes = [40, 80, 70, 80, 80, 80, 60, 70]
   494                                         "Interface", "   Input", "   Output", "   InOut", "   External",
   488             self.ColAlignements = [wx.ALIGN_CENTER, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_CENTER, wx.ALIGN_CENTER]
   495                                         "Variables", "   Local", "   Temp"]#,"Access"]
   489         else:
   496 
       
   497             # these condense the ColAlignements list
       
   498             l = wx.ALIGN_LEFT
       
   499             c = wx.ALIGN_CENTER 
       
   500 
       
   501             #                      Num  Name    Class   Type    Loc     Init    Retain  Const   Doc
       
   502             self.ColSizes       = [40,  80,     70,     80,     80,     80,     60,     70,     80]
       
   503             self.ColAlignements = [c,   l,      l,      l,      l,      l,      c,      c,      l]
       
   504 
       
   505         else:
       
   506             # this is an element that cannot have located variables
   490             self.Table = VariableTable(self, [], GetVariableTableColnames(False))
   507             self.Table = VariableTable(self, [], GetVariableTableColnames(False))
       
   508 
   491             if element_type == "function":
   509             if element_type == "function":
   492                 self.FilterChoices = ["All", "Interface", "   Input", "   Output", "   InOut", "Variables", "   Local", "   Temp"]
   510                 self.FilterChoices = ["All",
       
   511                                         "Interface", "   Input", "   Output", "   InOut",
       
   512                                         "Variables", "   Local", "   Temp"]
   493             else:
   513             else:
   494                 self.FilterChoices = ["All", "Interface", "   Input", "   Output", "   InOut", "   External", "Variables", "   Local", "   Temp"]
   514                 self.FilterChoices = ["All",
   495             self.ColSizes = [40, 120, 70, 80, 120, 60, 70]
   515                                         "Interface", "   Input", "   Output", "   InOut", "   External",
   496             self.ColAlignements = [wx.ALIGN_CENTER, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_CENTER, wx.ALIGN_CENTER]
   516                                         "Variables", "   Local", "   Temp"]
       
   517 
       
   518             # these condense the ColAlignements list
       
   519             l = wx.ALIGN_LEFT
       
   520             c = wx.ALIGN_CENTER 
       
   521 
       
   522             #                      Num  Name    Class   Type    Init    Retain  Const   Doc
       
   523             self.ColSizes       = [40,  80,     70,     80,     80,     60,     70,     160]
       
   524             self.ColAlignements = [c,   l,      l,      l,      l,      c,      c,      l]
       
   525 
   497         for choice in self.FilterChoices:
   526         for choice in self.FilterChoices:
   498             self.ClassFilter.Append(_(choice))
   527             self.ClassFilter.Append(_(choice))
       
   528 
   499         reverse_transfer = {}
   529         reverse_transfer = {}
   500         for filter, choice in self.FilterChoiceTransfer.items():
   530         for filter, choice in self.FilterChoiceTransfer.items():
   501             reverse_transfer[choice] = filter
   531             reverse_transfer[choice] = filter
   502         self.ClassFilter.SetStringSelection(_(reverse_transfer[self.Filter]))
   532         self.ClassFilter.SetStringSelection(_(reverse_transfer[self.Filter]))
   503         self.RefreshTypeList()
   533         self.RefreshTypeList()