Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSApplication.d @ 0:380af2bdd8e5
Upload of whole dwt tree
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 17:00:02 +0200 |
parents | |
children | 8b48be5454ce |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:380af2bdd8e5 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2007 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * | |
11 * Port to the D Programming language: | |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | |
13 *******************************************************************************/ | |
14 module dwt.internal.cocoa.NSApplication; | |
15 | |
16 import dwt.internal.cocoa.NSArray; | |
17 import dwt.internal.cocoa.NSDate; | |
18 import dwt.internal.cocoa.NSDictionary; | |
19 import dwt.internal.cocoa.NSDockTile; | |
20 import dwt.internal.cocoa.NSEvent; | |
21 import dwt.internal.cocoa.NSException; | |
22 import dwt.internal.cocoa.NSGraphicsContext; | |
23 import dwt.internal.cocoa.NSImage; | |
24 import dwt.internal.cocoa.NSInteger; | |
25 import dwt.internal.cocoa.NSMenu; | |
26 import dwt.internal.cocoa.NSResponder; | |
27 import dwt.internal.cocoa.NSString; | |
28 import dwt.internal.cocoa.NSWindow; | |
29 import dwt.internal.cocoa.OS; | |
30 import objc = dwt.internal.objc.runtime; | |
31 | |
32 public class NSApplication : NSResponder | |
33 { | |
34 public this () | |
35 { | |
36 super(); | |
37 } | |
38 | |
39 public this (objc.id id) | |
40 { | |
41 super(id); | |
42 } | |
43 | |
44 public void abortModal () | |
45 { | |
46 OS.objc_msgSend(this.id, OS.sel_abortModal); | |
47 } | |
48 | |
49 public void activateContextHelpMode (id sender) | |
50 { | |
51 OS.objc_msgSend(this.id, OS.sel_activateContextHelpMode_1, sender !is null ? sender.id : null); | |
52 } | |
53 | |
54 public void activateIgnoringOtherApps (bool flag) | |
55 { | |
56 OS.objc_msgSend(this.id, OS.sel_activateIgnoringOtherApps_1, flag); | |
57 } | |
58 | |
59 public void addWindowsItem (NSWindow win, NSString aString, bool isFilename) | |
60 { | |
61 OS.objc_msgSend(this.id, OS.sel_addWindowsItem_1title_1filename_1, win !is null ? win.id : null, aString !is null ? aString.id : null, | |
62 isFilename); | |
63 } | |
64 | |
65 public NSImage applicationIconImage () | |
66 { | |
67 objc.id result = OS.objc_msgSend(this.id, OS.sel_applicationIconImage); | |
68 return result !is null ? new NSImage(result) : null; | |
69 } | |
70 | |
71 public void arrangeInFront (id sender) | |
72 { | |
73 OS.objc_msgSend(this.id, OS.sel_arrangeInFront_1, sender !is null ? sender.id : null); | |
74 } | |
75 | |
76 public objc.id beginModalSessionForWindow_ (NSWindow theWindow) | |
77 { | |
78 return OS.objc_msgSend(this.id, OS.sel_beginModalSessionForWindow_1, theWindow !is null ? theWindow.id : null); | |
79 } | |
80 | |
81 public objc.id beginModalSessionForWindow_relativeToWindow_ (NSWindow theWindow, NSWindow docWindow) | |
82 { | |
83 return OS.objc_msgSend(this.id, OS.sel_beginModalSessionForWindow_1relativeToWindow_1, theWindow !is null ? theWindow.id : null, | |
84 docWindow !is null ? docWindow.id : null); | |
85 } | |
86 | |
87 public void beginSheet (NSWindow sheet, NSWindow docWindow, id modalDelegate, objc.id didEndSelector, objc.id contextInfo) | |
88 { | |
89 OS.objc_msgSend(this.id, OS.sel_beginSheet_1modalForWindow_1modalDelegate_1didEndSelector_1contextInfo_1, sheet !is null ? sheet.id : null, | |
90 docWindow !is null ? docWindow.id : null, modalDelegate !is null ? modalDelegate.id : null, didEndSelector, contextInfo); | |
91 } | |
92 | |
93 public void cancelUserAttentionRequest (objc.id request) | |
94 { | |
95 OS.objc_msgSend(this.id, OS.sel_cancelUserAttentionRequest_1, request); | |
96 } | |
97 | |
98 public void changeWindowsItem (NSWindow win, NSString aString, bool isFilename) | |
99 { | |
100 OS.objc_msgSend(this.id, OS.sel_changeWindowsItem_1title_1filename_1, win !is null ? win.id : null, aString !is null ? aString.id : null, | |
101 isFilename); | |
102 } | |
103 | |
104 public NSGraphicsContext context () | |
105 { | |
106 objc.id result = OS.objc_msgSend(this.id, OS.sel_context); | |
107 return result !is null ? new NSGraphicsContext(result) : null; | |
108 } | |
109 | |
110 public NSEvent currentEvent () | |
111 { | |
112 objc.id result = OS.objc_msgSend(this.id, OS.sel_currentEvent); | |
113 return result !is null ? new NSEvent(result) : null; | |
114 } | |
115 | |
116 public void deactivate () | |
117 { | |
118 OS.objc_msgSend(this.id, OS.sel_deactivate); | |
119 } | |
120 | |
121 public id delegatee () | |
122 { | |
123 objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate); | |
124 return result !is null ? new id(result) : null; | |
125 } | |
126 | |
127 public static void detachDrawingThread (objc.id selector, id target, id argument) | |
128 { | |
129 OS.objc_msgSend(OS.class_NSApplication, OS.sel_detachDrawingThread_1toTarget_1withObject_1, selector, target !is null ? target.id : null, | |
130 argument !is null ? argument.id : null); | |
131 } | |
132 | |
133 public void discardEventsMatchingMask (NSUInteger mask, NSEvent lastEvent) | |
134 { | |
135 OS.objc_msgSend(this.id, OS.sel_discardEventsMatchingMask_1beforeEvent_1, mask, lastEvent !is null ? lastEvent.id : null); | |
136 } | |
137 | |
138 public NSDockTile dockTile () | |
139 { | |
140 objc.id result = OS.objc_msgSend(this.id, OS.sel_dockTile); | |
141 return result !is null ? new NSDockTile(result) : null; | |
142 } | |
143 | |
144 public void endModalSession (objc.id session) | |
145 { | |
146 OS.objc_msgSend(this.id, OS.sel_endModalSession_1, session); | |
147 } | |
148 | |
149 public void endSheet_ (NSWindow sheet) | |
150 { | |
151 OS.objc_msgSend(this.id, OS.sel_endSheet_1, sheet !is null ? sheet.id : null); | |
152 } | |
153 | |
154 public void endSheet_returnCode_ (NSWindow sheet, NSInteger returnCode) | |
155 { | |
156 OS.objc_msgSend(this.id, OS.sel_endSheet_1returnCode_1, sheet !is null ? sheet.id : null, returnCode); | |
157 } | |
158 | |
159 public void finishLaunching () | |
160 { | |
161 OS.objc_msgSend(this.id, OS.sel_finishLaunching); | |
162 } | |
163 | |
164 public void hide (id sender) | |
165 { | |
166 OS.objc_msgSend(this.id, OS.sel_hide_1, sender !is null ? sender.id : null); | |
167 } | |
168 | |
169 public void hideOtherApplications (id sender) | |
170 { | |
171 OS.objc_msgSend(this.id, OS.sel_hideOtherApplications_1, sender !is null ? sender.id : null); | |
172 } | |
173 | |
174 public bool isActive () | |
175 { | |
176 return OS.objc_msgSend(this.id, OS.sel_isActive) !is null; | |
177 } | |
178 | |
179 public bool isHidden () | |
180 { | |
181 return OS.objc_msgSend(this.id, OS.sel_isHidden) !is null; | |
182 } | |
183 | |
184 public bool isRunning () | |
185 { | |
186 return OS.objc_msgSend(this.id, OS.sel_isRunning) !is null; | |
187 } | |
188 | |
189 public NSWindow keyWindow () | |
190 { | |
191 objc.id result = OS.objc_msgSend(this.id, OS.sel_keyWindow); | |
192 return result !is null ? new NSWindow(result) : null; | |
193 } | |
194 | |
195 public NSMenu mainMenu () | |
196 { | |
197 objc.id result = OS.objc_msgSend(this.id, OS.sel_mainMenu); | |
198 return result !is null ? new NSMenu(result) : null; | |
199 } | |
200 | |
201 public NSWindow mainWindow () | |
202 { | |
203 objc.id result = OS.objc_msgSend(this.id, OS.sel_mainWindow); | |
204 return result !is null ? new NSWindow(result) : null; | |
205 } | |
206 | |
207 public NSWindow makeWindowsPerform (objc.id aSelector, bool flag) | |
208 { | |
209 objc.id result = OS.objc_msgSend(this.id, OS.sel_makeWindowsPerform_1inOrder_1, aSelector, flag); | |
210 return result !is null ? new NSWindow(result) : null; | |
211 } | |
212 | |
213 public void miniaturizeAll (id sender) | |
214 { | |
215 OS.objc_msgSend(this.id, OS.sel_miniaturizeAll_1, sender !is null ? sender.id : null); | |
216 } | |
217 | |
218 public NSWindow modalWindow () | |
219 { | |
220 objc.id result = OS.objc_msgSend(this.id, OS.sel_modalWindow); | |
221 return result !is null ? new NSWindow(result) : null; | |
222 } | |
223 | |
224 public NSEvent nextEventMatchingMask (NSUInteger mask, NSDate expiration, NSString mode, bool deqFlag) | |
225 { | |
226 objc.id result = OS.objc_msgSend(this.id, OS.sel_nextEventMatchingMask_1untilDate_1inMode_1dequeue_1, mask, | |
227 expiration !is null ? expiration.id : null, mode !is null ? mode.id : null, deqFlag); | |
228 return result !is null ? new NSEvent(result) : null; | |
229 } | |
230 | |
231 public void orderFrontCharacterPalette (id sender) | |
232 { | |
233 OS.objc_msgSend(this.id, OS.sel_orderFrontCharacterPalette_1, sender !is null ? sender.id : null); | |
234 } | |
235 | |
236 public void orderFrontColorPanel (id sender) | |
237 { | |
238 OS.objc_msgSend(this.id, OS.sel_orderFrontColorPanel_1, sender !is null ? sender.id : null); | |
239 } | |
240 | |
241 public void orderFrontStandardAboutPanel (id sender) | |
242 { | |
243 OS.objc_msgSend(this.id, OS.sel_orderFrontStandardAboutPanel_1, sender !is null ? sender.id : null); | |
244 } | |
245 | |
246 public void orderFrontStandardAboutPanelWithOptions (NSDictionary optionsDictionary) | |
247 { | |
248 OS.objc_msgSend(this.id, OS.sel_orderFrontStandardAboutPanelWithOptions_1, optionsDictionary !is null ? optionsDictionary.id : null); | |
249 } | |
250 | |
251 public NSArray orderedDocuments () | |
252 { | |
253 objc.id result = OS.objc_msgSend(this.id, OS.sel_orderedDocuments); | |
254 return result !is null ? new NSArray(result) : null; | |
255 } | |
256 | |
257 public NSArray orderedWindows () | |
258 { | |
259 objc.id result = OS.objc_msgSend(this.id, OS.sel_orderedWindows); | |
260 return result !is null ? new NSArray(result) : null; | |
261 } | |
262 | |
263 public void postEvent (NSEvent event, bool flag) | |
264 { | |
265 OS.objc_msgSend(this.id, OS.sel_postEvent_1atStart_1, event !is null ? event.id : null, flag); | |
266 } | |
267 | |
268 public void preventWindowOrdering () | |
269 { | |
270 OS.objc_msgSend(this.id, OS.sel_preventWindowOrdering); | |
271 } | |
272 | |
273 public void registerServicesMenuSendTypes (NSArray sendTypes, NSArray returnTypes) | |
274 { | |
275 OS.objc_msgSend(this.id, OS.sel_registerServicesMenuSendTypes_1returnTypes_1, sendTypes !is null ? sendTypes.id : null, | |
276 returnTypes !is null ? returnTypes.id : null); | |
277 } | |
278 | |
279 public void removeWindowsItem (NSWindow win) | |
280 { | |
281 OS.objc_msgSend(this.id, OS.sel_removeWindowsItem_1, win !is null ? win.id : null); | |
282 } | |
283 | |
284 public void replyToApplicationShouldTerminate (bool shouldTerminate) | |
285 { | |
286 OS.objc_msgSend(this.id, OS.sel_replyToApplicationShouldTerminate_1, shouldTerminate); | |
287 } | |
288 | |
289 public void replyToOpenOrPrint (objc.id reply) | |
290 { | |
291 OS.objc_msgSend(this.id, OS.sel_replyToOpenOrPrint_1, reply); | |
292 } | |
293 | |
294 public void reportException (NSException theException) | |
295 { | |
296 OS.objc_msgSend(this.id, OS.sel_reportException_1, theException !is null ? theException.id : null); | |
297 } | |
298 | |
299 public NSInteger requestUserAttention (objc.id requestType) | |
300 { | |
301 return OS.objc_msgSend(this.id, OS.sel_requestUserAttention_1, requestType); | |
302 } | |
303 | |
304 public void run () | |
305 { | |
306 OS.objc_msgSend(this.id, OS.sel_run); | |
307 } | |
308 | |
309 public objc.id runModalForWindow_ (NSWindow theWindow) | |
310 { | |
311 return OS.objc_msgSend(this.id, OS.sel_runModalForWindow_1, theWindow !is null ? theWindow.id : null); | |
312 } | |
313 | |
314 public objc.id runModalForWindow_relativeToWindow_ (NSWindow theWindow, NSWindow docWindow) | |
315 { | |
316 return OS.objc_msgSend(this.id, OS.sel_runModalForWindow_1relativeToWindow_1, theWindow !is null ? theWindow.id : null, | |
317 docWindow !is null ? docWindow.id : null); | |
318 } | |
319 | |
320 public objc.id runModalSession (objc.id session) | |
321 { | |
322 return OS.objc_msgSend(this.id, OS.sel_runModalSession_1, session); | |
323 } | |
324 | |
325 public void runPageLayout (id sender) | |
326 { | |
327 OS.objc_msgSend(this.id, OS.sel_runPageLayout_1, sender !is null ? sender.id : null); | |
328 } | |
329 | |
330 public bool sendAction (objc.id theAction, id theTarget, id sender) | |
331 { | |
332 return OS.objc_msgSend(this.id, OS.sel_sendAction_1to_1from_1, theAction, theTarget !is null ? theTarget.id : null, | |
333 sender !is null ? sender.id : null) !is null; | |
334 } | |
335 | |
336 public void sendEvent (NSEvent theEvent) | |
337 { | |
338 OS.objc_msgSend(this.id, OS.sel_sendEvent_1, theEvent !is null ? theEvent.id : null); | |
339 } | |
340 | |
341 public NSMenu servicesMenu () | |
342 { | |
343 objc.id result = OS.objc_msgSend(this.id, OS.sel_servicesMenu); | |
344 return result !is null ? new NSMenu(result) : null; | |
345 } | |
346 | |
347 public id servicesProvider () | |
348 { | |
349 objc.id result = OS.objc_msgSend(this.id, OS.sel_servicesProvider); | |
350 return result !is null ? new id(result) : null; | |
351 } | |
352 | |
353 public void setApplicationIconImage (NSImage image) | |
354 { | |
355 OS.objc_msgSend(this.id, OS.sel_setApplicationIconImage_1, image !is null ? image.id : null); | |
356 } | |
357 | |
358 public void setDelegate (id anObject) | |
359 { | |
360 OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null); | |
361 } | |
362 | |
363 public void setMainMenu (NSMenu aMenu) | |
364 { | |
365 OS.objc_msgSend(this.id, OS.sel_setMainMenu_1, aMenu !is null ? aMenu.id : null); | |
366 } | |
367 | |
368 public void setServicesMenu (NSMenu aMenu) | |
369 { | |
370 OS.objc_msgSend(this.id, OS.sel_setServicesMenu_1, aMenu !is null ? aMenu.id : null); | |
371 } | |
372 | |
373 public void setServicesProvider (id provider) | |
374 { | |
375 OS.objc_msgSend(this.id, OS.sel_setServicesProvider_1, provider !is null ? provider.id : null); | |
376 } | |
377 | |
378 public void setWindowsMenu (NSMenu aMenu) | |
379 { | |
380 OS.objc_msgSend(this.id, OS.sel_setWindowsMenu_1, aMenu !is null ? aMenu.id : null); | |
381 } | |
382 | |
383 public void setWindowsNeedUpdate (bool needUpdate) | |
384 { | |
385 OS.objc_msgSend(this.id, OS.sel_setWindowsNeedUpdate_1, needUpdate); | |
386 } | |
387 | |
388 public static NSApplication sharedApplication () | |
389 { | |
390 objc.id result = OS.objc_msgSend(OS.class_NSApplication, OS.sel_sharedApplication); | |
391 return result !is null ? new NSApplication(result) : null; | |
392 } | |
393 | |
394 public void showHelp (id sender) | |
395 { | |
396 OS.objc_msgSend(this.id, OS.sel_showHelp_1, sender !is null ? sender.id : null); | |
397 } | |
398 | |
399 public void stop (id sender) | |
400 { | |
401 OS.objc_msgSend(this.id, OS.sel_stop_1, sender !is null ? sender.id : null); | |
402 } | |
403 | |
404 public void stopModal () | |
405 { | |
406 OS.objc_msgSend(this.id, OS.sel_stopModal); | |
407 } | |
408 | |
409 public void stopModalWithCode (NSInteger returnCode) | |
410 { | |
411 OS.objc_msgSend(this.id, OS.sel_stopModalWithCode_1, returnCode); | |
412 } | |
413 | |
414 public id targetForAction_ (objc.SEL theAction) | |
415 { | |
416 objc.id result = OS.objc_msgSend(this.id, OS.sel_targetForAction_1, theAction); | |
417 return result !is null ? new id(result) : null; | |
418 } | |
419 | |
420 public id targetForAction_to_from_ (objc.SEL theAction, id theTarget, id sender) | |
421 { | |
422 objc.id result = OS.objc_msgSend(this.id, OS.sel_targetForAction_1to_1from_1, theAction, theTarget !is null ? theTarget.id : null, | |
423 sender !is null ? sender.id : null); | |
424 return result !is null ? new id(result) : null; | |
425 } | |
426 | |
427 public void terminate (id sender) | |
428 { | |
429 OS.objc_msgSend(this.id, OS.sel_terminate_1, sender !is null ? sender.id : null); | |
430 } | |
431 | |
432 public bool tryToPerform (objc.SEL anAction, id anObject) | |
433 { | |
434 return OS.objc_msgSend(this.id, OS.sel_tryToPerform_1with_1, anAction, anObject !is null ? anObject.id : null) !is null; | |
435 } | |
436 | |
437 public void unhide (id sender) | |
438 { | |
439 OS.objc_msgSend(this.id, OS.sel_unhide_1, sender !is null ? sender.id : null); | |
440 } | |
441 | |
442 public void unhideAllApplications (id sender) | |
443 { | |
444 OS.objc_msgSend(this.id, OS.sel_unhideAllApplications_1, sender !is null ? sender.id : null); | |
445 } | |
446 | |
447 public void unhideWithoutActivation () | |
448 { | |
449 OS.objc_msgSend(this.id, OS.sel_unhideWithoutActivation); | |
450 } | |
451 | |
452 public void updateWindows () | |
453 { | |
454 OS.objc_msgSend(this.id, OS.sel_updateWindows); | |
455 } | |
456 | |
457 public void updateWindowsItem (NSWindow win) | |
458 { | |
459 OS.objc_msgSend(this.id, OS.sel_updateWindowsItem_1, win !is null ? win.id : null); | |
460 } | |
461 | |
462 public id validRequestorForSendType (NSString sendType, NSString returnType) | |
463 { | |
464 objc.id result = OS.objc_msgSend(this.id, OS.sel_validRequestorForSendType_1returnType_1, sendType !is null ? sendType.id : null, | |
465 returnType !is null ? returnType.id : null); | |
466 return result !is null ? new id(result) : null; | |
467 } | |
468 | |
469 public NSWindow windowWithWindowNumber (NSInteger windowNum) | |
470 { | |
471 objc.id result = OS.objc_msgSend(this.id, OS.sel_windowWithWindowNumber_1, windowNum); | |
472 return result !is null ? new NSWindow(result) : null; | |
473 } | |
474 | |
475 public NSArray windows () | |
476 { | |
477 objc.id result = OS.objc_msgSend(this.id, OS.sel_windows); | |
478 return result !is null ? new NSArray(result) : null; | |
479 } | |
480 | |
481 public NSMenu windowsMenu () | |
482 { | |
483 objc.id result = OS.objc_msgSend(this.id, OS.sel_windowsMenu); | |
484 return result !is null ? new NSMenu(result) : null; | |
485 } | |
486 | |
487 } |