Advertisement
jsbsan

caretaker

Dec 8th, 2013
2,182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GAMBAS 1.43 KB | None | 0 0
  1. ' Gambas class file
  2.  
  3. Private listaEstadosUndo As New State[] 'lista de undo deshacer
  4. Private listaEstadosRedo As New State[] 'lista de rehacer
  5.  
  6. '---------------------------------------------------------
  7. 'UNDO
  8. '---------------------------------------------------------
  9. Public Sub addMementoUndo(s As State)
  10.  
  11.   listaEstadosUndo.Add(s)
  12.  
  13. End
  14.  
  15. Public Sub addMementoRedo(s As State)
  16.  
  17.   listaEstadosRedo.Add(s)
  18.  
  19. End
  20.  
  21. Public Function getMementoUndo() As State
  22.   'devuelve y borra el ultimo estado de la lista...
  23.  
  24.   Dim s As State
  25.  
  26.   If listaEstadosUndo.count > 0 Then
  27.     s = listaEstadosUndo.Pop()
  28.     addMementoRedo(s)
  29.     Return s
  30.   Else
  31.     Return Null
  32.   Endif
  33.  
  34. End
  35.  
  36. Public Function getEstadosGuardadosUndo() As Integer
  37.  
  38.   Return listaEstadosUndo.Count
  39.  
  40. End
  41.  
  42. Public Sub BorrarEstadosUndo()
  43.  
  44.   listaEstadosUndo.Clear()
  45.  
  46. End
  47.  
  48. '-------------------------------------------------------
  49. 'REDO
  50. '-------------------------------------------------------
  51.  
  52. Public Function getMementoRedo() As State
  53.   'devuelve y borra el ultimo estado de la lista...
  54.  
  55.   Dim s As State
  56.  
  57.   If listaEstadosRedo.Count > 0 Then
  58.     s = listaEstadosRedo.Pop()
  59.     addMementoUndo(s)
  60.     Return s
  61.   Else
  62.     Return Null
  63.   Endif
  64.  
  65. End
  66.  
  67. Public Function getEstadosGuardadosRedo() As Integer
  68.  
  69.   Return listaEstadosRedo.Count
  70.  
  71. End
  72.  
  73. Public Sub BorrarEstadosRedo()
  74.  
  75.   listaEstadosRedo.Clear()
  76.  
  77. End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement