+ def Apply(self):
+ xxx = self.xxx
+ # !!! Save undo info
+# if xxx.undo: xxx.undo.unlink()
+# xxx.undo = xxx.element.cloneNode(false)
+ if self.controlName:
+ name = self.controlName.GetValue()
+ if xxx.name != name:
+ xxx.name = name
+ xxx.element.setAttribute('name', name)
+ for param, w in self.controls.items():
+ if w.modified:
+ paramObj = xxx.params[param]
+ value = w.GetValue()
+ if param in xxx.specials:
+ xxx.setSpecial(param, value)
+ else:
+ paramObj.update(value)
+
+################################################################################
+
+# Panel for displaying properties
+class PropPage(ParamPage):
+ def __init__(self, parent, label, xxx):
+ ParamPage.__init__(self, parent, xxx)
+ box = wxStaticBox(self, -1, label)
+ box.SetFont(labelFont)
+ topSizer = wxStaticBoxSizer(box, wxVERTICAL)
+ sizer = wxFlexGridSizer(len(xxx.allParams), 2, 1, 1)
+ if xxx.hasName:
+ label = wxStaticText(self, -1, 'XML ID:', size=(100,-1))
+ control = ParamText(self, name='XML_name')
+ sizer.AddMany([ (label, 0, wxALIGN_CENTER_VERTICAL),
+ (control, 0, wxALIGN_CENTER_VERTICAL) ])
+ self.controlName = control
+ for param in xxx.allParams:
+ present = param in xxx.params
+ if param in xxx.required:
+ label = wxStaticText(self, paramIDs[param], param + ':',
+ size = (100,-1), name = param)
+ else:
+ # Notebook has one very loooooong parameter
+ if param == 'usenotebooksizer': sParam = 'usesizer:'
+ else: sParam = param + ':'
+ label = wxCheckBox(self, paramIDs[param], sParam,
+ size = (100,-1), name = param)
+ self.checks[param] = label
+ try:
+ typeClass = xxx.paramDict[param]
+ except KeyError:
+ try:
+ # Standart type
+ typeClass = paramDict[param]
+ except KeyError:
+ # Default
+ typeClass = ParamText
+ control = typeClass(self, param)
+ control.Enable(present)
+ sizer.AddMany([ (label, 0, wxALIGN_CENTER_VERTICAL),
+ (control, 0, wxALIGN_CENTER_VERTICAL) ])
+ self.controls[param] = control
+ topSizer.Add(sizer, 1, wxALL | wxEXPAND, 3)
+ self.SetAutoLayout(true)
+ self.SetSizer(topSizer)
+ topSizer.Fit(self)
+ def SetValues(self, xxx):
+ self.xxx = xxx
+ # Set values, checkboxes to false, disable defaults
+ if xxx.hasName:
+ self.controlName.SetValue(xxx.name)
+ for param in xxx.allParams:
+ w = self.controls[param]
+ w.modified = false
+ try:
+ value = xxx.params[param].value()
+ w.Enable(true)
+ w.SetValue(value)
+ if not param in xxx.required:
+ self.checks[param].SetValue(true)
+ except KeyError:
+ self.checks[param].SetValue(false)
+ w.SetValue('')
+ w.Enable(false)
+ self.SetModified(false)
+
+################################################################################
+
+# Style notebook page
+class StylePage(ParamPage):
+ def __init__(self, parent, label, xxx):
+ ParamPage.__init__(self, parent, xxx)
+ box = wxStaticBox(self, -1, label)
+ box.SetFont(labelFont)
+ topSizer = wxStaticBoxSizer(box, wxVERTICAL)
+ sizer = wxFlexGridSizer(len(xxx.styles), 2, 1, 1)
+ for param in xxx.styles:
+ present = param in xxx.params.keys()
+ check = wxCheckBox(self, paramIDs[param],
+ param + ':', size = (100,-1), name = param)
+ check.SetValue(present)
+ control = paramDict[param](self, name = param)
+ control.Enable(present)
+ sizer.AddMany([ (check, 0, wxALIGN_CENTER_VERTICAL),
+ (control, 0, wxALIGN_CENTER_VERTICAL) ])
+ self.checks[param] = check
+ self.controls[param] = control
+ topSizer.Add(sizer, 1, wxALL | wxEXPAND, 3)
+ self.SetAutoLayout(true)
+ self.SetSizer(topSizer)
+ topSizer.Fit(self)
+ # Set data for a cahced page
+ def SetValues(self, xxx):
+ self.xxx = xxx
+ for param in xxx.styles:
+ present = param in xxx.params.keys()
+ check = self.checks[param]
+ check.SetValue(present)
+ w = self.controls[param]
+ w.modified = false
+ if present:
+ w.SetValue(xxx.params[param].value())
+ else:
+ w.SetValue('')
+ w.Enable(present)
+ self.SetModified(false)
+
+################################################################################