home *** CD-ROM | disk | FTP | other *** search
- // EOUndoManager.h
- // Copyright (c) 1995, NeXT Software, Inc. All rights reserved.
- //
- // EOUndoManager is a general-purpose undo stack where clients can register
- // callbacks to be invoked should an undo be requested.
- // The EOEditingContext is one important client of the EOUndoManager. It
- // automatically registers undo events for all changes made the
- // Enterprise Objects that it watches.
- //
- #import <Foundation/Foundation.h>
- #import <EOControl/EODefines.h>
-
- @class _EOUndoStack;
-
- @interface EOUndoManager : NSObject
- {
- _EOUndoStack *undoStack;
- _EOUndoStack *redoStack;
- unsigned disabled;
- id target;
- struct {
- unsigned undoing:1;
- unsigned redoing:1;
- unsigned registeredForCallback:1;
- unsigned postingCheckpointNotification:1;
- unsigned groupsByEvent:1;
- unsigned extraBits:27;
- } _flags;
- }
-
- - (void)beginUndoGrouping;
- - (void)endUndoGrouping;
- // These nest.
-
- - (void)disableUndoRegistration;
- - (void)reenableUndoRegistration;
-
- - (BOOL)groupsByEvent;
- - (void)setGroupsByEvent:(BOOL)groupsByEvent;
- // If groupsByEvent is enabled, the undoManager automatically groups
- // all undos registered during a single NSRunLoop event together in
- // a single top-level group. This featured is enabled by default.
-
- - (void)setLevelsOfUndo:(unsigned)levels;
- - (unsigned)levelsOfUndo;
- // Sets the number of complete groups (not operations) that should
- // be kept my the manager. When limit is reached, oldest undos are
- // thrown away. 0 means no limit !
-
- - (void)undo;
- // Undo until a matching begin. It terminates a top level undo if
- // necesary. Useful for undoing when groupByEvents is on (default is
- // on)
- - (void)redo;
- // Will redo last top-level undo.
-
- - (void)undoNestedGroup;
- // Undoes a nested grouping without first trying to close a top level
- // undo group.
-
- - (BOOL)canUndo;
- - (BOOL)canRedo;
- // returns whether or not the UndoManager has anything to undo or redo
-
- - (BOOL)isUndoing;
- - (BOOL)isRedoing;
- // returns whether or not the UndoManager is currently in the process
- // of invoking undo or redo operations.
-
- - (void)registerUndoWithTarget:object selector:(SEL)selector arg:anObject;
-
- - (void)forgetAll;
-
- - (void)forgetAllWithTarget:(id)target;
- // Should be called from the dealloc method of any object that may have
- // registered as a target for undo operations
-
- // Invocation based undo:
- - (id)prepareWithInvocationTarget:target;
- // called as:
- // [[undoManager prepareWithInvocationTarget:self] setFont:oldFont color:oldColor]
- // When undo is called, the specified target will be called with
- // [target setFont:oldFont color:oldColor]
-
- - (void)forwardInvocation:(NSInvocation *)anInvocation;
-
-
- @end
-
- // Notifications:
- EOCONTROL_EXTERN NSString *EOUndoManagerCheckpointNotification;
- // This is called before an undo group is begun or ended so any
- // clients that need to lazily register undos can do so in the
- // correct group.
-
-
- // used with NSRunLoop's performSelector:target:argument:order:modes:
- enum {
- EOUndoManagerCloseGroupingRunLoopOrdering = 350000
- };
-