Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSEvent.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.NSEvent; | |
15 | |
16 import dwt.internal.cocoa.id; | |
17 import dwt.internal.cocoa.CGEventTypes; | |
18 import dwt.internal.cocoa.CGFloat; | |
19 import dwt.internal.cocoa.NSDate : NSTimeInterval; | |
20 import dwt.internal.cocoa.NSGraphicsContext; | |
21 import dwt.internal.cocoa.NSInteger; | |
22 import dwt.internal.cocoa.NSObject; | |
23 import dwt.internal.cocoa.NSPoint; | |
24 import dwt.internal.cocoa.NSString; | |
25 import dwt.internal.cocoa.NSTrackingArea; | |
26 import dwt.internal.cocoa.NSWindow; | |
27 import dwt.internal.cocoa.OS; | |
28 import objc = dwt.internal.objc.runtime; | |
29 | |
30 enum NSEventType | |
31 { | |
32 NSLeftMouseDown = 1, | |
33 NSLeftMouseUp = 2, | |
34 NSRightMouseDown = 3, | |
35 NSRightMouseUp = 4, | |
36 NSMouseMoved = 5, | |
37 NSLeftMouseDragged = 6, | |
38 NSRightMouseDragged = 7, | |
39 NSMouseEntered = 8, | |
40 NSMouseExited = 9, | |
41 NSKeyDown = 10, | |
42 NSKeyUp = 11, | |
43 NSFlagsChanged = 12, | |
44 NSAppKitDefined = 13, | |
45 NSSystemDefined = 14, | |
46 NSApplicationDefined = 15, | |
47 NSPeriodic = 16, | |
48 NSCursorUpdate = 17, | |
49 NSScrollWheel = 22, | |
50 NSTabletPoint = 23, | |
51 NSTabletProximity = 24, | |
52 NSOtherMouseDown = 25, | |
53 NSOtherMouseUp = 26, | |
54 NSOtherMouseDragged = 27 | |
55 } | |
56 | |
57 enum NSPointingDeviceType | |
58 { | |
59 NSUnknownPointingDevice = NX_TABLET_POINTER_UNKNOWN, | |
60 NSPenPointingDevice = NX_TABLET_POINTER_PEN, | |
61 NSCursorPointingDevice = NX_TABLET_POINTER_CURSOR, | |
62 NSEraserPointingDevice = NX_TABLET_POINTER_ERASER | |
63 } | |
64 | |
65 public class NSEvent : NSObject | |
66 { | |
67 public this () | |
68 { | |
69 super(); | |
70 } | |
71 | |
72 public this (objc.id id) | |
73 { | |
74 super(id); | |
75 } | |
76 | |
77 public CGEventRef CGEvent () | |
78 { | |
79 return OS.objc_msgSend(this.id, OS.sel_CGEvent); | |
80 } | |
81 | |
82 public NSInteger absoluteX () | |
83 { | |
84 return OS.objc_msgSend(this.id, OS.sel_absoluteX); | |
85 } | |
86 | |
87 public NSInteger absoluteY () | |
88 { | |
89 return OS.objc_msgSend(this.id, OS.sel_absoluteY); | |
90 } | |
91 | |
92 public NSInteger absoluteZ () | |
93 { | |
94 return OS.objc_msgSend(this.id, OS.sel_absoluteZ); | |
95 } | |
96 | |
97 public NSUInteger buttonMask () | |
98 { | |
99 return OS.objc_msgSend(this.id, OS.sel_buttonMask); | |
100 } | |
101 | |
102 public NSInteger buttonNumber () | |
103 { | |
104 return OS.objc_msgSend(this.id, OS.sel_buttonNumber); | |
105 } | |
106 | |
107 public NSUInteger capabilityMask () | |
108 { | |
109 return OS.objc_msgSend(this.id, OS.sel_capabilityMask); | |
110 } | |
111 | |
112 public NSString characters () | |
113 { | |
114 objc.id result = OS.objc_msgSend(this.id, OS.sel_characters); | |
115 return result !is null ? new NSString(result) : null; | |
116 } | |
117 | |
118 public NSString charactersIgnoringModifiers () | |
119 { | |
120 objc.id result = OS.objc_msgSend(this.id, OS.sel_charactersIgnoringModifiers); | |
121 return result !is null ? new NSString(result) : null; | |
122 } | |
123 | |
124 public NSInteger clickCount () | |
125 { | |
126 return OS.objc_msgSend(this.id, OS.sel_clickCount); | |
127 } | |
128 | |
129 public NSGraphicsContext context () | |
130 { | |
131 objc.id result = OS.objc_msgSend(this.id, OS.sel_context); | |
132 return result !is null ? new NSGraphicsContext(result) : null; | |
133 } | |
134 | |
135 public NSInteger data1 () | |
136 { | |
137 return OS.objc_msgSend(this.id, OS.sel_data1); | |
138 } | |
139 | |
140 public NSInteger data2 () | |
141 { | |
142 return OS.objc_msgSend(this.id, OS.sel_data2); | |
143 } | |
144 | |
145 public CGFloat deltaX () | |
146 { | |
147 return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_deltaX); | |
148 } | |
149 | |
150 public CGFloat deltaY () | |
151 { | |
152 return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_deltaY); | |
153 } | |
154 | |
155 public CGFloat deltaZ () | |
156 { | |
157 return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_deltaZ); | |
158 } | |
159 | |
160 public NSUInteger deviceID () | |
161 { | |
162 return OS.objc_msgSend(this.id, OS.sel_deviceID); | |
163 } | |
164 | |
165 public static NSEvent enterExitEventWithType (objc.id type, NSPoint location, NSUInteger flags, NSTimeInterval time, NSInteger wNum, | |
166 NSGraphicsContext context, NSInteger eNum, NSInteger tNum, void* data) | |
167 { | |
168 objc.id result = OS.objc_msgSend(OS.class_NSEvent, | |
169 OS.sel_enterExitEventWithType_1location_1modifierFlags_1timestamp_1windowNumber_1context_1eventNumber_1trackingNumber_1userData_1, | |
170 type, location, flags, time, wNum, context !is null ? context.id : null, eNum, tNum, data); | |
171 return result !is null ? new NSEvent(result) : null; | |
172 } | |
173 | |
174 public NSInteger eventNumber () | |
175 { | |
176 return OS.objc_msgSend(this.id, OS.sel_eventNumber); | |
177 } | |
178 | |
179 public /*const*/void* eventRef () | |
180 { | |
181 return OS.objc_msgSend(this.id, OS.sel_eventRef); | |
182 } | |
183 | |
184 public static NSEvent eventWithCGEvent (CGEvent cgEvent) | |
185 { | |
186 objc.id result = OS.objc_msgSend(OS.class_NSEvent, OS.sel_eventWithCGEvent_1, cgEvent); | |
187 return result !is null ? new NSEvent(result) : null; | |
188 } | |
189 | |
190 public static NSEvent eventWithEventRef (/*const*/void* eventRef) | |
191 { | |
192 objc.id result = OS.objc_msgSend(OS.class_NSEvent, OS.sel_eventWithEventRef_1, eventRef); | |
193 return result !is null ? new NSEvent(result) : null; | |
194 } | |
195 | |
196 public bool isARepeat () | |
197 { | |
198 return OS.objc_msgSend(this.id, OS.sel_isARepeat) !is null; | |
199 } | |
200 | |
201 public bool isEnteringProximity () | |
202 { | |
203 return OS.objc_msgSend(this.id, OS.sel_isEnteringProximity) !is null; | |
204 } | |
205 | |
206 public static bool isMouseCoalescingEnabled () | |
207 { | |
208 return OS.objc_msgSend(OS.class_NSEvent, OS.sel_isMouseCoalescingEnabled) !is null; | |
209 } | |
210 | |
211 public short keyCode () | |
212 { | |
213 return cast(short) OS.objc_msgSend(this.id, OS.sel_keyCode); | |
214 } | |
215 | |
216 public static NSEvent keyEventWithType (NSEventType type, NSPoint location, NSUInteger flags, NSTimeInterval time, NSInteger wNum, | |
217 NSGraphicsContext context, NSString keys, NSString ukeys, bool flag, short code) | |
218 { | |
219 objc.id | |
220 result = OS.objc_msgSend( | |
221 OS.class_NSEvent, | |
222 OS.sel_keyEventWithType_1location_1modifierFlags_1timestamp_1windowNumber_1context_1characters_1charactersIgnoringModifiers_1isARepeat_1keyCode_1, | |
223 type, location, flags, time, wNum, context !is null ? context.id : null, keys !is null ? keys.id : null, | |
224 ukeys !is null ? ukeys.id : null, flag, code); | |
225 return result !is null ? new NSEvent(result) : null; | |
226 } | |
227 | |
228 public NSPoint locationInWindow () | |
229 { | |
230 NSPoint result; | |
231 OS.objc_msgSend_struct(result, this.id, OS.sel_locationInWindow); | |
232 return result; | |
233 } | |
234 | |
235 public NSUInteger modifierFlags () | |
236 { | |
237 return OS.objc_msgSend(this.id, OS.sel_modifierFlags); | |
238 } | |
239 | |
240 public static NSEvent mouseEventWithType (NSEventType type, NSPoint location, NSUInteger flags, NSTimeInterval time, NSInteger wNum, | |
241 NSGraphicsContext context, NSInteger eNum, NSInteger cNum, float pressure) | |
242 { | |
243 objc.id result = OS.objc_msgSend(OS.class_NSEvent, | |
244 OS.sel_mouseEventWithType_1location_1modifierFlags_1timestamp_1windowNumber_1context_1eventNumber_1clickCount_1pressure_1, type, | |
245 location, flags, time, wNum, context !is null ? context.id : null, eNum, cNum, pressure); | |
246 return result !is null ? new NSEvent(result) : null; | |
247 } | |
248 | |
249 public static NSPoint mouseLocation () | |
250 { | |
251 NSPoint result; | |
252 OS.objc_msgSend_struct(result, OS.class_NSEvent, OS.sel_mouseLocation); | |
253 return result; | |
254 } | |
255 | |
256 public static NSEvent otherEventWithType (NSEventType type, NSPoint location, NSUInteger flags, NSTimeInterval time, NSInteger wNum, NSGraphicsContext context, | |
257 short subtype, NSInteger d1, NSInteger d2) | |
258 { | |
259 objc.id result = OS.objc_msgSend(OS.class_NSEvent, | |
260 OS.sel_otherEventWithType_1location_1modifierFlags_1timestamp_1windowNumber_1context_1subtype_1data1_1data2_1, type, location, flags, | |
261 time, wNum, context !is null ? context.id : null, subtype, d1, d2); | |
262 return result !is null ? new NSEvent(result) : null; | |
263 } | |
264 | |
265 public NSUInteger pointingDeviceID () | |
266 { | |
267 return OS.objc_msgSend(this.id, OS.sel_pointingDeviceID); | |
268 } | |
269 | |
270 public NSUInteger pointingDeviceSerialNumber () | |
271 { | |
272 return OS.objc_msgSend(this.id, OS.sel_pointingDeviceSerialNumber); | |
273 } | |
274 | |
275 public NSPointingDeviceType pointingDeviceType () | |
276 { | |
277 return OS.objc_msgSend(this.id, OS.sel_pointingDeviceType); | |
278 } | |
279 | |
280 public float pressure () | |
281 { | |
282 return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_pressure); | |
283 } | |
284 | |
285 public float rotation () | |
286 { | |
287 return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_rotation); | |
288 } | |
289 | |
290 public static void setMouseCoalescingEnabled (bool flag) | |
291 { | |
292 OS.objc_msgSend(OS.class_NSEvent, OS.sel_setMouseCoalescingEnabled_1, flag); | |
293 } | |
294 | |
295 public static void startPeriodicEventsAfterDelay (double delay, double period) | |
296 { | |
297 OS.objc_msgSend(OS.class_NSEvent, OS.sel_startPeriodicEventsAfterDelay_1withPeriod_1, delay, period); | |
298 } | |
299 | |
300 public static void stopPeriodicEvents () | |
301 { | |
302 OS.objc_msgSend(OS.class_NSEvent, OS.sel_stopPeriodicEvents); | |
303 } | |
304 | |
305 public short subtype () | |
306 { | |
307 return cast(short) OS.objc_msgSend(this.id, OS.sel_subtype); | |
308 } | |
309 | |
310 public NSUInteger systemTabletID () | |
311 { | |
312 return OS.objc_msgSend(this.id, OS.sel_systemTabletID); | |
313 } | |
314 | |
315 public NSUInteger tabletID () | |
316 { | |
317 return OS.objc_msgSend(this.id, OS.sel_tabletID); | |
318 } | |
319 | |
320 public float tangentialPressure () | |
321 { | |
322 return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_tangentialPressure); | |
323 } | |
324 | |
325 public NSPoint tilt () | |
326 { | |
327 NSPoint result; | |
328 OS.objc_msgSend_stret(result, this.id, OS.sel_tilt); | |
329 return result; | |
330 } | |
331 | |
332 public NSTimeInterval timestamp () | |
333 { | |
334 return OS.objc_msgSend_fpret(this.id, OS.sel_timestamp); | |
335 } | |
336 | |
337 public NSTrackingArea trackingArea () | |
338 { | |
339 objc.id result = OS.objc_msgSend(this.id, OS.sel_trackingArea); | |
340 return result !is null ? new NSTrackingArea(result) : null; | |
341 } | |
342 | |
343 public NSInteger trackingNumber () | |
344 { | |
345 return OS.objc_msgSend(this.id, OS.sel_trackingNumber); | |
346 } | |
347 | |
348 public NSEventType type () | |
349 { | |
350 return OS.objc_msgSend(this.id, OS.sel_type); | |
351 } | |
352 | |
353 public long uniqueID () | |
354 { | |
355 return cast(long) OS.objc_msgSend(this.id, OS.sel_uniqueID); | |
356 } | |
357 | |
358 public void* userData () | |
359 { | |
360 return OS.objc_msgSend(this.id, OS.sel_userData); | |
361 } | |
362 | |
363 public id vendorDefined () | |
364 { | |
365 objc.id result = OS.objc_msgSend(this.id, OS.sel_vendorDefined); | |
366 return result !is null ? new id(result) : null; | |
367 } | |
368 | |
369 public NSUInteger vendorID () | |
370 { | |
371 return OS.objc_msgSend(this.id, OS.sel_vendorID); | |
372 } | |
373 | |
374 public NSUInteger vendorPointingDeviceType () | |
375 { | |
376 return OS.objc_msgSend(this.id, OS.sel_vendorPointingDeviceType); | |
377 } | |
378 | |
379 public NSWindow window () | |
380 { | |
381 objc.id result = OS.objc_msgSend(this.id, OS.sel_window); | |
382 return result !is null ? new NSWindow(result) : null; | |
383 } | |
384 | |
385 public NSInteger windowNumber () | |
386 { | |
387 return OS.objc_msgSend(this.id, OS.sel_windowNumber); | |
388 } | |
389 | |
390 } |