A new version of XRCed from Roman Rolinsky with a few tweaks by me.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14470 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-03-06 21:41:19 +00:00
parent 820b49cdbf
commit f0c20d947b
9 changed files with 1319 additions and 603 deletions

View File

@@ -1,3 +1,32 @@
0.0.7
-----
Some command-line arguments.
"Test window" command and toolbar button.
New panel interphace (wxHTMLWindow is not used anymore).
Toggling between embedded and detached panel.
Cache for already used windows.
Current top-level control is bold, if test window shown.
Undo/redo broken.
CheckListBox does not work unless wxXRC source fixed (in both wxPytnon and
wxWin):
contrib/src/xrc/xmlrsall.cpp
45,46c45,46
< AddHandler(new wxListCtrlXmlHandler);
< #if CHECKLISTBOX
---
> AddHandler(new wxListCtrlXmlHandler);
> #if wxUSE_CHECKLISTBOX
0.0.6 0.0.6
----- -----

View File

@@ -7,53 +7,65 @@
Installation on UNIX Installation on UNIX
-------------------- --------------------
XRCed was developed using Python 2.1.1. xml.dom.minidom module should be XRCed requires wxGTK and wxPython greater than 2.3.2, and Python 2.2 (it may
available. XML support requires Expat package (http://expat.sourceforge.net), work with earlier version, but was not tested).
and you have to uncomment expat lines in Modules/Setup file of Python source:
EXPAT_DIR=$(HOME)/expat Of course wxGTK's XRC library (libwxxrc) must be installed.
pyexpat pyexpat.c -I$(EXPAT_DIR)/xmlparse -L$(EXPAT_DIR) -lexpat
wxPython version used was 2.3.1, which itself uses wxGTK 2.3.1. wxPython Installation on Windows
should be modified to support some extra functions. To update it, go to -----------------------
wxPython source directory and untar "wxPython-update.tgz" (included with
xrced) file there. Then recompile (run "b 21" for example) it and install as
usual (or you can set your environment to use it from the source tree).
Works with wxPython 2.3.2 for Python 2.2.
Short manual Short manual
------------ ------------
XRCed's idea is very straightforward: it is a visual tool for editing an XML
file conforming to XRC format. Every operation performed in XRCed has direct
correspondence to XML structure. So it is not really a usual point-and-click
GUI builder, but don't let that scare you.
To start xrced, change to the directory where you installed it and run To start xrced, change to the directory where you installed it and run
"python2.1 xrced.py". "python2.2 xrced.py".
On UNIX you can edit wrapper script "xrced.sh" to point to your installation
directory.
To create an object, first you should select some object in the tree (or the To create an object, first you should select some object in the tree (or the
root item if it's empty) then press the right mouse button and select right root item if it's empty) then press the right mouse button and select an
(in another sense now :) ) command. The pulldown menu is context-dependent on appropriate command. The pulldown menu is context-dependent on the selected
the selected object. object.
XRCed tries to guess if new object should be added as a next sibling or a XRCed tries to guess if new object should be added as a next sibling or a
child of current object, depending on the possibility of the object to have child of current object, depending on the possibility of the object to have
child objects and expanded state (if tree item is collapsed, new object will child objects and expanded state (if tree item is collapsed, new object will
be sibling). You can change this behavior to create siblings by pressing and be sibling). You can change this behavior to create siblings by pressing and
holding the Control key before clicking the mouse. holding the Shift and Control keys before clicking the mouse.
Same applies for copy/paste, but at the moment Control key is ignored. Pressed Control key while pressing right button makes next item a sibling of
selected item regardless of its expanded state.
Pressed Shift key changes the place for inserting new child to be before
selected child, not after as by default.
Panel on the right contains object properties. Properties which are optional Panel on the right contains object properties. Properties which are optional
should be "checked" first. XMLID of the object is the textbox to the right of should be "checked" first. This panel can be made separate by unchecking
the class name. "Embed Panel" in View menu.
All properties can be edited as text, and some are supplied with special All properties can be edited as text, and some are supplied with special
editing controls. editing controls.
The names of the properties are exactly as in XRC file, and it's usually not
hard to guess what they do. XML ID is the name of the window, and must be
present for top-level windows (though this is not enforced by XRCed).
To display the preview window double-click a top-level object (you should To display the preview window double-click a top-level object (you should
assign an XMLID to it first). After that, if you select a child object, it assign an XMLID to it first), press "Test" toolbar button or select command
from View menu, or press F5. After that, if you select a child object, it
becomes highlighted, and if you change it, preview is updated when you select becomes highlighted, and if you change it, preview is updated when you select
another item or press Ctrl-R (refresh). To turn off automatic update, toggle another item or press Ctrl-R (refresh). To turn off automatic update, toggle
"View->Auto-refresh" or toolbar auto-refresh button (to the right of refresh "View->Auto-refresh" or toolbar auto-refresh button (to the right of the
button). refresh button).
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@@ -1,33 +1,29 @@
TODO for XRCed TODO for XRCed
============== ==============
* Undo/Redo - Undo/Redo
* menu - accel not displayed in preview - menu - accel not displayed in preview
* tree icons + tree icons
* paste as sibling (toolbar toggle button) - replace object with another, keeping children
* replace object with abother, keeping children + write tmp file for current dialog/panel/etc.
* write tmp file for current dialog/panel/etc. + XML indents
* XML indents ? select same notebook pages after update
* select same notebook pages after update - put some default values in tree ctrl etc.
* put some default values in tree ctrl etc. - special (fast) update for some values: pos/size, value/content, sizeritem
* special (fast) update for some values: pos/size, value/content, sizeritem
stuff (?), well, as much as possible stuff (?), well, as much as possible
* highlighting with better method - highlighting with better method
* import XRC/WXR files - import XRC/WXR files
* disable some window creation when it's not valid + disable some window creation when it's not valid
* check for memory leaks from wx objects - check for memory leaks from wx objects
* style defaults for `hidde' and `focused' should be false

View File

@@ -119,15 +119,34 @@ def getPasteBitmap():
def getPasteImage(): def getPasteImage():
return wxImageFromBitmap(getPasteBitmap()) return wxImageFromBitmap(getPasteBitmap())
#----------------------------------------------------------------------
def getTestData():
return cPickle.loads(zlib.decompress(
'x\xda\x95\xd2=\x0b\xc20\x10\x06\xe0\xbd\xbf\xe2\xc0\xa1N\xa1\x1f\n\xba*t\
\xf4\x86.\xb7\x96\xe2d\xf1\xfc\xff\x93\xb9$\xcd5M\xa9xY\xf2\xf2\x10r$w\x9c>u\
\xd1\x97\xcd\t\x9a\x16\xceP\x97\xc5\xd0\x97\x06F\xb8M\xc3\xf8r\x89l:\xb4\x95\
,\x97Q\xf2\xb5\x92\xe52K\xee.\xdd\xbd\xf2\x19l~\xf0\xfb\x19\xc2v\xfd\x81Fj\
\x1b\xcd\\9\x12\xd1\x8cD+$f\x0efw\xb4\x8b\xb8D\xb1\xa0nG\xbb\x88\x8a\xde,r@w\
4A\x07\x8b\xa3\x01\xb5\x95\xd8V\x86Fm\x03M\xb4\x05\xaaF\xcb1\xb9R_h\xd5\x10f\
\xc8\x1c\x15\xd3_\x89&\x8a+\x04$\xff\x14D\xe8-\x9d\x04\xcb\xa4\x94\xcd\x10\
\xa2\xd2\xef\x013_\xba\x1d\xa3N' ))
def getTestBitmap():
return wxBitmapFromXPMData(getTestData())
def getTestImage():
return wxImageFromBitmap(getTestBitmap())
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def getRefreshData(): def getRefreshData():
return cPickle.loads(zlib.decompress( return cPickle.loads(zlib.decompress(
'x\xda\xad\xd2\xbb\x0e\xc20\x0c\x05\xd0\xbd_q%\x860]\xf55\xc0\x0f0\xb2t\xf1\ 'x\xda\xad\xd2\xbb\x0e\xc20\x0c\x05\xd0\xbd_q%\x860]\xf5\xc1\x00?\xc0\xc8\
\x8a\x10\x1bj\xf9\xff\x89\xbc\x9a\x9a\xe2\xc2Rg\x89u\x14+vr|\xbe\x9ajpm\x8f\ \xd2\xc5+Bl\xa8\xed\xffO\xcd\xab\xa9\x01\x17\t\x81\xb3\xc4:\x8a\x15;\xd9?\
\xb6C\x87\xc6U\xb7\xc1\t\xee8\x9c\xeb\xb0b\x0e\x9f_\xa7\xf1\x11\x13\x06\xbc\ \xa6\xa6\xea]{@\xdb\xa1C\xe3\xaak\xef\x047\xecNuX1\x87\xcf/\xe3p\x8f\t\x03\
\x9cj\x1f\x19\xed\xd8\r\x19b\x03\xbd\x88R\x85\x8c&XTc\xb2\xb0\x11\x13\x89_\ \x9e\x8f\xb5\x8f\x8cv|\x83\x0c\xb1\x81^D\xa9BF\x13\xac\xaa1Y\xd8\x88\x89\xc4\
\xc8\xb4\xd9(\xab\xeb~`"\x13\x91\xc9F\xd5\xee\x9e8w@\x1bY\xae\xfd]6\x9f\xb0&\ \'d\xdal\x94\xd5u\x9f0\x91\x89\xc8d\xa3j\xf7\x9f\xb8t@\x1bY\xae\xfd^6\x9f\
4\x1f\xa5\x8dQY\xaa\x9a\x8f]\x86\xb1nED\x8a\xfd\xfdC|\x03\xab\xaaw\xdd' )) \xb0&\xb4\x1c\xa5\x8dQY\xaa\x9a\x8f]\x86\xf1\xda\x8a\x88\x14\xc3O\x1f\x8c3\
\x1dNw\xdd' ))
def getRefreshBitmap(): def getRefreshBitmap():
return wxBitmapFromXPMData(getRefreshData()) return wxBitmapFromXPMData(getRefreshData())
@@ -138,14 +157,13 @@ def getRefreshImage():
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def getAutoRefreshData(): def getAutoRefreshData():
return cPickle.loads(zlib.decompress( return cPickle.loads(zlib.decompress(
'x\xda\xad\xd21\x0e\xc20\x0c\x05\xd0\xbd\xa7\xb0\xc4\x10&+-\x1d\xca\x05\x18Y\ 'x\xda\x95\xd2;\x0e\xc20\x0c\x06\xe0\xbd\xa7\xb0\xc4\x10&+-\x1d\xca\x05\x18Y\
\xba\xfc\x15!6\x84\xb9\xffD\x9c8%R\x92\x8a\x01gh\xacW9\xb2\x93\xe3\xf3=\x0e\ \xba\xfc+Bl\x08s\xff\x89<\x9c\x12\xc9I\xa5:Cc}\x95#;9\xbf\xbf\xe3\xb0\xbai\
\xab\x9bf\x9aN4\xd3\xe8\x86\xdb\xea@w:\x9c\xbd\xae\x98S\xc8\xaf\xf2z\xc4D\ \xa6\xe9B3\x8dnx\xac\x0e\xf4\xa4\xd3\xd5\xc7\x95r\n\xf9]>\xaf\x94HD\xef\x97\
\x14\xbd_\x16\x9f\x905\xbf\x84\xcc\xe7\x9f\xdb\xf17d\x8d\x0e\x06A\xa1\x05r4\ \xc5g\xe4\x98\xdfB\xe6\xcb\xcf\xed8\x82\x1c\xa3\x83APi\x85\x9c\x0c\xf4\xd7\
\xd0WKL\xa6\x1b4\x91i\x0f9m:eA\x12\x025*\x05\x03\x9b\x96\xad\x00\xf6i\xa1\ \x1a\xb3\xc5\r\x9a\xc8\xb4\x87\x9c7\x9d\xb2 \t\x01\x8b\x91\x82\x81U\xebV\x00\
\x85luk\xec\x94\xdd\xc5\xd4\x81\xb4\xcb\xf2\xa6\x10\xa9\xca\xdahbO\xa8\xd1\ \xfd\xb4PC\xb6\xba\x16;ew1w \xed\xb2\xbc)DLY\x1dM\xea\t\x16u@\xe8\\\x19\x95\
\x06\x84\xce\x95Q\x1e\x7f\xe7\xb2\xb3U\xad\xc0\x8e\xfb\xe9\r\xf1\x07\xdbD\ \xf1w.\xbb\x98i\x05z\xdc\xe17d\x90\x7f\x95\x07\x86\x9f' ))
\x86\x9f' ))
def getAutoRefreshBitmap(): def getAutoRefreshBitmap():
return wxBitmapFromXPMData(getAutoRefreshData()) return wxBitmapFromXPMData(getAutoRefreshData())

View File

@@ -23,8 +23,8 @@ genericStyles = ['wxSIMPLE_BORDER', 'wxDOUBLE_BORDER',
# Class that can properly disable children # Class that can properly disable children
class PPanel(wxPanel): class PPanel(wxPanel):
def __init__(self, parent, id, name): def __init__(self, parent, name):
wxPanel.__init__(self, parent, id, name=name) wxPanel.__init__(self, parent, -1, name=name)
self.modified = self.freeze = false self.modified = self.freeze = false
def Enable(self, value): def Enable(self, value):
# Something strange is going on with enable so we make sure... # Something strange is going on with enable so we make sure...
@@ -36,8 +36,8 @@ class PPanel(wxPanel):
panel.SetModified(true) panel.SetModified(true)
class ParamBinaryOr(PPanel): class ParamBinaryOr(PPanel):
def __init__(self, parent, id, size, name): def __init__(self, parent, name):
PPanel.__init__(self, parent, id, name) PPanel.__init__(self, parent, name)
self.ID_TEXT_CTRL = wxNewId() self.ID_TEXT_CTRL = wxNewId()
self.ID_BUTTON_CHOICES = wxNewId() self.ID_BUTTON_CHOICES = wxNewId()
self.SetBackgroundColour(panel.GetBackgroundColour()) self.SetBackgroundColour(panel.GetBackgroundColour())
@@ -97,7 +97,10 @@ class ParamBinaryOr(PPanel):
value.append(self.values[i]) value.append(self.values[i])
# Add ignored flags # Add ignored flags
value.extend(ignored) value.extend(ignored)
self.SetValue(reduce(lambda a,b: a+'|'+b, value)) if value:
self.SetValue(reduce(lambda a,b: a+'|'+b, value))
else:
self.SetValue('')
self.SetModified() self.SetModified()
dlg.Destroy() dlg.Destroy()
@@ -109,31 +112,31 @@ class ParamFlag(ParamBinaryOr):
equal = {'wxALIGN_CENTER': 'wxALIGN_CENTRE', equal = {'wxALIGN_CENTER': 'wxALIGN_CENTRE',
'wxALIGN_CENTER_VERTICAL': 'wxALIGN_CENTRE_VERTICAL', 'wxALIGN_CENTER_VERTICAL': 'wxALIGN_CENTRE_VERTICAL',
'wxALIGN_CENTER_HORIZONTAL': 'wxALIGN_CENTRE_HORIZONTAL'} 'wxALIGN_CENTER_HORIZONTAL': 'wxALIGN_CENTRE_HORIZONTAL'}
def __init__(self, parent, id, size, name): def __init__(self, parent, name):
ParamBinaryOr.__init__(self, parent, id, size, name) ParamBinaryOr.__init__(self, parent, name)
class ParamStyle(ParamBinaryOr): class ParamStyle(ParamBinaryOr):
equal = {'wxALIGN_CENTER': 'wxALIGN_CENTRE'} equal = {'wxALIGN_CENTER': 'wxALIGN_CENTRE'}
def __init__(self, parent, id = -1, size = wxDefaultSize, name = ''): def __init__(self, parent, name):
self.values = currentXXX.winStyles + genericStyles self.values = currentXXX.winStyles + genericStyles
ParamBinaryOr.__init__(self, parent, id, size, name) ParamBinaryOr.__init__(self, parent, name)
class ParamNonGenericStyle(ParamBinaryOr): class ParamNonGenericStyle(ParamBinaryOr):
def __init__(self, parent, id = -1, size = wxDefaultSize, name = ''): def __init__(self, parent, name):
self.values = currentXXX.winStyles self.values = currentXXX.winStyles
ParamBinaryOr.__init__(self, parent, id, size, name) ParamBinaryOr.__init__(self, parent, name)
class ParamExStyle(ParamBinaryOr): class ParamExStyle(ParamBinaryOr):
def __init__(self, parent, id = -1, size = wxDefaultSize, name = ''): def __init__(self, parent, name):
if currentXXX: if currentXXX:
self.values = currentXXX.exStyles # constant at the moment self.values = currentXXX.exStyles # constant at the moment
else: else:
self.values = [] self.values = []
ParamBinaryOr.__init__(self, parent, id, size, name) ParamBinaryOr.__init__(self, parent, name)
class ParamColour(PPanel): class ParamColour(PPanel):
def __init__(self, parent, id = -1, size = wxDefaultSize, name = ''): def __init__(self, parent, name):
PPanel.__init__(self, parent, id, name) PPanel.__init__(self, parent, name)
self.ID_TEXT_CTRL = wxNewId() self.ID_TEXT_CTRL = wxNewId()
self.ID_BUTTON = wxNewId() self.ID_BUTTON = wxNewId()
self.SetBackgroundColour(panel.GetBackgroundColour()) self.SetBackgroundColour(panel.GetBackgroundColour())
@@ -153,7 +156,6 @@ class ParamColour(PPanel):
return self.value return self.value
def SetValue(self, value): def SetValue(self, value):
self.freeze = true self.freeze = true
value = string.strip(value)
if not value: value = '#FFFFFF' if not value: value = '#FFFFFF'
self.value = value self.value = value
self.text.SetValue(str(value)) # update text ctrl self.text.SetValue(str(value)) # update text ctrl
@@ -198,8 +200,8 @@ fontStylesXml2wx = ReverseMap(fontStylesWx2Xml)
fontWeightsXml2wx = ReverseMap(fontWeightsWx2Xml) fontWeightsXml2wx = ReverseMap(fontWeightsWx2Xml)
class ParamFont(PPanel): class ParamFont(PPanel):
def __init__(self, parent, id = -1, size = wxDefaultSize, name = ''): def __init__(self, parent, name):
PPanel.__init__(self, parent, id, name) PPanel.__init__(self, parent, name)
self.ID_TEXT_CTRL = wxNewId() self.ID_TEXT_CTRL = wxNewId()
self.ID_BUTTON_SELECT = wxNewId() self.ID_BUTTON_SELECT = wxNewId()
self.SetBackgroundColour(panel.GetBackgroundColour()) self.SetBackgroundColour(panel.GetBackgroundColour())
@@ -219,34 +221,56 @@ class ParamFont(PPanel):
self.SetModified() self.SetModified()
self.textModified = true self.textModified = true
evt.Skip() evt.Skip()
def _defaultValue(self):
return ['12', 'default', 'normal', 'normal', '0', '', '']
def GetValue(self): def GetValue(self):
if self.textModified: # text has newer value if self.textModified: # text has newer value
return eval(self.text.GetValue()) try:
return eval(self.text.GetValue())
except SyntaxError:
wxLogError('Syntax error in parameter value: ' + self.GetName())
return self._defaultValue()
return self.value return self.value
def SetValue(self, value): def SetValue(self, value):
self.freeze = true # disable other handlers self.freeze = true # disable other handlers
if not value: value = [''] * 7 if not value: value = self._defaultValue()
self.value = value self.value = value
self.text.SetValue(str(value)) # update text ctrl self.text.SetValue(str(value)) # update text ctrl
self.freeze = false self.freeze = false
def OnButtonSelect(self, evt): def OnButtonSelect(self, evt):
if self.textModified: # text has newer value if self.textModified: # text has newer value
self.value = eval(self.text.GetValue()) try:
self.value = eval(self.text.GetValue())
except SyntaxError:
wxLogError('Syntax error in parameter value: ' + self.GetName())
self.value = self._defaultValue()
# Make initial font # Make initial font
try: size = int(self.value[0]) # Default values
except ValueError: size = 12 size = 12
try: family = fontFamiliesXml2wx[self.value[1]] family = wxDEFAULT
except KeyError: family = wxDEFAULT style = weight = wxNORMAL
try: style = fontStylesXml2wx[self.value[2]] underlined = 0
except KeyError: style = wxNORMAL face = ''
try: weight = fontWeightsXml2wx[self.value[3]]
except KeyError: weight = wxNORMAL
try: underlined = int(self.value[4])
except ValueError: underlined = 0
face = self.value[5]
mapper = wxFontMapper()
enc = wxFONTENCODING_DEFAULT enc = wxFONTENCODING_DEFAULT
if not self.value[6]: enc = mapper.CharsetToEncoding(self.value[6]) # Fall back to default if exceptions
error = false
try:
try: size = int(self.value[0])
except ValueError: error = true
try: family = fontFamiliesXml2wx[self.value[1]]
except KeyError: error = true
try: style = fontStylesXml2wx[self.value[2]]
except KeyError: error = true
try: weight = fontWeightsXml2wx[self.value[3]]
except KeyError: error = true
try: underlined = int(self.value[4])
except ValueError: error = true
face = self.value[5]
mapper = wxFontMapper()
if not self.value[6]: enc = mapper.CharsetToEncoding(self.value[6])
except IndexError:
error = true
if error: wxLogError('Invalid font specification')
if enc == wxFONTENCODING_DEFAULT: enc = wxFONTENCODING_SYSTEM if enc == wxFONTENCODING_DEFAULT: enc = wxFONTENCODING_SYSTEM
font = wxFont(size, family, style, weight, underlined, face, enc) font = wxFont(size, family, style, weight, underlined, face, enc)
data = wxFontData() data = wxFontData()
@@ -254,11 +278,14 @@ class ParamFont(PPanel):
dlg = wxFontDialog(self, data) dlg = wxFontDialog(self, data)
if dlg.ShowModal() == wxID_OK: if dlg.ShowModal() == wxID_OK:
font = dlg.GetFontData().GetChosenFont() font = dlg.GetFontData().GetChosenFont()
value = [str(font.GetPointSize()), fontFamiliesWx2Xml[font.GetFamily()], value = [str(font.GetPointSize()),
fontStylesWx2Xml[font.GetStyle()], fontFamiliesWx2Xml.get(font.GetFamily(), "default"),
fontWeightsWx2Xml[font.GetWeight()], fontStylesWx2Xml.get(font.GetStyle(), "normal"),
str(font.GetUnderlined()), font.GetFaceName(), fontWeightsWx2Xml.get(font.GetWeight(), "normal"),
wxFontMapper_GetEncodingName(font.GetEncoding())] str(font.GetUnderlined()),
font.GetFaceName(),
wxFontMapper_GetEncodingName(font.GetEncoding())
]
# Add ignored flags # Add ignored flags
self.SetValue(value) self.SetValue(value)
self.SetModified() self.SetModified()
@@ -268,8 +295,8 @@ class ParamFont(PPanel):
################################################################################ ################################################################################
class ParamInt(PPanel): class ParamInt(PPanel):
def __init__(self, parent, id = -1, size = wxDefaultSize, name = ''): def __init__(self, parent, name):
PPanel.__init__(self, parent, id, name) PPanel.__init__(self, parent, name)
self.ID_SPIN_CTRL = wxNewId() self.ID_SPIN_CTRL = wxNewId()
sizer = wxBoxSizer() sizer = wxBoxSizer()
self.spin = wxSpinCtrl(self, self.ID_SPIN_CTRL, size=wxSize(50,-1)) self.spin = wxSpinCtrl(self, self.ID_SPIN_CTRL, size=wxSize(50,-1))
@@ -283,7 +310,6 @@ class ParamInt(PPanel):
return str(self.spin.GetValue()) return str(self.spin.GetValue())
def SetValue(self, value): def SetValue(self, value):
self.freeze = true self.freeze = true
value = string.strip(value)
if not value: value = 0 if not value: value = 0
self.spin.SetValue(int(value)) self.spin.SetValue(int(value))
self.freeze = false self.freeze = false
@@ -293,8 +319,8 @@ class ParamInt(PPanel):
evt.Skip() evt.Skip()
class ParamText(PPanel): class ParamText(PPanel):
def __init__(self, parent, id = -1, size = wxDefaultSize, name = '', textWidth=200): def __init__(self, parent, name, textWidth=200):
PPanel.__init__(self, parent, id, name) PPanel.__init__(self, parent, name)
self.ID_TEXT_CTRL = wxNewId() self.ID_TEXT_CTRL = wxNewId()
# We use sizer even here to have the same size of text control # We use sizer even here to have the same size of text control
sizer = wxBoxSizer() sizer = wxBoxSizer()
@@ -317,29 +343,25 @@ class ParamText(PPanel):
evt.Skip() evt.Skip()
class ParamAccel(ParamText): class ParamAccel(ParamText):
def __init__(self, parent, id = -1, size = wxDefaultSize, name = ''): def __init__(self, parent, name):
ParamText.__init__(self, parent, id, size, name, 50) ParamText.__init__(self, parent, name, 50)
class ParamPosSize(ParamText): class ParamPosSize(ParamText):
def __init__(self, parent, id = -1, size = wxDefaultSize, name = ''): def __init__(self, parent, name):
ParamText.__init__(self, parent, id, size, name, 80) ParamText.__init__(self, parent, name, 80)
class ContentDialog(wxDialog): class ContentDialog(wxDialogPtr):
def __init__(self, parent, value): def __init__(self, parent, value):
#wxPreDialog(self) # Is this normal???
# Use another constructor
w = frame.res.LoadDialog(parent, 'ID_DIALOG_CONTENT') w = frame.res.LoadDialog(parent, 'ID_DIALOG_CONTENT')
self.this = w.this wxDialogPtr.__init__(self, w.this)
w.thisown = 0
self.thisown = 1 self.thisown = 1
#frame.res.LoadOnDialog(self, parent, 'ID_DIALOG_CONTENT')
self.Center() self.Center()
self.list = self.FindWindowByName('ID_LIST') self.list = self.FindWindowByName('ID_LIST')
# Set list items # Set list items
for v in value: for v in value:
self.list.Append(v) self.list.Append(v)
self.SetAutoLayout(true) self.SetAutoLayout(true)
# !!! self.SetSizer(sizer)
self.GetSizer().Fit(self) self.GetSizer().Fit(self)
# Callbacks # Callbacks
self.ID_BUTTON_APPEND = XMLID('ID_BUTTON_APPEND') self.ID_BUTTON_APPEND = XMLID('ID_BUTTON_APPEND')
@@ -379,9 +401,69 @@ class ContentDialog(wxDialog):
evt.Enable(self.list.GetSelection() != -1 and \ evt.Enable(self.list.GetSelection() != -1 and \
self.list.GetSelection() < self.list.Number() - 1) self.list.GetSelection() < self.list.Number() - 1)
class ContentCheckListDialog(wxDialogPtr):
def __init__(self, parent, value):
# Is this normal???
w = frame.res.LoadDialog(parent, 'ID_DIALOG_CONTENT_CHECK_LIST')
wxDialogPtr.__init__(self, w.this)
self.thisown = 1
self.Center()
self.list = self.FindWindowByName('ID_CHECK_LIST')
# Set list items
i = 0
for v,ch in value:
self.list.Append(v)
self.list.Check(i, ch)
i += 1
self.SetAutoLayout(true)
self.GetSizer().Fit(self)
# Callbacks
self.ID_BUTTON_APPEND = XMLID('ID_BUTTON_APPEND')
self.ID_BUTTON_REMOVE = XMLID('ID_BUTTON_REMOVE')
self.ID_BUTTON_UP = XMLID('ID_BUTTON_UP')
self.ID_BUTTON_DOWN = XMLID('ID_BUTTON_DOWN')
EVT_CHECKLISTBOX(self, self.list.GetId(), self.OnCheck)
EVT_BUTTON(self, self.ID_BUTTON_UP, self.OnButtonUp)
EVT_BUTTON(self, self.ID_BUTTON_DOWN, self.OnButtonDown)
EVT_BUTTON(self, self.ID_BUTTON_APPEND, self.OnButtonAppend)
EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove)
EVT_UPDATE_UI(self, self.ID_BUTTON_UP, self.OnUpdateUI)
EVT_UPDATE_UI(self, self.ID_BUTTON_DOWN, self.OnUpdateUI)
EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI)
def OnCheck(self, evt):
# !!! Wrong wxGTK (wxMSW?) behavior: toggling selection if checking
self.list.Deselect(evt.GetSelection())
def OnButtonUp(self, evt):
i = self.list.GetSelection()
str, ch = self.list.GetString(i), self.list.IsChecked(i)
self.list.Delete(i)
self.list.InsertItems([str], i-1)
self.list.Check(i-1, ch)
self.list.SetSelection(i-1)
def OnButtonDown(self, evt):
i = self.list.GetSelection()
str, ch = self.list.GetString(i), self.list.IsChecked(i)
self.list.Delete(i)
self.list.InsertItems([str], i+1)
self.list.Check(i+1, ch)
self.list.SetSelection(i+1)
def OnButtonAppend(self, evt):
str = wxGetTextFromUser('Enter new item:', 'Append', '', self)
self.list.Append(str)
def OnButtonRemove(self, evt):
self.list.Delete(self.list.GetSelection())
def OnUpdateUI(self, evt):
if evt.GetId() == self.ID_BUTTON_REMOVE:
evt.Enable(self.list.GetSelection() != -1)
elif evt.GetId() == self.ID_BUTTON_UP:
evt.Enable(self.list.GetSelection() > 0)
elif evt.GetId() == self.ID_BUTTON_DOWN:
evt.Enable(self.list.GetSelection() != -1 and \
self.list.GetSelection() < self.list.Number() - 1)
class ParamContent(PPanel): class ParamContent(PPanel):
def __init__(self, parent, id = -1, size = wxDefaultSize, name = ''): def __init__(self, parent, name):
PPanel.__init__(self, parent, id, name) PPanel.__init__(self, parent, name)
self.ID_TEXT_CTRL = wxNewId() self.ID_TEXT_CTRL = wxNewId()
self.ID_BUTTON_EDIT = wxNewId() self.ID_BUTTON_EDIT = wxNewId()
self.SetBackgroundColour(panel.GetBackgroundColour()) self.SetBackgroundColour(panel.GetBackgroundColour())
@@ -403,7 +485,11 @@ class ParamContent(PPanel):
evt.Skip() evt.Skip()
def GetValue(self): def GetValue(self):
if self.textModified: # text has newer value if self.textModified: # text has newer value
return eval(self.text.GetValue()) try:
return eval(self.text.GetValue())
except SyntaxError:
wxLogError('Syntax error in parameter value: ' + self.GetName())
return []
return self.value return self.value
def SetValue(self, value): def SetValue(self, value):
self.freeze = true self.freeze = true
@@ -412,7 +498,11 @@ class ParamContent(PPanel):
self.freeze = false self.freeze = false
def OnButtonEdit(self, evt): def OnButtonEdit(self, evt):
if self.textModified: # text has newer value if self.textModified: # text has newer value
self.value = eval(self.text.GetValue()) try:
self.value = eval(self.text.GetValue())
except SyntaxError:
wxLogError('Syntax error in parameter value: ' + self.GetName())
self.value = []
dlg = ContentDialog(self, self.value) dlg = ContentDialog(self, self.value)
if dlg.ShowModal() == wxID_OK: if dlg.ShowModal() == wxID_OK:
value = [] value = []
@@ -424,11 +514,65 @@ class ParamContent(PPanel):
self.textModified = false self.textModified = false
dlg.Destroy() dlg.Destroy()
# CheckList content
class ParamContentCheckList(PPanel):
def __init__(self, parent, name):
PPanel.__init__(self, parent, name)
self.ID_TEXT_CTRL = wxNewId()
self.ID_BUTTON_EDIT = wxNewId()
self.SetBackgroundColour(panel.GetBackgroundColour())
sizer = wxBoxSizer()
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1))
sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 10)
self.button = wxButton(self, self.ID_BUTTON_EDIT, 'Edit...')
sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL)
self.SetAutoLayout(true)
self.SetSizer(sizer)
sizer.Fit(self)
self.textModified = false
EVT_BUTTON(self, self.ID_BUTTON_EDIT, self.OnButtonEdit)
EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
def OnChange(self, evt):
if self.freeze: return
self.SetModified()
self.textModified = true
evt.Skip()
def GetValue(self):
if self.textModified: # text has newer value
try:
return eval(self.text.GetValue())
except SyntaxError:
wxLogError('Syntax error in parameter value: ' + self.GetName())
return []
return self.value
def SetValue(self, value):
self.freeze = true
self.value = value
self.text.SetValue(str(value)) # update text ctrl
self.freeze = false
def OnButtonEdit(self, evt):
if self.textModified: # text has newer value
try:
self.value = eval(self.text.GetValue())
except SyntaxError:
wxLogError('Syntax error in parameter value: ' + self.GetName())
self.value = []
dlg = ContentCheckListDialog(self, self.value)
if dlg.ShowModal() == wxID_OK:
value = []
for i in range(dlg.list.Number()):
value.append((dlg.list.GetString(i), dlg.list.IsChecked(i)))
# Add ignored flags
self.SetValue(value)
self.SetModified()
self.textModified = false
dlg.Destroy()
# Boxless radiobox # Boxless radiobox
class RadioBox(PPanel): class RadioBox(PPanel):
def __init__(self, parent, id, choices, def __init__(self, parent, id, choices,
pos=wxDefaultPosition, size=wxDefaultSize, name='radiobox'): pos=wxDefaultPosition, name='radiobox'):
PPanel.__init__(self, parent, id, name) PPanel.__init__(self, parent, name)
self.SetBackgroundColour(panel.GetBackgroundColour()) self.SetBackgroundColour(panel.GetBackgroundColour())
self.choices = choices self.choices = choices
topSizer = wxBoxSizer() topSizer = wxBoxSizer()
@@ -456,8 +600,8 @@ class RadioBox(PPanel):
class ParamBool(RadioBox): class ParamBool(RadioBox):
values = {'yes': '1', 'no': '0'} values = {'yes': '1', 'no': '0'}
seulav = {'1': 'yes', '0': 'no'} seulav = {'1': 'yes', '0': 'no'}
def __init__(self, parent, id = -1, size = wxDefaultSize, name = ''): def __init__(self, parent, name):
RadioBox.__init__(self, parent, id, choices = self.values.keys(), name=name) RadioBox.__init__(self, parent, -1, choices = self.values.keys(), name=name)
def GetValue(self): def GetValue(self):
return self.values[self.GetStringSelection()] return self.values[self.GetStringSelection()]
def SetValue(self, value): def SetValue(self, value):
@@ -467,8 +611,8 @@ class ParamBool(RadioBox):
class ParamOrient(RadioBox): class ParamOrient(RadioBox):
values = {'horizontal': 'wxHORIZONTAL', 'vertical': 'wxVERTICAL'} values = {'horizontal': 'wxHORIZONTAL', 'vertical': 'wxVERTICAL'}
seulav = {'wxHORIZONTAL': 'horizontal', 'wxVERTICAL': 'vertical'} seulav = {'wxHORIZONTAL': 'horizontal', 'wxVERTICAL': 'vertical'}
def __init__(self, parent, id = -1, size = wxDefaultSize, name = ''): def __init__(self, parent, name):
RadioBox.__init__(self, parent, id, choices = self.values.keys(), name=name) RadioBox.__init__(self, parent, -1, choices = self.values.keys(), name=name)
def GetValue(self): def GetValue(self):
return self.values[self.GetStringSelection()] return self.values[self.GetStringSelection()]
def SetValue(self, value): def SetValue(self, value):
@@ -476,8 +620,8 @@ class ParamOrient(RadioBox):
self.SetStringSelection(self.seulav[value]) self.SetStringSelection(self.seulav[value])
class ParamFile(PPanel): class ParamFile(PPanel):
def __init__(self, parent, id = -1, size = wxDefaultSize, name = ''): def __init__(self, parent, name):
PPanel.__init__(self, parent, id, name) PPanel.__init__(self, parent, name)
self.ID_TEXT_CTRL = wxNewId() self.ID_TEXT_CTRL = wxNewId()
self.ID_BUTTON_BROWSE = wxNewId() self.ID_BUTTON_BROWSE = wxNewId()
self.SetBackgroundColour(panel.GetBackgroundColour()) self.SetBackgroundColour(panel.GetBackgroundColour())
@@ -499,7 +643,7 @@ class ParamFile(PPanel):
evt.Skip() evt.Skip()
def GetValue(self): def GetValue(self):
if self.textModified: # text has newer value if self.textModified: # text has newer value
return eval(self.text.GetValue()) return self.text.GetValue()
return self.value return self.value
def SetValue(self, value): def SetValue(self, value):
self.freeze = true self.freeze = true
@@ -510,11 +654,12 @@ class ParamFile(PPanel):
if self.textModified: # text has newer value if self.textModified: # text has newer value
self.value = self.text.GetValue() self.value = self.text.GetValue()
dlg = wxFileDialog(self, dlg = wxFileDialog(self,
defaultDir = os.path.abspath(os.path.dirname(self.value)), defaultDir = os.path.dirname(self.value),
defaultFile = os.path.basename(self.value)) defaultFile = os.path.basename(self.value))
if dlg.ShowModal() == wxID_OK: if dlg.ShowModal() == wxID_OK:
# Make relative # Make relative
common = os.path.commonprefix([frame.dataFile, dlg.GetPath()]) common = os.path.commonprefix([os.path.abspath(frame.dataFile),
dlg.GetPath()])
self.SetValue(dlg.GetPath()[len(common):]) self.SetValue(dlg.GetPath()[len(common):])
self.SetModified() self.SetModified()
self.textModified = false self.textModified = false

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
python2.2 YOUR_PATH_TO_XRCED/xrced.py $*

View File

@@ -1,2 +1,167 @@
<?xml version="1.0" ?> <?xml version="1.0" ?>
<resource><object class="wxDialog" name="ID_DIALOG_CONTENT"><title>Content</title><size>250,300</size><object class="wxBoxSizer"><orient>wxVERTICAL</orient><object class="sizeritem"><object class="wxBoxSizer"><orient>wxHORIZONTAL</orient><object class="sizeritem"><object class="wxListBox" name="ID_LIST"><content/></object><option>1</option><flag>wxTOP|wxBOTTOM|wxLEFT|wxEXPAND</flag><border>5</border></object><object class="sizeritem"><object class="wxBoxSizer"><orient>wxVERTICAL</orient><object class="sizeritem"><object class="wxButton" name="ID_BUTTON_UP"><label>Move Up</label></object><flag>wxBOTTOM</flag><border>5</border></object><object class="sizeritem"><object class="wxButton" name="ID_BUTTON_DOWN"><label>Move Down</label></object></object><object class="spacer"><size>10,20</size><option>1</option></object><object class="sizeritem"><object class="wxButton" name="ID_BUTTON_APPEND"><label>Append...</label></object><flag>wxBOTTOM</flag><border>5</border></object><object class="sizeritem"><object class="wxButton" name="ID_BUTTON_REMOVE"><label>Remove</label></object></object></object><flag>wxALL|wxEXPAND</flag><border>5</border></object></object><option>1</option><flag>wxEXPAND</flag></object><object class="sizeritem"><object class="wxStaticLine"/><flag>wxEXPAND</flag></object><object class="sizeritem"><object class="wxBoxSizer"><orient>wxHORIZONTAL</orient><object class="sizeritem"><object class="wxButton" name="wxID_OK"><label>OK</label><default>1</default></object><flag>wxRIGHT</flag><border>10</border></object><object class="sizeritem"><object class="wxButton" name="wxID_CANCEL"><label>Cancel</label></object></object></object><flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag><border>10</border></object></object><style>wxRESIZE_BORDER</style></object></resource> <resource>
<object class="wxDialog" name="ID_DIALOG_CONTENT">
<title>Content</title>
<size>250,300</size>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<object class="wxListBox" name="ID_LIST">
<content/>
</object>
<option>1</option>
<flag>wxTOP|wxBOTTOM|wxLEFT|wxEXPAND</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<object class="wxButton" name="ID_BUTTON_UP">
<label>Move Up</label>
</object>
<flag>wxBOTTOM</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxButton" name="ID_BUTTON_DOWN">
<label>Move Down</label>
</object>
</object>
<object class="spacer">
<size>10,20</size>
<option>1</option>
</object>
<object class="sizeritem">
<object class="wxButton" name="ID_BUTTON_APPEND">
<label>Append...</label>
</object>
<flag>wxBOTTOM</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxButton" name="ID_BUTTON_REMOVE">
<label>Remove</label>
</object>
</object>
</object>
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
</object>
</object>
<option>1</option>
<flag>wxEXPAND</flag>
</object>
<object class="sizeritem">
<object class="wxStaticLine"/>
<flag>wxEXPAND</flag>
</object>
<object class="sizeritem">
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<object class="wxButton" name="wxID_OK">
<label>OK</label>
<default>1</default>
</object>
<flag>wxRIGHT</flag>
<border>10</border>
</object>
<object class="sizeritem">
<object class="wxButton" name="wxID_CANCEL">
<label>Cancel</label>
</object>
</object>
</object>
<flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag>
<border>10</border>
</object>
</object>
<style>wxRESIZE_BORDER</style>
</object>
<object class="wxDialog" name="ID_DIALOG_CONTENT_CHECK_LIST">
<title>Content</title>
<size>250,300</size>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<object class="wxCheckList" name="ID_CHECK_LIST">
<content/>
</object>
<option>1</option>
<flag>wxTOP|wxBOTTOM|wxLEFT|wxEXPAND</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<object class="wxButton" name="ID_BUTTON_UP">
<label>Move Up</label>
</object>
<flag>wxBOTTOM</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxButton" name="ID_BUTTON_DOWN">
<label>Move Down</label>
</object>
</object>
<object class="spacer">
<size>10,20</size>
<option>1</option>
</object>
<object class="sizeritem">
<object class="wxButton" name="ID_BUTTON_APPEND">
<label>Append...</label>
</object>
<flag>wxBOTTOM</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxButton" name="ID_BUTTON_REMOVE">
<label>Remove</label>
</object>
</object>
</object>
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
</object>
</object>
<option>1</option>
<flag>wxEXPAND</flag>
</object>
<object class="sizeritem">
<object class="wxStaticLine"/>
<flag>wxEXPAND</flag>
</object>
<object class="sizeritem">
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<object class="wxButton" name="wxID_OK">
<label>OK</label>
<default>1</default>
</object>
<flag>wxRIGHT</flag>
<border>10</border>
</object>
<object class="sizeritem">
<object class="wxButton" name="wxID_CANCEL">
<label>Cancel</label>
</object>
</object>
</object>
<flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag>
<border>10</border>
</object>
</object>
<style>wxRESIZE_BORDER</style>
</object>
</resource>

View File

@@ -51,7 +51,7 @@ class xxxParamContent:
text = n.childNodes[0] # first child must be text node text = n.childNodes[0] # first child must be text node
assert text.nodeType == minidom.Node.TEXT_NODE assert text.nodeType == minidom.Node.TEXT_NODE
l.append(text) l.append(text)
data.append(text.data) data.append(str(text.data))
else: # remove other else: # remove other
node.removeChild(n) node.removeChild(n)
n.unlink() n.unlink()
@@ -61,7 +61,8 @@ class xxxParamContent:
def update(self, value): def update(self, value):
# If number if items is not the same, recreate children # If number if items is not the same, recreate children
if len(value) != len(self.l): # remove first if number of items has changed if len(value) != len(self.l): # remove first if number of items has changed
for n in self.node.childNodes: childNodes = self.node.childNodes[:]
for n in childNodes:
self.node.removeChild(n) self.node.removeChild(n)
l = [] l = []
for str in value: for str in value:
@@ -70,11 +71,59 @@ class xxxParamContent:
itemElem.appendChild(itemText) itemElem.appendChild(itemText)
self.node.appendChild(itemElem) self.node.appendChild(itemElem)
l.append(itemText) l.append(itemText)
self.l = l
else: else:
for i in range(len(value)): for i in range(len(value)):
self.l[i].data = value[i] self.l[i].data = value[i]
self.data = value self.data = value
# Content parameter for checklist
class xxxParamContentCheckList:
def __init__(self, node):
self.node = node
data, l = [], [] # data is needed to quicker value retrieval
nodes = node.childNodes[:] # make a copy of the child list
for n in nodes:
if n.nodeType == minidom.Node.ELEMENT_NODE:
assert n.tagName == 'item', 'bad content content'
checked = n.getAttribute('checked')
if not n.hasChildNodes():
# If does not have child nodes, create empty text node
text = tree.dom.createTextNode('')
node.appendChild(text)
else:
# !!! normalize?
text = n.childNodes[0] # first child must be text node
assert text.nodeType == minidom.Node.TEXT_NODE
l.append((text, n))
data.append((str(text.data), int(checked)))
else: # remove other
node.removeChild(n)
n.unlink()
self.l, self.data = l, data
def value(self):
return self.data
def update(self, value):
# If number if items is not the same, recreate children
if len(value) != len(self.l): # remove first if number of items has changed
childNodes = self.node.childNodes[:]
for n in childNodes:
self.node.removeChild(n)
l = []
for (s,ch) in value:
itemElem = tree.dom.createElement('item')
itemElem.setAttribute('checked', str(ch))
itemText = tree.dom.createTextNode(s)
itemElem.appendChild(itemText)
self.node.appendChild(itemElem)
l.append((itemText, itemElem))
self.l = l
# else:
# for i in range(len(value)):
# self.l[i][0].data = value[i]
# self.l[i][1].setAttributedata = value[i]
self.data = value
################################################################################ ################################################################################
# Classes to interface DOM objects # Classes to interface DOM objects
@@ -84,6 +133,7 @@ class xxxObject:
hasStyle = true # almost everyone hasStyle = true # almost everyone
hasName = true # has name attribute? hasName = true # has name attribute?
isSizer = hasChild = false isSizer = hasChild = false
allParams = None # Some nodes have no parameters
# Style parameters (all optional) # Style parameters (all optional)
styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'tooltip'] styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'tooltip']
# Special parameters # Special parameters
@@ -121,7 +171,10 @@ class xxxObject:
elif tag in self.specials: elif tag in self.specials:
self.special(tag, node) self.special(tag, node)
elif tag == 'content': elif tag == 'content':
self.params[tag] = xxxParamContent(node) if self.className == 'wxCheckList':
self.params[tag] = xxxParamContentCheckList(node)
else:
self.params[tag] = xxxParamContent(node)
elif tag == 'font': # has children elif tag == 'font': # has children
self.params[tag] = xxxParamFont(self, node) self.params[tag] = xxxParamFont(self, node)
else: # simple parameter else: # simple parameter
@@ -130,52 +183,6 @@ class xxxObject:
# Remove all other nodes # Remove all other nodes
element.removeChild(node) element.removeChild(node)
node.unlink() node.unlink()
# Generate HTML
def generateHtml(self, prefix=''):
SetCurrentXXX(self)
html = '<table cellspacing=0 cellpadding=0><tr><td width=120>\
<font size="+1"><b>%s</b></font></td>' % self.className
# Has id (name) attribute
if self.hasName:
html += """\
<td><wxp module="xxx" class="ParamText" width=150>
<param name="name" value="data_name">
</wxp></td>"""
html += '</table><p>'
html += '<table cellspacing=0 cellpadding=0>\n'
# Add required parameters
for param in self.allParams:
# Add checkbox or just text
if param in self.required:
html += '<tr><td width=20></td><td width=100>%s: </td>' % param
else: # optional parameter
html += """\
<tr><td width=20><wxp class="wxCheckBox">
<param name="id" value="%d">
<param name="size" value="(20,-1)">
<param name="name" value="%s">
<param name="label" value=("")>
</wxp></td><td width=100>%s: </td>
""" % (paramIDs[param], prefix + 'check_' + param, param)
# Get parameter type
try:
# Local or overriden type
typeClass = self.paramDict[param].__name__
except KeyError:
try:
# Standart type
typeClass = paramDict[param].__name__
except KeyError:
# Default
typeClass = 'ParamText'
html += """\
<td><wxp module="xxx" class="%s">
<param name="id" value="%d">
<param name="name" value="%s">
</wxp></td>
""" % (typeClass, -1, prefix + 'data_' + param)
html += '</table>\n'
return html
# Returns real tree object # Returns real tree object
def treeObject(self): def treeObject(self):
if self.hasChild: return self.child if self.hasChild: return self.child
@@ -229,8 +236,12 @@ class xxxParamFont(xxxParam):
class xxxContainer(xxxObject): class xxxContainer(xxxObject):
hasChildren = true hasChildren = true
# Special class for root node
class xxxMainNode(xxxContainer):
hasStyle = hasName = false
################################################################################ ################################################################################
# Top-level windwos # Top-level windwows
class xxxPanel(xxxContainer): class xxxPanel(xxxContainer):
allParams = ['pos', 'size', 'style'] allParams = ['pos', 'size', 'style']
@@ -347,9 +358,6 @@ class xxxListCtrl(xxxObject):
'wxLC_USER_TEXT', 'wxLC_EDIT_LABELS', 'wxLC_NO_HEADER', 'wxLC_USER_TEXT', 'wxLC_EDIT_LABELS', 'wxLC_NO_HEADER',
'wxLC_SINGLE_SEL', 'wxLC_SORT_ASCENDING', 'wxLC_SORT_DESCENDING'] 'wxLC_SINGLE_SEL', 'wxLC_SORT_ASCENDING', 'wxLC_SORT_DESCENDING']
# !!! temporary
xxxCheckList = xxxListCtrl
class xxxTreeCtrl(xxxObject): class xxxTreeCtrl(xxxObject):
allParams = ['pos', 'size', 'style'] allParams = ['pos', 'size', 'style']
winStyles = ['wxTR_HAS_BUTTONS', 'wxTR_NO_LINES', 'wxTR_LINES_AT_ROOT', winStyles = ['wxTR_HAS_BUTTONS', 'wxTR_NO_LINES', 'wxTR_LINES_AT_ROOT',
@@ -422,6 +430,15 @@ class xxxListBox(xxxObject):
winStyles = ['wxLB_SINGLE', 'wxLB_MULTIPLE', 'wxLB_EXTENDED', 'wxLB_HSCROLL', winStyles = ['wxLB_SINGLE', 'wxLB_MULTIPLE', 'wxLB_EXTENDED', 'wxLB_HSCROLL',
'wxLB_ALWAYS_SB', 'wxLB_NEEDED_SB', 'wxLB_SORT'] 'wxLB_ALWAYS_SB', 'wxLB_NEEDED_SB', 'wxLB_SORT']
class xxxCheckList(xxxObject):
allParams = ['content', 'pos', 'size', 'style']
required = ['content']
winStyles = ['wxLC_LIST', 'wxLC_REPORT', 'wxLC_ICON', 'wxLC_SMALL_ICON',
'wxLC_ALIGN_TOP', 'wxLC_ALIGN_LEFT', 'wxLC_AUTOARRANGE',
'wxLC_USER_TEXT', 'wxLC_EDIT_LABELS', 'wxLC_NO_HEADER',
'wxLC_SINGLE_SEL', 'wxLC_SORT_ASCENDING', 'wxLC_SORT_DESCENDING']
paramDict = {'content': ParamContentCheckList}
################################################################################ ################################################################################
# Sizers # Sizers
@@ -507,16 +524,13 @@ class xxxChildContainer(xxxObject):
element.removeChild(node) element.removeChild(node)
node.unlink() node.unlink()
assert 0, 'no child found' assert 0, 'no child found'
def generateHtml(self):
return xxxObject.generateHtml(self, '_') + '<hr>\n' + \
self.child.generateHtml()
class xxxSizerItem(xxxChildContainer): class xxxSizerItem(xxxChildContainer):
allParams = ['option', 'flag', 'border'] allParams = ['option', 'flag', 'border']
paramDict = {'option': ParamInt} paramDict = {'option': ParamInt}
def __init__(self, parent, element): def __init__(self, parent, element):
xxxChildContainer.__init__(self, parent, element) xxxChildContainer.__init__(self, parent, element)
# Remove pos parameter - unnecessary for sizeritems # Remove pos parameter - not needed for sizeritems
if 'pos' in self.child.allParams: if 'pos' in self.child.allParams:
self.child.allParams = self.child.allParams[:] self.child.allParams = self.child.allParams[:]
self.child.allParams.remove('pos') self.child.allParams.remove('pos')
@@ -556,7 +570,6 @@ class xxxMenuItem(xxxObject):
class xxxSeparator(xxxObject): class xxxSeparator(xxxObject):
hasName = hasStyle = false hasName = hasStyle = false
allParams = []
################################################################################ ################################################################################
@@ -616,9 +629,10 @@ paramIDs = {'fg': wxNewId(), 'bg': wxNewId(), 'exstyle': wxNewId(), 'font': wxNe
'tooltip': wxNewId() 'tooltip': wxNewId()
} }
for cl in xxxDict.values(): for cl in xxxDict.values():
for param in cl.allParams + cl.paramDict.keys(): if cl.allParams:
if not paramIDs.has_key(param): for param in cl.allParams + cl.paramDict.keys():
paramIDs[param] = wxNewId() if not paramIDs.has_key(param):
paramIDs[param] = wxNewId()
################################################################################ ################################################################################
# Helper functions # Helper functions
@@ -633,7 +647,7 @@ def MakeXXXFromDOM(parent, element):
return xxxDict[element.getAttribute('class')](parent, element) return xxxDict[element.getAttribute('class')](parent, element)
except KeyError: except KeyError:
# Verify that it's not recursive exception # Verify that it's not recursive exception
if element.getAttribute('class') not in xxxDict.keys(): if element.getAttribute('class') not in xxxDict:
print 'ERROR: unknown class:', element.getAttribute('class') print 'ERROR: unknown class:', element.getAttribute('class')
raise raise