controls/LocationCellEditor.py
changeset 655 435e2d8ee580
parent 615 8baeb9dff775
child 657 b286a16162fc
equal deleted inserted replaced
654:f8445d00613d 655:435e2d8ee580
    70     '''
    70     '''
    71     def __init__(self, parent, locations):
    71     def __init__(self, parent, locations):
    72         self._init_ctrls(parent)
    72         self._init_ctrls(parent)
    73         self.Locations = locations
    73         self.Locations = locations
    74         self.VarType = None
    74         self.VarType = None
       
    75         self.Default = False
    75 
    76 
    76     def SetVarType(self, vartype):
    77     def SetVarType(self, vartype):
    77         self.VarType = vartype
    78         self.VarType = vartype
    78 
    79 
    79     def SetValue(self, value):
    80     def SetValue(self, value):
       
    81         self.Default = value
    80         self.Location.SetValue(value)
    82         self.Location.SetValue(value)
    81     
    83     
    82     def GetValue(self):
    84     def GetValue(self):
    83         return self.Location.GetValue()
    85         return self.Location.GetValue()
    84 
    86 
    98 
   100 
    99         self.Location.SetFocus()
   101         self.Location.SetFocus()
   100 
   102 
   101     def OnLocationChar(self, event):
   103     def OnLocationChar(self, event):
   102         keycode = event.GetKeyCode()
   104         keycode = event.GetKeyCode()
   103         if keycode in [wx.WXK_RETURN, wx.WXK_TAB, wx.WXK_ESCAPE]:
   105         if keycode in [wx.WXK_RETURN, wx.WXK_TAB]:
   104             self.Parent.Parent.ProcessEvent(event)
   106             self.Parent.Parent.ProcessEvent(event)
   105             self.Parent.Parent.SetFocus()
   107         elif keycode == wx.WXK_ESCAPE:
       
   108             self.Location.SetValue(self.Default)
       
   109             self.Parent.Parent.CloseEditControl()
   106         else:
   110         else:
   107             event.Skip()
   111             event.Skip()
   108 
   112 
   109     def SetInsertionPoint(self, i):
   113     def SetInsertionPoint(self, i):
   110         self.Location.SetInsertionPoint(i)
   114         self.Location.SetInsertionPoint(i)
   145         old_loc = self.Table.GetValueByName(row, 'Location')
   149         old_loc = self.Table.GetValueByName(row, 'Location')
   146         if loc != old_loc:
   150         if loc != old_loc:
   147             self.Table.SetValueByName(row, 'Location', loc)
   151             self.Table.SetValueByName(row, 'Location', loc)
   148             return True
   152             return True
   149         return False
   153         return False
   150 
   154     
   151     def SetSize(self, rect):
   155     def SetSize(self, rect):
   152         self.CellControl.SetDimensions(rect.x + 1, rect.y,
   156         self.CellControl.SetDimensions(rect.x + 1, rect.y,
   153                                         rect.width, rect.height,
   157                                         rect.width, rect.height,
   154                                         wx.SIZE_ALLOW_MINUS_ONE)
   158                                         wx.SIZE_ALLOW_MINUS_ONE)
   155 
   159