1 /* Interface for <NSUndoManager> for GNUStep
2    Copyright (C) 1998 Free Software Foundation, Inc.
3 
4    Written by:  Richard Frith-Macdonald <richard@brainstorm.co.uk>
5 
6    This file is part of the GNUstep Base Library.
7 
8    This library is free software; you can redistribute it and/or
9    modify it under the terms of the GNU Lesser General Public
10    License as published by the Free Software Foundation; either
11    version 2 of the License, or (at your option) any later version.
12 
13    This library is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    Lesser General Public License for more details.
17 
18    You should have received a copy of the GNU Lesser General Public
19    License along with this library; if not, write to the Free
20    Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21    Boston, MA 02110 USA.
22 */
23 
24 #ifndef __NSUndoManager_h_OBJECTS_INCLUDE
25 #define __NSUndoManager_h_OBJECTS_INCLUDE
26 #import	<GNUstepBase/GSVersionMacros.h>
27 
28 #if	OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
29 
30 #import	<Foundation/NSObject.h>
31 
32 #if	defined(__cplusplus)
33 extern "C" {
34 #endif
35 
36 @class NSArray;
37 @class NSString;
38 @class NSMutableArray;
39 @class NSInvocation;
40 
41 /** Defines run loop ordering for closing undo groupings. */
42 enum {
43   NSUndoCloseGroupingRunLoopOrdering = 350000
44 };
45 
46 /* Public notification */
47 
48 /**
49  *  Notification posted whenever [NSUndoManager] opens or closes an undo
50  *  group.  The undo manager itself is the notification object, with no
51  *  <em>userInfo</em> dictionary.
52  */
53 GS_EXPORT NSString* const NSUndoManagerCheckpointNotification;
54 
55 /**
56  * Notification posted after an [NSUndoManager] opens an undo group.
57  */
58 GS_EXPORT NSString* const NSUndoManagerDidOpenUndoGroupNotification;
59 
60 /**
61  * Notification posted after an [NSUndoManager] executes a redo operation.
62  */
63 GS_EXPORT NSString* const NSUndoManagerDidRedoChangeNotification;
64 
65 /**
66  * Notification posted after an [NSUndoManager] executes an undo operation.
67  */
68 GS_EXPORT NSString* const NSUndoManagerDidUndoChangeNotification;
69 
70 /**
71  * Notification posted before an [NSUndoManager] closes an undo group.
72  */
73 GS_EXPORT NSString* const NSUndoManagerWillCloseUndoGroupNotification;
74 
75 /**
76  * Notification posted before an [NSUndoManager] will execute a redo operation.
77  */
78 GS_EXPORT NSString* const NSUndoManagerWillRedoChangeNotification;
79 
80 /**
81  * Notification posted before an [NSUndoManager] will execute an undo operation.
82  */
83 GS_EXPORT NSString* const NSUndoManagerWillUndoChangeNotification;
84 
85 @interface NSUndoManager : NSObject
86 {
87 #if	GS_EXPOSE(NSUndoManager)
88 @private
89   NSMutableArray	*_redoStack;
90   NSMutableArray	*_undoStack;
91   id			_group;
92   id			_nextTarget;
93   NSArray		*_modes;
94   BOOL			_isRedoing;
95   BOOL			_isUndoing;
96   BOOL			_groupsByEvent;
97   BOOL			_runLoopGroupingPending;
98   unsigned		_disableCount;
99   unsigned		_levelsOfUndo;
100 #endif
101 #if     GS_NONFRAGILE
102 #else
103   /* Pointer to private additional data used to avoid breaking ABI
104    * when we don't have the non-fragile ABI available.
105    * Use this mechanism rather than changing the instance variable
106    * layout (see Source/GSInternal.h for details).
107    */
108   @private id _internal GS_UNUSED_IVAR;
109 #endif
110 }
111 
112 - (void) beginUndoGrouping;
113 - (BOOL) canRedo;
114 - (BOOL) canUndo;
115 - (void) disableUndoRegistration;
116 - (void) enableUndoRegistration;
117 - (void) endUndoGrouping;
118 - (void) forwardInvocation: (NSInvocation*)anInvocation;
119 - (NSInteger) groupingLevel;
120 - (BOOL) groupsByEvent;
121 - (BOOL) isRedoing;
122 - (BOOL) isUndoing;
123 - (BOOL) isUndoRegistrationEnabled;
124 - (NSUInteger) levelsOfUndo;
125 - (id) prepareWithInvocationTarget: (id)target;
126 - (void) redo;
127 - (NSString*) redoActionName;
128 - (NSString*) redoMenuItemTitle;
129 - (NSString*) redoMenuTitleForUndoActionName: (NSString*)actionName;
130 - (void) registerUndoWithTarget: (id)target
131 		       selector: (SEL)aSelector
132 			 object: (id)anObject;
133 - (void) removeAllActions;
134 - (void) removeAllActionsWithTarget: (id)target;
135 - (NSArray*) runLoopModes;
136 - (void) setActionName: (NSString*)name;
137 - (void) setGroupsByEvent: (BOOL)flag;
138 - (void) setLevelsOfUndo: (NSUInteger)num;
139 - (void) setRunLoopModes: (NSArray*)newModes;
140 - (void) undo;
141 - (NSString*) undoActionName;
142 - (NSString*) undoMenuItemTitle;
143 - (NSString*) undoMenuTitleForUndoActionName: (NSString*)actionName;
144 - (void) undoNestedGroup;
145 
146 @end
147 
148 #if	defined(__cplusplus)
149 }
150 #endif
151 
152 #endif	/* GS_API_MACOSX */
153 
154 #endif /* __NSUndoManager_h_OBJECTS_INCLUDE */
155