From: Robin Dunn <robin@alldunn.com> Date: Fri, 8 Mar 2002 17:55:41 +0000 (+0000) Subject: Yet another update of XRCed. Fixes some display issues and some minor X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/c1beeb57cf1ffdfcd07b3039de324ea68e8c41b1?ds=sidebyside Yet another update of XRCed. Fixes some display issues and some minor buglets. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14494 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/wxPython/tools/XRCed/params.py b/wxPython/tools/XRCed/params.py index 93b8d2fb3e..319034e02e 100644 --- a/wxPython/tools/XRCed/params.py +++ b/wxPython/tools/XRCed/params.py @@ -144,7 +144,7 @@ class ParamColour(PPanel): 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) @@ -156,11 +156,10 @@ class ParamColour(PPanel): 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) @@ -169,7 +168,6 @@ class ParamColour(PPanel): def OnChange(self, evt): if self.freeze: return self.SetModified() - self.textModified = true evt.Skip() def OnPaintButton(self, evt): dc = wxPaintDC(self.button) @@ -179,11 +177,12 @@ class ParamColour(PPanel): 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() ################################################################################ diff --git a/wxPython/tools/XRCed/xrced.py b/wxPython/tools/XRCed/xrced.py index 5b45307ad0..503c1b1b0f 100644 --- a/wxPython/tools/XRCed/xrced.py +++ b/wxPython/tools/XRCed/xrced.py @@ -6,7 +6,7 @@ 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 @@ -27,7 +27,7 @@ else: modernFont = wxFont(10, wxMODERN, wxNORMAL, wxNORMAL) progname = 'XRCed' -version = '0.0.7-2' +version = '0.0.7-3' # Local modules from xxx import * @@ -183,6 +183,8 @@ class Panel(wxNotebook): else: # Remove page if exists if self.GetPageCount() == 2: + self.SetSelection(0) + self.page1.Refresh() self.RemovePage(1) def Clear(self): self.SetData(None) @@ -370,12 +372,13 @@ class StylePage(ParamPage): 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) ################################################################################ @@ -422,7 +425,7 @@ class XML_Tree(wxTreeCtrl): 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) @@ -523,7 +526,6 @@ class XML_Tree(wxTreeCtrl): except: print 'ERROR: MakeXXXFromDom(%s, %s)' % (xxxParent, node) raise -# return treeObj = xxx.treeObject() # Append tree item item = self.AppendItem(itemParent, treeObj.treeName(), @@ -609,8 +611,8 @@ class XML_Tree(wxTreeCtrl): 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' @@ -998,13 +1000,7 @@ class Frame(wxFrame): 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 @@ -1075,11 +1071,12 @@ class Frame(wxFrame): '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) @@ -1527,20 +1524,35 @@ class Frame(wxFrame): 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 @@ -1694,8 +1706,6 @@ class Frame(wxFrame): 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 @@ -1724,16 +1734,13 @@ class Frame(wxFrame): 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() @@ -1792,12 +1799,15 @@ class Frame(wxFrame): 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: diff --git a/wxPython/tools/XRCed/xxx.py b/wxPython/tools/XRCed/xxx.py index 7dfdeb4900..cf141ee949 100644 --- a/wxPython/tools/XRCed/xxx.py +++ b/wxPython/tools/XRCed/xxx.py @@ -11,11 +11,19 @@ import wxPython.lib.wxpTag 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('') @@ -29,9 +37,6 @@ class xxxParam: 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): @@ -48,9 +53,9 @@ 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: @@ -92,9 +97,9 @@ class xxxParamContent: 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: @@ -213,12 +218,13 @@ class xxxObject: ################################################################################ -# 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: @@ -248,9 +254,6 @@ class xxxParamFont(xxxObject): self.data = v def value(self): return self.data - def remove(self): - self.parentNode.removeChild(self.element) - self.element.unlink() ################################################################################