Subversion Repositories AndroidProjects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1452 chris 1
//
2
//  
3
//  xCSCarbon
4
//
5
//  Created by Erik Ylvisaker on 3/17/08.
6
//  Copyright 2008 __MyCompanyName__. All rights reserved.
7
//
8
//
9
 
10
using System;
11
using System.Collections.Generic;
12
using System.IO;
13
using System.Text;
14
 
15
namespace OpenTK.Platform.MacOS.Carbon
16
{
17
    internal struct EventInfo
18
    {
19
        internal EventInfo(IntPtr eventRef)
20
        {
21
            this._eventClass = API.GetEventClass(eventRef);
22
            this._eventKind = API.GetEventKind(eventRef);
23
        }
24
 
25
        uint _eventKind;
26
        EventClass _eventClass;
27
 
28
        public EventClass EventClass { get { return _eventClass; }}
29
 
30
        public WindowEventKind WindowEventKind
31
        {
32
            get
33
            {
34
                if (EventClass == EventClass.Window)
35
                    return (WindowEventKind) _eventKind;
36
                else
37
                    throw new InvalidCastException("Event is not a Window event.");
38
            }
39
        }
40
        public KeyboardEventKind KeyboardEventKind
41
        {
42
            get
43
            {
44
                if (EventClass == EventClass.Keyboard)
45
                    return (KeyboardEventKind) _eventKind;
46
                else
47
                    throw new InvalidCastException("Event is not a Keyboard event.");
48
            }
49
        }
50
        public MouseEventKind MouseEventKind
51
        {
52
            get
53
            {
54
                if (EventClass == EventClass.Mouse)
55
                    return (MouseEventKind) _eventKind;
56
                else
57
                    throw new InvalidCastException("Event is not an Mouse event.");
58
            }
59
        }
60
        public AppEventKind AppEventKind
61
        {
62
            get
63
            {
64
                if (EventClass == EventClass.Application)
65
                    return (AppEventKind) _eventKind;
66
                else
67
                    throw new InvalidCastException("Event is not an Application event.");
68
            }
69
        }
70
 
71
 
72
        public override string ToString()
73
        {
74
            switch(EventClass)
75
            {
76
                case EventClass.Application:
77
                    return "Event: App " + AppEventKind.ToString();
78
                case EventClass.Keyboard:
79
                    return "Event: Keyboard " + KeyboardEventKind.ToString();
80
                case EventClass.Mouse:
81
                    return "Event: Mouse " + MouseEventKind.ToString();
82
                case EventClass.Window:
83
                    return "Event: Window " + WindowEventKind.ToString();
84
            }
85
 
86
            return "Event: Unknown Class " + EventClass.ToString() + "   kind: " + _eventKind.ToString();
87
        }
88
    }
89
}