API  0.9.10
CPUndoManager Class Reference

A general mechanism for user action "undo". More...

#import <CPUndoManager.h>

+ Inheritance diagram for CPUndoManager:

Instance Methods

(void) - beginUndoGrouping
 
(BOOL) - canRedo
 
(BOOL) - canUndo
 
(void) - disableUndoRegistration
 
(void) - enableUndoRegistration
 
(void) - encodeWithCoder:
 
(void) - endUndoGrouping
 
(unsigned) - groupingLevel
 
(BOOL) - groupsByEvent
 
(id) - init
 
(id) - initWithCoder:
 
(BOOL) - isRedoing
 
(BOOL) - isUndoing
 
(BOOL) - isUndoRegistrationEnabled
 
(void) - observeChangesForKeyPath:ofObject:
 
(void) - observeValueForKeyPath:ofObject:change:context:
 
(id) - prepareWithInvocationTarget:
 
(void) - redo
 
(CPString- redoActionName
 
(CPString- redoMenuItemTitle
 
(CPString- redoMenuTitleForUndoActionName:
 
(void) - registerUndoWithTarget:selector:object:
 
(void) - removeAllActions
 
(void) - removeAllActionsWithTarget:
 
(CPArray) - runLoopModes
 
(void) - setActionName:
 
(void) - setGroupsByEvent:
 
(void) - setRunLoopModes:
 
(void) - stopObservingChangesForKeyPath:ofObject:
 
(void) - undo
 
(CPString- undoActionName
 
(CPString- undoMenuItemTitle
 
(CPString- undoMenuTitleForUndoActionName:
 
(void) - undoNestedGroup
 
- Instance Methods inherited from CPObject
(void) - addObserver:forKeyPath:options:context:
 
(void) - applyChange:toKeyPath:
 
(id) - autorelease
 
(id) - awakeAfterUsingCoder:
 
(void) - awakeFromCib
 
(void) - bind:toObject:withKeyPath:options:
 
(Class) - classForCoder
 
(Class) - classForKeyedArchiver
 
(CPString- className
 
(id) - copy
 
(void) - dealloc
 
(CPString- description
 
(CPDictionary- dictionaryWithValuesForKeys:
 
(void) - didChange:valuesAtIndexes:forKey:
 
(void) - didChangeValueForKey:
 
(void) - didChangeValueForKey:withSetMutation:usingObjects:
 
(void) - doesNotRecognizeSelector:
 
(CPArray) - exposedBindings
 
(id) - forwardingTargetForSelector:
 
(void) - forwardInvocation:
 
(unsigned) - hash
 
(BOOL) - implementsSelector:
 
(CPDictionary- infoForBinding:
 
(BOOL) - isEqual:
 
(BOOL) - isKindOfClass:
 
(BOOL) - isMemberOfClass:
 
(BOOL) - isProxy
 
(IMP) - methodForSelector:
 
(CPMethodSignature) - methodSignatureForSelector:
 
(id) - mutableArrayValueForKey:
 
(id) - mutableArrayValueForKeyPath:
 
(id) - mutableCopy
 
(id) - mutableSetValueForKey:
 
(id) - mutableSetValueForKeyPath:
 
(id) - performSelector:
 
(id) - performSelector:withObject:
 
(void) - performSelector:withObject:afterDelay:
 
(void) - performSelector:withObject:afterDelay:inModes:
 
(id) - performSelector:withObject:withObject:
 
(id) - performSelector:withObjects:
 
(void) - release
 
(void) - removeObserver:forKeyPath:
 
(id) - replacementObjectForArchiver:
 
(id) - replacementObjectForCoder:
 
(id) - replacementObjectForKeyedArchiver:
 
(BOOL) - respondsToSelector:
 
(id) - retain
 
(id) - self
 
(void) - setValue:forKey:
 
(void) - setValue:forKeyPath:
 
(void) - setValue:forUndefinedKey:
 
(void) - setValuesForKeysWithDictionary:
 
(CPString- UID
 
(void) - unbind:
 
(Class) - valueClassForBinding:
 
(id) - valueForKey:
 
(id) - valueForKeyPath:
 
(id) - valueForUndefinedKey:
 
(void) - willChange:valuesAtIndexes:forKey:
 
(void) - willChangeValueForKey:
 
(void) - willChangeValueForKey:withSetMutation:usingObjects:
 

Additional Inherited Members

- Class Methods inherited from CPObject
(BOOL) + accessInstanceVariablesDirectly
 
(id) + alloc
 
(id) + allocWithCoder:
 
(BOOL) + automaticallyNotifiesObserversForKey:
 
(void) + cancelPreviousPerformRequestsWithTarget:
 
(void) + cancelPreviousPerformRequestsWithTarget:selector:object:
 
(Class) + class
 
(BOOL) + conformsToProtocol:
 
(void) + exposeBinding:
 
(void) + initialize
 
(IMP) + instanceMethodForSelector:
 
(BOOL) + instancesImplementSelector:
 
(BOOL) + instancesRespondToSelector:
 
(BOOL) + isBindingExclusive:
 
(BOOL) + isSubclassOfClass:
 
(CPSet) + keyPathsForValuesAffectingValueForKey:
 
(void) + load
 
(id) + new
 
(void) + object:performSelector:withObject:afterDelay:inModes:
 
(void) + setVersion:
 
(Class) + superclass
 
(int) + version
 

Detailed Description

A general mechanism for user action "undo".

CPUndoManager provides a general mechanism supporting implementation of user action "undo" in applications. Essentially, it allows you to store sequences of messages and receivers that need to be invoked to undo or redo an action. The various methods in this class provide for grouping of sets of actions, execution of undo or redo actions, and tuning behavior parameters such as the size of the undo stack. Each application entity with its own editing history (e.g., a document) should have its own undo manager instance. Obtain an instance through a simple [[CPUndoManager alloc] init] message.

Definition at line 2 of file CPUndoManager.h.

Method Documentation

◆ beginUndoGrouping()

- (void) beginUndoGrouping
implementation

Starts a new grouping of undo tasks, and makes it the current grouping.

Definition at line 428 of file CPUndoManager.j.

◆ canRedo()

- (BOOL) canRedo
implementation

Returns YES if the user can perform a redo operation.

Definition at line 315 of file CPUndoManager.j.

◆ canUndo()

- (BOOL) canUndo
implementation

Returns YES if the user can perform an undo operation.

Definition at line 327 of file CPUndoManager.j.

◆ disableUndoRegistration()

- (void) disableUndoRegistration
implementation

Disables undo registrations.

Definition at line 561 of file CPUndoManager.j.

◆ enableUndoRegistration()

- (void) enableUndoRegistration
implementation

Enables undo registrations. Calls to this method must be balanced with calls to disableUndoRegistration. So, if two disable calls were made, two enable calls are required to actually enable undo registration again.

Definition at line 509 of file CPUndoManager.j.

◆ encodeWithCoder:()

- (void) encodeWithCoder: (CPCoder aCoder
implementation

Provided by category CPUndoManager(CPCoding).

Definition at line 865 of file CPUndoManager.j.

◆ endUndoGrouping()

- (void) endUndoGrouping
implementation

Closes the current undo grouping.

Exceptions
CPInternalInconsistencyExceptionif no undo group is open

Definition at line 460 of file CPUndoManager.j.

◆ groupingLevel()

- (unsigned) groupingLevel
implementation

Returns the number of undo/redo groups.

Definition at line 546 of file CPUndoManager.j.

◆ groupsByEvent()

- (BOOL) groupsByEvent
implementation

Returns YES if the manager groups undo operations at every iteration of the run loop.

Definition at line 521 of file CPUndoManager.j.

◆ init()

- (id) init
implementation

Initializes the undo manager

Returns
the initialized undo manager

Reimplemented from CPObject.

Definition at line 203 of file CPUndoManager.j.

◆ initWithCoder:()

- (id) initWithCoder: (CPCoder aCoder
implementation

Provided by category CPUndoManager(CPCoding).

Definition at line 843 of file CPUndoManager.j.

◆ isRedoing()

- (BOOL) isRedoing
implementation

Returns YES if the manager is currently performing a redo.

Definition at line 586 of file CPUndoManager.j.

◆ isUndoing()

- (BOOL) isUndoing
implementation

Returns YES if the manager is currently performing an undo.

Definition at line 578 of file CPUndoManager.j.

◆ isUndoRegistrationEnabled()

- (BOOL) isUndoRegistrationEnabled
implementation

Returns YES if undo registration is enabled.

Definition at line 569 of file CPUndoManager.j.

◆ observeChangesForKeyPath:ofObject:()

- (void) observeChangesForKeyPath: (CPString aKeyPath
ofObject: (id)  anObject 
implementation

Definition at line 800 of file CPUndoManager.j.

◆ observeValueForKeyPath:ofObject:change:context:()

- (void) observeValueForKeyPath: (CPString aKeyPath
ofObject: (id)  anObject
change: (CPDictionary aChange
context: (id)  aContext 
implementation

Definition at line 813 of file CPUndoManager.j.

◆ prepareWithInvocationTarget:()

- (id) prepareWithInvocationTarget: (id)  aTarget
implementation

Prepares the specified target for the undo action.

Parameters
aTargetthe target to receive the action
Returns
the undo manager

Definition at line 269 of file CPUndoManager.j.

◆ redo()

- (void) redo
implementation

Performs the redo operation using the last grouping on the redo stack.

Definition at line 385 of file CPUndoManager.j.

◆ redoActionName()

- (CPString) redoActionName
implementation

If the receiver can perform a redo, this method returns the action name previously associated with the top grouping with -setActionName:. This name should identify the action to be redone.

Returns
the redo action's name, or nil if no there's no redo on the stack.

Definition at line 661 of file CPUndoManager.j.

◆ redoMenuItemTitle()

- (CPString) redoMenuItemTitle
implementation

Returns the full localized title of the actions to be displayed as a menu item. This method first invokes [-redoActionName] and passes it to [-redoMenuTitleForUndoActionName:] and returns the result.

Definition at line 674 of file CPUndoManager.j.

◆ redoMenuTitleForUndoActionName:()

- (CPString) redoMenuTitleForUndoActionName: (CPString anActionName
implementation

Returns the localized title of the actions to be displayed as a menu item identified by actionName, by appending a localized command string like "Redo <localized(actionName)>".

Definition at line 684 of file CPUndoManager.j.

◆ registerUndoWithTarget:selector:object:()

- (void) registerUndoWithTarget: (id)  aTarget
selector: (SEL)  aSelector
object: (id)  anObject 
implementation

Registers an undo operation. You invoke this method with the target of the undo action providing the selector which can perform the undo with the provided object. The object is often a dictionary of the identifying the attribute and their values before the change. The invocation will be added to the current grouping. If the registrations have been disabled through -disableUndoRegistration, this method does nothing.

Parameters
aTargetthe target for the undo invocation
aSelectorthe selector for the action message
anObjectthe argument for the action message
Exceptions
CPInternalInconsistencyExceptionif no undo group is currently open

Definition at line 248 of file CPUndoManager.j.

◆ removeAllActions()

- (void) removeAllActions
implementation

Clears all redo and undo operations and enables undo registrations.

Definition at line 595 of file CPUndoManager.j.

◆ removeAllActionsWithTarget:()

- (void) removeAllActionsWithTarget: (id)  aTarget
implementation

Removes any redo and undo operations that use the specified target.

Parameters
aTargetthe target for which operations should be removed.

Definition at line 614 of file CPUndoManager.j.

◆ runLoopModes()

- (CPArray) runLoopModes
implementation

Returns the CPRunLoopModes in which the receiver registers the -endUndoGrouping processing when it -groupsByEvent.

Definition at line 742 of file CPUndoManager.j.

◆ setActionName:()

- (void) setActionName: (CPString anActionName
implementation

Sets the name associated with the actions of the current group. Typically, you can call this method while registering the actions for the current group.

Parameters
anActionNamethe new name for the current group

Definition at line 649 of file CPUndoManager.j.

◆ setGroupsByEvent:()

- (void) setGroupsByEvent: (BOOL)  aFlag
implementation

Sets whether the manager should group undo operations at every iteration of the run loop.

Parameters
aFlagYES groups undo operations

Definition at line 530 of file CPUndoManager.j.

◆ setRunLoopModes:()

- (void) setRunLoopModes: (CPArray)  modes
implementation

Sets the modes in which the receiver registers the calls with the current run loop to invoke -endUndoGrouping when it -groupsByEvent. This method first cancels any pending registrations in the old modes and registers the invocation in the new modes.

Parameters
modesthe modes in which calls are registered

Definition at line 755 of file CPUndoManager.j.

◆ stopObservingChangesForKeyPath:ofObject:()

- (void) stopObservingChangesForKeyPath: (CPString aKeyPath
ofObject: (id)  anObject 
implementation

Definition at line 808 of file CPUndoManager.j.

◆ undo()

- (void) undo
implementation

Ends the current grouping, and performs an 'undo' operation.

Definition at line 339 of file CPUndoManager.j.

◆ undoActionName()

- (CPString) undoActionName
implementation

If the receiver can perform an undo, this method returns the action name previously associated with the top grouping with -setActionName:. This name should identify the action to be undone.

Returns
the undo action name or nil if no if there's no undo on the stack.

Definition at line 702 of file CPUndoManager.j.

◆ undoMenuItemTitle()

- (CPString) undoMenuItemTitle
implementation

Returns the full localized title of the actions to be displayed as a menu item. This method first invokes [-undoActionName] and passes it to [-undoMenuTitleForUndoActionName:] and returns the result.

Definition at line 715 of file CPUndoManager.j.

◆ undoMenuTitleForUndoActionName:()

- (CPString) undoMenuTitleForUndoActionName: (CPString anActionName
implementation

Returns the localized title of the actions to be displayed as a menu item identified by actionName, by appending a localized command string like "Undo <localized(actionName)>".

Definition at line 725 of file CPUndoManager.j.

◆ undoNestedGroup()

- (void) undoNestedGroup
implementation

Performs an undo on the last undo group.

Definition at line 350 of file CPUndoManager.j.


The documentation for this class was generated from the following files: