Mercurial > projects > dstep
comparison dstep/appkit/NSEvent.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | |
children | b9de51448c6b |
comparison
equal
deleted
inserted
replaced
15:7ff919f595d5 | 16:19885b43130e |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Sep 24, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.appkit.NSEvent; | |
8 | |
9 import dstep.appkit.NSGraphicsContext; | |
10 import dstep.appkit.NSTrackingArea; | |
11 import dstep.appkit.NSWindow; | |
12 import dstep.applicationservices.ApplicationServices; | |
13 import dstep.foundation.NSCoder; | |
14 import dstep.foundation.NSDate; | |
15 import dstep.foundation.NSGeometry; | |
16 import dstep.foundation.NSObjCRuntime; | |
17 import dstep.foundation.NSObject; | |
18 import dstep.foundation.NSString; | |
19 import dstep.foundation.NSZone; | |
20 //import dstep.iokit.hidsystem.IOLLEvent; | |
21 import dstep.internal.Version; | |
22 import dstep.objc.bridge.Bridge; | |
23 import dstep.objc.objc; | |
24 | |
25 typedef NSUInteger NSEventType; | |
26 typedef NSUInteger NSPointingDeviceType; | |
27 | |
28 enum : NSUInteger | |
29 { | |
30 NSLeftMouseDown = 1, | |
31 NSLeftMouseUp = 2, | |
32 NSRightMouseDown = 3, | |
33 NSRightMouseUp = 4, | |
34 NSMouseMoved = 5, | |
35 NSLeftMouseDragged = 6, | |
36 NSRightMouseDragged = 7, | |
37 NSMouseEntered = 8, | |
38 NSMouseExited = 9, | |
39 NSKeyDown = 10, | |
40 NSKeyUp = 11, | |
41 NSFlagsChanged = 12, | |
42 NSAppKitDefined = 13, | |
43 NSSystemDefined = 14, | |
44 NSApplicationDefined = 15, | |
45 NSPeriodic = 16, | |
46 NSCursorUpdate = 17, | |
47 NSScrollWheel = 22, | |
48 NSTabletPoint = 23, | |
49 NSTabletProximity = 24, | |
50 NSOtherMouseDown = 25, | |
51 NSOtherMouseUp = 26, | |
52 NSOtherMouseDragged = 27 | |
53 } | |
54 | |
55 enum : NSUInteger | |
56 { | |
57 NSLeftMouseDownMask = 1 << NSLeftMouseDown, | |
58 NSLeftMouseUpMask = 1 << NSLeftMouseUp, | |
59 NSRightMouseDownMask = 1 << NSRightMouseDown, | |
60 NSRightMouseUpMask = 1 << NSRightMouseUp, | |
61 NSMouseMovedMask = 1 << NSMouseMoved, | |
62 NSLeftMouseDraggedMask = 1 << NSLeftMouseDragged, | |
63 NSRightMouseDraggedMask = 1 << NSRightMouseDragged, | |
64 NSMouseEnteredMask = 1 << NSMouseEntered, | |
65 NSMouseExitedMask = 1 << NSMouseExited, | |
66 NSKeyDownMask = 1 << NSKeyDown, | |
67 NSKeyUpMask = 1 << NSKeyUp, | |
68 NSFlagsChangedMask = 1 << NSFlagsChanged, | |
69 NSAppKitDefinedMask = 1 << NSAppKitDefined, | |
70 NSSystemDefinedMask = 1 << NSSystemDefined, | |
71 NSApplicationDefinedMask = 1 << NSApplicationDefined, | |
72 NSPeriodicMask = 1 << NSPeriodic, | |
73 NSCursorUpdateMask = 1 << NSCursorUpdate, | |
74 NSScrollWheelMask = 1 << NSScrollWheel, | |
75 NSTabletPointMask = 1 << NSTabletPoint, | |
76 NSTabletProximityMask = 1 << NSTabletProximity, | |
77 NSOtherMouseDownMask = 1 << NSOtherMouseDown, | |
78 NSOtherMouseUpMask = 1 << NSOtherMouseUp, | |
79 NSOtherMouseDraggedMask = 1 << NSOtherMouseDragged, | |
80 NSAnyEventMask = (2147483647L * 2UL + 1UL) | |
81 } | |
82 | |
83 version (D_LP64) | |
84 { | |
85 enum : ulong | |
86 { | |
87 NSAlphaShiftKeyMask = 1 << 16, | |
88 NSShiftKeyMask = 1 << 17, | |
89 NSControlKeyMask = 1 << 18, | |
90 NSAlternateKeyMask = 1 << 19, | |
91 NSCommandKeyMask = 1 << 20, | |
92 NSNumericPadKeyMask = 1 << 21, | |
93 NSHelpKeyMask = 1 << 22, | |
94 NSFunctionKeyMask = 1 << 23, | |
95 NSDeviceIndependentModifierFlagsMask = 0xffff0000UL | |
96 } | |
97 } | |
98 | |
99 else | |
100 { | |
101 enum : uint | |
102 { | |
103 NSAlphaShiftKeyMask = 1 << 16, | |
104 NSShiftKeyMask = 1 << 17, | |
105 NSControlKeyMask = 1 << 18, | |
106 NSAlternateKeyMask = 1 << 19, | |
107 NSCommandKeyMask = 1 << 20, | |
108 NSNumericPadKeyMask = 1 << 21, | |
109 NSHelpKeyMask = 1 << 22, | |
110 NSFunctionKeyMask = 1 << 23, | |
111 NSDeviceIndependentModifierFlagsMask = 0xffff0000U | |
112 } | |
113 } | |
114 | |
115 enum | |
116 { | |
117 NSUnknownPointingDevice = 0, | |
118 NSPenPointingDevice = 1, | |
119 NSCursorPointingDevice = 2, | |
120 NSEraserPointingDevice = 3 | |
121 } | |
122 | |
123 enum | |
124 { | |
125 NSPenTipMask = 0x0001, | |
126 NSPenLowerSideMask = 0x0002, | |
127 NSPenUpperSideMask = 0x0004 | |
128 } | |
129 | |
130 enum | |
131 { | |
132 NSUpArrowFunctionKey = 0xF700, | |
133 NSDownArrowFunctionKey = 0xF701, | |
134 NSLeftArrowFunctionKey = 0xF702, | |
135 NSRightArrowFunctionKey = 0xF703, | |
136 NSF1FunctionKey = 0xF704, | |
137 NSF2FunctionKey = 0xF705, | |
138 NSF3FunctionKey = 0xF706, | |
139 NSF4FunctionKey = 0xF707, | |
140 NSF5FunctionKey = 0xF708, | |
141 NSF6FunctionKey = 0xF709, | |
142 NSF7FunctionKey = 0xF70A, | |
143 NSF8FunctionKey = 0xF70B, | |
144 NSF9FunctionKey = 0xF70C, | |
145 NSF10FunctionKey = 0xF70D, | |
146 NSF11FunctionKey = 0xF70E, | |
147 NSF12FunctionKey = 0xF70F, | |
148 NSF13FunctionKey = 0xF710, | |
149 NSF14FunctionKey = 0xF711, | |
150 NSF15FunctionKey = 0xF712, | |
151 NSF16FunctionKey = 0xF713, | |
152 NSF17FunctionKey = 0xF714, | |
153 NSF18FunctionKey = 0xF715, | |
154 NSF19FunctionKey = 0xF716, | |
155 NSF20FunctionKey = 0xF717, | |
156 NSF21FunctionKey = 0xF718, | |
157 NSF22FunctionKey = 0xF719, | |
158 NSF23FunctionKey = 0xF71A, | |
159 NSF24FunctionKey = 0xF71B, | |
160 NSF25FunctionKey = 0xF71C, | |
161 NSF26FunctionKey = 0xF71D, | |
162 NSF27FunctionKey = 0xF71E, | |
163 NSF28FunctionKey = 0xF71F, | |
164 NSF29FunctionKey = 0xF720, | |
165 NSF30FunctionKey = 0xF721, | |
166 NSF31FunctionKey = 0xF722, | |
167 NSF32FunctionKey = 0xF723, | |
168 NSF33FunctionKey = 0xF724, | |
169 NSF34FunctionKey = 0xF725, | |
170 NSF35FunctionKey = 0xF726, | |
171 NSInsertFunctionKey = 0xF727, | |
172 NSDeleteFunctionKey = 0xF728, | |
173 NSHomeFunctionKey = 0xF729, | |
174 NSBeginFunctionKey = 0xF72A, | |
175 NSEndFunctionKey = 0xF72B, | |
176 NSPageUpFunctionKey = 0xF72C, | |
177 NSPageDownFunctionKey = 0xF72D, | |
178 NSPrintScreenFunctionKey = 0xF72E, | |
179 NSScrollLockFunctionKey = 0xF72F, | |
180 NSPauseFunctionKey = 0xF730, | |
181 NSSysReqFunctionKey = 0xF731, | |
182 NSBreakFunctionKey = 0xF732, | |
183 NSResetFunctionKey = 0xF733, | |
184 NSStopFunctionKey = 0xF734, | |
185 NSMenuFunctionKey = 0xF735, | |
186 NSUserFunctionKey = 0xF736, | |
187 NSSystemFunctionKey = 0xF737, | |
188 NSPrintFunctionKey = 0xF738, | |
189 NSClearLineFunctionKey = 0xF739, | |
190 NSClearDisplayFunctionKey = 0xF73A, | |
191 NSInsertLineFunctionKey = 0xF73B, | |
192 NSDeleteLineFunctionKey = 0xF73C, | |
193 NSInsertCharFunctionKey = 0xF73D, | |
194 NSDeleteCharFunctionKey = 0xF73E, | |
195 NSPrevFunctionKey = 0xF73F, | |
196 NSNextFunctionKey = 0xF740, | |
197 NSSelectFunctionKey = 0xF741, | |
198 NSExecuteFunctionKey = 0xF742, | |
199 NSUndoFunctionKey = 0xF743, | |
200 NSRedoFunctionKey = 0xF744, | |
201 NSFindFunctionKey = 0xF745, | |
202 NSHelpFunctionKey = 0xF746, | |
203 NSModeSwitchFunctionKey = 0xF747 | |
204 } | |
205 | |
206 enum | |
207 { | |
208 NSWindowExposedEventType = 0, | |
209 NSApplicationActivatedEventType = 1, | |
210 NSApplicationDeactivatedEventType = 2, | |
211 NSWindowMovedEventType = 4, | |
212 NSScreenChangedEventType = 8, | |
213 NSAWTEventType = 16 | |
214 } | |
215 | |
216 enum | |
217 { | |
218 NSPowerOffEventType = 1 | |
219 } | |
220 | |
221 enum | |
222 { | |
223 NSMouseEventSubtype = 0, | |
224 NSTabletPointEventSubtype = 1, | |
225 NSTabletProximityEventSubtype = 2 | |
226 } | |
227 | |
228 class NSEvent : NSObject, INSCopying, INSCoding | |
229 { | |
230 mixin (ObjcWrap); | |
231 | |
232 this (NSCoder aDecoder) | |
233 { | |
234 super(typeof(this).alloc.initWithCoder(aDecoder).objcObject); | |
235 } | |
236 | |
237 void encodeWithCoder (NSCoder aCoder) | |
238 { | |
239 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
240 } | |
241 | |
242 typeof(this) initWithCoder (NSCoder aDecoder) | |
243 { | |
244 return invokeObjcSelf!(typeof(this), "initWithCoder:", NSCoder)(aDecoder); | |
245 } | |
246 | |
247 typeof(this) copyWithZone (NSZone* zone) | |
248 { | |
249 return invokeObjcSelf!(typeof(this), "copyWithZone:", NSZone*)(zone); | |
250 } | |
251 | |
252 uint type () | |
253 { | |
254 return invokeObjcSelf!(uint, "type"); | |
255 } | |
256 | |
257 NSUInteger modifierFlags () | |
258 { | |
259 return invokeObjcSelf!(NSUInteger, "modifierFlags"); | |
260 } | |
261 | |
262 double timestamp () | |
263 { | |
264 return invokeObjcSelf!(double, "timestamp"); | |
265 } | |
266 | |
267 NSWindow window () | |
268 { | |
269 return invokeObjcSelf!(NSWindow, "window"); | |
270 } | |
271 | |
272 NSInteger windowNumber () | |
273 { | |
274 return invokeObjcSelf!(NSInteger, "windowNumber"); | |
275 } | |
276 | |
277 NSGraphicsContext context () | |
278 { | |
279 return invokeObjcSelf!(NSGraphicsContext, "context"); | |
280 } | |
281 | |
282 NSInteger clickCount () | |
283 { | |
284 return invokeObjcSelf!(NSInteger, "clickCount"); | |
285 } | |
286 | |
287 NSInteger buttonNumber () | |
288 { | |
289 return invokeObjcSelf!(NSInteger, "buttonNumber"); | |
290 } | |
291 | |
292 NSInteger eventNumber () | |
293 { | |
294 return invokeObjcSelf!(NSInteger, "eventNumber"); | |
295 } | |
296 | |
297 float pressure () | |
298 { | |
299 return invokeObjcSelf!(float, "pressure"); | |
300 } | |
301 | |
302 NSPoint locationInWindow () | |
303 { | |
304 return invokeObjcSelf!(NSPoint, "locationInWindow"); | |
305 } | |
306 | |
307 CGFloat deltaX () | |
308 { | |
309 return invokeObjcSelf!(CGFloat, "deltaX"); | |
310 } | |
311 | |
312 CGFloat deltaY () | |
313 { | |
314 return invokeObjcSelf!(CGFloat, "deltaY"); | |
315 } | |
316 | |
317 CGFloat deltaZ () | |
318 { | |
319 return invokeObjcSelf!(CGFloat, "deltaZ"); | |
320 } | |
321 | |
322 NSString characters () | |
323 { | |
324 return invokeObjcSelf!(NSString, "characters"); | |
325 } | |
326 | |
327 NSString charactersIgnoringModifiers () | |
328 { | |
329 return invokeObjcSelf!(NSString, "charactersIgnoringModifiers"); | |
330 } | |
331 | |
332 bool isARepeat () | |
333 { | |
334 return invokeObjcSelf!(bool, "isARepeat"); | |
335 } | |
336 | |
337 ushort keyCode () | |
338 { | |
339 return invokeObjcSelf!(ushort, "keyCode"); | |
340 } | |
341 | |
342 NSInteger trackingNumber () | |
343 { | |
344 return invokeObjcSelf!(NSInteger, "trackingNumber"); | |
345 } | |
346 | |
347 void* userData () | |
348 { | |
349 return invokeObjcSelf!(void*, "userData"); | |
350 } | |
351 | |
352 NSTrackingArea trackingArea () | |
353 { | |
354 return invokeObjcSelf!(NSTrackingArea, "trackingArea"); | |
355 } | |
356 | |
357 short subtype () | |
358 { | |
359 return invokeObjcSelf!(short, "subtype"); | |
360 } | |
361 | |
362 NSInteger data1 () | |
363 { | |
364 return invokeObjcSelf!(NSInteger, "data1"); | |
365 } | |
366 | |
367 NSInteger data2 () | |
368 { | |
369 return invokeObjcSelf!(NSInteger, "data2"); | |
370 } | |
371 | |
372 void* eventRef () | |
373 { | |
374 return invokeObjcSelf!(void*, "eventRef"); | |
375 } | |
376 | |
377 static NSEvent eventWithEventRef (void* eventRef) | |
378 { | |
379 return invokeObjcSelfClass!(NSEvent, "eventWithEventRef:", void*)(eventRef); | |
380 } | |
381 | |
382 CGEventRef CGEvent () | |
383 { | |
384 return invokeObjcSelf!(CGEventRef, "CGEvent"); | |
385 } | |
386 | |
387 static NSEvent eventWithCGEvent (CGEventRef cgEvent) | |
388 { | |
389 return invokeObjcSelfClass!(NSEvent, "eventWithCGEvent:", CGEventRef)(cgEvent); | |
390 } | |
391 | |
392 static void setMouseCoalescingEnabled (bool flag) | |
393 { | |
394 return invokeObjcSelfClass!(void, "setMouseCoalescingEnabled:", bool)(flag); | |
395 } | |
396 | |
397 static bool isMouseCoalescingEnabled () | |
398 { | |
399 return invokeObjcSelfClass!(bool, "isMouseCoalescingEnabled"); | |
400 } | |
401 | |
402 NSUInteger deviceID () | |
403 { | |
404 return invokeObjcSelf!(NSUInteger, "deviceID"); | |
405 } | |
406 | |
407 NSInteger absoluteX () | |
408 { | |
409 return invokeObjcSelf!(NSInteger, "absoluteX"); | |
410 } | |
411 | |
412 NSInteger absoluteY () | |
413 { | |
414 return invokeObjcSelf!(NSInteger, "absoluteY"); | |
415 } | |
416 | |
417 NSInteger absoluteZ () | |
418 { | |
419 return invokeObjcSelf!(NSInteger, "absoluteZ"); | |
420 } | |
421 | |
422 NSUInteger buttonMask () | |
423 { | |
424 return invokeObjcSelf!(NSUInteger, "buttonMask"); | |
425 } | |
426 | |
427 NSPoint tilt () | |
428 { | |
429 return invokeObjcSelf!(NSPoint, "tilt"); | |
430 } | |
431 | |
432 float rotation () | |
433 { | |
434 return invokeObjcSelf!(float, "rotation"); | |
435 } | |
436 | |
437 float tangentialPressure () | |
438 { | |
439 return invokeObjcSelf!(float, "tangentialPressure"); | |
440 } | |
441 | |
442 Object vendorDefined () | |
443 { | |
444 return invokeObjcSelf!(Object, "vendorDefined"); | |
445 } | |
446 | |
447 NSUInteger vendorID () | |
448 { | |
449 return invokeObjcSelf!(NSUInteger, "vendorID"); | |
450 } | |
451 | |
452 NSUInteger tabletID () | |
453 { | |
454 return invokeObjcSelf!(NSUInteger, "tabletID"); | |
455 } | |
456 | |
457 NSUInteger pointingDeviceID () | |
458 { | |
459 return invokeObjcSelf!(NSUInteger, "pointingDeviceID"); | |
460 } | |
461 | |
462 NSUInteger systemTabletID () | |
463 { | |
464 return invokeObjcSelf!(NSUInteger, "systemTabletID"); | |
465 } | |
466 | |
467 NSUInteger vendorPointingDeviceType () | |
468 { | |
469 return invokeObjcSelf!(NSUInteger, "vendorPointingDeviceType"); | |
470 } | |
471 | |
472 NSUInteger pointingDeviceSerialNumber () | |
473 { | |
474 return invokeObjcSelf!(NSUInteger, "pointingDeviceSerialNumber"); | |
475 } | |
476 | |
477 ulong uniqueID () | |
478 { | |
479 return invokeObjcSelf!(ulong, "uniqueID"); | |
480 } | |
481 | |
482 NSUInteger capabilityMask () | |
483 { | |
484 return invokeObjcSelf!(NSUInteger, "capabilityMask"); | |
485 } | |
486 | |
487 uint pointingDeviceType () | |
488 { | |
489 return invokeObjcSelf!(uint, "pointingDeviceType"); | |
490 } | |
491 | |
492 bool isEnteringProximity () | |
493 { | |
494 return invokeObjcSelf!(bool, "isEnteringProximity"); | |
495 } | |
496 | |
497 static void startPeriodicEventsAfterDelay (double delay, double period) | |
498 { | |
499 return invokeObjcSelfClass!(void, "startPeriodicEventsAfterDelay:withPeriod:", double, double)(delay, period); | |
500 } | |
501 | |
502 static void stopPeriodicEvents () | |
503 { | |
504 return invokeObjcSelfClass!(void, "stopPeriodicEvents"); | |
505 } | |
506 | |
507 static NSEvent mouseEventWithType (uint type, NSPoint location, NSUInteger flags, double time, NSInteger wNum, NSGraphicsContext context, NSInteger eNum, NSInteger cNum, float pressure) | |
508 { | |
509 return invokeObjcSelfClass!(NSEvent, "mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:", uint, NSPoint, NSUInteger, double, NSInteger, NSGraphicsContext, NSInteger, NSInteger, float)(type, location, flags, time, wNum, context, eNum, cNum, pressure); | |
510 } | |
511 | |
512 static NSEvent keyEventWithType (uint type, NSPoint location, NSUInteger flags, double time, NSInteger wNum, NSGraphicsContext context, NSString keys, NSString ukeys, bool flag, ushort code) | |
513 { | |
514 return invokeObjcSelfClass!(NSEvent, "keyEventWithType:location:modifierFlags:timestamp:windowNumber:context:characters:charactersIgnoringModifiers:isARepeat:keyCode:", uint, NSPoint, NSUInteger, double, NSInteger, NSGraphicsContext, NSString, NSString, bool, ushort)(type, location, flags, time, wNum, context, keys, ukeys, flag, code); | |
515 } | |
516 | |
517 static NSEvent enterExitEventWithType (uint type, NSPoint location, NSUInteger flags, double time, NSInteger wNum, NSGraphicsContext context, NSInteger eNum, NSInteger tNum, void* data) | |
518 { | |
519 return invokeObjcSelfClass!(NSEvent, "enterExitEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:trackingNumber:userData:", uint, NSPoint, NSUInteger, double, NSInteger, NSGraphicsContext, NSInteger, NSInteger, void*)(type, location, flags, time, wNum, context, eNum, tNum, data); | |
520 } | |
521 | |
522 static NSEvent otherEventWithType (uint type, NSPoint location, NSUInteger flags, double time, NSInteger wNum, NSGraphicsContext context, short subtype, NSInteger d1, NSInteger d2) | |
523 { | |
524 return invokeObjcSelfClass!(NSEvent, "otherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:", uint, NSPoint, NSUInteger, double, NSInteger, NSGraphicsContext, short, NSInteger, NSInteger)(type, location, flags, time, wNum, context, subtype, d1, d2); | |
525 } | |
526 | |
527 static NSPoint mouseLocation () | |
528 { | |
529 return invokeObjcSelfClass!(NSPoint, "mouseLocation"); | |
530 } | |
531 | |
532 } | |
533 |