~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/monomac/src/AppKit/NSEvent.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.Drawing;
 
3
using System.Diagnostics;
 
4
using MonoMac.Foundation;
 
5
using MonoMac.CoreGraphics;
 
6
 
 
7
namespace MonoMac.AppKit {
 
8
 
 
9
        [DebuggerTypeProxy (typeof(NSEvent.NSEventDebuggerProxy))]
 
10
        public partial class NSEvent {
 
11
                
 
12
                class NSEventDebuggerProxy {
 
13
                        NSEvent target;
 
14
                        
 
15
                        public NSEventDebuggerProxy (NSEvent target)
 
16
                        {
 
17
                                this.target = target;
 
18
                        }
 
19
 
 
20
                        #region Generic Event Information
 
21
 
 
22
                        // FIXME: broken
 
23
                        internal NSGraphicsContext Context {
 
24
                                get {
 
25
                                        return target.Context;
 
26
                                }
 
27
                        }
 
28
 
 
29
                        public PointF LocationInWindow {
 
30
                                get {
 
31
                                        return target.LocationInWindow;
 
32
                                }
 
33
                        }
 
34
                        
 
35
                        public NSEventModifierMask ModifierFlags {
 
36
                                get {
 
37
                                        return target.ModifierFlags;
 
38
                                }
 
39
                        }
 
40
 
 
41
                        public double Timestamp {
 
42
                                get {
 
43
                                        return target.Timestamp;
 
44
                                }
 
45
                        }
 
46
 
 
47
                        public NSEventType Type {
 
48
                                get {
 
49
                                        return target.Type;
 
50
                                }
 
51
                        }
 
52
 
 
53
                        public NSWindow Window {
 
54
                                get {
 
55
                                        return target.Window;
 
56
                                }
 
57
                        }
 
58
                        
 
59
                        public int WindowNumber {
 
60
                                get {
 
61
                                        return target.WindowNumber;
 
62
                                }
 
63
                        }
 
64
 
 
65
                        public IntPtr CGEvent {
 
66
                                get {
 
67
                                        return target.CGEvent;
 
68
                                }
 
69
                        }
 
70
 
 
71
                        #endregion
 
72
 
 
73
                        #region Key Event Information
 
74
 
 
75
                        bool IsKeyEvent ()
 
76
                        {
 
77
                                switch (target.Type) {
 
78
                                case NSEventType.KeyDown:
 
79
                                case NSEventType.KeyUp:
 
80
                                        return true;
 
81
                                default:
 
82
                                        return false;
 
83
                                }
 
84
                        }
 
85
 
 
86
                        void CheckKeyEvent ()
 
87
                        {
 
88
                                if (IsKeyEvent ())
 
89
                                        return;
 
90
                                throw new InvalidOperationException ("Not a key event.");
 
91
                        }
 
92
 
 
93
                        public string Characters {
 
94
                                get {
 
95
                                        CheckKeyEvent ();
 
96
                                        return target.Characters;
 
97
                                }
 
98
                        }
 
99
                        
 
100
                        public string CharactersIgnoringModifiers {
 
101
                                get {
 
102
                                        CheckKeyEvent ();
 
103
                                        return target.CharactersIgnoringModifiers;
 
104
                                }
 
105
                        }
 
106
                        
 
107
                        public bool IsARepeat {
 
108
                                get {
 
109
                                        CheckKeyEvent ();
 
110
                                        return target.IsARepeat;
 
111
                                }
 
112
                        }
 
113
                        
 
114
                        public ushort KeyCode {
 
115
                                get {
 
116
                                        CheckKeyEvent ();
 
117
                                        return target.KeyCode;
 
118
                                }
 
119
                        }
 
120
 
 
121
                        #endregion
 
122
 
 
123
                        #region Tablet Pointing Information
 
124
 
 
125
                        const int TabletPointEventSubtype = 1;
 
126
                        const int TabletProximityEventSubtype = 2;
 
127
 
 
128
                        bool IsMouseEvent ()
 
129
                        {
 
130
                                switch (target.Type) {
 
131
                                case NSEventType.LeftMouseDown:
 
132
                                case NSEventType.LeftMouseUp:
 
133
                                case NSEventType.RightMouseDown:
 
134
                                case NSEventType.RightMouseUp:
 
135
                                case NSEventType.MouseMoved:
 
136
                                case NSEventType.LeftMouseDragged:
 
137
                                case NSEventType.RightMouseDragged:
 
138
                                case NSEventType.MouseEntered:
 
139
                                case NSEventType.MouseExited:
 
140
                                case NSEventType.OtherMouseDown:
 
141
                                case NSEventType.OtherMouseUp:
 
142
                                case NSEventType.OtherMouseDragged:
 
143
                                        return true;
 
144
                                default:
 
145
                                        return false;
 
146
                                }
 
147
                        }
 
148
 
 
149
                        bool IsTabletPointingEvent ()
 
150
                        {
 
151
                                if (IsMouseEvent ())
 
152
                                        return target.Subtype == TabletPointEventSubtype;
 
153
                                return target.Type == NSEventType.TabletPoint;
 
154
                        }
 
155
 
 
156
                        void CheckTabletPointingEvent ()
 
157
                        {
 
158
                                if (IsTabletPointingEvent ())
 
159
                                        return;
 
160
                                throw new InvalidOperationException ("Not a tablet pointing event.");
 
161
                        }
 
162
                        
 
163
                        public int AbsoluteX {
 
164
                                get {
 
165
                                        CheckTabletPointingEvent ();
 
166
                                        return target.AbsoluteX;
 
167
                                }
 
168
                        }
 
169
                        
 
170
                        public int AbsoluteY {
 
171
                                get {
 
172
                                        CheckTabletPointingEvent ();
 
173
                                        return target.AbsoluteY;
 
174
                                }
 
175
                        }
 
176
                        
 
177
                        public int AbsoluteZ {
 
178
                                get {
 
179
                                        CheckTabletPointingEvent ();
 
180
                                        return target.AbsoluteZ;
 
181
                                }
 
182
                        }
 
183
 
 
184
                        public uint ButtonMask {
 
185
                                get {
 
186
                                        CheckTabletPointingEvent ();
 
187
                                        return target.ButtonMask;
 
188
                                }
 
189
                        }
 
190
 
 
191
                        public float Rotation {
 
192
                                get {
 
193
                                        CheckTabletPointingEvent ();
 
194
                                        return target.Rotation;
 
195
                                }
 
196
                        }
 
197
 
 
198
                        public float TangentialPressure {
 
199
                                get {
 
200
                                        CheckTabletPointingEvent ();
 
201
                                        return target.TangentialPressure;
 
202
                                }
 
203
                        }
 
204
 
 
205
                        public PointF Tilt {
 
206
                                get {
 
207
                                        CheckTabletPointingEvent ();
 
208
                                        return target.Tilt;
 
209
                                }
 
210
                        }
 
211
 
 
212
                        public NSObject VendorDefined {
 
213
                                get {
 
214
                                        CheckTabletPointingEvent ();
 
215
                                        return target.VendorDefined;
 
216
                                }
 
217
                        }
 
218
 
 
219
                        #endregion
 
220
 
 
221
                        #region Mouse Event Information
 
222
 
 
223
                        void CheckMouseEvent ()
 
224
                        {
 
225
                                if (IsMouseEvent ())
 
226
                                        return;
 
227
                                throw new InvalidOperationException ("Not a mouse event.");
 
228
                        }
 
229
 
 
230
                        public int ButtonNumber {
 
231
                                get {
 
232
                                        CheckMouseEvent ();
 
233
                                        return target.ButtonNumber;
 
234
                                }
 
235
                        }
 
236
                        
 
237
                        public int ClickCount {
 
238
                                get {
 
239
                                        CheckMouseEvent ();
 
240
                                        return target.ClickCount;
 
241
                                }
 
242
                        }
 
243
 
 
244
                        public float Pressure {
 
245
                                get {
 
246
                                        CheckMouseEvent ();
 
247
                                        return target.Pressure;
 
248
                                }
 
249
                        }
 
250
 
 
251
                        #endregion
 
252
 
 
253
                        #region Mouse Tracking Event Information
 
254
 
 
255
                        bool IsMouseTrackingEvent ()
 
256
                        {
 
257
                                // FIXME
 
258
                                return false;
 
259
                        }
 
260
 
 
261
                        void CheckMouseTrackingEvent ()
 
262
                        {
 
263
                                if (IsMouseTrackingEvent ())
 
264
                                        return;
 
265
                                throw new InvalidOperationException ("Not a mouse tracking event.");
 
266
                        }
 
267
                        
 
268
                        internal int EventNumber {
 
269
                                get {
 
270
                                        CheckMouseTrackingEvent ();
 
271
                                        return target.EventNumber;
 
272
                                }
 
273
                        }
 
274
 
 
275
                        internal int TrackingNumber {
 
276
                                get {
 
277
                                        CheckMouseTrackingEvent ();
 
278
                                        return target.TrackingNumber;
 
279
                                }
 
280
                        }
 
281
 
 
282
                        internal NSTrackingArea TrackingArea {
 
283
                                get {
 
284
                                        CheckMouseTrackingEvent ();
 
285
                                        return target.TrackingArea;
 
286
                                }
 
287
                        }
 
288
 
 
289
                        internal IntPtr UserData {
 
290
                                get {
 
291
                                        CheckMouseTrackingEvent ();
 
292
                                        return target.UserData;
 
293
                                }
 
294
                        }
 
295
 
 
296
                        #endregion
 
297
 
 
298
                        #region Custom Event Information
 
299
 
 
300
                        bool IsCustomEvent ()
 
301
                        {
 
302
                                switch (target.Type) {
 
303
                                case NSEventType.AppKitDefined:
 
304
                                case NSEventType.SystemDefined:
 
305
                                case NSEventType.ApplicationDefined:
 
306
                                case NSEventType.Periodic:
 
307
                                        return true;
 
308
                                default:
 
309
                                        return false;
 
310
                                }
 
311
                        }
 
312
 
 
313
                        void CheckCustomEvent ()
 
314
                        {
 
315
                                if (IsCustomEvent ())
 
316
                                        return;
 
317
                                throw new InvalidOperationException ("Not a custom event.");
 
318
                        }
 
319
 
 
320
                        public short Subtype {
 
321
                                get {
 
322
                                        CheckCustomEvent ();
 
323
                                        return target.Subtype;
 
324
                                }
 
325
                        }
 
326
 
 
327
                        public int Data1 {
 
328
                                get {
 
329
                                        CheckCustomEvent ();
 
330
                                        return target.Data1;
 
331
                                }
 
332
                        }
 
333
 
 
334
                        public int Data2 {
 
335
                                get {
 
336
                                        CheckCustomEvent ();
 
337
                                        return target.Data1;
 
338
                                }
 
339
                        }
 
340
 
 
341
                        #endregion
 
342
 
 
343
                        #region Scroll Wheel Event Information
 
344
 
 
345
                        bool IsScrollWheelEvent ()
 
346
                        {
 
347
                                switch (target.Type) {
 
348
                                case NSEventType.ScrollWheel:
 
349
                                        return true;
 
350
                                default:
 
351
                                        return false;
 
352
                                }
 
353
                        }
 
354
                        
 
355
                        void CheckScrollWheelEvent ()
 
356
                        {
 
357
                                if (IsScrollWheelEvent ())
 
358
                                        return;
 
359
                                throw new InvalidOperationException ("Not a scroll wheel event.");
 
360
                        }
 
361
                        
 
362
                        public float DeltaX {
 
363
                                get {
 
364
                                        CheckScrollWheelEvent ();
 
365
                                        return target.Data1;
 
366
                                }
 
367
                        }
 
368
 
 
369
                        public float DeltaY {
 
370
                                get {
 
371
                                        CheckScrollWheelEvent ();
 
372
                                        return target.Data1;
 
373
                                }
 
374
                        }
 
375
 
 
376
                        public float DeltaZ {
 
377
                                get {
 
378
                                        CheckScrollWheelEvent ();
 
379
                                        return target.Data1;
 
380
                                }
 
381
                        }
 
382
 
 
383
                        #endregion
 
384
 
 
385
                        #region Tablet Proximity Information
 
386
 
 
387
                        bool IsTabletProximityEvent ()
 
388
                        {
 
389
                                if (IsMouseEvent ())
 
390
                                        return target.Subtype == TabletProximityEventSubtype;
 
391
                                return target.Type == NSEventType.TabletProximity;
 
392
                        }
 
393
 
 
394
                        void CheckTabletProximityEvent ()
 
395
                        {
 
396
                                if (IsTabletProximityEvent ())
 
397
                                        return;
 
398
                                throw new InvalidOperationException ("Not a tablet proximity event.");
 
399
                        }
 
400
 
 
401
                        public uint CapabilityMask {
 
402
                                get {
 
403
                                        CheckTabletProximityEvent ();
 
404
                                        return target.CapabilityMask;
 
405
                                }
 
406
                        }
 
407
 
 
408
                        public uint DeviceID {
 
409
                                get {
 
410
                                        CheckTabletProximityEvent ();
 
411
                                        return target.DeviceID;
 
412
                                }
 
413
                        }
 
414
 
 
415
                        public bool IsEnteringProximity {
 
416
                                get {
 
417
                                        CheckTabletProximityEvent ();
 
418
                                        return target.IsEnteringProximity;
 
419
                                }
 
420
                        }
 
421
 
 
422
                        public uint PointingDeviceSerialNumber {
 
423
                                get {
 
424
                                        CheckTabletProximityEvent ();
 
425
                                        return target.PointingDeviceSerialNumber;
 
426
                                }
 
427
                        }
 
428
 
 
429
                        public uint PointingDeviceID {
 
430
                                get {
 
431
                                        CheckTabletProximityEvent ();
 
432
                                        return target.PointingDeviceID ();
 
433
                                }
 
434
                        }
 
435
                        
 
436
                        public NSPointingDeviceType PointingDeviceType {
 
437
                                get {
 
438
                                        CheckTabletProximityEvent ();
 
439
                                        return target.PointingDeviceType;
 
440
                                }
 
441
                        }
 
442
 
 
443
                        public uint SystemTabletID {
 
444
                                get {
 
445
                                        CheckTabletProximityEvent ();
 
446
                                        return target.SystemTabletID;
 
447
                                }
 
448
                        }
 
449
 
 
450
                        public uint TabletID {
 
451
                                get {
 
452
                                        CheckTabletProximityEvent ();
 
453
                                        return target.TabletID;
 
454
                                }
 
455
                        }
 
456
 
 
457
                        public long UniqueID {
 
458
                                get {
 
459
                                        CheckTabletProximityEvent ();
 
460
                                        return target.UniqueID;
 
461
                                }
 
462
                        }
 
463
 
 
464
                        public uint VendorID {
 
465
                                get {
 
466
                                        CheckTabletProximityEvent ();
 
467
                                        return target.VendorID;
 
468
                                }
 
469
                        }
 
470
 
 
471
                        public uint VendorPointingDeviceType {
 
472
                                get {
 
473
                                        CheckTabletProximityEvent ();
 
474
                                        return target.VendorPointingDeviceType;
 
475
                                }
 
476
                        }
 
477
 
 
478
                        #endregion
 
479
 
 
480
                        #region Touch and Gesture Events
 
481
 
 
482
                        bool IsTouchOrGestureEvent ()
 
483
                        {
 
484
                                // FIXME
 
485
                                return false;
 
486
                        }
 
487
                        
 
488
                        void CheckTouchOrGestureEvent ()
 
489
                        {
 
490
                                if (IsTouchOrGestureEvent ())
 
491
                                        return;
 
492
                                throw new InvalidOperationException ("Not a touch or gesture event.");
 
493
                        }
 
494
 
 
495
                        internal float Magnification {
 
496
                                get {
 
497
                                        CheckTouchOrGestureEvent ();
 
498
                                        return target.Magnification;
 
499
                                }
 
500
                        }
 
501
 
 
502
                        #endregion
 
503
 
 
504
                        #region Scroll Wheel and Flick Events
 
505
 
 
506
                        bool IsScrollWheelOrFlickEvent ()
 
507
                        {
 
508
                                if (IsScrollWheelEvent ())
 
509
                                        return true;
 
510
                                return false;
 
511
                        }
 
512
                        
 
513
                        void CheckScrollWheelOrFlickEvent ()
 
514
                        {
 
515
                                if (IsScrollWheelOrFlickEvent ())
 
516
                                        return;
 
517
                                throw new InvalidOperationException ("Not a scroll wheel or flick event.");
 
518
                        }
 
519
                        
 
520
                        public bool HasPreciseScrollingDeltas {
 
521
                                get {
 
522
                                        CheckScrollWheelOrFlickEvent ();
 
523
                                        return target.HasPreciseScrollingDeltas;
 
524
                                }
 
525
                        }
 
526
                        
 
527
                        public float ScrollingDeltaX {
 
528
                                get {
 
529
                                        CheckScrollWheelOrFlickEvent ();
 
530
                                        return target.ScrollingDeltaX;
 
531
                                }
 
532
                        }
 
533
 
 
534
                        public float ScrollingDeltaY {
 
535
                                get {
 
536
                                        CheckScrollWheelOrFlickEvent ();
 
537
                                        return target.ScrollingDeltaY;
 
538
                                }
 
539
                        }
 
540
 
 
541
                        public NSEventPhase MomentumPhase {
 
542
                                get {
 
543
                                        CheckScrollWheelOrFlickEvent ();
 
544
                                        return target.MomentumPhase;
 
545
                                }
 
546
                        }
 
547
 
 
548
                        public NSEventPhase Phase {
 
549
                                get {
 
550
                                        CheckScrollWheelOrFlickEvent ();
 
551
                                        return target.Phase;
 
552
                                }
 
553
                        }
 
554
 
 
555
                        public bool IsDirectionInvertedFromDevice {
 
556
                                get {
 
557
                                        CheckScrollWheelOrFlickEvent ();
 
558
                                        return target.IsDirectionInvertedFromDevice;
 
559
                                }
 
560
                        }
 
561
#endregion
 
562
                }
 
563
                
 
564
        }
 
565
}
 
566