-v output version info and exit
"""
-
from globals import *
import os, sys, getopt, re, traceback, tempfile, shutil
xxxMenuBar:'MENUBAR', xxxMenu:'MENU', xxxToolBar:'TOOLBAR',
xxxWizard:'WIZARD'}
+defaultName = 'UNTITLED.xrc'
+
################################################################################
# ScrolledMessageDialog - modified from wxPython lib to set fixed-width font
EVT_MENU(self, self.ID_README, self.OnReadme)
# Update events
+ EVT_UPDATE_UI(self, wxID_SAVE, self.OnUpdateUI)
EVT_UPDATE_UI(self, wxID_CUT, self.OnUpdateUI)
EVT_UPDATE_UI(self, wxID_COPY, self.OnUpdateUI)
EVT_UPDATE_UI(self, wxID_PASTE, self.OnUpdateUI)
# !!! frame styles are broken
# Miniframe for not embedded mode
- miniFrame = wxFrame(self, -1, 'Properties Panel',
+ miniFrame = wxFrame(self, -1, 'Properties & Style',
(conf.panelX, conf.panelY),
(conf.panelWidth, conf.panelHeight))
self.miniFrame = miniFrame
def OnSaveOrSaveAs(self, evt):
if evt.GetId() == wxID_SAVEAS or not self.dataFile:
- if self.dataFile: defaultName = ''
- else: defaultName = 'UNTITLED.xrc'
+ if self.dataFile: name = ''
+ else: name = defaultName
dirname = os.path.abspath(os.path.dirname(self.dataFile))
- dlg = wxFileDialog(self, 'Save As', dirname, defaultName, '*.xrc',
+ dlg = wxFileDialog(self, 'Save As', dirname, name, '*.xrc',
wxSAVE | wxOVERWRITE_PROMPT | wxCHANGE_DIR)
if dlg.ShowModal() == wxID_OK:
path = dlg.GetPath()
tree.pendingHighLight = newItem
else:
tree.pendingHighLight = None
- self.modified = True
+ self.SetModified()
self.SetStatusText('Pasted')
def OnCutDelete(self, evt):
if self.clipboard: self.clipboard.unlink()
self.clipboard = elem.cloneNode(True)
tree.pendingHighLight = None
- tree.Unselect()
+ tree.UnselectAll()
+ tree.selection = None
+ # Update tools
+ g.tools.UpdateUI()
panel.Clear()
- self.modified = True
+ self.SetModified()
self.SetStatusText(status)
def OnSubclass(self, evt):
subclass = dlg.GetValue()
if subclass:
elem.setAttribute('subclass', subclass)
- self.modified = True
elif elem.hasAttribute('subclass'):
elem.removeAttribute('subclass')
- self.modified = True
+ self.SetModified()
xxx.subclass = elem.getAttribute('subclass')
tree.SetItemText(selected, xxx.treeName())
panel.pages[0].box.SetLabel(xxx.panelName())
parent = tree.GetPyData(parentLeaf)
if parent.hasChild: parent = parent.child
- # Create element
- className = pullDownMenu.createMap[evt.GetId()]
- xxx = MakeEmptyXXX(parent, className)
+ # Create object_ref?
+ if evt.GetId() == ID_NEW.REF:
+ ref = wxGetTextFromUser('Create reference to:', 'Create reference')
+ if not ref: return
+ xxx = MakeEmptyRefXXX(parent, ref)
+ else:
+ # Create empty element
+ className = pullDownMenu.createMap[evt.GetId()]
+ xxx = MakeEmptyXXX(parent, className)
# Set default name for top-level windows
if parent.__class__ == xxxMainNode:
else:
tree.pendingHighLight = None
tree.SetFocus()
- self.modified = True
+ self.SetModified()
+
# Replace one object with another
def OnReplace(self, evt):
else:
tree.pendingHighLight = None
tree.SetFocus()
- self.modified = True
+ self.SetModified()
# Expand/collapse subtree
def OnExpand(self, evt):
def OnUpdateUI(self, evt):
if evt.GetId() in [wxID_CUT, wxID_COPY, self.ID_DELETE]:
evt.Enable(tree.selection is not None and tree.selection != tree.root)
+ elif evt.GetId() == wxID_SAVE:
+ evt.Enable(self.modified)
elif evt.GetId() in [wxID_PASTE, self.ID_TOOL_PASTE]:
evt.Enable((self.clipboard and tree.selection) != None)
elif evt.GetId() == self.ID_TEST:
self.clipboard.unlink()
self.clipboard = None
undoMan.Clear()
- self.modified = False
+ self.SetModified(False)
tree.Clear()
panel.Clear()
if g.testWin:
g.testWin.Destroy()
g.testWin = None
- self.SetTitle(progname)
# Numbers for new controls
self.maxIDs = {}
self.maxIDs[xxxPanel] = self.maxIDs[xxxDialog] = self.maxIDs[xxxFrame] = \
self.maxIDs[xxxMenuBar] = self.maxIDs[xxxMenu] = self.maxIDs[xxxToolBar] = \
self.maxIDs[xxxWizard] = 0
+ def SetModified(self, state=True):
+ self.modified = state
+ name = os.path.basename(self.dataFile)
+ if not name: name = defaultName
+ if state:
+ self.SetTitle(progname + ': ' + name + ' *')
+ else:
+ self.SetTitle(progname + ': ' + name)
+
def Open(self, path):
if not os.path.exists(path):
wxLogError('File does not exists: %s' % path)
f.close()
self.domCopy.unlink()
self.domCopy = None
- self.modified = False
+ self.SetModified(False)
panel.SetModified(False)
except:
inf = sys.exc_info()
# If save was successful, modified flag is unset
if not self.modified: return True
elif say == wxID_NO:
- self.modified = False
+ self.SetModified(False)
panel.SetModified(False)
return True
return False