self.ID_BUTTON = wxNewId()
self.SetBackgroundColour(panel.GetBackgroundColour())
sizer = wxBoxSizer()
- self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=buttonSize)
+ self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=(65,-1))
sizer.Add(self.text, 0, wxRIGHT, 5)
self.button = wxPanel(self, self.ID_BUTTON, wxDefaultPosition, wxSize(40, -1))
sizer.Add(self.button, 0, wxGROW)
EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
EVT_LEFT_DOWN(self.button, self.OnLeftDown)
def GetValue(self):
- return self.value
+ return self.text.GetValue()
def SetValue(self, value):
self.freeze = true
if not value: value = '#FFFFFF'
- self.value = value
self.text.SetValue(str(value)) # update text ctrl
colour = wxColour(int(value[1:3], 16), int(value[3:5], 16), int(value[5:7], 16))
self.button.SetBackgroundColour(colour)
def OnChange(self, evt):
if self.freeze: return
self.SetModified()
- self.textModified = true
evt.Skip()
def OnPaintButton(self, evt):
dc = wxPaintDC(self.button)
size = self.button.GetSize()
dc.DrawRectangle(0, 0, size.x, size.y)
def OnLeftDown(self, evt):
- dlg = wxColourDialog(self)
+ data = wxColourData()
+ data.SetColour(self.GetValue())
+ dlg = wxColourDialog(self, data)
if dlg.ShowModal() == wxID_OK:
self.SetValue('#%02X%02X%02X' % dlg.GetColourData().GetColour().Get())
self.SetModified()
- self.textModified = false
dlg.Destroy()
################################################################################
from wxPython.wx import *
from wxPython.xrc import *
-from wxPython.html import *
+from wxPython.html import wxHtmlWindow
from xml.dom import minidom
import os
import getopt
modernFont = wxFont(10, wxMODERN, wxNORMAL, wxNORMAL)
progname = 'XRCed'
-version = '0.0.7-2'
+version = '0.0.7-3'
# Local modules
from xxx import *
else:
# Remove page if exists
if self.GetPageCount() == 2:
+ self.SetSelection(0)
+ self.page1.Refresh()
self.RemovePage(1)
def Clear(self):
self.SetData(None)
present = param in xxx.params.keys()
check = self.checks[param]
check.SetValue(present)
- control = self.controls[param]
+ w = self.controls[param]
+ w.modified = false
if present:
- control.SetValue(xxx.params[param].value())
+ w.SetValue(xxx.params[param].value())
else:
- control.SetValue('')
- control.Enable(present)
+ w.SetValue('')
+ w.Enable(present)
self.SetModified(false)
################################################################################
self.SetBackgroundColour(wxColour(224, 248, 224))
EVT_TREE_SEL_CHANGED(self, self.GetId(), self.OnSelChanged)
# One works on Linux, another on Windows
- if wxGetOsVersion()[1] == 1:
+ if wxGetOsVersion()[0] == wxGTK:
EVT_TREE_ITEM_ACTIVATED(self, self.GetId(), self.OnItemActivated)
else:
EVT_LEFT_DCLICK(self, self.OnDClick)
except:
print 'ERROR: MakeXXXFromDom(%s, %s)' % (xxxParent, node)
raise
-# return
treeObj = xxx.treeObject()
# Append tree item
item = self.AppendItem(itemParent, treeObj.treeName(),
if panel.IsModified():
self.Apply(xxx, oldItem)
#if conf.autoRefresh:
- if testWin and not tree.IsHighlatable(oldItem):
- if testWin.highLight:
+ if testWin:
+ if testWin.highLight and not tree.IsHighlatable(oldItem):
testWin.highLight.Remove()
self.needUpdate = true
status = 'Changes were applied'
icon = wxIcon(os.path.join(sys.path[0], 'xrced.ico'), wxBITMAP_TYPE_ICO)
self.SetIcon(icon)
- # Defaults
- self.sashPos = 100
- self.panelX = self.panelY = -1
- self.panelWidth = 300
- self.panelHeight = 200
-
- # Idle flas
+ # Idle flag
self.inIdle = false
# Make menus
'Refresh', 'Refresh view')
tb.AddSimpleTool(self.ID_AUTO_REFRESH, images.getAutoRefreshBitmap(),
'Auto-refresh', 'Toggle auto-refresh mode', true)
- if wxGetOsVersion()[1] == 1:
+ if wxGetOsVersion()[0] == wxGTK:
tb.AddSeparator() # otherwise auto-refresh sticks in status line
tb.ToggleTool(self.ID_AUTO_REFRESH, conf.autoRefresh)
tb.Realize()
self.tb = tb
+ self.minWidth = tb.GetSize()[0] # minimal width is the size of toolbar
# File
EVT_MENU(self, wxID_NEW, self.OnNew)
conf.embedPanel = evt.IsChecked()
if conf.embedPanel:
# Remember last dimentions
- self.panelWidth, self.panelHeight = panel.GetSize()
+ conf.panelX, conf.panelY = self.miniFrame.GetPosition()
+ conf.panelWidth, conf.panelHeight = self.miniFrame.GetSize()
+ size = self.GetSize()
+ pos = self.GetPosition()
+ sizePanel = panel.GetSize()
panel.Reparent(self.splitter)
self.miniFrame.GetSizer().RemoveWindow(panel)
- self.splitter.SplitVertically(tree, panel, self.sashPos)
+ wxYield()
+ # Widen
+ self.SetDimensions(pos.x, pos.y, size.x + sizePanel.x, size.y)
+ self.splitter.SplitVertically(tree, panel, conf.sashPos)
self.miniFrame.Show(false)
else:
- self.sashPos = self.splitter.GetSashPosition()
+ conf.sashPos = self.splitter.GetSashPosition()
+ pos = self.GetPosition()
+ size = self.GetSize()
+ sizePanel = panel.GetSize()
self.splitter.Unsplit(panel)
sizer = self.miniFrame.GetSizer()
panel.Reparent(self.miniFrame)
panel.Show(true)
sizer.Add(panel, 1, wxEXPAND)
self.miniFrame.Show(true)
- self.miniFrame.SetSize((self.panelWidth, self.panelHeight))
+ self.miniFrame.SetDimensions(conf.panelX, conf.panelY,
+ conf.panelWidth, conf.panelHeight)
+ wxYield()
+ # Reduce width
+ self.SetDimensions(pos.x, pos.y,
+ max(size.x - sizePanel.x, self.minWidth), size.y)
def OnTest(self, evt):
if not tree.selection: return # key pressed event
evt.Enable((self.clipboard and tree.selection) != None)
elif evt.GetId() == self.ID_TEST:
evt.Enable(tree.selection != tree.root)
- elif evt.GetId() == self.ID_REFRESH:
- evt.Enable(testWin != None)
def OnIdle(self, evt):
if self.inIdle: return # Recursive call protection
if testWin: testWin.Destroy()
# Destroy cached windows
panel.cacheParent.Destroy()
-# for w in panel.styleCache.values(): w.Destroy()
if not panel.GetPageCount() == 2:
panel.page2.Destroy()
conf.x, conf.y = self.GetPosition()
conf.width, conf.height = self.GetSize()
if conf.embedPanel:
conf.sashPos = self.splitter.GetSashPosition()
- conf.panelWidth, conf.panelHeight = self.panelWidth, self.panelHeight
else:
- conf.sashPos = self.sashPos
conf.panelX, conf.panelY = self.miniFrame.GetPosition()
conf.panelWidth, conf.panelHeight = self.miniFrame.GetSize()
evt.Skip()
self.OnRefresh(wxCommandEvent())
f = open(path, 'w')
# Make temporary copy
- self.domCopy = domCopy = tree.dom.cloneNode(true)
- self.Indent(domCopy.getElementsByTagName('resource')[0])
- domCopy.writexml(f)
-# domCopy.unlink()
- self.domCopy = None
+ # !!! We can't clone dom node, it works only once
+ #self.domCopy = tree.dom.cloneNode(true)
+ self.domCopy = minidom.Document()
+ mainNode = self.domCopy.appendChild(tree.mainNode.cloneNode(true))
+ self.Indent(mainNode)
+ self.domCopy.writexml(f)
f.close()
+ self.domCopy.unlink()
+ self.domCopy = None
self.modified = false
panel.SetModified(false)
except:
from params import *
-# Parameter value class
-class xxxParam:
- # Standard use: for text nodes
+# Base class for interface parameter classes
+class xxxNode:
def __init__(self, node):
self.node = node
+ def remove(self):
+ self.node.parentNode.removeChild(self.node)
+ self.node.unlink()
+
+# Generic (text) parameter class
+class xxxParam(xxxNode):
+ # Standard use: for text nodes
+ def __init__(self, node):
+ xxxNode.__init__(self, node)
if not node.hasChildNodes():
# If does not have child nodes, create empty text node
text = tree.dom.createTextNode('')
return self.textNode.data
def update(self, value):
self.textNode.data = value
- def remove(self):
- self.node.parentNode.removeChild(self.node)
- self.node.unlink()
# Integer parameter
class xxxParamInt(xxxParam):
self.textNode.data = str(value)
# Content parameter
-class xxxParamContent:
+class xxxParamContent(xxxNode):
def __init__(self, node):
- self.node = node
+ xxxNode.__init__(self, node)
data, l = [], [] # data is needed to quicker value retrieval
nodes = node.childNodes[:] # make a copy of the child list
for n in nodes:
self.data = value
# Content parameter for checklist
-class xxxParamContentCheckList:
+class xxxParamContentCheckList(xxxNode):
def __init__(self, node):
- self.node = node
+ xxxNode.__init__(self, node)
data, l = [], [] # data is needed to quicker value retrieval
nodes = node.childNodes[:] # make a copy of the child list
for n in nodes:
################################################################################
-# This is a little special
-class xxxParamFont(xxxObject):
+# This is a little special: it is both xxxObject and xxxNode
+class xxxParamFont(xxxObject, xxxNode):
allParams = ['size', 'style', 'weight', 'family', 'underlined',
'face', 'encoding']
def __init__(self, parent, element):
xxxObject.__init__(self, parent, element)
+ xxxNode.__init__(self, element)
self.parentNode = parent # required to behave similar to DOM node
v = []
for p in self.allParams:
self.data = v
def value(self):
return self.data
- def remove(self):
- self.parentNode.removeChild(self.element)
- self.element.unlink()
################################################################################