comparison dwt/internal/cocoa/NSRunLoop.d @ 45:d8635bb48c7c

Merge with SWT 3.5
author Jacob Carlborg <doob@me.com>
date Mon, 01 Dec 2008 17:07:00 +0100
parents f565d3a95c0a
children
comparison
equal deleted inserted replaced
44:ca5e494f2bbf 45:d8635bb48c7c
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2007 IBM Corporation and others. 2 * Copyright (c) 2000, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 * 10 *
11 * Port to the D programming language: 11 * Port to the D programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com> 12 * Jacob Carlborg <doob@me.com>
13 *******************************************************************************/ 13 *******************************************************************************/
14 module dwt.internal.cocoa.NSRunLoop; 14 module dwt.internal.cocoa.NSRunLoop;
15 15
16 import dwt.internal.cocoa.CFRunLoopRef; 16 import dwt.dwthelper.utils;
17 import dwt.internal.cocoa.id; 17 import cocoa = dwt.internal.cocoa.id;
18 import dwt.internal.cocoa.NSArray;
19 import dwt.internal.cocoa.NSDate; 18 import dwt.internal.cocoa.NSDate;
20 import dwt.internal.cocoa.NSInteger;
21 import dwt.internal.cocoa.NSObject; 19 import dwt.internal.cocoa.NSObject;
22 import dwt.internal.cocoa.NSPort;
23 import dwt.internal.cocoa.NSString; 20 import dwt.internal.cocoa.NSString;
24 import dwt.internal.cocoa.NSTimer;
25 import dwt.internal.cocoa.OS; 21 import dwt.internal.cocoa.OS;
26 import objc = dwt.internal.objc.runtime; 22 import objc = dwt.internal.objc.runtime;
27 23
28 public class NSRunLoop : NSObject 24 public class NSRunLoop : NSObject {
29 {
30 25
31 public this () 26 public this() {
32 { 27 super();
33 super(); 28 }
34 }
35 29
36 public this (objc.id id) 30 public this(objc.id id) {
37 { 31 super(id);
38 super(id); 32 }
39 }
40 33
41 public void acceptInputForMode (NSString mode, NSDate limitDate) 34 public this(cocoa.id id) {
42 { 35 super(id);
43 OS.objc_msgSend(this.id_, OS.sel_acceptInputForMode_1beforeDate_1, mode !is null ? mode.id_ : null, limitDate !is null ? limitDate.id_ : null); 36 }
44 }
45 37
46 public void addPort (NSPort aPort, NSString mode) 38 public static NSRunLoop currentRunLoop() {
47 { 39 objc.id result = OS.objc_msgSend(OS.class_NSRunLoop, OS.sel_currentRunLoop);
48 OS.objc_msgSend(this.id_, OS.sel_addPort_1forMode_1, aPort !is null ? aPort.id_ : null, mode !is null ? mode.id_ : null); 40 return result !is null ? new NSRunLoop(result) : null;
49 } 41 }
50 42
51 public void addTimer (NSTimer timer, NSString mode) 43 public static NSRunLoop mainRunLoop() {
52 { 44 objc.id result = OS.objc_msgSend(OS.class_NSRunLoop, OS.sel_mainRunLoop);
53 OS.objc_msgSend(this.id_, OS.sel_addTimer_1forMode_1, timer !is null ? timer.id_ : null, mode !is null ? mode.id_ : null); 45 return result !is null ? new NSRunLoop(result) : null;
54 } 46 }
55 47
56 public void cancelPerformSelector (objc.SEL aSelector, id target, id arg) 48 public bool runMode(NSString mode, NSDate limitDate) {
57 { 49 return OS.objc_msgSend_bool(this.id, OS.sel_runMode_beforeDate_, mode !is null ? mode.id : null, limitDate !is null ? limitDate.id : null);
58 OS.objc_msgSend(this.id_, OS.sel_cancelPerformSelector_1target_1argument_1, aSelector, target !is null ? target.id_ : null, 50 }
59 arg !is null ? arg.id_ : null);
60 }
61
62 public void cancelPerformSelectorsWithTarget (id target)
63 {
64 OS.objc_msgSend(this.id_, OS.sel_cancelPerformSelectorsWithTarget_1, target !is null ? target.id_ : null);
65 }
66
67 public void configureAsServer ()
68 {
69 OS.objc_msgSend(this.id_, OS.sel_configureAsServer);
70 }
71
72 public NSString currentMode ()
73 {
74 objc.id result = OS.objc_msgSend(this.id_, OS.sel_currentMode);
75 return result !is null ? new NSString(result) : null;
76 }
77
78 public static NSRunLoop currentRunLoop ()
79 {
80 objc.id result = OS.objc_msgSend(OS.class_NSRunLoop, OS.sel_currentRunLoop);
81 return result !is null ? new NSRunLoop(result) : null;
82 }
83
84 public CFRunLoopRef getCFRunLoop ()
85 {
86 return cast(CFRunLoopRef) OS.objc_msgSend(this.id_, OS.sel_getCFRunLoop);
87 }
88
89 public NSDate limitDateForMode (NSString mode)
90 {
91 objc.id result = OS.objc_msgSend(this.id_, OS.sel_limitDateForMode_1, mode !is null ? mode.id_ : null);
92 return result !is null ? new NSDate(result) : null;
93 }
94
95 public static NSRunLoop mainRunLoop ()
96 {
97 objc.id result = OS.objc_msgSend(OS.class_NSRunLoop, OS.sel_mainRunLoop);
98 return result !is null ? new NSRunLoop(result) : null;
99 }
100
101 public void performSelector (objc.SEL aSelector, id target, id arg, NSUInteger order, NSArray modes)
102 {
103 OS.objc_msgSend(this.id_, OS.sel_performSelector_1target_1argument_1order_1modes_1, aSelector, target !is null ? target.id_ : null,
104 arg !is null ? arg.id_ : null, order, modes !is null ? modes.id_ : null);
105 }
106
107 public void removePort (NSPort aPort, NSString mode)
108 {
109 OS.objc_msgSend(this.id_, OS.sel_removePort_1forMode_1, aPort !is null ? aPort.id_ : null, mode !is null ? mode.id_ : null);
110 }
111
112 public void run ()
113 {
114 OS.objc_msgSend(this.id_, OS.sel_run);
115 }
116
117 public bool runMode (NSString mode, NSDate limitDate)
118 {
119 return OS.objc_msgSend(this.id_, OS.sel_runMode_1beforeDate_1, mode !is null ? mode.id_ : null, limitDate !is null ? limitDate.id_ : null) !is null;
120 }
121
122 public void runUntilDate (NSDate limitDate)
123 {
124 OS.objc_msgSend(this.id_, OS.sel_runUntilDate_1, limitDate !is null ? limitDate.id_ : null);
125 }
126 51
127 } 52 }