Updated XRCed

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12253 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2001-11-02 01:59:05 +00:00
parent b6ea61a589
commit a40b5e8474
8 changed files with 677 additions and 399 deletions

View File

@@ -80,12 +80,11 @@ include src/gtk/*.h
include src/gtk/*.py include src/gtk/*.py
include tools/*.py include tools/*.py
tools/XRCed/CHANGES include tools/XRCed/CHANGES
tools/XRCed/TODO include tools/XRCed/TODO
tools/XRCed/README include tools/XRCed/README
tools/XRCed/*.py include tools/XRCed/*.py
tools/XRCed/*.xrc include tools/XRCed/*.xrc
include contrib/glcanvas/*.i include contrib/glcanvas/*.i
include contrib/glcanvas/*.py include contrib/glcanvas/*.py

View File

@@ -1,3 +1,14 @@
0.0.5
-----
Added notebook with properties page and style page. Fixed some problems
on Windows.
0.0.4
-----
Some fixes suggested by RD
0.0.3 0.0.3
----- -----

View File

@@ -26,3 +26,8 @@ TODO for XRCed
* import XRC/WXR files * import XRC/WXR files
* disable some window creation when it's not valid
* check for memory leaks from wx objects
* style defaults for `hidde' and `focused' should be false

View File

@@ -5,6 +5,26 @@ from wxPython.wx import wxBitmapFromXPMData, wxImageFromBitmap
import cPickle, zlib import cPickle, zlib
def getIconData():
return cPickle.loads(zlib.decompress(
'x\xda\x9d\x90\xbb\x0e\xc20\x0cEw\xbe\xc2\x12C\x91"Y-\xa2\x82\xd1\x80\xd45C\
\x97\xac\x88\x11\xa4\xf0\xff\x13\xd7Nh\xa0\xcd\x00\xb8y\xf4\xe6\xf8\x95l\xee\
\x8fn56\xdb\x1da\xec\xa9kV\x97\xb1\tt\xa5\xd3\xfdr\xbd\x99b\xa8\xf5\xf1\xa0\
\x9fi\xa7\xba\x85\rI\xcb\x8bg\x1dU\xf7m\xbf\xeb[\xd3\xfe\xa53\'\xd5\xc3a8O\
\xban_@\x0eL10\x07X\xc4iL[\x8e\x8c\x81 \xe1\xc3\xea\x17\xd4/NPct\x85{0N\xcc\
\xa5f\xb4\x83\x94\xd6|\xde\x1b\xb2"\x9a\x16\x05\xe6\x10\x81\x08\xe5\x9cZ\x1d\
K\xcd\xd4\xed\x04-}\xb9\n\n\x12\xdb\xb0\x99\x0e\xe8\x8f\x17\xf2N~\x81\xe2}"^\
\x16\xd0;\x18\xce\x9c\xcb?oP\x9c\xc7t\xf0\xb1\xfd\x13Z&,9z\x0eS:\x04/\x1bB:\
\x81Q\x15jM4Z\xaf\x99\xba\xf4\xf5n\xed\x9e\x92\xef)B\x7f\xbem\x81\xfc\x04\
\x8f\xd5\x99\xcc' ))
def getIconBitmap():
return wxBitmapFromXPMData(getIconData())
def getIconImage():
return wxImageFromBitmap(getIconBitmap())
#----------------------------------------------------------------------
def getNewData(): def getNewData():
return cPickle.loads(zlib.decompress( return cPickle.loads(zlib.decompress(
"x\xda\xd3\xc8)0\xe4\nV72Q02V0Q0T\xe7J\x0cV\xd7SHVp\xcaIL\xce\x06\xf3\xf2\ "x\xda\xd3\xc8)0\xe4\nV72Q02V0Q0T\xe7J\x0cV\xd7SHVp\xcaIL\xce\x06\xf3\xf2\
@@ -133,6 +153,34 @@ def getAutoRefreshBitmap():
def getAutoRefreshImage(): def getAutoRefreshImage():
return wxImageFromBitmap(getAutoRefreshBitmap()) return wxImageFromBitmap(getAutoRefreshBitmap())
#----------------------------------------------------------------------
def getTreeDefaultData():
return cPickle.loads(zlib.decompress(
"x\xda\xd3\xc8)0\xe4\nV74S04Q0U0T\xe7J\x0cV\x8fPHVp\xcaIL\xce\x06\xf3\xfc\
\x81<eK\x03K\x13K\x030_\x01\xc8\xf7\xcb\xcfK\x05s\xf4@\x92n\x16n\xcen\x16`~>\
\x88\xefb\xe0b\xe2\x02S\x8c\n\xc8\x10\xd4\x83\x80\x08T\xc1|\x10\xf0\xa7\xae\
\xa0?\x18\xa0\nF@\x01\x99\x8e'FP\x0f\x00\xdc\x1bL7" ))
def getTreeDefaultBitmap():
return wxBitmapFromXPMData(getTreeDefaultData())
def getTreeDefaultImage():
return wxImageFromBitmap(getTreeDefaultBitmap())
#----------------------------------------------------------------------
def getTreeRootData():
return cPickle.loads(zlib.decompress(
'x\xda\xd3\xc8)0\xe4\nV74S04Q0V0T\xe7J\x0cV\xd7SHVp\xcaIL\xce\x06\xf3"\x80<e\
c\x0b\x10\x04\xf3\x15\x80|\xbf\xfc\xbcT(\x07\x15 \x04\xf5\x80\x00Y0\x02\x080\
\x04\x15"\xb0i\x8f\x80\xe9\x87\xa8\x86\n\xc2\xf4\xa3\x08\x0e\xa8v\x9c~G\x15\
\xd4\x03\x00\x87\xa5@\xc2' ))
def getTreeRootBitmap():
return wxBitmapFromXPMData(getTreeRootData())
def getTreeRootImage():
return wxImageFromBitmap(getTreeRootBitmap())
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def getTreePanelData(): def getTreePanelData():
return cPickle.loads(zlib.decompress( return cPickle.loads(zlib.decompress(

View File

@@ -2,6 +2,7 @@
# Purpose: Classes for parameter introduction # Purpose: Classes for parameter introduction
# Author: Roman Rolinsky <rolinsky@mema.ucl.ac.be> # Author: Roman Rolinsky <rolinsky@mema.ucl.ac.be>
# Created: 22.08.2001 # Created: 22.08.2001
# RCS-ID: $Id$
from wxPython.wx import * from wxPython.wx import *
from wxPython.xrc import * from wxPython.xrc import *
@@ -13,25 +14,23 @@ def SetCurrentXXX(xxx):
global currentXXX global currentXXX
currentXXX = xxx currentXXX = xxx
# Register objects in the view
registered = {}
def Register(param, obj):
registered[param] = obj
def GetRegistered(param):
return registered[param]
def ClearRegister():
registered.clear()
genericStyles = ['wxSIMPLE_BORDER', 'wxSUNKEN_BORDER', 'wxRAISED_BORDER', genericStyles = ['wxSIMPLE_BORDER', 'wxSUNKEN_BORDER', 'wxRAISED_BORDER',
'wxTAB_TRAVERSAL', 'wxWANTS_CHARS', 'wxVSCROLL', 'wxHSCROLL'] 'wxTAB_TRAVERSAL', 'wxWANTS_CHARS', 'wxVSCROLL', 'wxHSCROLL']
class ParamBinaryOr(wxPanel): # Class that can properly disable children
ID_TEXT_CTRL = wxNewId() class PPanel(wxPanel):
ID_BUTTON_CHOICES = wxNewId() def __init__(self, parent, id, name):
def __init__(self, parent, id, value, size, name, param):
wxPanel.__init__(self, parent, id, name=name) wxPanel.__init__(self, parent, id, name=name)
def Enable(self, value):
for w in self.GetChildren():
w.Enable(value)
class ParamBinaryOr(PPanel):
def __init__(self, parent, id, value, size, name):
PPanel.__init__(self, parent, id, name)
self.ID_TEXT_CTRL = wxNewId()
self.ID_BUTTON_CHOICES = wxNewId()
self.SetBackgroundColour(panel.GetBackgroundColour()) self.SetBackgroundColour(panel.GetBackgroundColour())
Register(param, self)
sizer = wxBoxSizer() sizer = wxBoxSizer()
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, value, size=wxSize(200,-1)) self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, value, size=wxSize(200,-1))
sizer.Add(self.text, 0, wxRIGHT, 10) sizer.Add(self.text, 0, wxRIGHT, 10)
@@ -50,9 +49,9 @@ class ParamBinaryOr(wxPanel):
def SetValue(self, value): def SetValue(self, value):
self.text.SetValue(value) self.text.SetValue(value)
def OnButtonChoices(self, evt): def OnButtonChoices(self, evt):
dlg = wxDialog(self, -1, 'Choices', size=wxSize(250,300)) dlg = wxDialog(self, -1, 'Choices')
topSizer = wxBoxSizer(wxVERTICAL) topSizer = wxBoxSizer(wxVERTICAL)
listBox = wxCheckListBox(dlg, -1, choices=self.values) listBox = wxCheckListBox(dlg, -1, choices=self.values, size=(250,200))
value = map(string.strip, string.split(self.text.GetValue(), '|')) value = map(string.strip, string.split(self.text.GetValue(), '|'))
if value == ['']: value = [] if value == ['']: value = []
ignored = [] ignored = []
@@ -76,6 +75,7 @@ class ParamBinaryOr(wxPanel):
topSizer.Add(sizer, 0, wxALL | wxEXPAND, 10) topSizer.Add(sizer, 0, wxALL | wxEXPAND, 10)
dlg.SetAutoLayout(true) dlg.SetAutoLayout(true)
dlg.SetSizer(topSizer) dlg.SetSizer(topSizer)
topSizer.Fit(dlg)
dlg.Center() dlg.Center()
if dlg.ShowModal() != wxID_OK: return if dlg.ShowModal() != wxID_OK: return
value = [] value = []
@@ -95,19 +95,153 @@ 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, value, size, name, param): def __init__(self, parent, id, value, size, name):
ParamBinaryOr.__init__(self, parent, id, value, size, name, param) ParamBinaryOr.__init__(self, parent, id, value, size, name)
class ParamStyle(ParamBinaryOr): class ParamStyle(ParamBinaryOr):
equal = {'wxALIGN_CENTER': 'wxALIGN_CENTRE'} equal = {'wxALIGN_CENTER': 'wxALIGN_CENTRE'}
def __init__(self, parent, id, value, size, name, param): def __init__(self, parent, id, value, size, name):
self.values = currentXXX.styles + genericStyles self.values = currentXXX.winStyles + genericStyles
ParamBinaryOr.__init__(self, parent, id, value, size, name, param) ParamBinaryOr.__init__(self, parent, id, value, size, name)
class ParamInt(wxPanel): class ParamExStyle(ParamBinaryOr):
ID_SPIN_CTRL = wxNewId() def __init__(self, parent, id, value, size, name):
def __init__(self, parent, id, value, size, name, param): if currentXXX:
wxPanel.__init__(self, parent, id, name=name) self.values = currentXXX.exStyles # constant at the moment
else:
self.values = []
ParamBinaryOr.__init__(self, parent, id, value, size, name)
class ParamColour(PPanel):
def __init__(self, parent, id, value, size, name):
PPanel.__init__(self, parent, id, name)
self.ID_TEXT_CTRL = wxNewId()
self.ID_BUTTON = wxNewId()
self.SetBackgroundColour(panel.GetBackgroundColour())
sizer = wxBoxSizer()
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, str(value), size=wxSize(60,-1))
sizer.Add(self.text, 0, wxGROW | wxRIGHT, 10)
self.button = wxPanel(self, self.ID_BUTTON, wxDefaultPosition, wxSize(40, -1))
sizer.Add(self.button, 0, wxGROW)
self.SetAutoLayout(true)
self.SetSizer(sizer)
sizer.Fit(self)
self.textModified = false
self.SetValue(value)
EVT_PAINT(self.button, self.OnPaintButton)
EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
EVT_LEFT_DOWN(self.button, self.OnLeftDown)
def GetValue(self):
return self.value
def SetValue(self, value):
if not value: value = '#FFFFFF'
self.value = value
self.text.SetValue(str(value)) # update text ctrl
self.button.SetBackgroundColour(wxNamedColour(value))
self.button.Refresh()
def OnChange(self, evt):
panel.SetModified(true)
self.textModified = true
evt.Skip()
def OnPaintButton(self, evt):
dc = wxPaintDC(self.button)
dc.SetBrush(wxTRANSPARENT_BRUSH)
if panel.page2.IsEnabled() and self.IsEnabled(): dc.SetPen(wxBLACK_PEN)
else: dc.SetPen(wxGREY_PEN)
size = self.button.GetSize()
dc.DrawRectangle(0, 0, size.x, size.y)
def OnLeftDown(self, evt):
dlg = wxColourDialog(self)
if dlg.ShowModal() == wxID_OK:
self.SetValue('#%02X%02X%02X' % dlg.GetColourData().GetColour().Get())
panel.SetModified(true)
################################################################################
# Mapping from wx constants ro XML strings
fontFamiliesWx2Xml = {wxDEFAULT: 'default', wxDECORATIVE: 'decorative',
wxROMAN: 'roman', wxSCRIPT: 'script', wxSWISS: 'swiss',
wxMODERN: 'modern'}
fontStylesWx2Xml = {wxNORMAL: 'normal', wxSLANT: 'slant', wxITALIC: 'italic'}
fontWeightsWx2Xml = {wxNORMAL: 'normal', wxLIGHT: 'light', wxBOLD: 'bold'}
def ReverseMap(m):
rm = {}
for k,v in m.items(): rm[v] = k
return rm
fontFamiliesXml2wx = ReverseMap(fontFamiliesWx2Xml)
fontStylesXml2wx = ReverseMap(fontStylesWx2Xml)
fontWeightsXml2wx = ReverseMap(fontWeightsWx2Xml)
class ParamFont(PPanel):
def __init__(self, parent, id, value, size, name):
PPanel.__init__(self, parent, id, name)
self.ID_TEXT_CTRL = wxNewId()
self.ID_BUTTON_SELECT = wxNewId()
self.SetBackgroundColour(panel.GetBackgroundColour())
sizer = wxBoxSizer()
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, str(value), size=wxSize(200,-1))
sizer.Add(self.text, 0, wxRIGHT, 10)
self.button = wxButton(self, self.ID_BUTTON_SELECT, 'Select...')
sizer.Add(self.button)
self.SetAutoLayout(true)
self.SetSizer(sizer)
sizer.Fit(self)
self.textModified = false
EVT_BUTTON(self, self.ID_BUTTON_SELECT, self.OnButtonSelect)
EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
def OnChange(self, evt):
panel.SetModified(true)
self.textModified = true
evt.Skip()
def GetValue(self):
if self.textModified: # text has newer value
return eval(self.text.GetValue())
return self.value
def SetValue(self, value):
if not value: value = [''] * 7
self.value = value
self.text.SetValue(str(value)) # update text ctrl
def OnButtonSelect(self, evt):
if self.textModified: # text has newer value
self.value = eval(self.text.GetValue())
# Make initial font
try: size = int(self.value[0])
except ValueError: size = 12
try: family = fontFamiliesXml2wx[self.value[1]]
except KeyError: family = wxDEFAULT
try: style = fontStylesXml2wx[self.value[2]]
except KeyError: style = wxNORMAL
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
if not self.value[6]: enc = mapper.CharsetToEncoding(self.value[6])
if enc == wxFONTENCODING_DEFAULT: enc = wxFONTENCODING_SYSTEM
font = wxFont(size, family, style, weight, underlined, face, enc)
data = wxFontData()
data.SetInitialFont(font)
dlg = wxFontDialog(self, data)
if dlg.ShowModal() != wxID_OK: return
font = dlg.GetFontData().GetChosenFont()
value = [str(font.GetPointSize()), fontFamiliesWx2Xml[font.GetFamily()],
fontStylesWx2Xml[font.GetStyle()],
fontWeightsWx2Xml[font.GetWeight()],
str(font.GetUnderlined()), font.GetFaceName(),
wxFontMapper_GetEncodingName(font.GetEncoding())]
# Add ignored flags
self.SetValue(value)
panel.SetModified(true)
self.textModified = false
################################################################################
class ParamInt(PPanel):
def __init__(self, parent, id, value, size, name):
PPanel.__init__(self, parent, id, name)
self.ID_SPIN_CTRL = wxNewId()
sizer = wxBoxSizer() sizer = wxBoxSizer()
self.spin = wxSpinCtrl(self, self.ID_SPIN_CTRL, value, size=wxSize(50,-1)) self.spin = wxSpinCtrl(self, self.ID_SPIN_CTRL, value, size=wxSize(50,-1))
self.SetBackgroundColour(panel.GetBackgroundColour()) self.SetBackgroundColour(panel.GetBackgroundColour())
@@ -115,7 +249,6 @@ class ParamInt(wxPanel):
self.SetAutoLayout(true) self.SetAutoLayout(true)
self.SetSizer(sizer) self.SetSizer(sizer)
sizer.Fit(self) sizer.Fit(self)
Register(param, self)
EVT_SPINCTRL(self, self.ID_SPIN_CTRL, self.OnChange) EVT_SPINCTRL(self, self.ID_SPIN_CTRL, self.OnChange)
def GetValue(self): def GetValue(self):
return str(self.spin.GetValue()) return str(self.spin.GetValue())
@@ -127,27 +260,24 @@ class ParamInt(wxPanel):
evt.Skip() evt.Skip()
class ParamText(wxTextCtrl): class ParamText(wxTextCtrl):
def __init__(self, parent, id, value, size, name, param): def __init__(self, parent, id, value, size, name):
wxTextCtrl.__init__(self, parent, id, value, size=wxSize(200,-1), name=name) wxTextCtrl.__init__(self, parent, id, value, size=wxSize(200,-1), name=name)
Register(param, self)
EVT_TEXT(self, id, self.OnChange) EVT_TEXT(self, id, self.OnChange)
def OnChange(self, evt): def OnChange(self, evt):
panel.SetModified(true) panel.SetModified(true)
evt.Skip() evt.Skip()
class ParamAccel(wxTextCtrl): class ParamAccel(wxTextCtrl):
def __init__(self, parent, id, value, size, name, param): def __init__(self, parent, id, value, size, name):
wxTextCtrl.__init__(self, parent, id, value, size=wxSize(50,-1), name=name) wxTextCtrl.__init__(self, parent, id, value, size=wxSize(50,-1), name=name)
Register(param, self)
EVT_TEXT(self, id, self.OnChange) EVT_TEXT(self, id, self.OnChange)
def OnChange(self, evt): def OnChange(self, evt):
panel.SetModified(true) panel.SetModified(true)
evt.Skip() evt.Skip()
class ParamPosSize(wxTextCtrl): class ParamPosSize(wxTextCtrl):
def __init__(self, parent, id, value, size, name, param): def __init__(self, parent, id, value, size, name):
wxTextCtrl.__init__(self, parent, id, value, size=wxSize(80,-1), name=name) wxTextCtrl.__init__(self, parent, id, value, size=wxSize(80,-1), name=name)
Register(param, self)
EVT_TEXT(self, id, self.OnChange) EVT_TEXT(self, id, self.OnChange)
def OnChange(self, evt): def OnChange(self, evt):
panel.SetModified(true) panel.SetModified(true)
@@ -155,6 +285,7 @@ class ParamPosSize(wxTextCtrl):
class ContentDialog(wxDialog): class ContentDialog(wxDialog):
def __init__(self, parent, value): def __init__(self, parent, value):
#wxPreDialog(self)
# Use another constructor # Use another constructor
w = frame.res.LoadDialog(parent, 'ID_DIALOG_CONTENT') w = frame.res.LoadDialog(parent, 'ID_DIALOG_CONTENT')
self.this = w.this self.this = w.this
@@ -166,8 +297,9 @@ class ContentDialog(wxDialog):
# Set list items # Set list items
for v in value: for v in value:
self.list.Append(v) self.list.Append(v)
# !!! Bug in XRC or wxWin listbox select random items self.SetAutoLayout(true)
self.FindWindowByName('wxID_OK').SetFocus() # !!! self.SetSizer(sizer)
self.GetSizer().Fit(self)
# Callbacks # Callbacks
self.ID_BUTTON_APPEND = XMLID('ID_BUTTON_APPEND') self.ID_BUTTON_APPEND = XMLID('ID_BUTTON_APPEND')
self.ID_BUTTON_REMOVE = XMLID('ID_BUTTON_REMOVE') self.ID_BUTTON_REMOVE = XMLID('ID_BUTTON_REMOVE')
@@ -203,15 +335,15 @@ class ContentDialog(wxDialog):
elif evt.GetId() == self.ID_BUTTON_UP: elif evt.GetId() == self.ID_BUTTON_UP:
evt.Enable(self.list.GetSelection() > 0) evt.Enable(self.list.GetSelection() > 0)
elif evt.GetId() == self.ID_BUTTON_DOWN: elif evt.GetId() == self.ID_BUTTON_DOWN:
evt.Enable(self.list.GetSelection() < self.list.Number() - 1) evt.Enable(self.list.GetSelection() != -1 and \
self.list.GetSelection() < self.list.Number() - 1)
class ParamContent(wxPanel): class ParamContent(PPanel):
ID_TEXT_CTRL = wxNewId() def __init__(self, parent, id, value, size, name):
ID_BUTTON_EDIT = wxNewId() PPanel.__init__(self, parent, id, name)
def __init__(self, parent, id, value, size, name, param): self.ID_TEXT_CTRL = wxNewId()
wxPanel.__init__(self, parent, id, name=name) self.ID_BUTTON_EDIT = wxNewId()
self.SetBackgroundColour(panel.GetBackgroundColour()) self.SetBackgroundColour(panel.GetBackgroundColour())
Register(param, self)
sizer = wxBoxSizer() sizer = wxBoxSizer()
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, str(value), size=wxSize(200,-1)) self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, str(value), size=wxSize(200,-1))
sizer.Add(self.text, 0, wxRIGHT, 10) sizer.Add(self.text, 0, wxRIGHT, 10)
@@ -248,11 +380,11 @@ class ParamContent(wxPanel):
self.textModified = false self.textModified = false
# Boxless radiobox # Boxless radiobox
class RadioBox(wxPanel): class RadioBox(PPanel):
ID_RADIO_CHOICE = wxNewId() # economize on IDs, use names
def __init__(self, parent, id, choices, def __init__(self, parent, id, choices,
pos=wxDefaultPosition, size=wxDefaultSize, name='radiobox'): pos=wxDefaultPosition, size=wxDefaultSize, name='radiobox'):
wxPanel.__init__(self, parent, id, pos, size, name=name) PPanel.__init__(self, parent, id, name)
self.ID_RADIO_CHOICE = wxNewId() # economize on IDs, use names
self.SetBackgroundColour(panel.GetBackgroundColour()) self.SetBackgroundColour(panel.GetBackgroundColour())
self.choices = choices self.choices = choices
topSizer = wxBoxSizer() topSizer = wxBoxSizer()
@@ -281,9 +413,8 @@ class RadioBox(wxPanel):
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, value, size, name, param): def __init__(self, parent, id, value, size, name):
RadioBox.__init__(self, parent, id, choices = self.values.keys(), name=name) RadioBox.__init__(self, parent, id, choices = self.values.keys(), name=name)
Register(param, self)
self.SetValue(value) self.SetValue(value)
def GetValue(self): def GetValue(self):
return self.values[self.GetStringSelection()] return self.values[self.GetStringSelection()]
@@ -294,9 +425,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, value, size, name, param): def __init__(self, parent, id, value, size, name):
RadioBox.__init__(self, parent, id, choices = self.values.keys(), name=name) RadioBox.__init__(self, parent, id, choices = self.values.keys(), name=name)
Register(param, self)
self.SetValue(value) self.SetValue(value)
def GetValue(self): def GetValue(self):
return self.values[self.GetStringSelection()] return self.values[self.GetStringSelection()]
@@ -306,7 +436,7 @@ class ParamOrient(RadioBox):
paramDict = { paramDict = {
'flag': ParamFlag, 'flag': ParamFlag,
'style': ParamStyle, 'style': ParamStyle, 'exstyle': ParamExStyle,
'pos': ParamPosSize, 'size': ParamPosSize, 'pos': ParamPosSize, 'size': ParamPosSize,
'border': ParamInt, 'cols': ParamInt, 'rows': ParamInt, 'border': ParamInt, 'cols': ParamInt, 'rows': ParamInt,
'vgap': ParamInt, 'hgap': ParamInt, 'vgap': ParamInt, 'hgap': ParamInt,
@@ -314,4 +444,8 @@ paramDict = {
'label': ParamText, 'title': ParamText, 'value': ParamText, 'label': ParamText, 'title': ParamText, 'value': ParamText,
'content': ParamContent, 'selection': ParamInt, 'content': ParamContent, 'selection': ParamInt,
'min': ParamInt, 'max': ParamInt, 'min': ParamInt, 'max': ParamInt,
'fg': ParamColour, 'bg': ParamColour, 'font': ParamFont,
'enabled': ParamBool, 'focused': ParamBool, 'hidden': ParamBool,
'tooltip': ParamText
} }

View File

@@ -2,6 +2,7 @@
# Purpose: XRC editor, main module # Purpose: XRC editor, main module
# Author: Roman Rolinsky <rolinsky@mema.ucl.ac.be> # Author: Roman Rolinsky <rolinsky@mema.ucl.ac.be>
# Created: 20.08.2001 # Created: 20.08.2001
# RCS-ID: $Id$
from wxPython.wx import * from wxPython.wx import *
from wxPython.xrc import * from wxPython.xrc import *
@@ -14,10 +15,14 @@ import tempfile
import images import images
# String constants # String constants
htmlHeader = '<html><body bgcolor="#b0c4de">\n'
faceColour = wxSystemSettings_GetSystemColour(wxSYS_COLOUR_3DFACE)
# Stange wxHtmlWindow behavior: when bgcolor is exact, it turns white
bgcolor = (faceColour.Red()-1, faceColour.Green()-1, faceColour.Blue()-1)
htmlHeader = '<html><body bgcolor="#%02x%02x%02x">\n' % bgcolor
htmlFooter = '</body></html>\n' htmlFooter = '</body></html>\n'
progname = 'XRCed' progname = 'XRCed'
version = '0.0.3' version = '0.0.5'
# Local modules # Local modules
from xxx import * from xxx import *
@@ -48,40 +53,85 @@ def SetMenu(m, list):
else: # separator else: # separator
m.AppendSeparator() m.AppendSeparator()
# Properties panel ################################################################################
class Panel(wxHtmlWindow):
def __init__(self, parent, id):
wxHtmlWindow.__init__(self, parent, id)
self.SetBorders(5)
self.SetFonts('', '', [8, 10, 12, 14, 16, 19, 24])
EVT_CHECKBOX(self, xxxObject.ID_CHECK_PARAMS, self.OnCheckParams)
EVT_CHECKBOX(self, xxxChildContainer.ID_CHECK_PARAMS, self.OnCheckParams)
self.modified = false
# Properties panel containing notebook
class Panel(wxNotebook):
def __init__(self, parent, id = -1):
wxNotebook.__init__(self, parent, id, style=wxNB_BOTTOM)
#self.SetBackgroundColour(wxColour(bgcolor))
sys.modules['params'].panel = self
self.page1 = HtmlPage(self)
self.AddPage(self.page1, 'Properties')
self.page2 = None
def SetData(self, xxx):
self.page1.SetPageData(xxx)
# Replace/remove style page
if self.page2:
self.RemovePage(1)
self.page2.Destroy()
if xxx and xxx.treeObject().hasStyle:
self.page2 = StylePage(self, xxx.treeObject())
self.AddPage(self.page2, 'Style')
else:
self.page2 = None
def Clear(self): def Clear(self):
self.SetPage(htmlHeader + 'select a tree item on the left' + htmlFooter) self.page1.Clear()
if self.page2:
self.RemovePage(1)
self.page2.Destroy()
self.page2 = None
# If some parameter on some page has changed
def IsModified(self):
return self.page1.IsModified() or self.page2 and self.page2.IsModified()
def SetModified(self, value):
self.page1.SetModified(value)
if self.page2:
self.page2.SetModified(value)
################################################################################
# General class for notebook pages
class ParamPage:
def __init__(self):
# Register event handlers
for id in paramIDs.values():
EVT_CHECKBOX(self, id, self.OnCheckParams)
def OnCheckParams(self, evt): def OnCheckParams(self, evt):
selected = tree.GetSelection() selected = tree.GetSelection()
xxx = tree.GetPyData(selected) xxx = tree.GetPyData(selected)
if xxx.hasChild and evt.GetId() != xxxChildContainer.ID_CHECK_PARAMS: winName = evt.GetEventObject().GetName()
xxx = xxx.child sizerParam = false
# Set current object if winName[0] == '_':
param = evt.GetEventObject().GetName()[6:] param = winName[7:]
if xxx.hasChild: sizerParam = true
w = GetRegistered('_'+param)
else: else:
w = GetRegistered(param) if xxx.hasChild: xxx = xxx.child
param = winName[6:]
# Set current object
if sizerParam:
w = self.FindWindowByName('_data_' + param)
else:
w = self.FindWindowByName('data_' + param)
elem = xxx.element elem = xxx.element
if evt.IsChecked(): if evt.IsChecked():
# Ad new text node in order of allParams # Ad new text node in order of allParams
w.SetValue('') w.SetValue('') # set empty (default) value
textElem = tree.dom.createElement(param) # For font element, we have to create another object
textNode = tree.dom.createTextNode('') if param == 'font':
textElem.appendChild(textNode) # Make XXX object
textElem = tree.dom.createElement('font')
font = xxxFont(xxx, textElem)
xxx.params['font'] = font
else:
textElem = tree.dom.createElement(param)
textNode = tree.dom.createTextNode('')
textElem.appendChild(textNode)
xxx.params[param] = textNode
# Find place to put new element: first present element after param # Find place to put new element: first present element after param
found = false found = false
for p in xxx.allParams[xxx.allParams.index(param) + 1:]: paramStyles = xxx.allParams + xxx.styles
for p in paramStyles[paramStyles.index(param) + 1:]:
# Content params don't have same type # Content params don't have same type
if xxx.params.has_key(p) and p != 'content': if xxx.params.has_key(p) and p != 'content':
found = true found = true
@@ -91,7 +141,6 @@ class Panel(wxHtmlWindow):
elem.insertBefore(textElem, nextTextElem) elem.insertBefore(textElem, nextTextElem)
else: else:
elem.appendChild(textElem) elem.appendChild(textElem)
xxx.params[param] = textNode
else: else:
# Remove parameter element and following text node # Remove parameter element and following text node
textElem = xxx.params[param].parentNode textElem = xxx.params[param].parentNode
@@ -105,12 +154,108 @@ class Panel(wxHtmlWindow):
# Set modified flas # Set modified flas
self.SetModified(true) self.SetModified(true)
# If some parameter was changed
################################################################################
# Properties panel notebook page
class HtmlPage(wxHtmlWindow, ParamPage):
def __init__(self, parent, id = -1):
wxHtmlWindow.__init__(self, parent, id)
ParamPage.__init__(self)
self.SetBorders(5)
if wxGetOsVersion()[1] == 1:
self.SetFonts('', '', [8, 10, 12, 14, 16, 19, 24])
else:
self.SetFonts("", "", [7, 8, 10, 12, 16, 22, 30])
self.modified = false
def Clear(self):
self.SetPage(htmlHeader + 'select a tree item on the left' + htmlFooter)
def SetPageData(self, xxx):
if not xxx:
self.SetPage(htmlHeader + 'this item has no properties' + htmlFooter)
return
self.SetPage(htmlHeader + xxx.generateHtml() + htmlFooter)
# Set values, checkboxes to false, disable defaults
if xxx.hasChild: prefix = '_'
else: prefix = ''
for param in xxx.allParams:
if xxx.params.has_key(param):
if param == 'content':
value = []
for text in xxx.params[param]:
value.append(str(text.data)) # convert from unicode
else:
value = xxx.params[param].data
self.FindWindowByName(prefix + 'data_' + param).SetValue(value)
if not param in xxx.required:
self.FindWindowByName(prefix + 'check_' + param).SetValue(true)
else:
self.FindWindowByName(prefix + 'data_' + param).Enable(false)
# Same for the child of sizeritem
if xxx.hasChild:
xxx = xxx.child
for param in xxx.allParams:
if xxx.params.has_key(param):
if param == 'content':
value = []
for text in xxx.params[param]:
value.append(str(text.data)) # convert from unicode
else:
value = xxx.params[param].data
self.FindWindowByName('data_' + param).SetValue(value)
if not param in xxx.required:
self.FindWindowByName('check_' + param).SetValue(true)
else:
self.FindWindowByName('data_' + param).Enable(false)
# If some parameter has changed
def IsModified(self): def IsModified(self):
return self.modified return self.modified
def SetModified(self, value): def SetModified(self, value):
self.modified = value self.modified = value
################################################################################
# Style notebook page
class StylePage(wxPanel, ParamPage):
def __init__(self, parent, xxx):
wxPanel.__init__(self, parent, -1)
ParamPage.__init__(self)
if wxGetOsVersion()[1] == 1:
self.SetFont(wxFont(12, wxDEFAULT, wxNORMAL, wxNORMAL))
else:
self.SetFont(wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL))
topSizer = wxBoxSizer(wxVERTICAL)
sizer = wxFlexGridSizer(len(xxx.styles), 2, 0, 1)
self.controls = {} # save python objects
for param in xxx.styles:
present = param in xxx.params.keys()
check = wxCheckBox(self, paramIDs[param],
param + ':', name = 'check_' + param)
check.SetValue(present)
control = paramDict[param](self, -1, '', (-1, -1),
'data_' + param)
if present:
control.SetValue(xxx.params[param].data)
else:
control.SetValue('')
control.Enable(present)
sizer.AddMany([ (check, 0, 0),
(control, 0, 0) ])
self.controls[param] = control
topSizer.Add(sizer, 1, wxALL, 5)
self.SetAutoLayout(true)
self.SetSizer(topSizer)
self.modified = false
# If some parameter has changed
def IsModified(self):
return self.modified
def SetModified(self, value):
self.modified = value
################################################################################
class HightLightBox: class HightLightBox:
def __init__(self, pos, size): def __init__(self, pos, size):
w = testWin.panel w = testWin.panel
@@ -136,6 +281,8 @@ class HightLightBox:
map(wxWindow.Destroy, self.lines) map(wxWindow.Destroy, self.lines)
testWin.highLight = None testWin.highLight = None
################################################################################
class MemoryFile: class MemoryFile:
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
@@ -151,7 +298,8 @@ class MemoryFile:
class XML_Tree(wxTreeCtrl): class XML_Tree(wxTreeCtrl):
def __init__(self, parent, id): def __init__(self, parent, id):
wxTreeCtrl.__init__(self, parent, id) wxTreeCtrl.__init__(self, parent, id,
style=wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT)
self.SetBackgroundColour(wxColour(224, 248, 224)) self.SetBackgroundColour(wxColour(224, 248, 224))
EVT_TREE_SEL_CHANGED(self, self.GetId(), self.OnSelChanged) EVT_TREE_SEL_CHANGED(self, self.GetId(), self.OnSelChanged)
EVT_TREE_ITEM_ACTIVATED(self, self.GetId(), self.OnItemActivated) EVT_TREE_ITEM_ACTIVATED(self, self.GetId(), self.OnItemActivated)
@@ -162,17 +310,19 @@ class XML_Tree(wxTreeCtrl):
self.dom = None self.dom = None
# Create image list # Create image list
il = wxImageList(16, 16, true) il = wxImageList(16, 16, true)
xxxPanel.image = il.AddIcon( wxIconFromXPMData(images.getTreePanelData()) ) self.rootImage = il.AddIcon(wxIconFromXPMData(images.getTreeRootData()))
xxxDialog.image = il.AddIcon( wxIconFromXPMData(images.getTreeDialogData()) ) xxxObject.image = il.AddIcon(wxIconFromXPMData(images.getTreeDefaultData()))
xxxFrame.image = il.AddIcon( wxIconFromXPMData(images.getTreeFrameData()) ) xxxPanel.image = il.AddIcon(wxIconFromXPMData(images.getTreePanelData()))
xxxMenuBar.image = il.AddIcon( wxIconFromXPMData(images.getTreeMenuBarData()) ) xxxDialog.image = il.AddIcon(wxIconFromXPMData(images.getTreeDialogData()))
xxxMenu.image = il.AddIcon( wxIconFromXPMData(images.getTreeMenuData()) ) xxxFrame.image = il.AddIcon(wxIconFromXPMData(images.getTreeFrameData()))
xxxSizer.imageH = il.AddIcon( wxIconFromXPMData(images.getTreeSizerHData()) ) xxxMenuBar.image = il.AddIcon(wxIconFromXPMData(images.getTreeMenuBarData()))
xxxSizer.imageV = il.AddIcon( wxIconFromXPMData(images.getTreeSizerVData()) ) xxxMenu.image = il.AddIcon(wxIconFromXPMData(images.getTreeMenuData()))
xxxStaticBoxSizer.imageH = il.AddIcon( wxIconFromXPMData(images.getTreeStaticBoxSizerHData()) ) xxxSizer.imageH = il.AddIcon(wxIconFromXPMData(images.getTreeSizerHData()))
xxxStaticBoxSizer.imageV = il.AddIcon( wxIconFromXPMData(images.getTreeStaticBoxSizerVData()) ) xxxSizer.imageV = il.AddIcon(wxIconFromXPMData(images.getTreeSizerVData()))
xxxGridSizer.image = il.AddIcon( wxIconFromXPMData(images.getTreeSizerGridData()) ) xxxStaticBoxSizer.imageH = il.AddIcon(wxIconFromXPMData(images.getTreeStaticBoxSizerHData()))
xxxFlexGridSizer.image = il.AddIcon( wxIconFromXPMData(images.getTreeSizerFlexGridData()) ) xxxStaticBoxSizer.imageV = il.AddIcon(wxIconFromXPMData(images.getTreeStaticBoxSizerVData()))
xxxGridSizer.image = il.AddIcon(wxIconFromXPMData(images.getTreeSizerGridData()))
xxxFlexGridSizer.image = il.AddIcon(wxIconFromXPMData(images.getTreeSizerFlexGridData()))
self.il = il self.il = il
self.SetImageList(il) self.SetImageList(il)
@@ -182,7 +332,7 @@ class XML_Tree(wxTreeCtrl):
wxTreeCtrl.Unselect(self) wxTreeCtrl.Unselect(self)
def GetSelection(self): def GetSelection(self):
return self.selection return self.selection
def ExpandAll(self, item): def ExpandAll(self, item):
if self.ItemHasChildren(item): if self.ItemHasChildren(item):
self.Expand(item) self.Expand(item)
@@ -226,7 +376,7 @@ class XML_Tree(wxTreeCtrl):
elif n.nodeType != minidom.Node.ELEMENT_NODE: elif n.nodeType != minidom.Node.ELEMENT_NODE:
treeObj.element.removeChild(n) treeObj.element.removeChild(n)
n.unlink() n.unlink()
# Remove leaf of tree, return it's data object # Remove leaf of tree, return it's data object
def RemoveLeaf(self, leaf): def RemoveLeaf(self, leaf):
@@ -300,51 +450,12 @@ class XML_Tree(wxTreeCtrl):
item = evt.GetItem() item = evt.GetItem()
self.selection = item # !!! fix self.selection = item # !!! fix
xxx = self.GetPyData(item) xxx = self.GetPyData(item)
html = htmlHeader # Update panel
# List of parameters tuples (parameter, isDefined) panel.SetData(xxx)
if not xxx: # root item # Remove highlight?
html += 'this item has no properties' + htmlFooter if not xxx and testWin and testWin.highLight:
panel.SetPage(html) testWin.highLight.Remove()
if testWin and testWin.highLight:
testWin.highLight.Remove()
return return
# Normal nodes
ClearRegister() # empty register
html += xxx.generateHtml()
html += htmlFooter
panel.SetPage(html)
# Set values, checkboxes to false, disable defaults
if xxx.hasChild: prefix = '_'
else: prefix = ''
for param in xxx.allParams:
if xxx.params.has_key(param):
if param == 'content':
value = []
for text in xxx.params[param]:
value.append(str(text.data)) # convert from unicode
else:
value = xxx.params[param].data
GetRegistered(prefix + param).SetValue(value)
if not param in xxx.required:
panel.FindWindowByName('check_' + param).SetValue(true)
else:
GetRegistered(prefix + param).Enable(false)
# Same for the child of sizeritem
if xxx.hasChild:
xxx = xxx.child
for param in xxx.allParams:
if xxx.params.has_key(param):
if param == 'content':
value = []
for text in xxx.params[param]:
value.append(str(text.data)) # convert from unicode
else:
value = xxx.params[param].data
GetRegistered(param).SetValue(value)
if not param in xxx.required:
panel.FindWindowByName('check_' + param).SetValue(true)
else:
GetRegistered(param).Enable(false)
# Clear flag # Clear flag
panel.SetModified(false) panel.SetModified(false)
# Hightlighting is done in OnIdle # Hightlighting is done in OnIdle
@@ -390,7 +501,7 @@ class XML_Tree(wxTreeCtrl):
except AttributeError: except AttributeError:
testWin.highLight = HightLightBox(pos, size) testWin.highLight = HightLightBox(pos, size)
testWin.highLight.item = item testWin.highLight.item = item
# Double-click # Double-click
def OnItemActivated(self, evt): def OnItemActivated(self, evt):
item = evt.GetItem() item = evt.GetItem()
@@ -399,7 +510,7 @@ class XML_Tree(wxTreeCtrl):
if panel.IsModified(): if panel.IsModified():
self.Apply(xxx, item) # apply changes self.Apply(xxx, item) # apply changes
self.CreateTestWin(item) self.CreateTestWin(item)
# (re)create test window # (re)create test window
def CreateTestWin(self, node): def CreateTestWin(self, node):
global testWin global testWin
@@ -494,7 +605,7 @@ class XML_Tree(wxTreeCtrl):
testWin.highLight = None testWin.highLight = None
if highLight and not tree.pendingHighLight: if highLight and not tree.pendingHighLight:
self.HighLight(highLight) self.HighLight(highLight)
def OnCloseTestWin(self, evt): def OnCloseTestWin(self, evt):
global testWin, testWinPos global testWin, testWinPos
testWinPos = testWin.GetPosition() testWinPos = testWin.GetPosition()
@@ -510,14 +621,15 @@ class XML_Tree(wxTreeCtrl):
if xxx.hasChildren and not self.ItemHasChildren(item): if xxx.hasChildren and not self.ItemHasChildren(item):
return false return false
return not (self.IsExpanded(item) and self.ItemHasChildren(item)) return not (self.IsExpanded(item) and self.ItemHasChildren(item))
# Pull-down # Pull-down
def OnRightDown(self, evt): def OnRightDown(self, evt):
# Setup menu # Setup menu
pullDownMenu.menu = wxMenu() menu = wxMenu()
item = self.GetSelection() item = self.GetSelection()
if not item.IsOk(): if not item.IsOk():
pullDownMenu.menu.Append(pullDownMenu.ID_EXPAND, 'Expand', 'Expand tree') menu.Append(pullDownMenu.ID_EXPAND, 'Expand', 'Expand tree')
else: else:
self.ctrl = evt.ControlDown() # save Ctrl state self.ctrl = evt.ControlDown() # save Ctrl state
m = wxMenu() # create menu m = wxMenu() # create menu
@@ -543,33 +655,31 @@ class XML_Tree(wxTreeCtrl):
m.Enable(pullDownMenu.ID_NEW_SPACER, false) m.Enable(pullDownMenu.ID_NEW_SPACER, false)
# Select correct label for create menu # Select correct label for create menu
if item == self.GetRootItem(): if item == self.GetRootItem():
pullDownMenu.menu.AppendMenu(wxNewId(), 'Create', m, 'Create top-level object') menu.AppendMenu(wxNewId(), 'Create', m, 'Create top-level object')
else: else:
if not needInsert: if not needInsert:
pullDownMenu.menu.AppendMenu(wxNewId(), 'Create child', m, menu.AppendMenu(wxNewId(), 'Create child', m,
'Create child object') 'Create child object')
else: else:
pullDownMenu.menu.AppendMenu(wxNewId(), 'Create Sibling', m, menu.AppendMenu(wxNewId(), 'Create Sibling', m,
'Create sibling of selected object') 'Create sibling of selected object')
pullDownMenu.menu.AppendSeparator() menu.AppendSeparator()
pullDownMenu.menu.Append(wxID_CUT, 'Cut', 'Cut to the clipboard') menu.Append(wxID_CUT, 'Cut', 'Cut to the clipboard')
pullDownMenu.menu.Append(wxID_COPY, 'Copy', 'Copy to the clipboard') menu.Append(wxID_COPY, 'Copy', 'Copy to the clipboard')
pullDownMenu.menu.Append(wxID_PASTE, 'Paste', 'Paste from the clipboard') menu.Append(wxID_PASTE, 'Paste', 'Paste from the clipboard')
pullDownMenu.menu.Append(pullDownMenu.ID_DELETE, menu.Append(pullDownMenu.ID_DELETE,
'Delete', 'Delete object') 'Delete', 'Delete object')
if item.IsOk() and self.ItemHasChildren(item): if item.IsOk() and self.ItemHasChildren(item):
pullDownMenu.menu.AppendSeparator() menu.AppendSeparator()
pullDownMenu.menu.Append(pullDownMenu.ID_EXPAND, 'Expand', 'Expand subtree') menu.Append(pullDownMenu.ID_EXPAND, 'Expand', 'Expand subtree')
self.PopupMenu(pullDownMenu.menu, evt.GetPosition()) self.PopupMenu(menu, evt.GetPosition())
pullDownMenu.menu.Destroy() menu.Destroy()
pullDownMenu.menu = None
# Clear tree # Clear tree
def Clear(self): def Clear(self):
self.DeleteAllItems() self.DeleteAllItems()
# Add minimal structure # Add minimal structure
root = self.AddRoot('XML tree') root = self.AddRoot('XML tree', self.rootImage)
self.Unselect() self.Unselect()
if self.dom: self.dom.unlink() if self.dom: self.dom.unlink()
self.dom = minidom.Document() self.dom = minidom.Document()
@@ -577,7 +687,7 @@ class XML_Tree(wxTreeCtrl):
# Create main node # Create main node
self.mainNode = self.dom.createElement('resource') self.mainNode = self.dom.createElement('resource')
self.dom.appendChild(self.mainNode) self.dom.appendChild(self.mainNode)
# Apply changes # Apply changes
def Apply(self, xxx, item): def Apply(self, xxx, item):
if not xxx: return if not xxx: return
@@ -585,7 +695,7 @@ class XML_Tree(wxTreeCtrl):
if xxx.undo: xxx.undo.unlink() if xxx.undo: xxx.undo.unlink()
xxx.undo = xxx.element.cloneNode(false) xxx.undo = xxx.element.cloneNode(false)
if xxx.hasName: if xxx.hasName:
name = GetRegistered('name').GetValue() name = panel.page1.FindWindowByName('data_name').GetValue()
if xxx.name != name: if xxx.name != name:
xxx.name = name xxx.name = name
xxx.element.setAttribute('name', name) xxx.element.setAttribute('name', name)
@@ -593,7 +703,7 @@ class XML_Tree(wxTreeCtrl):
if xxx.hasChild: prefix = '_' if xxx.hasChild: prefix = '_'
else: prefix = '' else: prefix = ''
for param, data in xxx.params.items(): for param, data in xxx.params.items():
value = GetRegistered(prefix + param).GetValue() value = panel.FindWindowByName(prefix + 'data_' + param).GetValue()
if param == 'content': if param == 'content':
# If number if items is not the same, recreate children # If number if items is not the same, recreate children
if len(value) != len(data): if len(value) != len(data):
@@ -611,6 +721,8 @@ class XML_Tree(wxTreeCtrl):
else: else:
for i in range(len(value)): for i in range(len(value)):
data[i].data = value[i] data[i].data = value[i]
elif param == 'font':
data.updateXML(value)
else: else:
data.data = value data.data = value
if xxx.hasChild: if xxx.hasChild:
@@ -622,10 +734,63 @@ class XML_Tree(wxTreeCtrl):
# Set global modified state # Set global modified state
frame.modified = true frame.modified = true
class PullDownMenu:
ID_NEW_PANEL = wxNewId()
ID_NEW_DIALOG = wxNewId()
ID_NEW_FRAME = wxNewId()
ID_NEW_MENU_BAR = wxNewId()
ID_NEW_MENU = wxNewId()
ID_NEW_STATIC_TEXT = wxNewId()
ID_NEW_TEXT_CTRL = wxNewId()
ID_NEW_BUTTON = wxNewId()
ID_NEW_BITMAP_BUTTON = wxNewId()
ID_NEW_RADIO_BUTTON = wxNewId()
ID_NEW_SPIN_BUTTON = wxNewId()
ID_NEW_STATIC_BOX = wxNewId()
ID_NEW_CHECK_BOX = wxNewId()
ID_NEW_RADIO_BOX = wxNewId()
ID_NEW_COMBO_BOX = wxNewId()
ID_NEW_LIST_BOX = wxNewId()
ID_NEW_STATIC_LINE = wxNewId()
ID_NEW_CHOICE = wxNewId()
ID_NEW_SLIDER = wxNewId()
ID_NEW_GAUGE = wxNewId()
ID_NEW_SCROLL_BAR = wxNewId()
ID_NEW_TREE_CTRL = wxNewId()
ID_NEW_LIST_CTRL = wxNewId()
ID_NEW_CHECK_LIST = wxNewId()
ID_NEW_NOTEBOOK = wxNewId()
ID_NEW_HTML_WINDOW = wxNewId()
ID_NEW_CALENDAR = wxNewId()
ID_NEW_BOX_SIZER = wxNewId()
ID_NEW_STATIC_BOX_SIZER = wxNewId()
ID_NEW_GRID_SIZER = wxNewId()
ID_NEW_FLEX_GRID_SIZER = wxNewId()
ID_NEW_SPACER = wxNewId()
ID_NEW_MENU = wxNewId()
ID_NEW_MENU_ITEM = wxNewId()
ID_NEW_SEPARATOR = wxNewId()
ID_NEW_LAST = wxNewId()
ID_EXPAND = wxNewId()
def __init__(self, parent):
self.ID_DELETE = parent.ID_DELETE
EVT_MENU_RANGE(parent, self.ID_NEW_PANEL,
self.ID_NEW_LAST, parent.OnCreate)
EVT_MENU(parent, self.ID_EXPAND, parent.OnExpand)
# We connect to tree, but process in frame
EVT_MENU_HIGHLIGHT_ALL(tree, parent.OnPullDownHighlight)
class Frame(wxFrame): class Frame(wxFrame):
def __init__(self, size): def __init__(self, size):
wxFrame.__init__(self, None, -1, '', size=size) wxFrame.__init__(self, None, -1, '', size=size)
self.CreateStatusBar() self.CreateStatusBar()
self.SetIcon(wxIconFromXPMData(images.getIconData()))
# Make menus # Make menus
menuBar = wxMenuBar() menuBar = wxMenuBar()
@@ -638,7 +803,7 @@ class Frame(wxFrame):
menu.AppendSeparator() menu.AppendSeparator()
menu.Append(wxID_EXIT, '&Quit\tCtrl-Q', 'Exit application') menu.Append(wxID_EXIT, '&Quit\tCtrl-Q', 'Exit application')
menuBar.Append(menu, '&File') menuBar.Append(menu, '&File')
menu = wxMenu() menu = wxMenu()
menu.Append(wxID_UNDO, '&Undo\tCtrl-Z', 'Undo') menu.Append(wxID_UNDO, '&Undo\tCtrl-Z', 'Undo')
menu.Append(wxID_REDO, '&Redo\tCtrl-R', 'Redo') menu.Append(wxID_REDO, '&Redo\tCtrl-R', 'Redo')
@@ -649,7 +814,7 @@ class Frame(wxFrame):
self.ID_DELETE = wxNewId() self.ID_DELETE = wxNewId()
menu.Append(self.ID_DELETE, '&Delete\tCtrl-D', 'Delete object') menu.Append(self.ID_DELETE, '&Delete\tCtrl-D', 'Delete object')
menuBar.Append(menu, '&Edit') menuBar.Append(menu, '&Edit')
menu = wxMenu() menu = wxMenu()
self.ID_REFRESH = wxNewId() self.ID_REFRESH = wxNewId()
menu.Append(self.ID_REFRESH, '&Refresh\tCtrl-R', 'Refresh view') menu.Append(self.ID_REFRESH, '&Refresh\tCtrl-R', 'Refresh view')
@@ -658,7 +823,7 @@ class Frame(wxFrame):
'Toggle auto-refresh mode', true) 'Toggle auto-refresh mode', true)
menu.Check(self.ID_AUTO_REFRESH, conf.autoRefresh) menu.Check(self.ID_AUTO_REFRESH, conf.autoRefresh)
menuBar.Append(menu, '&View') menuBar.Append(menu, '&View')
menu = wxMenu() menu = wxMenu()
menu.Append(wxID_ABOUT, 'About...', 'About XCRed') menu.Append(wxID_ABOUT, 'About...', 'About XCRed')
if debug: if debug:
@@ -671,8 +836,8 @@ class Frame(wxFrame):
self.SetMenuBar(menuBar) self.SetMenuBar(menuBar)
# Create toolbar # Create toolbar
tb = self.CreateToolBar()#wxTB_DOCKABLE | wxTB_FLAT) tb = self.CreateToolBar(wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT)
tb.SetToolBitmapSize((24,23)) tb.SetToolBitmapSize((24, 23))
tb.AddSimpleTool(wxID_NEW, images.getNewBitmap(), 'New', 'New file') tb.AddSimpleTool(wxID_NEW, images.getNewBitmap(), 'New', 'New file')
tb.AddSimpleTool(wxID_OPEN, images.getOpenBitmap(), 'Open', 'Open file') tb.AddSimpleTool(wxID_OPEN, images.getOpenBitmap(), 'Open', 'Open file')
tb.AddSimpleTool(wxID_SAVE, images.getSaveBitmap(), 'Save', 'Save file') tb.AddSimpleTool(wxID_SAVE, images.getSaveBitmap(), 'Save', 'Save file')
@@ -686,8 +851,8 @@ class Frame(wxFrame):
tb.AddSimpleTool(self.ID_AUTO_REFRESH, images.getAutoRefreshBitmap(), tb.AddSimpleTool(self.ID_AUTO_REFRESH, images.getAutoRefreshBitmap(),
'Auto-refresh', 'Toggle auto-refresh mode', true) 'Auto-refresh', 'Toggle auto-refresh mode', true)
tb.ToggleTool(self.ID_AUTO_REFRESH, conf.autoRefresh) tb.ToggleTool(self.ID_AUTO_REFRESH, conf.autoRefresh)
self.tb = tb
tb.Realize() tb.Realize()
self.tb = tb
# File # File
EVT_MENU(self, wxID_NEW, self.OnNew) EVT_MENU(self, wxID_NEW, self.OnNew)
@@ -715,85 +880,26 @@ class Frame(wxFrame):
EVT_UPDATE_UI(self, self.ID_DELETE, self.OnUpdateUI) EVT_UPDATE_UI(self, self.ID_DELETE, self.OnUpdateUI)
# Build interface # Build interface
splitter = wxSplitterWindow(self, -1) sizer = wxBoxSizer(wxVERTICAL)
sizer.Add(wxStaticLine(self, -1), 0, wxEXPAND)
splitter = wxSplitterWindow(self, -1, style=wxSP_3DSASH)
splitter.SetMinimumPaneSize(100)
# Create tree # Create tree
global tree global tree
tree = XML_Tree(splitter, -1) tree = XML_Tree(splitter, -1)
sys.modules['xxx'].tree = tree sys.modules['xxx'].tree = tree
# Create panel for parameters # Create panel for parameters
global panel global panel
#panel = wxPanel(self, -1) panel = Panel(splitter)
# Sizer for static box
#sizer = wxBoxSizer()
panel = Panel(splitter, -1)
sys.modules['params'].panel = panel
#sizer.Add(panel, 1, wxEXPAND)
#box = wxStaticBox(panel, -1, 'Parameters')
#boxSizer = wxStaticBoxSizer(box)
#boxSizer.Add(wxButton(panel, -1, 'BUTT ON'))
#sizer.Add(boxSizer, 1, wxEXPAND | wxALL, 10)
#panel.SetAutoLayout(true)
#panel.SetSizer(sizer)
# Set plitter windows # Set plitter windows
splitter.SplitVertically(tree, panel, 200) splitter.SplitVertically(tree, panel, 200)
#topSizer = wxBoxSizer() sizer.Add(splitter, 1, wxEXPAND)
#topSizer.Add(splitter, 1, wxEXPAND) self.SetAutoLayout(true)
#self.SetAutoLayout(true) self.SetSizer(sizer)
#self.SetSizer(topSizer)
# Init pull-down menu data # Init pull-down menu data
class MenuData: pass
global pullDownMenu global pullDownMenu
pullDownMenu = MenuData() pullDownMenu = PullDownMenu(self)
pullDownMenu.menu = None
pullDownMenu.ID_NEW_PANEL = wxNewId()
pullDownMenu.ID_NEW_DIALOG = wxNewId()
pullDownMenu.ID_NEW_FRAME = wxNewId()
pullDownMenu.ID_NEW_MENU_BAR = wxNewId()
pullDownMenu.ID_NEW_MENU = wxNewId()
pullDownMenu.ID_NEW_STATIC_TEXT = wxNewId()
pullDownMenu.ID_NEW_TEXT_CTRL = wxNewId()
pullDownMenu.ID_NEW_BUTTON = wxNewId()
pullDownMenu.ID_NEW_BITMAP_BUTTON = wxNewId()
pullDownMenu.ID_NEW_RADIO_BUTTON = wxNewId()
pullDownMenu.ID_NEW_SPIN_BUTTON = wxNewId()
pullDownMenu.ID_NEW_STATIC_BOX = wxNewId()
pullDownMenu.ID_NEW_CHECK_BOX = wxNewId()
pullDownMenu.ID_NEW_RADIO_BOX = wxNewId()
pullDownMenu.ID_NEW_COMBO_BOX = wxNewId()
pullDownMenu.ID_NEW_LIST_BOX = wxNewId()
pullDownMenu.ID_NEW_STATIC_LINE = wxNewId()
pullDownMenu.ID_NEW_CHOICE = wxNewId()
pullDownMenu.ID_NEW_SLIDER = wxNewId()
pullDownMenu.ID_NEW_GAUGE = wxNewId()
pullDownMenu.ID_NEW_SCROLL_BAR = wxNewId()
pullDownMenu.ID_NEW_TREE_CTRL = wxNewId()
pullDownMenu.ID_NEW_LIST_CTRL = wxNewId()
pullDownMenu.ID_NEW_CHECK_LIST = wxNewId()
pullDownMenu.ID_NEW_NOTEBOOK = wxNewId()
pullDownMenu.ID_NEW_HTML_WINDOW = wxNewId()
pullDownMenu.ID_NEW_CALENDAR = wxNewId()
pullDownMenu.ID_NEW_BOX_SIZER = wxNewId()
pullDownMenu.ID_NEW_STATIC_BOX_SIZER = wxNewId()
pullDownMenu.ID_NEW_GRID_SIZER = wxNewId()
pullDownMenu.ID_NEW_FLEX_GRID_SIZER = wxNewId()
pullDownMenu.ID_NEW_SPACER = wxNewId()
pullDownMenu.ID_NEW_MENU = wxNewId()
pullDownMenu.ID_NEW_MENU_ITEM = wxNewId()
pullDownMenu.ID_NEW_SEPARATOR = wxNewId()
pullDownMenu.ID_NEW_LAST = wxNewId()
pullDownMenu.ID_DELETE = self.ID_DELETE
pullDownMenu.ID_EXPAND = wxNewId()
EVT_MENU_RANGE(self, pullDownMenu.ID_NEW_PANEL,
pullDownMenu.ID_NEW_LAST, self.OnCreate)
EVT_MENU(self, pullDownMenu.ID_EXPAND, self.OnExpand)
# We connect to tree, but process in frame
EVT_MENU_HIGHLIGHT_ALL(tree, self.OnPullDownHighlight)
# Mapping from IDs to element names # Mapping from IDs to element names
self.createMap = { self.createMap = {
pullDownMenu.ID_NEW_PANEL: 'wxPanel', pullDownMenu.ID_NEW_PANEL: 'wxPanel',
@@ -809,13 +915,13 @@ class Frame(wxFrame):
pullDownMenu.ID_NEW_BITMAP_BUTTON: 'wxBitmapButton', pullDownMenu.ID_NEW_BITMAP_BUTTON: 'wxBitmapButton',
pullDownMenu.ID_NEW_RADIO_BUTTON: 'wxRadioButton', pullDownMenu.ID_NEW_RADIO_BUTTON: 'wxRadioButton',
pullDownMenu.ID_NEW_SPIN_BUTTON: 'wxSpinButton', pullDownMenu.ID_NEW_SPIN_BUTTON: 'wxSpinButton',
pullDownMenu.ID_NEW_STATIC_BOX: 'wxStaticBox', pullDownMenu.ID_NEW_STATIC_BOX: 'wxStaticBox',
pullDownMenu.ID_NEW_CHECK_BOX: 'wxCheckBox', pullDownMenu.ID_NEW_CHECK_BOX: 'wxCheckBox',
pullDownMenu.ID_NEW_RADIO_BOX: 'wxRadioBox', pullDownMenu.ID_NEW_RADIO_BOX: 'wxRadioBox',
pullDownMenu.ID_NEW_COMBO_BOX: 'wxComboBox', pullDownMenu.ID_NEW_COMBO_BOX: 'wxComboBox',
pullDownMenu.ID_NEW_LIST_BOX: 'wxListBox', pullDownMenu.ID_NEW_LIST_BOX: 'wxListBox',
pullDownMenu.ID_NEW_STATIC_LINE: 'wxStaticLine', pullDownMenu.ID_NEW_STATIC_LINE: 'wxStaticLine',
pullDownMenu.ID_NEW_CHOICE: 'wxChoice', pullDownMenu.ID_NEW_CHOICE: 'wxChoice',
pullDownMenu.ID_NEW_SLIDER: 'wxSlider', pullDownMenu.ID_NEW_SLIDER: 'wxSlider',
@@ -827,7 +933,7 @@ class Frame(wxFrame):
pullDownMenu.ID_NEW_NOTEBOOK: 'wxNotebook', pullDownMenu.ID_NEW_NOTEBOOK: 'wxNotebook',
pullDownMenu.ID_NEW_HTML_WINDOW: 'wxHtmlWindow', pullDownMenu.ID_NEW_HTML_WINDOW: 'wxHtmlWindow',
pullDownMenu.ID_NEW_CALENDAR: 'wxCalendar', pullDownMenu.ID_NEW_CALENDAR: 'wxCalendar',
pullDownMenu.ID_NEW_BOX_SIZER: 'wxBoxSizer', pullDownMenu.ID_NEW_BOX_SIZER: 'wxBoxSizer',
pullDownMenu.ID_NEW_STATIC_BOX_SIZER: 'wxStaticBoxSizer', pullDownMenu.ID_NEW_STATIC_BOX_SIZER: 'wxStaticBoxSizer',
pullDownMenu.ID_NEW_GRID_SIZER: 'wxGridSizer', pullDownMenu.ID_NEW_GRID_SIZER: 'wxGridSizer',
@@ -882,7 +988,7 @@ class Frame(wxFrame):
(pullDownMenu.ID_NEW_MENU_ITEM, 'MenuItem', 'Create menu item'), (pullDownMenu.ID_NEW_MENU_ITEM, 'MenuItem', 'Create menu item'),
(pullDownMenu.ID_NEW_SEPARATOR, 'Separator', 'Create separator'), (pullDownMenu.ID_NEW_SEPARATOR, 'Separator', 'Create separator'),
] ]
# Initialize # Initialize
self.Clear() self.Clear()
@@ -905,7 +1011,7 @@ class Frame(wxFrame):
self.Open(path) self.Open(path)
wxEndBusyCursor() wxEndBusyCursor()
self.SetStatusText('Ready') self.SetStatusText('Ready')
dlg.Destroy() dlg.Destroy()
def OnSaveOrSaveAs(self, evt): def OnSaveOrSaveAs(self, evt):
if evt.GetId() == wxID_SAVEAS or not self.dataFile: if evt.GetId() == wxID_SAVEAS or not self.dataFile:
@@ -914,9 +1020,12 @@ class Frame(wxFrame):
dlg = wxFileDialog(self, 'Save As', os.path.dirname(self.dataFile), dlg = wxFileDialog(self, 'Save As', os.path.dirname(self.dataFile),
defaultName, '*.xrc', defaultName, '*.xrc',
wxSAVE | wxOVERWRITE_PROMPT | wxCHANGE_DIR) wxSAVE | wxOVERWRITE_PROMPT | wxCHANGE_DIR)
if dlg.ShowModal() == wxID_CANCEL: return if dlg.ShowModal() == wxID_OK:
path = dlg.GetPath() path = dlg.GetPath()
dlg.Destroy() dlg.Destroy()
else:
dlg.Destroy()
return
else: else:
path = self.dataFile path = self.dataFile
self.SetStatusText('Saving...') self.SetStatusText('Saving...')
@@ -939,10 +1048,10 @@ class Frame(wxFrame):
xxx = MakeXXXFromDOM(tree.GetPyData(parent).treeObject(), elem) xxx = MakeXXXFromDOM(tree.GetPyData(parent).treeObject(), elem)
item = tree.InsertItem( parent, prev, xxx.treeObject().className, item = tree.InsertItem( parent, prev, xxx.treeObject().className,
data=wxTreeItemData(xxx) ) data=wxTreeItemData(xxx) )
def OnRedo(self, evt): def OnRedo(self, evt):
print '*** being implemented' print '*** being implemented'
def OnCut(self, evt): def OnCut(self, evt):
selected = tree.GetSelection() selected = tree.GetSelection()
# Undo info # Undo info
@@ -985,7 +1094,7 @@ class Frame(wxFrame):
appendChild = true appendChild = true
selected = tree.GetItemParent(selected) selected = tree.GetItemParent(selected)
# Expanded container (must have children) # Expanded container (must have children)
elif tree.IsExpanded(selected) and tree.ItemHasChildren(selected): elif tree.IsExpanded(selected) and tree.ItemHasChildren(selected):
appendChild = false appendChild = false
nextItem = tree.GetFirstChild(selected, 0)[0] nextItem = tree.GetFirstChild(selected, 0)[0]
parentLeaf = selected parentLeaf = selected
@@ -1111,11 +1220,9 @@ class Frame(wxFrame):
self.tb.ToggleTool(self.ID_AUTO_REFRESH, conf.autoRefresh) self.tb.ToggleTool(self.ID_AUTO_REFRESH, conf.autoRefresh)
def OnAbout(self, evt): def OnAbout(self, evt):
dlg = wxMessageDialog(self, '%s %s\n\nRoman Rolinsky <rolinsky@mema.ucl.ac.be>' % \ wxMessageDialog(self, '%s %s\n\nRoman Rolinsky <rolinsky@mema.ucl.ac.be>' % \
(progname, version), (progname, version),
'About %s' % progname, wxOK | wxCENTRE) 'About %s' % progname, wxOK | wxCENTRE).ShowModal()
dlg.ShowModal()
dlg.Destroy()
# Simple emulation of python command line # Simple emulation of python command line
def OnDebugCMD(self, evt): def OnDebugCMD(self, evt):
@@ -1146,7 +1253,7 @@ class Frame(wxFrame):
appendChild = true appendChild = true
selected = tree.GetItemParent(selected) selected = tree.GetItemParent(selected)
# Expanded container (must have children) # Expanded container (must have children)
elif tree.IsExpanded(selected) and tree.ItemHasChildren(selected): elif tree.IsExpanded(selected) and tree.ItemHasChildren(selected):
appendChild = false appendChild = false
nextItem = tree.GetFirstChild(selected, 0)[0] nextItem = tree.GetFirstChild(selected, 0)[0]
parentLeaf = selected parentLeaf = selected
@@ -1203,9 +1310,12 @@ class Frame(wxFrame):
def OnPullDownHighlight(self, evt): def OnPullDownHighlight(self, evt):
menuId = evt.GetMenuId() menuId = evt.GetMenuId()
help = '' if menuId != -1:
if menuId != -1: help = pullDownMenu.GetHelpString(menuId) menu = evt.GetEventObject()
self.SetStatusText(help) help = menu.GetHelpString(menuId)
self.SetStatusText(help)
else:
self.SetStatusText('')
def OnUpdateUI(self, evt): def OnUpdateUI(self, evt):
if evt.GetId() in [wxID_CUT, wxID_COPY, self.ID_DELETE]: if evt.GetId() in [wxID_CUT, wxID_COPY, self.ID_DELETE]:
@@ -1258,9 +1368,11 @@ class Frame(wxFrame):
self.SetTitle(progname + ': ' + os.path.basename(path)) self.SetTitle(progname + ': ' + os.path.basename(path))
except: except:
wxLogError('Error reading file: ' + path) wxLogError('Error reading file: ' + path)
raise
def Save(self, path): def Save(self, path):
try: try:
self.OnRefresh(wxCommandEvent())
memFile = MemoryFile(path) memFile = MemoryFile(path)
tree.dom.writexml(memFile) tree.dom.writexml(memFile)
memFile.close() memFile.close()
@@ -1268,14 +1380,13 @@ class Frame(wxFrame):
panel.SetModified(false) panel.SetModified(false)
except: except:
wxLogError('Error writing file: ' + path) wxLogError('Error writing file: ' + path)
raise
def AskSave(self): def AskSave(self):
if not (self.modified or panel.IsModified()): return true if not (self.modified or panel.IsModified()): return true
flags = wxICON_EXCLAMATION | wxYES_NO | wxCANCEL | wxCENTRE flags = wxICON_EXCLAMATION | wxYES_NO | wxCANCEL | wxCENTRE
dlg = wxMessageDialog( self, 'File is modified. Save before exit?', say = wxMessageDialog( self, 'File is modified. Save before exit?',
'Save before too late?', flags ) 'Save before too late?', flags ).ShowModal()
say = dlg.ShowModal()
dlg.Destroy()
if say == wxID_YES: if say == wxID_YES:
self.OnSaveOrSaveAs(wxCommandEvent(wxID_SAVE)) self.OnSaveOrSaveAs(wxCommandEvent(wxID_SAVE))
# If save was successful, modified flag is unset # If save was successful, modified flag is unset
@@ -1286,6 +1397,8 @@ class Frame(wxFrame):
return true return true
return false return false
################################################################################
class App(wxApp): class App(wxApp):
def OnInit(self): def OnInit(self):
self.SetAppName("xrced") self.SetAppName("xrced")

View File

@@ -1,89 +1,2 @@
<?xml version="1.0" ?> <?xml version="1.0" ?>
<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></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">
<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">
</object>
<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>
</object>
</resource>

View File

@@ -1,7 +1,8 @@
# Name: xxx.py (xxx is easy to distinguish from 'wx' :) ) # Name: xxx.py ('xxx' is easy to distinguish from 'wx' :) )
# Purpose: XML interface classes # Purpose: XML interface classes
# Author: Roman Rolinsky <rolinsky@mema.ucl.ac.be> # Author: Roman Rolinsky <rolinsky@mema.ucl.ac.be>
# Created: 22.08.2001 # Created: 22.08.2001
# RCS-ID: $Id$
from wxPython.wx import * from wxPython.wx import *
from wxPython.xrc import * from wxPython.xrc import *
@@ -12,23 +13,23 @@ from params import *
# Classes to interface DOM objects # Classes to interface DOM objects
class xxxObject: class xxxObject:
# Param ids for controls
ID_CHECK_PARAMS = wxNewId()
ID_TEXT_PARAMS = wxNewId()
# Default behavior # Default behavior
hasChildren = false # has children elements? hasChildren = false # has children elements?
hasStyle = true # almost everyone
hasName = true # has name attribute? hasName = true # has name attribute?
isSizer = hasChild = false isSizer = hasChild = false
# Style parameters (all optional)
styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'tooltip']
# Required paremeters: none by default # Required paremeters: none by default
required = [] required = []
# Default parameters with default values # Default parameters with default values
default = {} default = {}
# Parameter types # Parameter types
paramDict = {} paramDict = {}
# Additional styles # Window styles and extended styles
styles = [] winStyles = []
# Tree icon index # Tree icon index
image = -1 #image = -1
# Construct a new xxx object from DOM element # Construct a new xxx object from DOM element
# parent is parent xxx object (or None if none), element is DOM element object # parent is parent xxx object (or None if none), element is DOM element object
def __init__(self, parent, element): def __init__(self, parent, element):
@@ -45,9 +46,10 @@ class xxxObject:
if node.nodeType == minidom.Node.ELEMENT_NODE: if node.nodeType == minidom.Node.ELEMENT_NODE:
if node.tagName == 'object': if node.tagName == 'object':
continue # do nothing for object children here continue # do nothing for object children here
if not node.tagName in self.allParams: if not node.tagName in self.allParams and not node.tagName in self.styles:
print 'WARNING: unknown parameter for %s: %s' % \ print 'WARNING: unknown parameter for %s: %s' % \
(self.className, node.tagName) (self.className, node.tagName)
continue
if node.tagName == 'content': # has items if node.tagName == 'content': # has items
# Param value is a list of text nodes # Param value is a list of text nodes
l = [] l = []
@@ -68,6 +70,9 @@ class xxxObject:
node.removeChild(n) node.removeChild(n)
n.unlink() n.unlink()
self.params[node.tagName] = l self.params[node.tagName] = l
elif node.tagName == 'font': # has children
# we read and write all font parameters at once
self.params[node.tagName] = xxxFont(self, node)
else: # simple parameter else: # simple parameter
if not node.hasChildNodes(): if not node.hasChildNodes():
# If does not have child nodes, create empty text node # If does not have child nodes, create empty text node
@@ -81,37 +86,35 @@ class xxxObject:
# Remove all other nodes # Remove all other nodes
element.removeChild(node) element.removeChild(node)
node.unlink() node.unlink()
# Generate HTML # Generate HTML
def generateHtml(self, prefix=''): def generateHtml(self, prefix=''):
SetCurrentXXX(self) SetCurrentXXX(self)
html = '<table cellspacing=0 cellpadding=0><tr><td width=130>\ html = '<table cellspacing=0 cellpadding=0><tr><td width=120>\
<font size="+1"><b>%s</b></font></td>' % self.className <font size="+1"><b>%s</b></font></td>' % self.className
# Has id (name) attribute # Has id (name) attribute
if self.hasName: if self.hasName:
html += """\ html += """\
<td><wxp module="xxx" class="ParamText" width=150> <td><wxp module="xxx" class="ParamText" width=150>
<param name="id" value="%d"> <param name="id" value="%d">
<param name="name" value="text_name"> <param name="name" value="data_name">
<param name="value" value='("%s")'> <param name="value" value='("%s")'>
<param name="param" value="name"> </wxp></td>""" % (-1, self.name)
</wxp></td>""" % (self.ID_TEXT_PARAMS, self.name)
html += '</table><p>' html += '</table><p>'
html += '<table cellspacing=0 cellpadding=0>\n' html += '<table cellspacing=0 cellpadding=0>\n'
# Add required parameters # Add required parameters
for param in self.allParams: for param in self.allParams:
# Add checkbox or just text # Add checkbox or just text
if param in self.required: if param in self.required:
html += '<tr><td width=25></td><td width=110>%s: </td>' % param html += '<tr><td width=20></td><td width=100>%s: </td>' % param
else: # optional parameter else: # optional parameter
html += """\ html += """\
<tr><td width=20><wxp class="wxCheckBox"> <tr><td width=20><wxp class="wxCheckBox">
<param name="id" value="%d"> <param name="id" value="%d">
<param name="size" value="(20,-1)"> <param name="size" value="(20,-1)">
<param name="name" value="check_%s"> <param name="name" value="%s">
<param name="label" value=("")> <param name="label" value=("")>
</wxp></td><td width=110>%s: </td> </wxp></td><td width=100>%s: </td>
""" % (self.ID_CHECK_PARAMS, param, param + '&nbsp;') """ % (paramIDs[param], prefix + 'check_' + param, param)
# Add value part # Add value part
if self.params.has_key(param): if self.params.has_key(param):
if param == 'content': if param == 'content':
@@ -137,12 +140,10 @@ class xxxObject:
html += """\ html += """\
<td><wxp module="xxx" class="%s"> <td><wxp module="xxx" class="%s">
<param name="id" value="%d"> <param name="id" value="%d">
<param name="name" value="text_%s"> <param name="name" value="%s">
<param name="value" value="%s"> <param name="value" value="%s">
<param name="param" value="%s">
</wxp></td> </wxp></td>
""" % (typeClass, self.ID_TEXT_PARAMS, """ % (typeClass, -1, prefix + 'data_' + param, value)
prefix + param, value, prefix + param)
html += '</table>\n' html += '</table>\n'
return html return html
# Returns real tree object # Returns real tree object
@@ -161,6 +162,41 @@ class xxxObject:
################################################################################ ################################################################################
class xxxFont(xxxObject):
allParams = ['size', 'style', 'weight', 'family', 'underlined',
'face', 'encoding']
def __init__(self, parent, element):
xxxObject.__init__(self, parent, element)
self.parentNode = element # required to behave similar to DOM node
self.data = self.value()
def updateXML(self, value):
# `value' is a list of strings corresponding to all parameters
elem = self.element
for node in elem.childNodes:
elem.removeChild(node)
i = 0
self.params.clear()
for param in self.allParams:
if value[i]:
fontElem = tree.dom.createElement(param)
textNode = tree.dom.createTextNode(value[i])
self.params[param] = textNode
fontElem.appendChild(textNode)
elem.appendChild(fontElem)
i += 1
# Update data
self.data = self.value()
def value(self):
v = []
for p in self.allParams:
try:
v.append(str(self.params[p].data))
except KeyError:
v.append('')
return v
################################################################################
class xxxContainer(xxxObject): class xxxContainer(xxxObject):
hasChildren = true hasChildren = true
@@ -169,21 +205,30 @@ class xxxContainer(xxxObject):
class xxxPanel(xxxContainer): class xxxPanel(xxxContainer):
allParams = ['pos', 'size', 'style'] allParams = ['pos', 'size', 'style']
styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle',
'tooltip']
exStyles = ['wxWS_EX_VALIDATE_RECURSIVELY']
class xxxDialog(xxxContainer): class xxxDialog(xxxContainer):
allParams = ['title', 'pos', 'size', 'style'] allParams = ['title', 'pos', 'size', 'style']
required = ['title'] required = ['title']
styles = ['wxDIALOG_MODAL', 'wxCAPTION', 'wxDEFAULT_DIALOG_STYLE', winStyles = ['wxDIALOG_MODAL', 'wxCAPTION', 'wxDEFAULT_DIALOG_STYLE',
'wxRESIZE_BORDER', 'wxSYSTEM_MENU', 'wxTHICK_FRAME', 'wxSTAY_ON_TOP'] 'wxRESIZE_BORDER', 'wxSYSTEM_MENU', 'wxTHICK_FRAME', 'wxSTAY_ON_TOP']
styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle',
'tooltip']
exStyles = ['wxWS_EX_VALIDATE_RECURSIVELY']
class xxxFrame(xxxContainer): class xxxFrame(xxxContainer):
allParams = ['title', 'centered', 'pos', 'size', 'style'] allParams = ['title', 'centered', 'pos', 'size', 'style']
paramDict = {'centered': ParamBool} paramDict = {'centered': ParamBool}
required = ['title'] required = ['title']
styles = ['wxDEFAULT_FRAME_STYLE', 'wxICONIZE', 'wxCAPTION', 'wxMINIMIZE', winStyles = ['wxDEFAULT_FRAME_STYLE', 'wxICONIZE', 'wxCAPTION', 'wxMINIMIZE',
'wxICONIZE', 'wxMINIMIZE_BOX', 'wxMAXIMIZE', 'wxMAXIMIZE_BOX', 'wxICONIZE', 'wxMINIMIZE_BOX', 'wxMAXIMIZE', 'wxMAXIMIZE_BOX',
'wxSTAY_ON_TOP', 'wxSYSTEM_MENU', 'wxRESIZE_BORDER', 'wxSTAY_ON_TOP', 'wxSYSTEM_MENU', 'wxRESIZE_BORDER',
'wxFRAME_FLOAT_ON_PARENT', 'wxFRAME_TOOL_WINDOW'] 'wxFRAME_FLOAT_ON_PARENT', 'wxFRAME_TOOL_WINDOW']
styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle',
'tooltip']
exStyles = ['wxWS_EX_VALIDATE_RECURSIVELY']
################################################################################ ################################################################################
# Controls # Controls
@@ -191,15 +236,15 @@ class xxxFrame(xxxContainer):
class xxxStaticText(xxxObject): class xxxStaticText(xxxObject):
allParams = ['label', 'pos', 'size', 'style'] allParams = ['label', 'pos', 'size', 'style']
required = ['label'] required = ['label']
styles = ['wxALIGN_LEFT', 'wxALIGN_RIGHT', 'wxALIGN_CENTRE', 'wxST_NO_AUTORESIZE'] winStyles = ['wxALIGN_LEFT', 'wxALIGN_RIGHT', 'wxALIGN_CENTRE', 'wxST_NO_AUTORESIZE']
class xxxStaticLine(xxxObject): class xxxStaticLine(xxxObject):
allParams = ['pos', 'size', 'style'] allParams = ['pos', 'size', 'style']
styles = ['wxLI_HORIZONTAL', 'wxLI_VERTICAL'] winStyles = ['wxLI_HORIZONTAL', 'wxLI_VERTICAL']
class xxxTextCtrl(xxxObject): class xxxTextCtrl(xxxObject):
allParams = ['value', 'pos', 'size', 'style'] allParams = ['value', 'pos', 'size', 'style']
styles = ['wxTE_PROCESS_ENTER', 'wxTE_PROCESS_TAB', 'wxTE_MULTILINE', winStyles = ['wxTE_PROCESS_ENTER', 'wxTE_PROCESS_TAB', 'wxTE_MULTILINE',
'wxTE_PASSWORD', 'wxTE_READONLY'] 'wxTE_PASSWORD', 'wxTE_READONLY']
class xxxChoice(xxxObject): class xxxChoice(xxxObject):
@@ -214,24 +259,24 @@ class xxxSlider(xxxObject):
'linesize': ParamInt, 'thumb': ParamInt, 'thumb': ParamInt, 'linesize': ParamInt, 'thumb': ParamInt, 'thumb': ParamInt,
'tick': ParamInt, 'selmin': ParamInt, 'selmax': ParamInt} 'tick': ParamInt, 'selmin': ParamInt, 'selmax': ParamInt}
required = ['value', 'min', 'max'] required = ['value', 'min', 'max']
styles = ['wxSL_HORIZONTAL', 'wxSL_VERTICAL', 'wxSL_AUTOTICKS', 'wxSL_LABELS', winStyles = ['wxSL_HORIZONTAL', 'wxSL_VERTICAL', 'wxSL_AUTOTICKS', 'wxSL_LABELS',
'wxSL_LEFT', 'wxSL_RIGHT', 'wxSL_TOP', 'wxSL_SELRANGE'] 'wxSL_LEFT', 'wxSL_RIGHT', 'wxSL_TOP', 'wxSL_SELRANGE']
class xxxGauge(xxxObject): class xxxGauge(xxxObject):
allParams = ['range', 'pos', 'size', 'style', 'value', 'shadow', 'bezel'] allParams = ['range', 'pos', 'size', 'style', 'value', 'shadow', 'bezel']
paramDict = {'range': ParamInt, 'value': ParamInt, paramDict = {'range': ParamInt, 'value': ParamInt,
'shadow': ParamInt, 'bezel': ParamInt} 'shadow': ParamInt, 'bezel': ParamInt}
styles = ['wxGA_HORIZONTAL', 'wxGA_VERTICAL', 'wxGA_PROGRESSBAR', 'wxGA_SMOOTH'] winStyles = ['wxGA_HORIZONTAL', 'wxGA_VERTICAL', 'wxGA_PROGRESSBAR', 'wxGA_SMOOTH']
class xxxScrollBar(xxxObject): class xxxScrollBar(xxxObject):
allParams = ['pos', 'size', 'style', 'value', 'thumbsize', 'range', 'pagesize'] allParams = ['pos', 'size', 'style', 'value', 'thumbsize', 'range', 'pagesize']
paramDict = {'value': ParamInt, 'range': ParamInt, 'thumbsize': ParamInt, paramDict = {'value': ParamInt, 'range': ParamInt, 'thumbsize': ParamInt,
'pagesize': ParamInt} 'pagesize': ParamInt}
styles = ['wxSB_HORIZONTAL', 'wxSB_VERTICAL'] winStyles = ['wxSB_HORIZONTAL', 'wxSB_VERTICAL']
class xxxListCtrl(xxxObject): class xxxListCtrl(xxxObject):
allParams = ['pos', 'size', 'style'] allParams = ['pos', 'size', 'style']
styles = ['wxLC_LIST', 'wxLC_REPORT', 'wxLC_ICON', 'wxLC_SMALL_ICON', winStyles = ['wxLC_LIST', 'wxLC_REPORT', 'wxLC_ICON', 'wxLC_SMALL_ICON',
'wxLC_ALIGN_TOP', 'wxLC_ALIGN_LEFT', 'wxLC_AUTOARRANGE', 'wxLC_ALIGN_TOP', 'wxLC_ALIGN_LEFT', 'wxLC_AUTOARRANGE',
'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']
@@ -241,13 +286,13 @@ xxxCheckList = xxxListCtrl
class xxxTreeCtrl(xxxObject): class xxxTreeCtrl(xxxObject):
allParams = ['pos', 'size', 'style'] allParams = ['pos', 'size', 'style']
styles = ['wxTR_HAS_BUTTONS', 'wxTR_NO_LINES', 'wxTR_LINES_AT_ROOT', winStyles = ['wxTR_HAS_BUTTONS', 'wxTR_NO_LINES', 'wxTR_LINES_AT_ROOT',
'wxTR_EDIT_LABELS', 'wxTR_MULTIPLE'] 'wxTR_EDIT_LABELS', 'wxTR_MULTIPLE']
class xxxHtmlWindow(xxxObject): class xxxHtmlWindow(xxxObject):
allParams = ['pos', 'size', 'style', 'borders', 'url', 'htmlcode'] allParams = ['pos', 'size', 'style', 'borders', 'url', 'htmlcode']
paramDict = {'borders': ParamInt} paramDict = {'borders': ParamInt}
styles = ['wxHW_SCROLLBAR_NEVER', 'wxHW_SCROLLBAR_AUTO'] winStyles = ['wxHW_SCROLLBAR_NEVER', 'wxHW_SCROLLBAR_AUTO']
class xxxCalendar(xxxObject): class xxxCalendar(xxxObject):
allParams = ['pos', 'size', 'style'] allParams = ['pos', 'size', 'style']
@@ -255,7 +300,7 @@ class xxxCalendar(xxxObject):
class xxxNotebook(xxxContainer): class xxxNotebook(xxxContainer):
allParams = ['usenotebooksizer', 'pos', 'size', 'style'] allParams = ['usenotebooksizer', 'pos', 'size', 'style']
paramDict = {'usenotebooksizer': ParamBool} paramDict = {'usenotebooksizer': ParamBool}
styles = ['wxNB_FIXEDWIDTH', 'wxNB_LEFT', 'wxNB_RIGHT', 'wxNB_BOTTOM'] winStyles = ['wxNB_FIXEDWIDTH', 'wxNB_LEFT', 'wxNB_RIGHT', 'wxNB_BOTTOM']
################################################################################ ################################################################################
# Buttons # Buttons
@@ -264,23 +309,23 @@ class xxxButton(xxxObject):
allParams = ['label', 'default', 'pos', 'size', 'style'] allParams = ['label', 'default', 'pos', 'size', 'style']
paramDict = {'default': ParamBool} paramDict = {'default': ParamBool}
required = ['label'] required = ['label']
styles = ['wxBU_LEFT', 'wxBU_TOP', 'wxBU_RIGHT', 'wxBU_BOTTOM'] winStyles = ['wxBU_LEFT', 'wxBU_TOP', 'wxBU_RIGHT', 'wxBU_BOTTOM']
class xxxBitmapButton(xxxObject): class xxxBitmapButton(xxxObject):
allParams = ['bitmap', 'selected', 'focus', 'disabled', 'default', allParams = ['bitmap', 'selected', 'focus', 'disabled', 'default',
'pos', 'size', 'style'] 'pos', 'size', 'style']
required = ['bitmap'] required = ['bitmap']
styles = ['wxBU_LEFT', 'wxBU_TOP', 'wxBU_RIGHT', 'wxBU_BOTTOM'] winStyles = ['wxBU_LEFT', 'wxBU_TOP', 'wxBU_RIGHT', 'wxBU_BOTTOM']
class xxxRadioButton(xxxObject): class xxxRadioButton(xxxObject):
allParams = ['label', 'value', 'pos', 'size', 'style'] allParams = ['label', 'value', 'pos', 'size', 'style']
paramDict = {'value': ParamBool} paramDict = {'value': ParamBool}
required = ['label'] required = ['label']
styles = ['wxRB_GROUP'] winStyles = ['wxRB_GROUP']
class xxxSpinButton(xxxObject): class xxxSpinButton(xxxObject):
allParams = ['pos', 'size', 'style'] allParams = ['pos', 'size', 'style']
styles = ['wxSP_HORIZONTAL', 'wxSP_VERTICAL', 'wxSP_ARROW_KEYS', 'wxSP_WRAP'] winStyles = ['wxSP_HORIZONTAL', 'wxSP_VERTICAL', 'wxSP_ARROW_KEYS', 'wxSP_WRAP']
################################################################################ ################################################################################
# Boxes # Boxes
@@ -293,7 +338,7 @@ class xxxRadioBox(xxxObject):
allParams = ['label', 'content', 'selection', 'dimension', 'pos', 'size', 'style'] allParams = ['label', 'content', 'selection', 'dimension', 'pos', 'size', 'style']
paramDict = {'dimension': ParamInt} paramDict = {'dimension': ParamInt}
required = ['label', 'content'] required = ['label', 'content']
styles = ['wxRA_SPECIFY_ROWS', 'wxRA_SPECIFY_COLS'] winStyles = ['wxRA_SPECIFY_ROWS', 'wxRA_SPECIFY_COLS']
class xxxCheckBox(xxxObject): class xxxCheckBox(xxxObject):
allParams = ['label', 'pos', 'size', 'style'] allParams = ['label', 'pos', 'size', 'style']
@@ -302,20 +347,20 @@ class xxxCheckBox(xxxObject):
class xxxComboBox(xxxObject): class xxxComboBox(xxxObject):
allParams = ['content', 'selection', 'value', 'pos', 'size', 'style'] allParams = ['content', 'selection', 'value', 'pos', 'size', 'style']
required = ['content'] required = ['content']
styles = ['wxCB_SIMPLE', 'wxCB_DROPDOWN', 'wxCB_READONLY', 'wxCB_DROPDOWN', winStyles = ['wxCB_SIMPLE', 'wxCB_DROPDOWN', 'wxCB_READONLY', 'wxCB_DROPDOWN',
'wxCB_SORT'] 'wxCB_SORT']
class xxxListBox(xxxObject): class xxxListBox(xxxObject):
allParams = ['content', 'selection', 'pos', 'size', 'style'] allParams = ['content', 'selection', 'pos', 'size', 'style']
required = ['content'] required = ['content']
styles = ['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']
################################################################################ ################################################################################
# Sizers # Sizers
class xxxSizer(xxxContainer): class xxxSizer(xxxContainer):
hasName = false hasName = hasStyle = false
paramDict = {'orient': ParamOrient} paramDict = {'orient': ParamOrient}
isSizer = true isSizer = true
@@ -344,10 +389,7 @@ class xxxFlexGridSizer(xxxGridSizer):
# Container with only one child. # Container with only one child.
# Not shown in tree. # Not shown in tree.
class xxxChildContainer(xxxObject): class xxxChildContainer(xxxObject):
# Special param ids hasName = hasStyle = false
ID_CHECK_PARAMS = wxNewId()
ID_TEXT_PARAMS = wxNewId()
hasName = false
hasChild = true hasChild = true
def __init__(self, parent, element): def __init__(self, parent, element):
xxxObject.__init__(self, parent, element) xxxObject.__init__(self, parent, element)
@@ -396,7 +438,7 @@ class xxxNotebookPage(xxxChildContainer):
self.child.allParams.remove('size') self.child.allParams.remove('size')
class xxxSpacer(xxxObject): class xxxSpacer(xxxObject):
hasName = false hasName = hasStyle = false
allParams = ['size', 'option', 'flag', 'border'] allParams = ['size', 'option', 'flag', 'border']
paramDict = {'option': ParamInt} paramDict = {'option': ParamInt}
default = {'size': '0,0'} default = {'size': '0,0'}
@@ -413,9 +455,11 @@ class xxxMenuItem(xxxObject):
default = {'label': ''} default = {'label': ''}
class xxxSeparator(xxxObject): class xxxSeparator(xxxObject):
hasName = false hasName = hasStyle = false
allParams = [] allParams = []
################################################################################
xxxDict = { xxxDict = {
'wxPanel': xxxPanel, 'wxPanel': xxxPanel,
'wxDialog': xxxDialog, 'wxDialog': xxxDialog,
@@ -460,6 +504,17 @@ xxxDict = {
'separator': xxxSeparator, 'separator': xxxSeparator,
} }
# Create IDs for all parameters of all classes
paramIDs = {'fg': wxNewId(), 'bg': wxNewId(), 'exstyle': wxNewId(), 'font': wxNewId(),
'enabled': wxNewId(), 'focused': wxNewId(), 'hidden': wxNewId(),
'tooltip': wxNewId()
}
for cl in xxxDict.values():
for param in cl.allParams + cl.paramDict.keys():
if not paramIDs.has_key(param):
paramIDs[param] = wxNewId()
################################################################################
# Helper functions # Helper functions
# Test for object elements # Test for object elements