Mercurial > projects > dstep
comparison dstep/appkit/NSDocumentController.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 | |
children | f8a3b67adfcb |
comparison
equal
deleted
inserted
replaced
15:7ff919f595d5 | 16:19885b43130e |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Sep 24, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.appkit.NSDocumentController; | |
8 | |
9 import dstep.foundation.NSArray; | |
10 import dstep.appkit.NSDocument; | |
11 import dstep.appkit.NSMenuItem; | |
12 import dstep.appkit.NSNibDeclarations; | |
13 import dstep.appkit.NSOpenPanel; | |
14 import dstep.appkit.NSUserInterfaceValidation; | |
15 import dstep.appkit.NSWindow; | |
16 import dstep.foundation.NSCoder; | |
17 import dstep.foundation.NSDate; | |
18 import dstep.foundation.NSError; | |
19 import dstep.foundation.NSObjCRuntime; | |
20 import dstep.foundation.NSObject; | |
21 import dstep.foundation.NSString; | |
22 import dstep.foundation.NSURL; | |
23 import dstep.foundation.NSZone; | |
24 import dstep.objc.bridge.Bridge; | |
25 import dstep.objc.objc; | |
26 | |
27 class NSDocumentController : NSObject, INSCoding, INSUserInterfaceValidations | |
28 { | |
29 mixin (ObjcWrap); | |
30 | |
31 this (NSCoder aDecoder) | |
32 { | |
33 super(typeof(this).alloc.initWithCoder(aDecoder).objcObject); | |
34 } | |
35 | |
36 void encodeWithCoder (NSCoder aCoder) | |
37 { | |
38 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
39 } | |
40 | |
41 typeof(this) initWithCoder (NSCoder aDecoder) | |
42 { | |
43 return invokeObjcSelf!(typeof(this), "initWithCoder:", NSCoder)(aDecoder); | |
44 } | |
45 | |
46 static Object sharedDocumentController () | |
47 { | |
48 return invokeObjcSelfClass!(Object, "sharedDocumentController"); | |
49 } | |
50 | |
51 NSDocumentController init () | |
52 { | |
53 id result = invokeObjcSelf!(id, "init"); | |
54 return result is this.objcObject ? this : (result !is null ? new NSDocumentController(result) : null); | |
55 } | |
56 | |
57 this () | |
58 { | |
59 super(NSDocumentController.alloc.init.objcObject); | |
60 } | |
61 | |
62 NSArray documents () | |
63 { | |
64 return invokeObjcSelf!(NSArray, "documents"); | |
65 } | |
66 | |
67 Object currentDocument () | |
68 { | |
69 return invokeObjcSelf!(Object, "currentDocument"); | |
70 } | |
71 | |
72 NSString currentDirectory () | |
73 { | |
74 return invokeObjcSelf!(NSString, "currentDirectory"); | |
75 } | |
76 | |
77 Object documentForURL (NSURL absoluteURL) | |
78 { | |
79 return invokeObjcSelf!(Object, "documentForURL:", NSURL)(absoluteURL); | |
80 } | |
81 | |
82 Object documentForWindow (NSWindow window) | |
83 { | |
84 return invokeObjcSelf!(Object, "documentForWindow:", NSWindow)(window); | |
85 } | |
86 | |
87 void addDocument (NSDocument document) | |
88 { | |
89 return invokeObjcSelf!(void, "addDocument:", NSDocument)(document); | |
90 } | |
91 | |
92 void removeDocument (NSDocument document) | |
93 { | |
94 return invokeObjcSelf!(void, "removeDocument:", NSDocument)(document); | |
95 } | |
96 | |
97 void newDocument (Object sender) | |
98 { | |
99 return invokeObjcSelf!(void, "newDocument:", Object)(sender); | |
100 } | |
101 | |
102 Object openUntitledDocumentAndDisplay (bool displayDocument, ref NSError outError) | |
103 { | |
104 id error; | |
105 | |
106 if (outError) | |
107 error = new objc_object; | |
108 | |
109 Object result = invokeObjcSelf!(Object, "openUntitledDocumentAndDisplay:error:", bool, id*)(displayDocument, &error); | |
110 | |
111 if (error) | |
112 outError = new NSError(error); | |
113 | |
114 return result; | |
115 } | |
116 | |
117 Object makeUntitledDocumentOfType (NSString typeName, ref NSError outError) | |
118 { | |
119 id error; | |
120 | |
121 if (outError) | |
122 error = new objc_object; | |
123 | |
124 Object result = invokeObjcSelf!(Object, "makeUntitledDocumentOfType:error:", NSString, id*)(typeName, &error); | |
125 | |
126 if (error) | |
127 outError = new NSError(error); | |
128 | |
129 return result; | |
130 } | |
131 | |
132 void openDocument (Object sender) | |
133 { | |
134 return invokeObjcSelf!(void, "openDocument:", Object)(sender); | |
135 } | |
136 | |
137 NSArray URLsFromRunningOpenPanel () | |
138 { | |
139 return invokeObjcSelf!(NSArray, "URLsFromRunningOpenPanel"); | |
140 } | |
141 | |
142 NSInteger runModalOpenPanel (NSOpenPanel openPanel, NSArray types) | |
143 { | |
144 return invokeObjcSelf!(NSInteger, "runModalOpenPanel:forTypes:", NSOpenPanel, NSArray)(openPanel, types); | |
145 } | |
146 | |
147 Object openDocumentWithContentsOfURL (NSURL absoluteURL, bool displayDocument, ref NSError outError) | |
148 { | |
149 id error; | |
150 | |
151 if (outError) | |
152 error = new objc_object; | |
153 | |
154 Object result = invokeObjcSelf!(Object, "openDocumentWithContentsOfURL:display:error:", NSURL, bool, id*)(absoluteURL, displayDocument, &error); | |
155 | |
156 if (error) | |
157 outError = new NSError(error); | |
158 | |
159 return result; | |
160 } | |
161 | |
162 Object makeDocumentWithContentsOfURL (NSURL absoluteURL, NSString typeName, ref NSError outError) | |
163 { | |
164 id error; | |
165 | |
166 if (outError) | |
167 error = new objc_object; | |
168 | |
169 Object result = invokeObjcSelf!(Object, "makeDocumentWithContentsOfURL:ofType:error:", NSURL, NSString, id*)(absoluteURL, typeName, &error); | |
170 | |
171 if (error) | |
172 outError = new NSError(error); | |
173 | |
174 return result; | |
175 } | |
176 | |
177 bool reopenDocumentForURL (NSURL absoluteDocumentURL, NSURL absoluteDocumentContentsURL, ref NSError outError) | |
178 { | |
179 id error; | |
180 | |
181 if (outError) | |
182 error = new objc_object; | |
183 | |
184 bool result = invokeObjcSelf!(bool, "reopenDocumentForURL:withContentsOfURL:error:", NSURL, NSURL, id*)(absoluteDocumentURL, absoluteDocumentContentsURL, &error); | |
185 | |
186 if (error) | |
187 outError = new NSError(error); | |
188 | |
189 return result; | |
190 } | |
191 | |
192 Object makeDocumentForURL (NSURL absoluteDocumentURL, NSURL absoluteDocumentContentsURL, NSString typeName, ref NSError outError) | |
193 { | |
194 id error; | |
195 | |
196 if (outError) | |
197 error = new objc_object; | |
198 | |
199 Object result = invokeObjcSelf!(Object, "makeDocumentForURL:withContentsOfURL:ofType:error:", NSURL, NSURL, NSString, id*)(absoluteDocumentURL, absoluteDocumentContentsURL, typeName, &error); | |
200 | |
201 if (error) | |
202 outError = new NSError(error); | |
203 | |
204 return result; | |
205 } | |
206 | |
207 void setAutosavingDelay (double autosavingDelay) | |
208 { | |
209 return invokeObjcSelf!(void, "setAutosavingDelay:", double)(autosavingDelay); | |
210 } | |
211 | |
212 double autosavingDelay () | |
213 { | |
214 return invokeObjcSelf!(double, "autosavingDelay"); | |
215 } | |
216 | |
217 void saveAllDocuments (Object sender) | |
218 { | |
219 return invokeObjcSelf!(void, "saveAllDocuments:", Object)(sender); | |
220 } | |
221 | |
222 bool hasEditedDocuments () | |
223 { | |
224 return invokeObjcSelf!(bool, "hasEditedDocuments"); | |
225 } | |
226 | |
227 void reviewUnsavedDocumentsWithAlertTitle (NSString title, bool cancellable, Object delegate_, SEL didReviewAllSelector, void* contextInfo) | |
228 { | |
229 return invokeObjcSelf!(void, "reviewUnsavedDocumentsWithAlertTitle:cancellable:delegate:didReviewAllSelector:contextInfo:", NSString, bool, Object, SEL, void*)(title, cancellable, delegate_, didReviewAllSelector, contextInfo); | |
230 } | |
231 | |
232 void closeAllDocumentsWithDelegate (Object delegate_, SEL didCloseAllSelector, void* contextInfo) | |
233 { | |
234 return invokeObjcSelf!(void, "closeAllDocumentsWithDelegate:didCloseAllSelector:contextInfo:", Object, SEL, void*)(delegate_, didCloseAllSelector, contextInfo); | |
235 } | |
236 | |
237 void presentError (NSError error, NSWindow window, Object delegate_, SEL didPresentSelector, void* contextInfo) | |
238 { | |
239 return invokeObjcSelf!(void, "presentError:modalForWindow:delegate:didPresentSelector:contextInfo:", NSError, NSWindow, Object, SEL, void*)(error, window, delegate_, didPresentSelector, contextInfo); | |
240 } | |
241 | |
242 bool presentError (NSError error) | |
243 { | |
244 return invokeObjcSelf!(bool, "presentError:", NSError)(error); | |
245 } | |
246 | |
247 NSError willPresentError (NSError error) | |
248 { | |
249 return invokeObjcSelf!(NSError, "willPresentError:", NSError)(error); | |
250 } | |
251 | |
252 NSUInteger maximumRecentDocumentCount () | |
253 { | |
254 return invokeObjcSelf!(NSUInteger, "maximumRecentDocumentCount"); | |
255 } | |
256 | |
257 void clearRecentDocuments (Object sender) | |
258 { | |
259 return invokeObjcSelf!(void, "clearRecentDocuments:", Object)(sender); | |
260 } | |
261 | |
262 void noteNewRecentDocument (NSDocument document) | |
263 { | |
264 return invokeObjcSelf!(void, "noteNewRecentDocument:", NSDocument)(document); | |
265 } | |
266 | |
267 void noteNewRecentDocumentURL (NSURL absoluteURL) | |
268 { | |
269 return invokeObjcSelf!(void, "noteNewRecentDocumentURL:", NSURL)(absoluteURL); | |
270 } | |
271 | |
272 NSArray recentDocumentURLs () | |
273 { | |
274 return invokeObjcSelf!(NSArray, "recentDocumentURLs"); | |
275 } | |
276 | |
277 NSString defaultType () | |
278 { | |
279 return invokeObjcSelf!(NSString, "defaultType"); | |
280 } | |
281 | |
282 NSString typeForContentsOfURL (NSURL inAbsoluteURL, ref NSError outError) | |
283 { | |
284 id error; | |
285 | |
286 if (outError) | |
287 error = new objc_object; | |
288 | |
289 NSString result = invokeObjcSelf!(NSString, "typeForContentsOfURL:error:", NSURL, id*)(inAbsoluteURL, &error); | |
290 | |
291 if (error) | |
292 outError = new NSError(error); | |
293 | |
294 return result; | |
295 } | |
296 | |
297 NSArray documentClassNames () | |
298 { | |
299 return invokeObjcSelf!(NSArray, "documentClassNames"); | |
300 } | |
301 | |
302 Class documentClassForType (NSString typeName) | |
303 { | |
304 return invokeObjcSelf!(Class, "documentClassForType:", NSString)(typeName); | |
305 } | |
306 | |
307 NSString displayNameForType (NSString typeName) | |
308 { | |
309 return invokeObjcSelf!(NSString, "displayNameForType:", NSString)(typeName); | |
310 } | |
311 | |
312 bool validateUserInterfaceItem (INSValidatedUserInterfaceItem anItem) | |
313 { | |
314 return invokeObjcSelf!(bool, "validateUserInterfaceItem:", INSValidatedUserInterfaceItem)(anItem); | |
315 } | |
316 | |
317 bool validateUserInterfaceItem (INSValidatedUserInterfaceItem anItem) | |
318 { | |
319 return invokeObjcSelf!(bool, "validateUserInterfaceItem:", INSValidatedUserInterfaceItem)(anItem); | |
320 } | |
321 } | |
322 |