ConfTreeNodeEditor.py
changeset 781 cdc6393705ce
parent 775 172be32a2482
equal deleted inserted replaced
780:70632f4612a1 781:cdc6393705ce
     7 
     7 
     8 from controls import EditorPanel
     8 from controls import EditorPanel
     9 
     9 
    10 from PLCOpenEditor import TITLE, FILEMENU, PROJECTTREE, PAGETITLES
    10 from PLCOpenEditor import TITLE, FILEMENU, PROJECTTREE, PAGETITLES
    11 
    11 
    12 from util.misc import opjimg
       
    13 from util.TextCtrlAutoComplete import TextCtrlAutoComplete
    12 from util.TextCtrlAutoComplete import TextCtrlAutoComplete
    14 from util.BrowseValuesLibraryDialog import BrowseValuesLibraryDialog
    13 from util.BrowseValuesLibraryDialog import BrowseValuesLibraryDialog
       
    14 from utils.BitmapLibrary import GetBitmap
    15 
    15 
    16 if wx.Platform == '__WXMSW__':
    16 if wx.Platform == '__WXMSW__':
    17     faces = { 'times': 'Times New Roman',
    17     faces = { 'times': 'Times New Roman',
    18               'mono' : 'Courier New',
    18               'mono' : 'Courier New',
    19               'helv' : 'Arial',
    19               'helv' : 'Arial',
   122     def __init__(self, parent, ID, bitmapname,
   122     def __init__(self, parent, ID, bitmapname,
   123                  pos = wx.DefaultPosition, size = wx.DefaultSize,
   123                  pos = wx.DefaultPosition, size = wx.DefaultSize,
   124                  style = 0,
   124                  style = 0,
   125                  name = "genstatbmp"):
   125                  name = "genstatbmp"):
   126         
   126         
   127         bitmappath = Bpath( "images", bitmapname)
   127         wx.lib.statbmp.GenStaticBitmap.__init__(self, parent, ID, 
   128         if os.path.isfile(bitmappath):
   128                  GetBitmap(bitmapname),
   129             bitmap = wx.Bitmap(bitmappath)
       
   130         else:
       
   131             bitmap = None
       
   132         wx.lib.statbmp.GenStaticBitmap.__init__(self, parent, ID, bitmap,
       
   133                  pos, size,
   129                  pos, size,
   134                  style,
   130                  style,
   135                  name)
   131                  name)
   136         
   132         
   137     def OnPaint(self, event):
   133     def OnPaint(self, event):
   149     SHOW_PARAMS = True
   145     SHOW_PARAMS = True
   150     
   146     
   151     def _init_ConfNodeEditor(self, prnt):
   147     def _init_ConfNodeEditor(self, prnt):
   152         self.ConfNodeEditor = None
   148         self.ConfNodeEditor = None
   153     
   149     
   154     def _init_Editor(self, prnt):
   150     def _init_Editor(self, parent):
   155         self.Editor = wx.SplitterWindow(id=self.ID, name='EditorSplitter', parent=prnt,
   151         self.Editor = wx.SplitterWindow(parent,
   156               size=wx.Size(0, 0), style=wx.SUNKEN_BORDER|wx.SP_3D)
   152               style=wx.SUNKEN_BORDER|wx.SP_3D)
   157         self.SetNeedUpdating(True)
   153         self.SetNeedUpdating(True)
   158         self.SetMinimumPaneSize(1)
   154         self.SetMinimumPaneSize(1)
   159         
   155         
   160         if self.SHOW_PARAMS:
   156         if self.SHOW_PARAMS:
   161             self.ParamsEditor = wx.ScrolledWindow(self.Editor, -1, size=wx.Size(-1, -1),
   157             self.ParamsEditor = wx.ScrolledWindow(self.Editor, 
   162                             style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER|wx.HSCROLL|wx.VSCROLL)
   158                   style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER|wx.HSCROLL|wx.VSCROLL)
   163             self.ParamsEditor.SetBackgroundColour(WINDOW_COLOUR)
   159             self.ParamsEditor.SetBackgroundColour(WINDOW_COLOUR)
   164             self.ParamsEditor.Bind(wx.EVT_SIZE, self.OnWindowResize)
   160             self.ParamsEditor.Bind(wx.EVT_SIZE, self.OnWindowResize)
   165             self.ParamsEditor.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
   161             self.ParamsEditor.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
   166             
   162             
   167             # Variable allowing disabling of ParamsEditor scroll when Popup shown 
   163             # Variable allowing disabling of ParamsEditor scroll when Popup shown 
   173                 self.ParamsEditorSizer.AddGrowableRow(1)
   169                 self.ParamsEditorSizer.AddGrowableRow(1)
   174                 
   170                 
   175                 self.ParamsEditor.SetSizer(self.ParamsEditorSizer)
   171                 self.ParamsEditor.SetSizer(self.ParamsEditorSizer)
   176                 
   172                 
   177                 baseparamseditor_sizer = wx.BoxSizer(wx.HORIZONTAL)
   173                 baseparamseditor_sizer = wx.BoxSizer(wx.HORIZONTAL)
   178                 self.ParamsEditorSizer.AddSizer(baseparamseditor_sizer, 0, border=5, 
   174                 self.ParamsEditorSizer.AddSizer(baseparamseditor_sizer, border=5, 
   179                                                 flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.TOP)
   175                       flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.TOP)
   180                 
   176                 
   181                 self.FullIECChannel = wx.StaticText(self.ParamsEditor, -1)
   177                 self.FullIECChannel = wx.StaticText(self.ParamsEditor, -1)
   182                 self.FullIECChannel.SetFont(
   178                 self.FullIECChannel.SetFont(
   183                     wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, 
   179                     wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, 
   184                             wx.BOLD, faceName = faces["helv"]))
   180                             wx.BOLD, faceName = faces["helv"]))
   185                 baseparamseditor_sizer.AddWindow(self.FullIECChannel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL)
   181                 baseparamseditor_sizer.AddWindow(self.FullIECChannel, 
       
   182                       flag=wx.ALIGN_CENTER_VERTICAL)
   186                 
   183                 
   187                 updownsizer = wx.BoxSizer(wx.VERTICAL)
   184                 updownsizer = wx.BoxSizer(wx.VERTICAL)
   188                 baseparamseditor_sizer.AddSizer(updownsizer, 0, border=5, 
   185                 baseparamseditor_sizer.AddSizer(updownsizer, border=5, 
   189                                             flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL)
   186                       flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL)
   190                 
   187                 
   191                 ieccupbutton_id = wx.NewId()
   188                 self.IECCUpButton = wx.lib.buttons.GenBitmapTextButton(self.ParamsEditor, 
   192                 self.IECCUpButton = wx.lib.buttons.GenBitmapTextButton(
   189                       bitmap=GetBitmap('IECCDown'), size=wx.Size(16, 16), style=wx.NO_BORDER)
   193                       id=ieccupbutton_id, bitmap=wx.Bitmap(opjimg('IECCDown')),
       
   194                       name='IECUpButton', parent=self.ParamsEditor, pos=wx.Point(0, 0),
       
   195                       size=wx.Size(16, 16), style=wx.NO_BORDER)
       
   196                 self.IECCUpButton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(1), 
   190                 self.IECCUpButton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(1), 
   197                                       id=ieccupbutton_id)
   191                       self.IECCUpButton)
   198                 updownsizer.AddWindow(self.IECCUpButton, 0, border=0, flag=wx.ALIGN_LEFT)
   192                 updownsizer.AddWindow(self.IECCUpButton, flag=wx.ALIGN_LEFT)
   199                 
   193                 
   200                 ieccdownbutton_id = wx.NewId()
   194                 self.IECCDownButton = wx.lib.buttons.GenBitmapButton(self.ParamsEditor, 
   201                 self.IECCDownButton = wx.lib.buttons.GenBitmapButton(
   195                       bitmap=GetBitmap('IECCUp'), size=wx.Size(16, 16), style=wx.NO_BORDER)
   202                       id=ieccdownbutton_id, bitmap=wx.Bitmap(opjimg('IECCUp')),
       
   203                       name='IECDownButton', parent=self.ParamsEditor, pos=wx.Point(0, 0),
       
   204                       size=wx.Size(16, 16), style=wx.NO_BORDER)
       
   205                 self.IECCDownButton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(-1), 
   196                 self.IECCDownButton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(-1), 
   206                                         id=ieccdownbutton_id)
   197                       self.IECCDownButton)
   207                 updownsizer.AddWindow(self.IECCDownButton, 0, border=0, flag=wx.ALIGN_LEFT)
   198                 updownsizer.AddWindow(self.IECCDownButton, flag=wx.ALIGN_LEFT)
   208                 
   199                 
   209                 confnodename_id = wx.NewId()
   200                 self.ConfNodeName = wx.TextCtrl(self.ParamsEditor, 
   210                 self.ConfNodeName = wx.TextCtrl(
       
   211                       self.ParamsEditor, confnodename_id, 
       
   212                       size=wx.Size(150, 25), style=wx.NO_BORDER)
   201                       size=wx.Size(150, 25), style=wx.NO_BORDER)
   213                 self.ConfNodeName.SetFont(
   202                 self.ConfNodeName.SetFont(
   214                     wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, 
   203                     wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, 
   215                             wx.BOLD, faceName = faces["helv"]))
   204                             wx.BOLD, faceName = faces["helv"]))
   216                 self.ConfNodeName.Bind(wx.EVT_TEXT, 
   205                 self.ConfNodeName.Bind(wx.EVT_TEXT, 
   217                     self.GetTextCtrlCallBackFunction(self.ConfNodeName, "BaseParams.Name", True), 
   206                       self.GetTextCtrlCallBackFunction(self.ConfNodeName, "BaseParams.Name", True), 
   218                     id=confnodename_id)
   207                       self.ConfNodeName)
   219                 baseparamseditor_sizer.AddWindow(self.ConfNodeName, 0, border=5, flag=wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
   208                 baseparamseditor_sizer.AddWindow(self.ConfNodeName, border=5, 
       
   209                       flag=wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
   220                 
   210                 
   221                 buttons_sizer = self.GenerateMethodButtonSizer()
   211                 buttons_sizer = self.GenerateMethodButtonSizer()
   222                 baseparamseditor_sizer.AddSizer(buttons_sizer, 0, border=0, flag=wx.ALIGN_CENTER)
   212                 baseparamseditor_sizer.AddSizer(buttons_sizer, flag=wx.ALIGN_CENTER)
   223             
   213             
   224             else:
   214             else:
   225                 self.ParamsEditorSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=1, vgap=5)
   215                 self.ParamsEditorSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=1, vgap=5)
   226                 self.ParamsEditorSizer.AddGrowableCol(0)
   216                 self.ParamsEditorSizer.AddGrowableCol(0)
   227                 self.ParamsEditorSizer.AddGrowableRow(0)
   217                 self.ParamsEditorSizer.AddGrowableRow(0)
   228             
   218             
   229             self.ConfNodeParamsSizer = wx.BoxSizer(wx.VERTICAL)
   219             self.ConfNodeParamsSizer = wx.BoxSizer(wx.VERTICAL)
   230             self.ParamsEditorSizer.AddSizer(self.ConfNodeParamsSizer, 0, border=5, 
   220             self.ParamsEditorSizer.AddSizer(self.ConfNodeParamsSizer, border=5, 
   231                                             flag=wx.LEFT|wx.RIGHT|wx.BOTTOM)
   221                   flag=wx.LEFT|wx.RIGHT|wx.BOTTOM)
   232             
   222             
   233             self.RefreshConfNodeParamsSizer()
   223             self.RefreshConfNodeParamsSizer()
   234         else:
   224         else:
   235             self.ParamsEditor = None
   225             self.ParamsEditor = None
   236         
   226         
   248             self.Editor.Initialize(self.ParamsEditor)
   238             self.Editor.Initialize(self.ParamsEditor)
   249     
   239     
   250     def __init__(self, parent, controler, window, tagname=""):
   240     def __init__(self, parent, controler, window, tagname=""):
   251         EditorPanel.__init__(self, parent, tagname, window, controler)
   241         EditorPanel.__init__(self, parent, tagname, window, controler)
   252         
   242         
   253         icon_path = self.Controler.GetIconPath()
   243         icon_name = self.Controler.GetIconName()
   254         if icon_path is None:
   244         if icon_name is not None:
   255             icon_path = opjimg("Extension")
   245             self.SetIcon(GetBitmap(icon_name))
   256         self.SetIcon(wx.Bitmap(icon_path, wx.BITMAP_TYPE_PNG))
   246         else:
   257     
   247             self.SetIcon(GetBitmap("Extension"))
       
   248         
   258     def __del__(self):
   249     def __del__(self):
   259         self.Controler.OnCloseEditor(self)
   250         self.Controler.OnCloseEditor(self)
   260     
   251     
   261     def GetTagName(self):
   252     def GetTagName(self):
   262         return self.Controler.CTNFullName()
   253         return self.Controler.CTNFullName()
   311         
   302         
   312         msizer = wx.BoxSizer(wx.HORIZONTAL)
   303         msizer = wx.BoxSizer(wx.HORIZONTAL)
   313         
   304         
   314         for confnode_method in self.Controler.ConfNodeMethods:
   305         for confnode_method in self.Controler.ConfNodeMethods:
   315             if "method" in confnode_method and confnode_method.get("shown",True):
   306             if "method" in confnode_method and confnode_method.get("shown",True):
   316                 id = wx.NewId()
   307                 button = GenBitmapTextButton(self.ParamsEditor,
   317                 label = confnode_method["name"]
   308                     bitmap=GetBitmap(confnode_method.get("bitmap", "Unknown")), 
   318                 bitmap_path = confnode_method.get("bitmap", "Unknown")
   309                     label=confnode_method["name"], style=wx.NO_BORDER)
   319                 if os.path.splitext(bitmap_path)[1] == "":
       
   320                     bitmap_path = Bpath("images", "%s.png" % bitmap_path)
       
   321                 button = GenBitmapTextButton(id=id, parent=self.ParamsEditor,
       
   322                     bitmap=wx.Bitmap(bitmap_path), label=label, 
       
   323                     name=label, pos=wx.DefaultPosition, style=wx.NO_BORDER)
       
   324                 button.SetFont(normal_bt_font)
   310                 button.SetFont(normal_bt_font)
   325                 button.SetToolTipString(confnode_method["tooltip"])
   311                 button.SetToolTipString(confnode_method["tooltip"])
   326                 if confnode_method.get("push", False):
   312                 if confnode_method.get("push", False):
   327                     button.Bind(wx.EVT_LEFT_DOWN, self.GetButtonCallBackFunction(confnode_method["method"], True))
   313                     button.Bind(wx.EVT_LEFT_DOWN, self.GetButtonCallBackFunction(confnode_method["method"], True))
   328                 else:
   314                 else:
   329                     button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(confnode_method["method"]), id=id)
   315                     button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(confnode_method["method"]), button)
   330                 # a fancy underline on mouseover
   316                 # a fancy underline on mouseover
   331                 def setFontStyle(b, s):
   317                 def setFontStyle(b, s):
   332                     def fn(event):
   318                     def fn(event):
   333                         b.SetFont(s)
   319                         b.SetFont(s)
   334                         b.Refresh()
   320                         b.Refresh()
   337                 button.Bind(wx.EVT_ENTER_WINDOW, setFontStyle(button, mouseover_bt_font))
   323                 button.Bind(wx.EVT_ENTER_WINDOW, setFontStyle(button, mouseover_bt_font))
   338                 button.Bind(wx.EVT_LEAVE_WINDOW, setFontStyle(button, normal_bt_font))
   324                 button.Bind(wx.EVT_LEAVE_WINDOW, setFontStyle(button, normal_bt_font))
   339                 #hack to force size to mini
   325                 #hack to force size to mini
   340                 if not confnode_method.get("enabled",True):
   326                 if not confnode_method.get("enabled",True):
   341                     button.Disable()
   327                     button.Disable()
   342                 msizer.AddWindow(button, 0, border=0, flag=wx.ALIGN_CENTER)
   328                 msizer.AddWindow(button, flag=wx.ALIGN_CENTER)
   343         return msizer
   329         return msizer
   344     
   330     
   345     def GenerateSizerElements(self, sizer, elements, path, clean = True):
   331     def GenerateSizerElements(self, sizer, elements, path, clean = True):
   346         if clean:
   332         if clean:
   347             sizer.Clear(True)
   333             sizer.Clear(True)
   351                 element_path = "%s.%s"%(path, element_infos["name"])
   337                 element_path = "%s.%s"%(path, element_infos["name"])
   352             else:
   338             else:
   353                 element_path = element_infos["name"]
   339                 element_path = element_infos["name"]
   354             if element_infos["type"] == "element":
   340             if element_infos["type"] == "element":
   355                 label = element_infos["name"]
   341                 label = element_infos["name"]
   356                 staticbox = wx.StaticBox(id=-1, label=_(label), 
   342                 staticbox = wx.StaticBox(self.ParamsEditor, 
   357                     name='%s_staticbox'%element_infos["name"], parent=self.ParamsEditor,
   343                       label=_(label), size=wx.Size(10, 0))
   358                     pos=wx.Point(0, 0), size=wx.Size(10, 0), style=0)
       
   359                 staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL)
   344                 staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL)
   360                 if first:
   345                 if first:
   361                     sizer.AddSizer(staticboxsizer, 0, border=5, flag=wx.GROW|wx.TOP|wx.BOTTOM)
   346                     sizer.AddSizer(staticboxsizer, border=5, 
       
   347                           flag=wx.GROW|wx.TOP|wx.BOTTOM)
   362                 else:
   348                 else:
   363                     sizer.AddSizer(staticboxsizer, 0, border=5, flag=wx.GROW|wx.BOTTOM)
   349                     sizer.AddSizer(staticboxsizer, border=5, 
   364                 self.GenerateSizerElements(staticboxsizer, element_infos["children"], element_path)
   350                           flag=wx.GROW|wx.BOTTOM)
       
   351                 self.GenerateSizerElements(staticboxsizer, 
       
   352                                            element_infos["children"], 
       
   353                                            element_path)
   365             else:
   354             else:
   366                 boxsizer = wx.FlexGridSizer(cols=3, rows=1)
   355                 boxsizer = wx.FlexGridSizer(cols=3, rows=1)
   367                 boxsizer.AddGrowableCol(1)
   356                 boxsizer.AddGrowableCol(1)
   368                 if first:
   357                 if first:
   369                     sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL)
   358                     sizer.AddSizer(boxsizer, border=5, 
       
   359                           flag=wx.GROW|wx.ALL)
   370                 else:
   360                 else:
   371                     sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
   361                     sizer.AddSizer(boxsizer, border=5, 
   372                 staticbitmap = GenStaticBitmap(ID=-1, bitmapname="%s.png"%element_infos["name"],
   362                           flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
       
   363                 
       
   364                 staticbitmap = GenStaticBitmap(ID=-1, bitmapname=element_infos["name"],
   373                     name="%s_bitmap"%element_infos["name"], parent=self.ParamsEditor,
   365                     name="%s_bitmap"%element_infos["name"], parent=self.ParamsEditor,
   374                     pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
   366                     pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
   375                 boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT)
   367                 boxsizer.AddWindow(staticbitmap, border=5, flag=wx.RIGHT)
   376                 label = element_infos["name"]
   368                 
   377                 statictext = wx.StaticText(id=-1, label="%s:"%_(label), 
   369                 statictext = wx.StaticText(self.ParamsEditor, 
   378                     name="%s_label"%element_infos["name"], parent=self.ParamsEditor, 
   370                       label="%s:"%_(element_infos["name"]))
   379                     pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
   371                 boxsizer.AddWindow(statictext, border=5, 
   380                 boxsizer.AddWindow(statictext, 0, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.RIGHT)
   372                       flag=wx.ALIGN_CENTER_VERTICAL|wx.RIGHT)
   381                 id = wx.NewId()
   373                 
   382                 if isinstance(element_infos["type"], types.ListType):
   374                 if isinstance(element_infos["type"], types.ListType):
   383                     if isinstance(element_infos["value"], types.TupleType):
   375                     if isinstance(element_infos["value"], types.TupleType):
   384                         browse_boxsizer = wx.BoxSizer(wx.HORIZONTAL)
   376                         browse_boxsizer = wx.BoxSizer(wx.HORIZONTAL)
   385                         boxsizer.AddSizer(browse_boxsizer, 0, border=0, flag=0)
   377                         boxsizer.AddSizer(browse_boxsizer)
   386                         
   378                         
   387                         textctrl = wx.TextCtrl(id=id, name=element_infos["name"], parent=self.ParamsEditor, 
   379                         textctrl = wx.TextCtrl(self.ParamsEditor, 
   388                             pos=wx.Point(0, 0), size=wx.Size(275, 25), style=wx.TE_READONLY)
   380                               size=wx.Size(275, 25), style=wx.TE_READONLY)
   389                         if element_infos["value"] is not None:
   381                         if element_infos["value"] is not None:
   390                             textctrl.SetValue(element_infos["value"][0])
   382                             textctrl.SetValue(element_infos["value"][0])
   391                             value_infos = element_infos["value"][1]
   383                             value_infos = element_infos["value"][1]
   392                         else:
   384                         else:
   393                             value_infos = None
   385                             value_infos = None
   394                         browse_boxsizer.AddWindow(textctrl, 0, border=0, flag=0)
   386                         browse_boxsizer.AddWindow(textctrl)
   395                         button_id = wx.NewId()
   387                         
   396                         button = wx.Button(id=button_id, name="browse_%s" % element_infos["name"], parent=self.ParamsEditor, 
   388                         button = wx.Button(self.ParamsEditor, 
   397                             label="...", pos=wx.Point(0, 0), size=wx.Size(25, 25))
   389                               label="...", size=wx.Size(25, 25))
   398                         browse_boxsizer.AddWindow(button, 0, border=0, flag=0)
   390                         browse_boxsizer.AddWindow(button)
   399                         button.Bind(wx.EVT_BUTTON, 
   391                         button.Bind(wx.EVT_BUTTON, 
   400                                     self.GetBrowseCallBackFunction(element_infos["name"], textctrl, element_infos["type"], 
   392                                     self.GetBrowseCallBackFunction(element_infos["name"], textctrl, element_infos["type"], 
   401                                                                    value_infos, element_path), 
   393                                                                    value_infos, element_path), 
   402                                     id=button_id)
   394                                     button)
   403                     else:
   395                     else:
   404                         combobox = wx.ComboBox(id=id, name=element_infos["name"], parent=self.ParamsEditor, 
   396                         combobox = wx.ComboBox(self.ParamsEditor, 
   405                             pos=wx.Point(0, 0), size=wx.Size(300, 28), style=wx.CB_READONLY)
   397                               size=wx.Size(300, 28), style=wx.CB_READONLY)
   406                         boxsizer.AddWindow(combobox, 0, border=0, flag=0)
   398                         boxsizer.AddWindow(combobox)
       
   399                         
   407                         if element_infos["use"] == "optional":
   400                         if element_infos["use"] == "optional":
   408                             combobox.Append("")
   401                             combobox.Append("")
   409                         if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType):
   402                         if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType):
   410                             for choice, xsdclass in element_infos["type"]:
   403                             for choice, xsdclass in element_infos["type"]:
   411                                 combobox.Append(choice)
   404                                 combobox.Append(choice)
   412                             name = element_infos["name"]
   405                             name = element_infos["name"]
   413                             value = element_infos["value"]
   406                             value = element_infos["value"]
   414                             staticbox = wx.StaticBox(id=-1, label="%s - %s"%(_(name), _(value)), 
   407                         
   415                                 name='%s_staticbox'%element_infos["name"], parent=self.ParamsEditor,
   408                             staticbox = wx.StaticBox(self.ParamsEditor, 
   416                                 pos=wx.Point(0, 0), size=wx.Size(10, 0), style=0)
   409                                   label="%s - %s"%(_(name), _(value)), size=wx.Size(10, 0))
   417                             staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL)
   410                             staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL)
   418                             sizer.AddSizer(staticboxsizer, 0, border=5, flag=wx.GROW|wx.BOTTOM)
   411                             sizer.AddSizer(staticboxsizer, border=5, flag=wx.GROW|wx.BOTTOM)
   419                             self.GenerateSizerElements(staticboxsizer, element_infos["children"], element_path)
   412                             self.GenerateSizerElements(staticboxsizer, element_infos["children"], element_path)
   420                             callback = self.GetChoiceContentCallBackFunction(combobox, staticboxsizer, element_path)
   413                             callback = self.GetChoiceContentCallBackFunction(combobox, staticboxsizer, element_path)
   421                         else:
   414                         else:
   422                             for choice in element_infos["type"]:
   415                             for choice in element_infos["type"]:
   423                                 combobox.Append(choice)
   416                                 combobox.Append(choice)
   424                             callback = self.GetChoiceCallBackFunction(combobox, element_path)
   417                             callback = self.GetChoiceCallBackFunction(combobox, element_path)
   425                         if element_infos["value"] is None:
   418                         if element_infos["value"] is None:
   426                             combobox.SetStringSelection("")
   419                             combobox.SetStringSelection("")
   427                         else:
   420                         else:
   428                             combobox.SetStringSelection(element_infos["value"])
   421                             combobox.SetStringSelection(element_infos["value"])
   429                         combobox.Bind(wx.EVT_COMBOBOX, callback, id=id)
   422                         combobox.Bind(wx.EVT_COMBOBOX, callback, combobox)
       
   423                 
   430                 elif isinstance(element_infos["type"], types.DictType):
   424                 elif isinstance(element_infos["type"], types.DictType):
   431                     scmin = -(2**31)
   425                     scmin = -(2**31)
   432                     scmax = 2**31-1
   426                     scmax = 2**31-1
   433                     if "min" in element_infos["type"]:
   427                     if "min" in element_infos["type"]:
   434                         scmin = element_infos["type"]["min"]
   428                         scmin = element_infos["type"]["min"]
   435                     if "max" in element_infos["type"]:
   429                     if "max" in element_infos["type"]:
   436                         scmax = element_infos["type"]["max"]
   430                         scmax = element_infos["type"]["max"]
   437                     spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=self.ParamsEditor, 
   431                     spinctrl = wx.SpinCtrl(self.ParamsEditor, 
   438                         pos=wx.Point(0, 0), size=wx.Size(300, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT)
   432                           size=wx.Size(300, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT)
   439                     spinctrl.SetRange(scmin,scmax)
   433                     spinctrl.SetRange(scmin, scmax)
   440                     boxsizer.AddWindow(spinctrl, 0, border=0, flag=0)
   434                     boxsizer.AddWindow(spinctrl)
   441                     if element_infos["value"] is not None:
   435                     if element_infos["value"] is not None:
   442                         spinctrl.SetValue(element_infos["value"])
   436                         spinctrl.SetValue(element_infos["value"])
   443                     spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, element_path), id=id)
   437                     spinctrl.Bind(wx.EVT_SPINCTRL, 
       
   438                                   self.GetTextCtrlCallBackFunction(spinctrl, element_path),
       
   439                                   spinctrl)
       
   440                 
   444                 else:
   441                 else:
   445                     if element_infos["type"] == "boolean":
   442                     if element_infos["type"] == "boolean":
   446                         checkbox = wx.CheckBox(id=id, name=element_infos["name"], parent=self.ParamsEditor, 
   443                         checkbox = wx.CheckBox(self.ParamsEditor, size=wx.Size(17, 25))
   447                             pos=wx.Point(0, 0), size=wx.Size(17, 25), style=0)
   444                         boxsizer.AddWindow(checkbox)
   448                         boxsizer.AddWindow(checkbox, 0, border=0, flag=0)
       
   449                         if element_infos["value"] is not None:
   445                         if element_infos["value"] is not None:
   450                             checkbox.SetValue(element_infos["value"])
   446                             checkbox.SetValue(element_infos["value"])
   451                         checkbox.Bind(wx.EVT_CHECKBOX, self.GetCheckBoxCallBackFunction(checkbox, element_path), id=id)
   447                         checkbox.Bind(wx.EVT_CHECKBOX, 
       
   448                                       self.GetCheckBoxCallBackFunction(checkbox, element_path), 
       
   449                                       checkbox)
       
   450                     
   452                     elif element_infos["type"] in ["unsignedLong", "long","integer"]:
   451                     elif element_infos["type"] in ["unsignedLong", "long","integer"]:
   453                         if element_infos["type"].startswith("unsigned"):
   452                         if element_infos["type"].startswith("unsigned"):
   454                             scmin = 0
   453                             scmin = 0
   455                         else:
   454                         else:
   456                             scmin = -(2**31)
   455                             scmin = -(2**31)
   457                         scmax = 2**31-1
   456                         scmax = 2**31-1
   458                         spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=self.ParamsEditor, 
   457                         spinctrl = wx.SpinCtrl(self.ParamsEditor, 
   459                             pos=wx.Point(0, 0), size=wx.Size(300, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT)
   458                               size=wx.Size(300, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT)
   460                         spinctrl.SetRange(scmin, scmax)
   459                         spinctrl.SetRange(scmin, scmax)
   461                         boxsizer.AddWindow(spinctrl, 0, border=0, flag=0)
   460                         boxsizer.AddWindow(spinctrl)
   462                         if element_infos["value"] is not None:
   461                         if element_infos["value"] is not None:
   463                             spinctrl.SetValue(element_infos["value"])
   462                             spinctrl.SetValue(element_infos["value"])
   464                         spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, element_path), id=id)
   463                         spinctrl.Bind(wx.EVT_SPINCTRL, 
       
   464                                       self.GetTextCtrlCallBackFunction(spinctrl, element_path), 
       
   465                                       spinctrl)
       
   466                     
   465                     else:
   467                     else:
   466                         choices = self.ParentWindow.GetConfigEntry(element_path, [""])
   468                         choices = self.ParentWindow.GetConfigEntry(element_path, [""])
   467                         textctrl = TextCtrlAutoComplete(id=id, 
   469                         textctrl = TextCtrlAutoComplete(name=element_infos["name"], 
   468                                                                      name=element_infos["name"], 
   470                                                         parent=self.ParamsEditor, 
   469                                                                      parent=self.ParamsEditor, 
   471                                                         appframe=self, 
   470                                                                      appframe=self, 
   472                                                         choices=choices, 
   471                                                                      choices=choices, 
   473                                                         element_path=element_path,
   472                                                                      element_path=element_path,
   474                                                         size=wx.Size(300, 25))
   473                                                                      pos=wx.Point(0, 0), 
       
   474                                                                      size=wx.Size(300, 25), 
       
   475                                                                      style=0)
       
   476                         
   475                         
   477                         boxsizer.AddWindow(textctrl, 0, border=0, flag=0)
   476                         boxsizer.AddWindow(textctrl)
   478                         if element_infos["value"] is not None:
   477                         if element_infos["value"] is not None:
   479                             textctrl.ChangeValue(str(element_infos["value"]))
   478                             textctrl.ChangeValue(str(element_infos["value"]))
   480                         textctrl.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(textctrl, element_path))
   479                         textctrl.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(textctrl, element_path))
   481             first = False
   480             first = False
   482     
   481