Mercurial > projects > dstep
annotate dstep/foundation/NSUndoManager.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | 89f3c3ef1fd2 |
children | b9de51448c6b |
rev | line source |
---|---|
14 | 1 /** |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Aug 3, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.foundation.NSUndoManager; | |
8 | |
9 import dstep.foundation.NSArray; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
10 import dstep.foundation.NSObjCRuntime; |
14 | 11 import dstep.foundation.NSObject; |
12 import dstep.foundation.NSString; | |
13 import dstep.objc.bridge.Bridge; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
14 import dstep.objc.objc; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
15 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
16 |
14 | 17 |
18 import bindings = dstep.foundation.NSUndoManager_bindings; | |
19 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
20 private |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
21 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
22 NSString NSUndoManagerCheckpointNotification_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
23 NSString NSUndoManagerWillUndoChangeNotification_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
24 NSString NSUndoManagerWillRedoChangeNotification_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
25 NSString NSUndoManagerDidUndoChangeNotification_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
26 NSString NSUndoManagerDidRedoChangeNotification_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
27 NSString NSUndoManagerDidOpenUndoGroupNotification_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
28 NSString NSUndoManagerWillCloseUndoGroupNotification_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
29 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
30 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
31 NSString NSUndoManagerCheckpointNotification () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
32 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
33 if (NSUndoManagerCheckpointNotification_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
34 return NSUndoManagerCheckpointNotification_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
35 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
36 return NSUndoManagerCheckpointNotification_ = new NSString(bindings.NSUndoManagerCheckpointNotification); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
37 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
38 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
39 NSString NSUndoManagerWillUndoChangeNotification () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
40 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
41 if (NSUndoManagerWillUndoChangeNotification_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
42 return NSUndoManagerWillUndoChangeNotification_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
43 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
44 return NSUndoManagerWillUndoChangeNotification_ = new NSString(bindings.NSUndoManagerWillUndoChangeNotification); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
45 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
46 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
47 NSString NSUndoManagerWillRedoChangeNotification () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
48 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
49 if (NSUndoManagerWillRedoChangeNotification_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
50 return NSUndoManagerWillRedoChangeNotification_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
51 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
52 return NSUndoManagerWillRedoChangeNotification_ = new NSString(bindings.NSUndoManagerWillRedoChangeNotification); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
53 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
54 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
55 NSString NSUndoManagerDidUndoChangeNotification () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
56 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
57 if (NSUndoManagerDidUndoChangeNotification_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
58 return NSUndoManagerDidUndoChangeNotification_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
59 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
60 return NSUndoManagerDidUndoChangeNotification_ = new NSString(bindings.NSUndoManagerDidUndoChangeNotification); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
61 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
62 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
63 NSString NSUndoManagerDidRedoChangeNotification () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
64 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
65 if (NSUndoManagerDidRedoChangeNotification_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
66 return NSUndoManagerDidRedoChangeNotification_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
67 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
68 return NSUndoManagerDidRedoChangeNotification_ = new NSString(bindings.NSUndoManagerDidRedoChangeNotification); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
69 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
70 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
71 NSString NSUndoManagerDidOpenUndoGroupNotification () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
72 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
73 if (NSUndoManagerDidOpenUndoGroupNotification_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
74 return NSUndoManagerDidOpenUndoGroupNotification_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
75 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
76 return NSUndoManagerDidOpenUndoGroupNotification_ = new NSString(bindings.NSUndoManagerDidOpenUndoGroupNotification); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
77 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
78 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
79 NSString NSUndoManagerWillCloseUndoGroupNotification () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
80 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
81 if (NSUndoManagerWillCloseUndoGroupNotification_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
82 return NSUndoManagerWillCloseUndoGroupNotification_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
83 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
84 return NSUndoManagerWillCloseUndoGroupNotification_ = new NSString(bindings.NSUndoManagerWillCloseUndoGroupNotification); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
85 } |
14 | 86 |
87 enum | |
88 { | |
89 NSUndoCloseGroupingRunLoopOrdering = 350000 | |
90 } | |
91 | |
92 class NSUndoManager : NSObject | |
93 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
94 mixin (ObjcWrap); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
95 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
96 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
97 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
98 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
99 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
100 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
101 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
102 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
103 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
104 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
105 |
14 | 106 void beginUndoGrouping () |
107 { | |
108 return invokeObjcSelf!(void, "beginUndoGrouping"); | |
109 } | |
110 | |
111 void endUndoGrouping () | |
112 { | |
113 return invokeObjcSelf!(void, "endUndoGrouping"); | |
114 } | |
115 | |
116 NSInteger groupingLevel () | |
117 { | |
118 return invokeObjcSelf!(NSInteger, "groupingLevel"); | |
119 } | |
120 | |
121 void disableUndoRegistration () | |
122 { | |
123 return invokeObjcSelf!(void, "disableUndoRegistration"); | |
124 } | |
125 | |
126 void enableUndoRegistration () | |
127 { | |
128 return invokeObjcSelf!(void, "enableUndoRegistration"); | |
129 } | |
130 | |
131 bool isUndoRegistrationEnabled () | |
132 { | |
133 return invokeObjcSelf!(bool, "isUndoRegistrationEnabled"); | |
134 } | |
135 | |
136 bool groupsByEvent () | |
137 { | |
138 return invokeObjcSelf!(bool, "groupsByEvent"); | |
139 } | |
140 | |
141 void setGroupsByEvent (bool groupsByEvent) | |
142 { | |
143 return invokeObjcSelf!(void, "setGroupsByEvent:", bool)(groupsByEvent); | |
144 } | |
145 | |
146 void setLevelsOfUndo (NSUInteger levels) | |
147 { | |
148 return invokeObjcSelf!(void, "setLevelsOfUndo:", NSUInteger)(levels); | |
149 } | |
150 | |
151 NSUInteger levelsOfUndo () | |
152 { | |
153 return invokeObjcSelf!(NSUInteger, "levelsOfUndo"); | |
154 } | |
155 | |
156 void setRunLoopModes (NSArray runLoopModes) | |
157 { | |
158 return invokeObjcSelf!(void, "setRunLoopModes:", NSArray)(runLoopModes); | |
159 } | |
160 | |
161 NSArray runLoopModes () | |
162 { | |
163 return invokeObjcSelf!(NSArray, "runLoopModes"); | |
164 } | |
165 | |
166 void undo () | |
167 { | |
168 return invokeObjcSelf!(void, "undo"); | |
169 } | |
170 | |
171 void redo () | |
172 { | |
173 return invokeObjcSelf!(void, "redo"); | |
174 } | |
175 | |
176 void undoNestedGroup () | |
177 { | |
178 return invokeObjcSelf!(void, "undoNestedGroup"); | |
179 } | |
180 | |
181 bool canUndo () | |
182 { | |
183 return invokeObjcSelf!(bool, "canUndo"); | |
184 } | |
185 | |
186 bool canRedo () | |
187 { | |
188 return invokeObjcSelf!(bool, "canRedo"); | |
189 } | |
190 | |
191 bool isUndoing () | |
192 { | |
193 return invokeObjcSelf!(bool, "isUndoing"); | |
194 } | |
195 | |
196 bool isRedoing () | |
197 { | |
198 return invokeObjcSelf!(bool, "isRedoing"); | |
199 } | |
200 | |
201 void removeAllActions () | |
202 { | |
203 return invokeObjcSelf!(void, "removeAllActions"); | |
204 } | |
205 | |
206 void removeAllActionsWithTarget (Object target) | |
207 { | |
208 return invokeObjcSelf!(void, "removeAllActionsWithTarget:", Object)(target); | |
209 } | |
210 | |
211 void registerUndoWithTarget (Object target, SEL selector, Object anObject) | |
212 { | |
213 return invokeObjcSelf!(void, "registerUndoWithTarget:selector:object:", Object, SEL, Object)(target, selector, anObject); | |
214 } | |
215 | |
216 Object prepareWithInvocationTarget (Object target) | |
217 { | |
218 return invokeObjcSelf!(Object, "prepareWithInvocationTarget:", Object)(target); | |
219 } | |
220 | |
221 NSString undoActionName () | |
222 { | |
223 return invokeObjcSelf!(NSString, "undoActionName"); | |
224 } | |
225 | |
226 NSString redoActionName () | |
227 { | |
228 return invokeObjcSelf!(NSString, "redoActionName"); | |
229 } | |
230 | |
231 void setActionName (NSString actionName) | |
232 { | |
233 return invokeObjcSelf!(void, "setActionName:", NSString)(actionName); | |
234 } | |
235 | |
236 NSString undoMenuItemTitle () | |
237 { | |
238 return invokeObjcSelf!(NSString, "undoMenuItemTitle"); | |
239 } | |
240 | |
241 NSString redoMenuItemTitle () | |
242 { | |
243 return invokeObjcSelf!(NSString, "redoMenuItemTitle"); | |
244 } | |
245 | |
246 NSString undoMenuTitleForUndoActionName (NSString actionName) | |
247 { | |
248 return invokeObjcSelf!(NSString, "undoMenuTitleForUndoActionName:", NSString)(actionName); | |
249 } | |
250 | |
251 NSString redoMenuTitleForUndoActionName (NSString actionName) | |
252 { | |
253 return invokeObjcSelf!(NSString, "redoMenuTitleForUndoActionName:", NSString)(actionName); | |
254 } | |
255 } | |
256 |