--- a/Beremiz.py Mon Jun 30 14:29:23 2008 +0200
+++ b/Beremiz.py Mon Jun 30 14:31:18 2008 +0200
@@ -433,7 +433,9 @@
maxx, maxy = sizer.GetMinSize()
self.PLCConfig.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT,
- maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, xstart, ystart)
+ maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, + max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT)), + max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT))) def RefreshPLCParams(self):
@@ -974,44 +976,19 @@
element_path = "%s.%s"%(path, element_infos["name"])
element_path = element_infos["name"]
- if isinstance(element_infos["type"], types.ListType):
- boxsizer = wx.BoxSizer(wx.HORIZONTAL)
+ if element_infos["type"] == "element": + staticbox = wx.StaticBox(id=-1, label=element_infos["name"], + name='%s_staticbox'%element_infos["name"], parent=parent, + pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0) + staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL) - sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL)
+ sizer.AddSizer(staticboxsizer, 0, border=0, flag=wx.GROW|wx.TOP) - sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
- staticbitmap = GenStaticBitmap(ID=-1, bitmapname="%s.png"%element_infos["name"],
- name="%s_bitmap"%element_infos["name"], parent=parent,
- pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
- boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT)
- statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"],
- name="%s_label"%element_infos["name"], parent=parent,
- pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0)
- boxsizer.AddWindow(statictext, 0, border=4, flag=wx.TOP)
- choicectrl = wx.Choice(id=id, name=element_infos["name"], parent=parent,
- pos=wx.Point(0, 0), size=wx.Size(150, 25), style=0)
- boxsizer.AddWindow(choicectrl, 0, border=0, flag=0)
- if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType):
- for choice, xsdclass in element_infos["type"]:
- choicectrl.Append(choice)
- staticbox = wx.StaticBox(id=-1, label="%(name)s - %(value)s"%element_infos,
- name='%s_staticbox'%element_infos["name"], parent=parent,
- pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0)
- staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL)
- sizer.AddSizer(staticboxsizer, 0, border=5, flag=wx.GROW|wx.BOTTOM)
- self.RefreshSizerElement(parent, staticboxsizer, plugin, element_infos["children"], element_path)
- callback = self.GetChoiceContentCallBackFunction(choicectrl, staticboxsizer, plugin, element_path)
- for choice in element_infos["type"]:
- choicectrl.Append(choice)
- callback = self.GetChoiceCallBackFunction(choicectrl, plugin, element_path)
- if element_infos["value"]:
- choicectrl.SetStringSelection(element_infos["value"])
- choicectrl.Bind(wx.EVT_CHOICE, callback, id=id)
- elif isinstance(element_infos["type"], types.DictType):
- boxsizer = wx.BoxSizer(wx.HORIZONTAL)
+ sizer.AddSizer(staticboxsizer, 0, border=0, flag=wx.GROW) + self.RefreshSizerElement(parent, staticboxsizer, plugin, element_infos["children"], element_path) + boxsizer = wx.FlexGridSizer(cols=3, rows=1) + boxsizer.AddGrowableCol(1) sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL)
@@ -1025,68 +1002,69 @@
pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0)
boxsizer.AddWindow(statictext, 0, border=4, flag=wx.TOP)
- if "min" in element_infos["type"]:
- scmin = element_infos["type"]["min"]
- if "max" in element_infos["type"]:
- scmax = element_infos["type"]["max"]
- spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=parent,
- pos=wx.Point(0, 0), size=wx.Size(150, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT)
- spinctrl.SetRange(scmin,scmax)
- boxsizer.AddWindow(spinctrl, 0, border=0, flag=0)
- spinctrl.SetValue(element_infos["value"])
- spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, plugin, element_path), id=id)
- elif element_infos["type"] == "element":
- staticbox = wx.StaticBox(id=-1, label=element_infos["name"],
- name='%s_staticbox'%element_infos["name"], parent=parent,
- pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0)
- staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL)
- sizer.AddSizer(staticboxsizer, 0, border=0, flag=wx.GROW|wx.TOP)
- sizer.AddSizer(staticboxsizer, 0, border=0, flag=wx.GROW)
- self.RefreshSizerElement(parent, staticboxsizer, plugin, element_infos["children"], element_path)
- boxsizer = wx.BoxSizer(wx.HORIZONTAL)
- sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL)
- sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
- staticbitmap = GenStaticBitmap(ID=-1, bitmapname="%s.png"%element_infos["name"],
- name="%s_bitmap"%element_infos["name"], parent=parent,
- pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
- boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT)
- statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"],
- name="%s_label"%element_infos["name"], parent=parent,
- pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0)
- boxsizer.AddWindow(statictext, 0, border=4, flag=wx.TOP)
- if element_infos["type"] == "boolean":
- checkbox = wx.CheckBox(id=id, name=element_infos["name"], parent=parent,
- pos=wx.Point(0, 0), size=wx.Size(17, 25), style=0)
- boxsizer.AddWindow(checkbox, 0, border=0, flag=0)
- checkbox.SetValue(element_infos["value"])
- checkbox.Bind(wx.EVT_CHECKBOX, self.GetCheckBoxCallBackFunction(checkbox, plugin, element_path), id=id)
- elif element_infos["type"] in ["unsignedLong", "long","integer"]:
- if element_infos["type"].startswith("unsigned"):
+ if isinstance(element_infos["type"], types.ListType): + choicectrl = wx.Choice(id=id, name=element_infos["name"], parent=parent, + pos=wx.Point(0, 0), size=wx.Size(150, 25), style=0) + boxsizer.AddWindow(choicectrl, 0, border=0, flag=0) + if element_infos["use"] == "optional": + if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType): + for choice, xsdclass in element_infos["type"]: + choicectrl.Append(choice) + staticbox = wx.StaticBox(id=-1, label="%(name)s - %(value)s"%element_infos, + name='%s_staticbox'%element_infos["name"], parent=parent, + pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0) + staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL) + sizer.AddSizer(staticboxsizer, 0, border=5, flag=wx.GROW|wx.BOTTOM) + self.RefreshSizerElement(parent, staticboxsizer, plugin, element_infos["children"], element_path) + callback = self.GetChoiceContentCallBackFunction(choicectrl, staticboxsizer, plugin, element_path)
+ for choice in element_infos["type"]: + choicectrl.Append(choice) + callback = self.GetChoiceCallBackFunction(choicectrl, plugin, element_path) + if element_infos["value"] is None: + choicectrl.SetStringSelection("") + choicectrl.SetStringSelection(element_infos["value"]) + choicectrl.Bind(wx.EVT_CHOICE, callback, id=id) + elif isinstance(element_infos["type"], types.DictType): + if "min" in element_infos["type"]: + scmin = element_infos["type"]["min"] + if "max" in element_infos["type"]: + scmax = element_infos["type"]["max"] spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=parent,
pos=wx.Point(0, 0), size=wx.Size(150, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT)
- spinctrl.SetRange(scmin, scmax)
+ spinctrl.SetRange(scmin,scmax) boxsizer.AddWindow(spinctrl, 0, border=0, flag=0)
spinctrl.SetValue(element_infos["value"])
spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, plugin, element_path), id=id)
- textctrl = wx.TextCtrl(id=id, name=element_infos["name"], parent=parent,
- pos=wx.Point(0, 0), size=wx.Size(150, 25), style=0)#wx.TE_PROCESS_ENTER)
- boxsizer.AddWindow(textctrl, 0, border=0, flag=0)
- textctrl.SetValue(str(element_infos["value"]))
- textctrl.Bind(wx.EVT_KILL_FOCUS, self.GetTextCtrlCallBackFunction(textctrl, plugin, element_path))
+ if element_infos["type"] == "boolean": + checkbox = wx.CheckBox(id=id, name=element_infos["name"], parent=parent, + pos=wx.Point(0, 0), size=wx.Size(17, 25), style=0) + boxsizer.AddWindow(checkbox, 0, border=0, flag=0) + checkbox.SetValue(element_infos["value"]) + checkbox.Bind(wx.EVT_CHECKBOX, self.GetCheckBoxCallBackFunction(checkbox, plugin, element_path), id=id) + elif element_infos["type"] in ["unsignedLong", "long","integer"]: + if element_infos["type"].startswith("unsigned"): + spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=parent, + pos=wx.Point(0, 0), size=wx.Size(150, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT) + spinctrl.SetRange(scmin, scmax) + boxsizer.AddWindow(spinctrl, 0, border=0, flag=0) + spinctrl.SetValue(element_infos["value"]) + spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, plugin, element_path), id=id) + textctrl = wx.TextCtrl(id=id, name=element_infos["name"], parent=parent, + pos=wx.Point(0, 0), size=wx.Size(150, 25), style=0)#wx.TE_PROCESS_ENTER) + boxsizer.AddWindow(textctrl, 0, border=0, flag=0) + textctrl.SetValue(str(element_infos["value"])) + textctrl.Bind(wx.EVT_KILL_FOCUS, self.GetTextCtrlCallBackFunction(textctrl, plugin, element_path)) def OnNewProjectMenu(self, event):