controls/LocationCellEditor.py
changeset 1536 3518d10487db
parent 1004 bf3b6998f7b6
child 1540 cf1df00e6f86
equal deleted inserted replaced
1535:b3c43aa29d94 1536:3518d10487db
   159         self.CellControl.SetValue(self.Table.GetValueByName(row, 'Location'))
   159         self.CellControl.SetValue(self.Table.GetValueByName(row, 'Location'))
   160         if isinstance(self.CellControl, LocationCellControl):
   160         if isinstance(self.CellControl, LocationCellControl):
   161             self.CellControl.SetVarType(self.Table.GetValueByName(row, 'Type'))
   161             self.CellControl.SetVarType(self.Table.GetValueByName(row, 'Type'))
   162         self.CellControl.SetFocus()
   162         self.CellControl.SetFocus()
   163 
   163 
   164     def EndEdit(self, row, col, grid):
   164     def EndEditInternal(self, row, col, grid, old_loc):
   165         loc = self.CellControl.GetValue()
   165         loc = self.CellControl.GetValue()
   166         old_loc = self.Table.GetValueByName(row, 'Location')
       
   167         changed = loc != old_loc
   166         changed = loc != old_loc
   168         if changed:
   167         if changed:
   169             self.Table.SetValueByName(row, 'Location', loc)
   168             self.Table.SetValueByName(row, 'Location', loc)
   170             self.Table.SetValueByName(row, 'Type', self.CellControl.GetVarType())
   169             self.Table.SetValueByName(row, 'Type', self.CellControl.GetVarType())
   171         self.CellControl.Disable()
   170         self.CellControl.Disable()
   172         return changed
   171         return changed
       
   172         
       
   173     if wx.VERSION >= (3, 0, 0):
       
   174         def EndEdit(self, row, col, grid, oldval):
       
   175             self.EndEditInternal(row, col, grid, oldval)
       
   176     else:
       
   177         def EndEdit(self, row, col, grid):
       
   178             old_loc = self.Table.GetValueByName(row, 'Location')            
       
   179             self.EndEditInternal(row, col, grid, oldval)
   173     
   180     
   174     def SetSize(self, rect):
   181     def SetSize(self, rect):
   175         self.CellControl.SetDimensions(rect.x + 1, rect.y,
   182         self.CellControl.SetDimensions(rect.x + 1, rect.y,
   176                                         rect.width, rect.height,
   183                                         rect.width, rect.height,
   177                                         wx.SIZE_ALLOW_MINUS_ONE)
   184                                         wx.SIZE_ALLOW_MINUS_ONE)