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.NSRunLoop;
|
|
8
|
|
9 import dstep.corefoundation.CFRunLoop;
|
|
10 import dstep.foundation.NSArray;
|
|
11 import dstep.foundation.NSDate;
|
|
12 import dstep.foundation.NSObject;
|
|
13 import dstep.foundation.NSPort;
|
|
14 import dstep.foundation.NSTimer;
|
|
15 import dstep.objc.bridge.Bridge;
|
|
16 import dstep.objc.objc : id;
|
|
17
|
|
18 import bindings = dstep.foundation.NSRunLoop_bindings;
|
|
19
|
|
20 const NSString NSDefaultRunLoopMode;
|
|
21 const NSString NSRunLoopCommonModes;
|
|
22
|
|
23 static this ()
|
|
24 {
|
|
25 NSDefaultRunLoopMode = new NSString(bindings.NSDefaultRunLoopMode);
|
|
26 NSRunLoopCommonModes = new NSString(bindings.NSRunLoopCommonModes);
|
|
27 }
|
|
28
|
|
29 class NSRunLoop : NSObject
|
|
30 {
|
|
31 mixin ObjcWrap;
|
|
32 mixin TNSOrderedPerform;
|
|
33 mixin TNSRunLoopConveniences;
|
|
34
|
|
35 static NSRunLoop currentRunLoop ()
|
|
36 {
|
|
37 return invokeObjcSelfClass!(NSRunLoop, "currentRunLoop"return result is this.objcObject ? this : (result !is null ? new NSRunLoop(result) : null); }
|
|
38
|
|
39 static NSRunLoop mainRunLoop ()
|
|
40 {
|
|
41 return invokeObjcSelfClass!(NSRunLoop, "mainRunLoop"return result is this.objcObject ? this : (result !is null ? new NSRunLoop(result) : null); }
|
|
42
|
|
43 NSString currentMode ()
|
|
44 {
|
|
45 return invokeObjcSelf!(NSString, "currentMode");
|
|
46 }
|
|
47
|
|
48 CFRunLoopRef getCFRunLoop ()
|
|
49 {
|
|
50 return invokeObjcSelf!(CFRunLoopRef, "getCFRunLoop");
|
|
51 }
|
|
52
|
|
53 void addTimer (NSTimer timer, NSString mode)
|
|
54 {
|
|
55 return invokeObjcSelf!(void, "addTimer:forMode:", NSTimer, NSString)(timer, mode);
|
|
56 }
|
|
57
|
|
58 void addPort (NSPort aPort, NSString mode)
|
|
59 {
|
|
60 return invokeObjcSelf!(void, "addPort:forMode:", NSPort, NSString)(aPort, mode);
|
|
61 }
|
|
62
|
|
63 void removePort (NSPort aPort, NSString mode)
|
|
64 {
|
|
65 return invokeObjcSelf!(void, "removePort:forMode:", NSPort, NSString)(aPort, mode);
|
|
66 }
|
|
67
|
|
68 NSDate limitDateForMode (NSString mode)
|
|
69 {
|
|
70 return invokeObjcSelf!(NSDate, "limitDateForMode:", NSString)(mode);
|
|
71 }
|
|
72
|
|
73 void acceptInputForMode (NSString mode, NSDate limitDate)
|
|
74 {
|
|
75 return invokeObjcSelf!(void, "acceptInputForMode:beforeDate:", NSString, NSDate)(mode, limitDate);
|
|
76 }
|
|
77 }
|
|
78
|
|
79 template TNSOrderedPerform ()
|
|
80 {
|
|
81 void performSelector (SEL aSelector, Object target, Object arg, NSUInteger order, NSArray modes)
|
|
82 {
|
|
83 return invokeObjcSelf!(void, "performSelector:target:argument:order:modes:", SEL, Object, Object, NSUInteger, NSArray)(aSelector, target, arg, order, modes);
|
|
84 }
|
|
85
|
|
86 void cancelPerformSelector (SEL aSelector, Object target, Object arg)
|
|
87 {
|
|
88 return invokeObjcSelf!(void, "cancelPerformSelector:target:argument:", SEL, Object, Object)(aSelector, target, arg);
|
|
89 }
|
|
90
|
|
91 void cancelPerformSelectorsWithTarget (Object target)
|
|
92 {
|
|
93 return invokeObjcSelf!(void, "cancelPerformSelectorsWithTarget:", Object)(target);
|
|
94 }
|
|
95 }
|
|
96
|
|
97 template TNSDelayedPerforming ()
|
|
98 {
|
|
99 void performSelector (SEL aSelector, Object anArgument, double delay, NSArray modes);
|
|
100 void performSelector (SEL aSelector, Object anArgument, double delay);
|
|
101 static void cancelPreviousPerformRequestsWithTarget (Object aTarget, SEL aSelector, Object anArgument);
|
|
102 static void cancelPreviousPerformRequestsWithTarget (Object aTarget);
|
|
103 }
|
|
104
|
|
105 template TNSRunLoopConveniences ()
|
|
106 {
|
|
107 void run ()
|
|
108 {
|
|
109 return invokeObjcSelf!(void, "run");
|
|
110 }
|
|
111
|
|
112 void runUntilDate (NSDate limitDate)
|
|
113 {
|
|
114 return invokeObjcSelf!(void, "runUntilDate:", NSDate)(limitDate);
|
|
115 }
|
|
116
|
|
117 bool runMode (NSString mode, NSDate limitDate)
|
|
118 {
|
|
119 return invokeObjcSelf!(bool, "runMode:beforeDate:", NSString, NSDate)(mode, limitDate);
|
|
120 }
|
|
121
|
|
122 void configureAsServer ()
|
|
123 {
|
|
124 return invokeObjcSelf!(void, "configureAsServer");
|
|
125 }
|
|
126 }
|
|
127
|