--- a/plugins/c_ext/CFileEditor.py Fri Dec 09 10:32:06 2011 +0100
+++ b/plugins/c_ext/CFileEditor.py Wed Dec 14 15:17:36 2011 +0100
@@ -5,7 +5,7 @@
-from controls import CustomGrid, EditorPanel
+from controls import CustomGrid, CustomTable, EditorPanel if wx.Platform == '__WXMSW__':
faces = { 'times': 'Times New Roman',
@@ -453,90 +453,15 @@
# Helper for VariablesGrid values
#-------------------------------------------------------------------------------
-class VariablesTable(wx.grid.PyGridTableBase):
+class VariablesTable(CustomTable):
- A custom wxGrid Table using user supplied data
- def __init__(self, parent, data, colnames):
- # The base class must be initialized *first*
- wx.grid.PyGridTableBase.__init__(self)
- self.colnames = colnames
- # we need to store the row length and collength to
- # see if the table has changed size
- self._rows = self.GetNumberRows()
- self._cols = self.GetNumberCols()
- def GetNumberCols(self):
- return len(self.colnames)
- def GetNumberRows(self):
- def GetColLabelValue(self, col):
- if col < len(self.colnames):
- return self.colnames[col]
- def GetRowLabelValues(self, row):
def GetValue(self, row, col):
if row < self.GetNumberRows():
- return str(self.data[row].get(self.GetColLabelValue(col), ""))
- def GetValueByName(self, row, colname):
- if row < self.GetNumberRows():
- return self.data[row].get(colname, None)
- def SetValue(self, row, col, value):
- if col < len(self.colnames):
- self.data[row][self.GetColLabelValue(col)] = value
+ return str(self.data[row].get(self.GetColLabelValue(col, False), "")) - def SetValueByName(self, row, colname, value):
- if row < self.GetNumberRows():
- self.data[row][colname] = value
- def ResetView(self, grid):
- (wxGrid) -> Reset the grid view. Call this to
- update the grid if rows and columns have been added or deleted
- for current, new, delmsg, addmsg in [
- (self._rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED),
- (self._cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED),
- msg = wx.grid.GridTableMessage(self,delmsg,new,current-new)
- grid.ProcessTableMessage(msg)
- msg = wx.grid.GridTableMessage(self,addmsg,new-current)
- grid.ProcessTableMessage(msg)
- self.UpdateValues(grid)
- self._rows = self.GetNumberRows()
- self._cols = self.GetNumberCols()
- # update the column rendering scheme
- self._updateColAttrs(grid)
- # update the scrollbars and the displayed part of the grid
- grid.AdjustScrollbars()
- def UpdateValues(self, grid):
- """Update all displayed values"""
- # This sends an event to the grid table to update all of the values
- msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES)
- grid.ProcessTableMessage(msg)
def _updateColAttrs(self, grid):
wxGrid -> update the column attributes to add the
@@ -568,41 +493,8 @@
grid.SetCellRenderer(row, col, renderer)
grid.SetCellBackgroundColour(row, col, wx.WHITE)
- def SetData(self, data):
- def GetCurrentIndex(self):
- return self.CurrentIndex
- def SetCurrentIndex(self, index):
- self.CurrentIndex = index
+ self.ResizeRow(grid, row) - def AppendRow(self, row_content):
- self.data.append(row_content)
- def InsertRow(self, row_index, row_content):
- self.data.insert(row_index, row_content)
- def RemoveRow(self, row_index):
- self.data.pop(row_index)
- def MoveRow(self, row_index, move):
- new_index = max(0, min(row_index + move, len(self.data) - 1))
- if new_index != row_index:
- self.data.insert(new_index, self.data.pop(row_index))
- def GetRow(self, row_index):
- return self.data[row_index]
[ID_VARIABLESEDITOR, ID_VARIABLESEDITORVARIABLESGRID,
ID_VARIABLESEDITORADDVARIABLEBUTTON, ID_VARIABLESEDITORDELETEVARIABLEBUTTON,
--- a/plugins/c_ext/c_ext.py Fri Dec 09 10:32:06 2011 +0100
+++ b/plugins/c_ext/c_ext.py Wed Dec 14 15:17:36 2011 +0100
@@ -31,7 +31,6 @@
self.CFile = CFileClasses["CFile"]()
- self.CFileBuffer = UndoBuffer(self.Copy(self.CFile), False)
if os.path.isfile(filepath):
xmlfile = open(filepath, 'r')
tree = minidom.parse(xmlfile)
@@ -42,11 +41,9 @@
self.CFile.loadXMLTree(child, ["xmlns", "xmlns:xsi", "xsi:schemaLocation"])
self.CFileBuffer = UndoBuffer(self.Copy(self.CFile), True)
+ self.CFileBuffer = UndoBuffer(self.Copy(self.CFile), False) - def GetIconPath(self, name):
return os.path.join(self.PlugPath(), "cfile.xml")
@@ -174,7 +171,7 @@
xmlfile.write(text.encode("utf-8"))
- self.CFileBuffer.CurrentSaved()
+ self.MarkCFileAsSaved() def PlugGenerate_C(self, buildpath, locations):
@@ -276,34 +273,41 @@
#-------------------------------------------------------------------------------
- Return a copy of the project
+ Return a copy of the cfile model return cPickle.loads(cPickle.dumps(model))
+ def CreateConfigBuffer(self, saved): + self.CFileBuffer = UndoBuffer(cPickle.dumps(self.CFile), saved) - self.CFileBuffer.Buffering(self.Copy(self.CFile))
+ self.CFileBuffer.Buffering(cPickle.dumps(self.CFile)) def StartBuffering(self):
- self.CFileBuffer.Buffering(self.CFile)
- self.CFile = self.Copy(self.CFile)
+ self.CFileBuffer.Buffering(cPickle.dumps(self.CFile)) + def MarkCFileAsSaved(self): + self.CFileBuffer.CurrentSaved() - return self.CFileBuffer.IsCurrentSaved()
+ return self.CFileBuffer.IsCurrentSaved() and not self.Buffering - self.CFile = self.Copy(self.CFileBuffer.Previous())
+ self.CFile = cPickle.loads(self.CFileBuffer.Previous()) - self.CFile = self.Copy(self.CFileBuffer.Next())
+ self.CFile = cPickle.loads(self.CFileBuffer.Next()) def GetBufferState(self):
first = self.CFileBuffer.IsFirst()