+################################################################################
+
+class PrefsDialog(wx.Dialog):
+
+ def __init__(self, parent):
+ pre = wx.PreDialog()
+ g.frame.res.LoadOnDialog(pre, parent, "DIALOG_PREFS")
+ self.PostCreate(pre)
+ self.checkControls = {} # map of check IDs to (control,dict,param)
+
+ xxx = sys.modules['xxx']
+ d = xxx.xxxSizerItem.defaults_panel
+
+ self.check_proportion_panel = xrc.XRCCTRL(self, 'check_proportion_panel')
+ id = self.check_proportion_panel.GetId()
+ wx.EVT_CHECKBOX(self, id, self.OnCheck)
+ self.checkControls[id] = (xrc.XRCCTRL(self, 'spin_proportion_panel'),
+ d, 'option')
+
+ self.check_flag_panel = xrc.XRCCTRL(self, 'check_flag_panel')
+ id = self.check_flag_panel.GetId()
+ wx.EVT_CHECKBOX(self, id, self.OnCheck)
+ self.checkControls[id] = (xrc.XRCCTRL(self, 'text_flag_panel'),
+ d, 'flag')
+
+ d = xxx.xxxSizerItem.defaults_control
+
+ self.check_proportion_panel = xrc.XRCCTRL(self, 'check_proportion_control')
+ id = self.check_proportion_panel.GetId()
+ wx.EVT_CHECKBOX(self, id, self.OnCheck)
+ self.checkControls[id] = (xrc.XRCCTRL(self, 'spin_proportion_control'),
+ d, 'option')
+
+ self.check_flag_panel = xrc.XRCCTRL(self, 'check_flag_control')
+ id = self.check_flag_panel.GetId()
+ wx.EVT_CHECKBOX(self, id, self.OnCheck)
+ self.checkControls[id] = (xrc.XRCCTRL(self, 'text_flag_control'),
+ d, 'flag')
+
+ for id,cdp in self.checkControls.items():
+ c,d,p = cdp
+ try:
+ if isinstance(c, wx.SpinCtrl):
+ c.SetValue(int(d[p]))
+ else:
+ c.SetValue(d[p])
+ self.FindWindowById(id).SetValue(True)
+ except KeyError:
+ c.Enable(False)
+
+ def OnCheck(self, evt):
+ self.checkControls[evt.GetId()][0].Enable(evt.IsChecked())
+ evt.Skip()
+