home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / EODEV.Z / EOUndoManager.h < prev    next >
Encoding:
Text File  |  1996-09-11  |  3.1 KB  |  101 lines

  1. // EOUndoManager.h
  2. // Copyright (c) 1995, NeXT Software, Inc. All rights reserved.
  3. //
  4. // EOUndoManager is a general-purpose undo stack where clients can register
  5. // callbacks to be invoked should an undo be requested.
  6. // The EOEditingContext is one important client of the EOUndoManager.  It
  7. // automatically registers undo events for all changes made the
  8. // Enterprise Objects that it watches.
  9. // 
  10. #import <Foundation/Foundation.h>
  11. #import <EOControl/EODefines.h>
  12.  
  13. @class _EOUndoStack;
  14.  
  15. @interface EOUndoManager : NSObject
  16. {
  17.     _EOUndoStack *undoStack;
  18.     _EOUndoStack *redoStack;
  19.     unsigned disabled;
  20.     id target;
  21.     struct {
  22.         unsigned undoing:1;
  23.         unsigned redoing:1;
  24.         unsigned registeredForCallback:1;
  25.         unsigned postingCheckpointNotification:1;
  26.         unsigned groupsByEvent:1;
  27.         unsigned extraBits:27;
  28.     } _flags;
  29. }
  30.  
  31. - (void)beginUndoGrouping;
  32. - (void)endUndoGrouping;
  33.     // These nest. 
  34.  
  35. - (void)disableUndoRegistration;
  36. - (void)reenableUndoRegistration;
  37.  
  38. - (BOOL)groupsByEvent;
  39. - (void)setGroupsByEvent:(BOOL)groupsByEvent;
  40.     // If groupsByEvent is enabled, the undoManager automatically groups
  41.     // all undos registered during a single NSRunLoop event together in
  42.     // a single top-level group. This featured is enabled by default.
  43.  
  44. - (void)setLevelsOfUndo:(unsigned)levels;
  45. - (unsigned)levelsOfUndo;
  46.     // Sets the number of complete groups (not operations) that should
  47.     // be kept my the manager.  When limit is reached, oldest undos are
  48.     // thrown away.  0 means no limit !
  49.  
  50. - (void)undo;
  51.     // Undo until a matching begin. It terminates a top level undo if
  52.     // necesary. Useful for undoing when groupByEvents is on (default is
  53.     // on)
  54. - (void)redo;
  55.     // Will redo last top-level undo.
  56.  
  57. - (void)undoNestedGroup;
  58.     // Undoes a nested grouping without first trying to close a top level
  59.     // undo group.
  60.  
  61. - (BOOL)canUndo;
  62. - (BOOL)canRedo;
  63.     // returns whether or not the UndoManager has anything to undo or redo
  64.  
  65. - (BOOL)isUndoing;
  66. - (BOOL)isRedoing;
  67.     // returns whether or not the UndoManager is currently in the process
  68.     // of invoking undo or redo operations.
  69.  
  70. - (void)registerUndoWithTarget:object selector:(SEL)selector arg:anObject;
  71.  
  72. - (void)forgetAll;
  73.  
  74. - (void)forgetAllWithTarget:(id)target;
  75.     // Should be called from the dealloc method of any object that may have
  76.     // registered as a target for undo operations
  77.  
  78. // Invocation based undo:
  79. - (id)prepareWithInvocationTarget:target;
  80.    // called as:
  81.    // [[undoManager prepareWithInvocationTarget:self] setFont:oldFont color:oldColor]
  82.    // When undo is called, the specified target will be called with
  83.    // [target setFont:oldFont color:oldColor]
  84.  
  85. - (void)forwardInvocation:(NSInvocation *)anInvocation;
  86.  
  87.  
  88. @end
  89.  
  90. // Notifications:
  91. EOCONTROL_EXTERN NSString *EOUndoManagerCheckpointNotification;
  92.     // This is called before an undo group is begun or ended so any
  93.     // clients that need to lazily register undos can do so in the
  94.     // correct group.
  95.  
  96.  
  97. // used with NSRunLoop's performSelector:target:argument:order:modes:
  98. enum {
  99.     EOUndoManagerCloseGroupingRunLoopOrdering        = 350000
  100. };
  101.