Mercurial > projects > dstep
comparison dstep/appkit/NSSavePanel.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 | b9de51448c6b |
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.NSSavePanel; | |
8 | |
9 import dstep.appkit.NSBox; | |
10 import dstep.appkit.NSNibDeclarations; | |
11 import dstep.appkit.NSPanel; | |
12 import dstep.appkit.NSTextField; | |
13 import dstep.appkit.NSTextView; | |
14 import dstep.appkit.NSView; | |
15 import dstep.appkit.NSWindow; | |
16 import dstep.foundation.NSArray; | |
17 import dstep.foundation.NSObjCRuntime; | |
18 import dstep.foundation.NSString; | |
19 import dstep.foundation.NSURL; | |
20 import dstep.objc.bridge.Bridge; | |
21 import dstep.objc.objc; | |
22 | |
23 // This should no need to be here | |
24 private enum | |
25 { | |
26 NSOKButton = 1, | |
27 NSCancelButton = 0 | |
28 } | |
29 | |
30 enum | |
31 { | |
32 NSFileHandlingPanelCancelButton = NSCancelButton, | |
33 NSFileHandlingPanelOKButton = NSOKButton | |
34 } | |
35 | |
36 struct _SPFlags | |
37 { | |
38 uint saveMode; | |
39 uint isExpanded; | |
40 uint allowsOtherFileTypes; | |
41 uint canCreateDirectories; | |
42 uint canSelectedHiddenExtension; | |
43 uint reserved; | |
44 } | |
45 | |
46 const TNSSavePanelRuntime = ` | |
47 | |
48 void ok (Object sender) | |
49 { | |
50 return invokeObjcSelf!(void, "ok:", Object)(sender); | |
51 } | |
52 | |
53 void cancel (Object sender) | |
54 { | |
55 return invokeObjcSelf!(void, "cancel:", Object)(sender); | |
56 } | |
57 | |
58 void beginSheetForDirectory (NSString path, NSString name, NSWindow docWindow, Object delegate_, SEL didEndSelector, void* contextInfo) | |
59 { | |
60 return invokeObjcSelf!(void, "beginSheetForDirectory:file:modalForWindow:modalDelegate:didEndSelector:contextInfo:", NSString, NSString, NSWindow, Object, SEL, void*)(path, name, docWindow, delegate_, didEndSelector, contextInfo); | |
61 } | |
62 | |
63 NSInteger runModalForDirectory (NSString path, NSString name) | |
64 { | |
65 return invokeObjcSelf!(NSInteger, "runModalForDirectory:file:", NSString, NSString)(path, name); | |
66 } | |
67 | |
68 NSInteger runModal () | |
69 { | |
70 return invokeObjcSelf!(NSInteger, "runModal"); | |
71 } | |
72 | |
73 //mixin ObjcBindMethod!(ok, "ok:"); | |
74 //mixin ObjcBindMethod!(cancel, "cancel:"); | |
75 //mixin ObjcBindMethod!(beginSheetForDirectory, "beginSheetForDirectory:file:modalForWindow:modalDelegate:didEndSelector:contextInfo:"); | |
76 //mixin ObjcBindMethod!(runModalForDirectory, "runModalForDirectory:file:"); | |
77 //mixin ObjcBindMethod!(runModal, "runModal"); | |
78 | |
79 `; | |
80 | |
81 const TNSSavePanelDelegate = ` | |
82 | |
83 bool panel (Object sender, NSString filename) | |
84 { | |
85 return invokeObjcSelf!(bool, "panel:shouldShowFilename:", Object, NSString)(sender, filename); | |
86 } | |
87 | |
88 int panel (Object sender, NSString name1, NSString name2, bool caseSensitive) | |
89 { | |
90 return invokeObjcSelf!(int, "panel:compareFilename:with:caseSensitive:", Object, NSString, NSString, bool)(sender, name1, name2, caseSensitive); | |
91 } | |
92 | |
93 bool panel (Object sender, NSString filename) | |
94 { | |
95 return invokeObjcSelf!(bool, "panel:isValidFilename:", Object, NSString)(sender, filename); | |
96 } | |
97 | |
98 NSString panel (Object sender, NSString filename, bool okFlag) | |
99 { | |
100 return invokeObjcSelf!(NSString, "panel:userEnteredFilename:confirmed:", Object, NSString, bool)(sender, filename, okFlag); | |
101 } | |
102 | |
103 void panel (Object sender, bool expanding) | |
104 { | |
105 return invokeObjcSelf!(void, "panel:willExpand:", Object, bool)(sender, expanding); | |
106 } | |
107 | |
108 void panel (Object sender, NSString path) | |
109 { | |
110 return invokeObjcSelf!(void, "panel:directoryDidChange:", Object, NSString)(sender, path); | |
111 } | |
112 | |
113 void panelSelectionDidChange (Object sender) | |
114 { | |
115 return invokeObjcSelf!(void, "panelSelectionDidChange:", Object)(sender); | |
116 } | |
117 | |
118 //mixin ObjcBindMethod!(panel, "panel:shouldShowFilename:"); | |
119 //mixin ObjcBindMethod!(panel, "panel:compareFilename:with:caseSensitive:"); | |
120 //mixin ObjcBindMethod!(panel, "panel:isValidFilename:"); | |
121 //mixin ObjcBindMethod!(panel, "panel:userEnteredFilename:confirmed:"); | |
122 //mixin ObjcBindMethod!(panel, "panel:willExpand:"); | |
123 //mixin ObjcBindMethod!(panel, "panel:directoryDidChange:"); | |
124 //mixin ObjcBindMethod!(panelSelectionDidChange, "panelSelectionDidChange:"); | |
125 | |
126 `; | |
127 | |
128 class NSSavePanel : NSPanel | |
129 { | |
130 mixin (ObjcWrap); | |
131 | |
132 static NSSavePanel savePanel () | |
133 { | |
134 return invokeObjcSelfClass!(NSSavePanel, "savePanel"); | |
135 } | |
136 | |
137 NSURL URL () | |
138 { | |
139 return invokeObjcSelf!(NSURL, "URL"); | |
140 } | |
141 | |
142 NSString filename () | |
143 { | |
144 return invokeObjcSelf!(NSString, "filename"); | |
145 } | |
146 | |
147 NSString directory () | |
148 { | |
149 return invokeObjcSelf!(NSString, "directory"); | |
150 } | |
151 | |
152 void setDirectory (NSString path) | |
153 { | |
154 return invokeObjcSelf!(void, "setDirectory:", NSString)(path); | |
155 } | |
156 | |
157 NSString requiredFileType () | |
158 { | |
159 return invokeObjcSelf!(NSString, "requiredFileType"); | |
160 } | |
161 | |
162 void setRequiredFileType (NSString type) | |
163 { | |
164 return invokeObjcSelf!(void, "setRequiredFileType:", NSString)(type); | |
165 } | |
166 | |
167 NSArray allowedFileTypes () | |
168 { | |
169 return invokeObjcSelf!(NSArray, "allowedFileTypes"); | |
170 } | |
171 | |
172 void setAllowedFileTypes (NSArray types) | |
173 { | |
174 return invokeObjcSelf!(void, "setAllowedFileTypes:", NSArray)(types); | |
175 } | |
176 | |
177 bool allowsOtherFileTypes () | |
178 { | |
179 return invokeObjcSelf!(bool, "allowsOtherFileTypes"); | |
180 } | |
181 | |
182 void setAllowsOtherFileTypes (bool flag) | |
183 { | |
184 return invokeObjcSelf!(void, "setAllowsOtherFileTypes:", bool)(flag); | |
185 } | |
186 | |
187 NSView accessoryView () | |
188 { | |
189 return invokeObjcSelf!(NSView, "accessoryView"); | |
190 } | |
191 | |
192 void setAccessoryView (NSView view) | |
193 { | |
194 return invokeObjcSelf!(void, "setAccessoryView:", NSView)(view); | |
195 } | |
196 | |
197 Object delegate_ () | |
198 { | |
199 return invokeObjcSelf!(Object, "delegate"); | |
200 } | |
201 | |
202 void setDelegate (Object delegate_) | |
203 { | |
204 return invokeObjcSelf!(void, "setDelegate:", Object)(delegate_); | |
205 } | |
206 | |
207 bool isExpanded () | |
208 { | |
209 return invokeObjcSelf!(bool, "isExpanded"); | |
210 } | |
211 | |
212 bool canCreateDirectories () | |
213 { | |
214 return invokeObjcSelf!(bool, "canCreateDirectories"); | |
215 } | |
216 | |
217 void setCanCreateDirectories (bool flag) | |
218 { | |
219 return invokeObjcSelf!(void, "setCanCreateDirectories:", bool)(flag); | |
220 } | |
221 | |
222 bool canSelectHiddenExtension () | |
223 { | |
224 return invokeObjcSelf!(bool, "canSelectHiddenExtension"); | |
225 } | |
226 | |
227 void setCanSelectHiddenExtension (bool flag) | |
228 { | |
229 return invokeObjcSelf!(void, "setCanSelectHiddenExtension:", bool)(flag); | |
230 } | |
231 | |
232 bool isExtensionHidden () | |
233 { | |
234 return invokeObjcSelf!(bool, "isExtensionHidden"); | |
235 } | |
236 | |
237 void setExtensionHidden (bool flag) | |
238 { | |
239 return invokeObjcSelf!(void, "setExtensionHidden:", bool)(flag); | |
240 } | |
241 | |
242 bool treatsFilePackagesAsDirectories () | |
243 { | |
244 return invokeObjcSelf!(bool, "treatsFilePackagesAsDirectories"); | |
245 } | |
246 | |
247 void setTreatsFilePackagesAsDirectories (bool flag) | |
248 { | |
249 return invokeObjcSelf!(void, "setTreatsFilePackagesAsDirectories:", bool)(flag); | |
250 } | |
251 | |
252 NSString prompt () | |
253 { | |
254 return invokeObjcSelf!(NSString, "prompt"); | |
255 } | |
256 | |
257 void setPrompt (NSString prompt) | |
258 { | |
259 return invokeObjcSelf!(void, "setPrompt:", NSString)(prompt); | |
260 } | |
261 | |
262 NSString title () | |
263 { | |
264 return invokeObjcSelf!(NSString, "title"); | |
265 } | |
266 | |
267 void setTitle (NSString title) | |
268 { | |
269 return invokeObjcSelf!(void, "setTitle:", NSString)(title); | |
270 } | |
271 | |
272 NSString nameFieldLabel () | |
273 { | |
274 return invokeObjcSelf!(NSString, "nameFieldLabel"); | |
275 } | |
276 | |
277 void setNameFieldLabel (NSString label) | |
278 { | |
279 return invokeObjcSelf!(void, "setNameFieldLabel:", NSString)(label); | |
280 } | |
281 | |
282 NSString message () | |
283 { | |
284 return invokeObjcSelf!(NSString, "message"); | |
285 } | |
286 | |
287 void setMessage (NSString message) | |
288 { | |
289 return invokeObjcSelf!(void, "setMessage:", NSString)(message); | |
290 } | |
291 | |
292 void validateVisibleColumns () | |
293 { | |
294 return invokeObjcSelf!(void, "validateVisibleColumns"); | |
295 } | |
296 | |
297 void selectText (Object sender) | |
298 { | |
299 return invokeObjcSelf!(void, "selectText:", Object)(sender); | |
300 } | |
301 | |
302 // NSSavePanelRuntime | |
303 void ok (Object sender) | |
304 { | |
305 return invokeObjcSelf!(void, "ok:", Object)(sender); | |
306 } | |
307 | |
308 void cancel (Object sender) | |
309 { | |
310 return invokeObjcSelf!(void, "cancel:", Object)(sender); | |
311 } | |
312 | |
313 void beginSheetForDirectory (NSString path, NSString name, NSWindow docWindow, Object delegate_, SEL didEndSelector, void* contextInfo) | |
314 { | |
315 return invokeObjcSelf!(void, "beginSheetForDirectory:file:modalForWindow:modalDelegate:didEndSelector:contextInfo:", NSString, NSString, NSWindow, Object, SEL, void*)(path, name, docWindow, delegate_, didEndSelector, contextInfo); | |
316 } | |
317 | |
318 NSInteger runModalForDirectory (NSString path, NSString name) | |
319 { | |
320 return invokeObjcSelf!(NSInteger, "runModalForDirectory:file:", NSString, NSString)(path, name); | |
321 } | |
322 | |
323 NSInteger runModal () | |
324 { | |
325 return invokeObjcSelf!(NSInteger, "runModal"); | |
326 } | |
327 } |