Preferences for default "sizeritem" parameters for new panels and
controls can be configured ("File">"Preferences..."). Implemented comment object for including simple one-line comments and comment directives as tree nodes. No validation is performed for a valid XML string so comments must not contain "-->". Comment directive is a special comment starting with '%' character, followed by a line of python code. It is executed using 'exec' when the resource file is opened. This is useful to import plugin modules containing custom handlers which are specific to the resource file, hovewer this is of course a security hole if you use foreign XRC files. A warning is displayed if the preference option 'ask' is selected (by default). Added support for custom controls and plugin modules. Refer to this wxPythonWiki for the details: http://wiki.wxpython.org/index.cgi/XRCed#custom Tool panel sections can be collapsed/expanded by clicking on the label of a tool group. Some undo/redo and other fixes. Fixes for wxMSW (notebook highlighting, control sizes, tree Unselect). Notebook page highlighting fix. Highlight resizes when the window is resized. ParamUnit spin button detects event handler re-entry (wxGTK probably has a bug in wxSpinButton with repeated events). Fix for dealing with empty 'growable' property, using MiniFrame for properties panel, the panel is restored together with the main window. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@44949 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -22,7 +22,7 @@ class Panel(wx.Notebook):
|
||||
# Set common button size for parameter buttons
|
||||
bTmp = wx.Button(self, -1, '')
|
||||
import params
|
||||
params.buttonSize = (self.DLG_SZE(buttonSize)[0], bTmp.GetSize()[1])
|
||||
params.buttonSize = (self.DLG_SZE(buttonSizeD)[0], bTmp.GetSize()[1])
|
||||
bTmp.Destroy()
|
||||
del bTmp
|
||||
|
||||
@@ -160,6 +160,7 @@ class Panel(wx.Notebook):
|
||||
# Register undo object when modifying first time
|
||||
if not self.modified and value:
|
||||
g.undoMan.RegisterUndo(UndoEdit())
|
||||
g.frame.SetModified()
|
||||
self.modified = value
|
||||
|
||||
def Apply(self):
|
||||
@@ -184,7 +185,7 @@ class ParamPage(wx.Panel):
|
||||
param = evt.GetEventObject().GetName()
|
||||
w = self.controls[param]
|
||||
w.Enable(True)
|
||||
objElem = xxx.element
|
||||
objElem = xxx.node
|
||||
if evt.IsChecked():
|
||||
# Ad new text node in order of allParams
|
||||
w.SetValue('') # set empty (default) value
|
||||
@@ -192,7 +193,7 @@ class ParamPage(wx.Panel):
|
||||
elem = g.tree.dom.createElement(param)
|
||||
# Some classes are special
|
||||
if param == 'font':
|
||||
xxx.params[param] = xxxParamFont(xxx.element, elem)
|
||||
xxx.params[param] = xxxParamFont(xxx.node, elem)
|
||||
elif param in xxxObject.bitmapTags:
|
||||
xxx.params[param] = xxxParamBitmap(elem)
|
||||
else:
|
||||
@@ -218,7 +219,7 @@ class ParamPage(wx.Panel):
|
||||
xxx.params[param].remove()
|
||||
del xxx.params[param]
|
||||
w.SetValue('')
|
||||
w.modified = False # mark as not changed
|
||||
w.SetModified(False) # mark as not changed
|
||||
w.Enable(False)
|
||||
# Set modified flag (provokes undo storing is necessary)
|
||||
panel.SetModified(True)
|
||||
@@ -228,7 +229,7 @@ class ParamPage(wx.Panel):
|
||||
name = self.controlName.GetValue()
|
||||
if xxx.name != name:
|
||||
xxx.name = name
|
||||
xxx.element.setAttribute('name', name)
|
||||
xxx.node.setAttribute('name', name)
|
||||
for param, w in self.controls.items():
|
||||
if w.modified:
|
||||
paramObj = xxx.params[param]
|
||||
@@ -237,10 +238,11 @@ class ParamPage(wx.Panel):
|
||||
xxx.setSpecial(param, value)
|
||||
else:
|
||||
paramObj.update(value)
|
||||
|
||||
# Save current state
|
||||
def SaveState(self):
|
||||
self.origChecks = map(lambda i: (i[0], i[1].GetValue()), self.checks.items())
|
||||
self.origControls = map(lambda i: (i[0], i[1].GetValue(), i[1].IsEnabled()),
|
||||
self.origControls = map(lambda i: (i[0], i[1].GetValue(), i[1].enabled),
|
||||
self.controls.items())
|
||||
if self.controlName:
|
||||
self.origName = self.controlName.GetValue()
|
||||
@@ -257,7 +259,8 @@ class ParamPage(wx.Panel):
|
||||
for k,v,e in state[1]:
|
||||
self.controls[k].SetValue(v)
|
||||
self.controls[k].Enable(e)
|
||||
if e: self.controls[k].modified = True
|
||||
# Set all states to modified
|
||||
if e and k in self.xxx.params: self.controls[k].modified = True
|
||||
if self.controlName:
|
||||
self.controlName.SetValue(state[2])
|
||||
|
||||
@@ -283,11 +286,15 @@ class PropPage(ParamPage):
|
||||
for param in xxx.allParams:
|
||||
present = xxx.params.has_key(param)
|
||||
if param in xxx.required:
|
||||
label = wx.StaticText(self, paramIDs[param], param + ':',
|
||||
size = (LABEL_WIDTH,-1), name = param)
|
||||
if isinstance(xxx, xxxComment):
|
||||
label = None
|
||||
else:
|
||||
label = wx.StaticText(self, paramIDs[param], param + ':',
|
||||
size = (LABEL_WIDTH,-1), name = param)
|
||||
else:
|
||||
# Notebook has one very loooooong parameter
|
||||
# Rename some parameters
|
||||
if param == 'usenotebooksizer': sParam = 'usesizer:'
|
||||
elif param == 'option': sParam = 'proportion'
|
||||
else: sParam = param + ':'
|
||||
label = wx.CheckBox(self, paramIDs[param], sParam,
|
||||
size = (LABEL_WIDTH,-1), name = param)
|
||||
@@ -303,13 +310,19 @@ class PropPage(ParamPage):
|
||||
typeClass = ParamText
|
||||
control = typeClass(self, param)
|
||||
control.Enable(present)
|
||||
sizer.AddMany([ (label, 0, wx.ALIGN_CENTER_VERTICAL),
|
||||
(control, 0, wx.ALIGN_CENTER_VERTICAL | wx.GROW) ])
|
||||
# Comment has only one parameter
|
||||
if isinstance(xxx, xxxComment):
|
||||
# Bind char event to check Enter key
|
||||
control.text.Bind(wx.EVT_CHAR, self.OnEnter)
|
||||
sizer.Add(control, 0, wx.ALIGN_CENTER_VERTICAL | wx.GROW)
|
||||
else:
|
||||
sizer.AddMany([ (label, 0, wx.ALIGN_CENTER_VERTICAL),
|
||||
(control, 0, wx.ALIGN_CENTER_VERTICAL | wx.GROW) ])
|
||||
self.controls[param] = control
|
||||
topSizer.Add(sizer, 1, wx.ALL | wx.EXPAND, 3)
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSizer(topSizer)
|
||||
topSizer.Fit(self)
|
||||
|
||||
def SetValues(self, xxx):
|
||||
self.xxx = xxx
|
||||
self.origChecks = []
|
||||
@@ -336,6 +349,13 @@ class PropPage(ParamPage):
|
||||
self.origChecks.append((param, False))
|
||||
self.origControls.append((param, '', False))
|
||||
|
||||
# This is called only for comment now
|
||||
def OnEnter(self, evt):
|
||||
if evt.GetKeyCode() == 13:
|
||||
g.tree.Apply(self.xxx, g.tree.selection)
|
||||
else:
|
||||
evt.Skip()
|
||||
|
||||
################################################################################
|
||||
|
||||
# Style notebook page
|
||||
@@ -362,6 +382,7 @@ class StylePage(ParamPage):
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSizer(topSizer)
|
||||
topSizer.Fit(self)
|
||||
|
||||
# Set data for a cahced page
|
||||
def SetValues(self, xxx):
|
||||
self.xxx = xxx
|
||||
|
Reference in New Issue
Block a user