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

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