Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSTimer.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.NSTimer; | |
15 | |
16 import dwt.internal.cocoa.id; | |
17 import dwt.internal.cocoa.NSDate; | |
18 import dwt.internal.cocoa.NSInvocation; | |
19 import dwt.internal.cocoa.NSObject; | |
20 import dwt.internal.cocoa.OS; | |
21 import objc = dwt.internal.objc.runtime; | |
22 | |
23 public class NSTimer : NSObject | |
24 { | |
25 | |
26 public this () | |
27 { | |
28 super(); | |
29 } | |
30 | |
31 public this (objc.id id) | |
32 { | |
33 super(id); | |
34 } | |
35 | |
36 public void fire () | |
37 { | |
38 OS.objc_msgSend(this.id, OS.sel_fire); | |
39 } | |
40 | |
41 public NSDate fireDate () | |
42 { | |
43 objc.id result = OS.objc_msgSend(this.id, OS.sel_fireDate); | |
44 return result !is null ? new NSDate(result) : null; | |
45 } | |
46 | |
47 public id initWithFireDate (NSDate date, NSTimeInterval ti, id t, objc.SEL s, id ui, bool rep) | |
48 { | |
49 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFireDate_1interval_1target_1selector_1userInfo_1repeats_1, | |
50 date !is null ? date.id : null, ti, t !is null ? t.id : null, s, ui !is null ? ui.id : null, rep); | |
51 return result !is null ? new id(result) : null; | |
52 } | |
53 | |
54 public void invalidate () | |
55 { | |
56 OS.objc_msgSend(this.id, OS.sel_invalidate); | |
57 } | |
58 | |
59 public bool isValid () | |
60 { | |
61 return OS.objc_msgSend(this.id, OS.sel_isValid) !is null; | |
62 } | |
63 | |
64 public static NSTimer static_scheduledTimerWithTimeInterval_invocation_repeats_ (NSTimeInterval ti, NSInvocation invocation, bool yesOrNo) | |
65 { | |
66 objc.id result = OS.objc_msgSend(OS.class_NSTimer, OS.sel_scheduledTimerWithTimeInterval_1invocation_1repeats_1, ti, | |
67 invocation !is null ? invocation.id : null, yesOrNo); | |
68 return result !is null ? new NSTimer(result) : null; | |
69 } | |
70 | |
71 public static NSTimer static_scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ (NSTimeInterval ti, id aTarget, objc.SEL aSelector, | |
72 objc.id userInfo, bool yesOrNo) | |
73 { | |
74 objc.id result = OS.objc_msgSend(OS.class_NSTimer, OS.sel_scheduledTimerWithTimeInterval_1target_1selector_1userInfo_1repeats_1, ti, | |
75 aTarget !is null ? aTarget.id : null, aSelector, userInfo, yesOrNo); | |
76 return result !is null ? new NSTimer(result) : null; | |
77 } | |
78 | |
79 public void setFireDate (NSDate date) | |
80 { | |
81 OS.objc_msgSend(this.id, OS.sel_setFireDate_1, date !is null ? date.id : null); | |
82 } | |
83 | |
84 public NSTimeInterval timeInterval () | |
85 { | |
86 return cast(NSTimeInterval) OS.objc_msgSend_fpret(this.id, OS.sel_timeInterval); | |
87 } | |
88 | |
89 public static NSTimer static_timerWithTimeInterval_invocation_repeats_ (NSTimeInterval ti, NSInvocation invocation, bool yesOrNo) | |
90 { | |
91 objc.id result = OS.objc_msgSend(OS.class_NSTimer, OS.sel_timerWithTimeInterval_1invocation_1repeats_1, ti, | |
92 invocation !is null ? invocation.id : null, yesOrNo); | |
93 return result !is null ? new NSTimer(result) : null; | |
94 } | |
95 | |
96 public static NSTimer static_timerWithTimeInterval_target_selector_userInfo_repeats_ (NSTimeInterval ti, id aTarget, objc.SEL aSelector, id userInfo, | |
97 bool yesOrNo) | |
98 { | |
99 objc.id result = OS.objc_msgSend(OS.class_NSTimer, OS.sel_timerWithTimeInterval_1target_1selector_1userInfo_1repeats_1, ti, | |
100 aTarget !is null ? aTarget.id : null, aSelector, userInfo !is null ? userInfo.id : null, yesOrNo); | |
101 return result !is null ? new NSTimer(result) : null; | |
102 } | |
103 | |
104 public objc.id userInfo () | |
105 { | |
106 return OS.objc_msgSend(this.id, OS.sel_userInfo); | |
107 } | |
108 | |
109 } |