00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 using System;
00011 using System.Collections.Generic;
00012 using System.IO;
00013 using System.Text;
00014
00015 namespace OpenTK.Platform.MacOS.Carbon
00016 {
00017 internal struct EventInfo
00018 {
00019 internal EventInfo(IntPtr eventRef)
00020 {
00021 this._eventClass = API.GetEventClass(eventRef);
00022 this._eventKind = API.GetEventKind(eventRef);
00023 }
00024
00025 uint _eventKind;
00026 EventClass _eventClass;
00027
00028 public EventClass EventClass { get { return _eventClass; }}
00029
00030 public WindowEventKind WindowEventKind
00031 {
00032 get
00033 {
00034 if (EventClass == EventClass.Window)
00035 return (WindowEventKind) _eventKind;
00036 else
00037 throw new InvalidCastException("Event is not a Window event.");
00038 }
00039 }
00040 public KeyboardEventKind KeyboardEventKind
00041 {
00042 get
00043 {
00044 if (EventClass == EventClass.Keyboard)
00045 return (KeyboardEventKind) _eventKind;
00046 else
00047 throw new InvalidCastException("Event is not a Keyboard event.");
00048 }
00049 }
00050 public MouseEventKind MouseEventKind
00051 {
00052 get
00053 {
00054 if (EventClass == EventClass.Mouse)
00055 return (MouseEventKind) _eventKind;
00056 else
00057 throw new InvalidCastException("Event is not an Mouse event.");
00058 }
00059 }
00060 public AppEventKind AppEventKind
00061 {
00062 get
00063 {
00064 if (EventClass == EventClass.Application)
00065 return (AppEventKind) _eventKind;
00066 else
00067 throw new InvalidCastException("Event is not an Application event.");
00068 }
00069 }
00070
00071
00072 public override string ToString()
00073 {
00074 switch(EventClass)
00075 {
00076 case EventClass.Application:
00077 return "Event: App " + AppEventKind.ToString();
00078 case EventClass.Keyboard:
00079 return "Event: Keyboard " + KeyboardEventKind.ToString();
00080 case EventClass.Mouse:
00081 return "Event: Mouse " + MouseEventKind.ToString();
00082 case EventClass.Window:
00083 return "Event: Window " + WindowEventKind.ToString();
00084 }
00085
00086 return "Event: Unknown Class " + EventClass.ToString() + " kind: " + _eventKind.ToString();
00087 }
00088 }
00089 }