DrawKit
Vector and illustration framework for Mac OS X
Instance Methods | List of all members
GCUndoManager Class Reference

This class is a public API-compatible replacement for NSUndoManager. More...

Inheritance diagram for GCUndoManager:
Inheritance graph
[legend]

Instance Methods

(void) - _processEndOfEventNotification:
 
(BOOL- automaticallyDiscardsEmptyGroups
 
(void) - beginUndoGrouping
 
(BOOL- canRedo
 
(BOOL- canUndo
 
(NSUInteger- changeCount
 
(void) - checkpoint
 
(void) - clearRedoStack
 
(GCUndoTaskCoalescingKind) - coalescingKind
 
(void) - conditionallyBeginUndoGrouping
 
(GCUndoGroup *) - currentGroup
 
(void) - disableUndoRegistration
 
(void) - disableUndoTaskCoalescing
 
(void) - enableUndoRegistration
 
(void) - enableUndoTaskCoalescing
 
(void) - endUndoGrouping
 
(void) - explodeTopUndoAction
 
(void) - forwardInvocation:
 
(NSUInteger- groupingLevel
 
(BOOL- groupsByEvent
 
(BOOL- isRedoing
 
(BOOL- isUndoing
 
(BOOL- isUndoRegistrationEnabled
 
(BOOL- isUndoTaskCoalescingEnabled
 
(NSUInteger- levelsOfUndo
 
(NSUInteger- numberOfRedoActions
 
(NSUInteger- numberOfUndoActions
 
(GCUndoGroup *) - peekRedo
 
(GCUndoGroup *) - peekUndo
 
(GCUndoGroup *) - popRedo
 
(void) - popRedoAndPerformTasks
 
(GCUndoGroup *) - popUndo
 
(void) - popUndoAndPerformTasks
 
(id- prepareWithInvocationTarget:
 
(void) - pushGroupOntoRedoStack:
 
(void) - pushGroupOntoUndoStack:
 
(void) - redo
 
(NSString *) - redoActionName
 
(NSString *) - redoMenuItemTitle
 
(NSString *) - redoMenuTitleForUndoActionName:
 
(NSArray *) - redoStack
 
(void) - registerUndoWithTarget:selector:object:
 
(void) - removeAllActions
 
(void) - removeAllActionsWithTarget:
 
(void) - reset
 
(void) - resetChangeCount
 
(BOOL- retainsTargets
 
(NSArray *) - runLoopModes
 
(void) - setActionName:
 
(void) - setAutomaticallyDiscardsEmptyGroups:
 
(void) - setCoalescingKind:
 
(void) - setGroupsByEvent:
 
(void) - setLevelsOfUndo:
 
(void) - setNextTarget:
 
(void) - setRetainsTargets:
 
(void) - setRunLoopModes:
 
(void) - setUndoManagerState:
 
(BOOL- submitUndoTask:
 
(void) - undo
 
(NSString *) - undoActionName
 
(GCUndoManagerState) - undoManagerState
 
(NSString *) - undoMenuItemTitle
 
(NSString *) - undoMenuTitleForUndoActionName:
 
(void) - undoNestedGroup
 
(NSArray *) - undoStack
 
- Instance Methods inherited from NSObject
(NSString *) - address
 
(DKStyleRegistry *) - applicationWillReturnStyleRegistry
 
(BOOL- canBeUsedWithSelectionTool
 
(id- categoryManager:shouldReplaceObject:withObject:
 
(Class- classForCoder
 
(NSColor *) - colorValue
 
(NSColor *) - colourValue
 
(id- copy
 
(void) - dealloc
 
(id- deepCopy
 
(NSDictionary *) - dimensionValuesForArrowStroke:
 
(CGFloat- drawing:convertDistanceToExternalCoordinates:
 
(NSPoint) - drawing:convertLocationToExternalCoordinates:
 
(void) - drawing:didDrawRect:inView:
 
(void) - drawing:willDrawRect:inView:
 
(NSString *) - drawing:willReturnAbbreviationForUnit:
 
(NSString *) - drawing:willReturnFormattedCoordinateForDistance:
 
(CGFloat- drawingWillReturnUnitToPointsConversonFactor:
 
(void) - finalize
 
(NSString *) - hexString
 
(void) - hotspot:didEndTrackingWithEvent:inView:
 
(void) - hotspot:isTrackingWithEvent:inView:
 
(void) - hotspot:willBeginTrackingWithEvent:inView:
 
(NSData *) - imageData
 
(NSImage *) - imageResourceNamed:
 
(id- init
 
(id- initWithExpression:
 
(id- instantiateObjectWithShortName:parameters:
 
(BOOL- isLiteralValue
 
(void) - layoutManager:willPlaceGlyphAtIndex:atLocation:pathAngle:yOffset:
 
(void) - menuItem:wasAddedForObject:inCategory:
 
(BOOL- moveObjectTo:position:slope:userInfo:
 
(id- mutableCopy
 
(void) - oneShotComplete
 
(void) - oneShotHasReached:
 
(void) - oneShotWillBegin
 
(void) - path:elementIndex:type:points:subPathIndex:subPathClosed:contextInfo:
 
(id- placeLinkFromPoint:toPoint:onPath:linkNumber:userInfo:
 
(id- placeObjectAtPoint:onPath:position:slope:userInfo:
 
(NSPoint) - point
 
(NSPoint) - pointForTextLayout
 
(DKStyle *) - registry:shouldReplaceStyle:withStyle:
 
(NSBezierPath *) - renderer:willRenderPath:
 
(void) - routeFinder:progressHasReached:
 
(void) - setValue:forNumericParameter:
 
(NSString *) - stringValue
 
(CGFloat- taperFactorAtDistance:onPath:ofLength:
 
(void) - toolDidPerformUndoableAction:
 
(void) - toolWillPerformUndoableAction:
 
(NSURL *) - url
 
- Instance Methods inherited from <NSObject>
(NSString *) - description
 
(NSUInteger- hash
 
(BOOL- isEqual:
 
- Instance Methods inherited from <NSKeyValueBindingCreation>
(void) - bind:toObject:withKeyPath:options:
 
(NSArray *) - exposedBindings
 
(NSDictionary *) - infoForBinding:
 
(NSArray *) - optionDescriptionsForBinding:
 
(void) - unbind:
 
(Class- valueClassForBinding:
 

Additional Inherited Members

- Class Methods inherited from NSObject
(id+ alloc
 
(Class+ class
 
(void) + initialize
 
(void) + load
 
(id+ new
 
- Class Methods inherited from <NSKeyValueBindingCreation>
(void) + exposeBinding:
 

Detailed Description

This class is a public API-compatible replacement for NSUndoManager.

This class is a public API-compatible replacement for NSUndoManager. It can only be used with Appkit however, not with other types of executable.

The point of this is to provide an undo manager whose source is openly readable, available and debuggable. It also does not exhibit the NSUndoManager bug whereby opening and closing a group without adding any tasks creates an empty task. That substantially simplifies how it can be used in an interactive situation such as handling the mouse down/drag/up triplet of views.

This also includes task coalescing whereby consecutive tasks having the same target and selector are only submitted to the stack once. This helps a lot with interactive tasks involving multiple events such as mouse dragging, so that undo does not replay all the intermediate steps.

Instances of this can be used as well as NSUndoManager if required. This handles all of its own event loop observing and automatic open and close of groups independently of the standard mechanism.

Otherwise this should behave identically to NSUndoManager when used in an application, except as noted below.

The sending of notifications is not quite as it appears to be documented for NSUndoManager. If you implement as documented, the change count for NSDocument is not managed correctly. Instead, this sends notifications in a manner that appears to be what NSUndoManager actually does, and so NSDocument change counts work as they should. Also, the purpose and exact usage of NSCheckPointNotification is unclear so while this follows the documentation, any code relying on this vague notification might not work correctly.

-undoNestedGroup only operates on top level groups in this implementation, and is thus functionally equivalent to -undo. In fact -undo simply calls -undoNestedGroup here.

Method Documentation

- (void) _processEndOfEventNotification: (NSNotification *)  note
- (BOOL) automaticallyDiscardsEmptyGroups
- (void) beginUndoGrouping
- (BOOL) canRedo
- (BOOL) canUndo
- (NSUInteger) changeCount
- (void) checkpoint
- (void) clearRedoStack
- (GCUndoTaskCoalescingKind) coalescingKind
- (void) conditionallyBeginUndoGrouping
- (GCUndoGroup*) currentGroup
- (void) disableUndoRegistration
- (void) disableUndoTaskCoalescing
- (void) enableUndoRegistration
- (void) enableUndoTaskCoalescing
- (void) endUndoGrouping
- (void) explodeTopUndoAction
- (void) forwardInvocation: (NSInvocation *)  invocation
- (NSUInteger) groupingLevel
- (BOOL) groupsByEvent
- (BOOL) isRedoing
- (BOOL) isUndoing
- (BOOL) isUndoRegistrationEnabled
- (BOOL) isUndoTaskCoalescingEnabled
- (NSUInteger) levelsOfUndo
- (NSUInteger) numberOfRedoActions
- (NSUInteger) numberOfUndoActions
- (GCUndoGroup*) peekRedo
- (GCUndoGroup*) peekUndo
- (GCUndoGroup*) popRedo
- (void) popRedoAndPerformTasks
- (GCUndoGroup*) popUndo
- (void) popUndoAndPerformTasks
- (id) prepareWithInvocationTarget: (id target
- (void) pushGroupOntoRedoStack: (GCUndoGroup *)  aGroup
- (void) pushGroupOntoUndoStack: (GCUndoGroup *)  aGroup
- (void) redo
- (NSString*) redoActionName
- (NSString*) redoMenuItemTitle
- (NSString*) redoMenuTitleForUndoActionName: (NSString *)  actionName
- (NSArray*) redoStack
- (void) registerUndoWithTarget: (id target
selector: (SEL selector
object: (id anObject 
- (void) removeAllActions
- (void) removeAllActionsWithTarget: (id target
- (void) reset
- (void) resetChangeCount
- (BOOL) retainsTargets
- (NSArray*) runLoopModes
- (void) setActionName: (NSString *)  actionName
- (void) setAutomaticallyDiscardsEmptyGroups: (BOOL autoDiscard
- (void) setCoalescingKind: (GCUndoTaskCoalescingKind)  kind
- (void) setGroupsByEvent: (BOOL groupByEvent
- (void) setLevelsOfUndo: (NSUInteger levels
- (void) setNextTarget: (id target
- (void) setRetainsTargets: (BOOL retainsTargets
- (void) setRunLoopModes: (NSArray *)  modes
- (void) setUndoManagerState: (GCUndoManagerState)  aState
- (BOOL) submitUndoTask: (GCConcreteUndoTask *)  aTask
- (void) undo
- (NSString*) undoActionName
- (GCUndoManagerState) undoManagerState
- (NSString*) undoMenuItemTitle
- (NSString*) undoMenuTitleForUndoActionName: (NSString *)  actionName
- (void) undoNestedGroup
- (NSArray*) undoStack