Event.hpp

00001 
00002 //
00003 // SFML - Simple and Fast Multimedia Library
00004 // Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
00005 //
00006 // This software is provided 'as-is', without any express or implied warranty.
00007 // In no event will the authors be held liable for any damages arising from the use of this software.
00008 //
00009 // Permission is granted to anyone to use this software for any purpose,
00010 // including commercial applications, and to alter it and redistribute it freely,
00011 // subject to the following restrictions:
00012 //
00013 // 1. The origin of this software must not be misrepresented;
00014 //    you must not claim that you wrote the original software.
00015 //    If you use this software in a product, an acknowledgment
00016 //    in the product documentation would be appreciated but is not required.
00017 //
00018 // 2. Altered source versions must be plainly marked as such,
00019 //    and must not be misrepresented as being the original software.
00020 //
00021 // 3. This notice may not be removed or altered from any source distribution.
00022 //
00024 
00025 #ifndef SFML_EVENT_HPP
00026 #define SFML_EVENT_HPP
00027 
00029 // Headers
00031 #include <SFML/Config.hpp>
00032 
00033 
00034 namespace sf
00035 {
00039 namespace Key
00040 {
00041     enum Code
00042     {
00043         A = 'a', Z = 'z', E = 'e', R = 'r', T = 't', Y = 'y', U = 'u', I = 'i', O = 'o', P = 'p',
00044         Q = 'q', S = 's', D = 'd', F = 'f', G = 'g', H = 'h', J = 'j', K = 'k', L = 'l', M = 'm',
00045         W = 'w', X = 'x', C = 'c', V = 'v', B = 'b', N = 'n',
00046         Num0 = '0', Num1 = '1', Num2 = '2', Num3 = '3', Num4 = '4',
00047         Num5 = '5', Num6 = '6', Num7 = '7', Num8 = '8', Num9 = '9', 
00048         Escape = 256,
00049         Control, Shift, Alt,
00050         Space, Return, Back, Tab, PageUp, PageDown, End, Home, Insert, Delete, Add, Subtract, Multiply, Divide,
00051         Left, Right, Up, Down,
00052         Numpad0, Numpad1, Numpad2, Numpad3, Numpad4, Numpad5, Numpad6, Numpad7, Numpad8, Numpad9,
00053         F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15,
00054         Pause,
00055 
00056         Count // For internal use
00057     };
00058 }
00059 
00060 
00064 namespace Mouse
00065 {
00066     enum Button
00067     {
00068         Left,
00069         Right,
00070         Middle,
00071         XButton1,
00072         XButton2,
00073 
00074         Count // For internal use
00075     };
00076 }
00077 
00078 
00082 namespace Joy
00083 {
00084     enum Axis
00085     {
00086         AxisX,
00087         AxisY,
00088         AxisZ,
00089         AxisR,
00090         AxisU,
00091         AxisV,
00092         AxisPOV,
00093 
00094         Count // For internal use
00095     };
00096 }
00097 
00098 
00102 class Event
00103 {
00104 public :
00105 
00109     enum EventType
00110     {
00111         Closed,
00112         Resized,
00113         LostFocus,
00114         GainedFocus,
00115         TextEntered,
00116         KeyPressed,
00117         KeyReleased,
00118         MouseWheelMoved,
00119         MouseButtonPressed,
00120         MouseButtonReleased,
00121         MouseMoved,
00122         JoyButtonPressed,
00123         JoyButtonReleased,
00124         JoyMoved
00125     };
00126 
00128     // Member data
00130     EventType Type; 
00131 
00132     union
00133     {
00137         struct
00138         {
00139             Uint16 Unicode;
00140         } Text;
00141 
00145         struct
00146         {
00147             Key::Code Code;
00148             bool      Alt;
00149             bool      Control;
00150             bool      Shift;
00151         } Key;
00152 
00156         struct
00157         {
00158             unsigned int X;
00159             unsigned int Y;
00160         } MouseMove;
00161 
00165         struct
00166         {
00167             Mouse::Button Button;
00168         } MouseButton;
00169 
00173         struct
00174         {
00175             int Delta;
00176         } MouseWheel;
00177 
00181         struct
00182         {
00183             unsigned int JoystickId;
00184             Joy::Axis    Axis;
00185             float        Position;
00186         } JoyMove;
00187 
00191         struct
00192         {
00193             unsigned int JoystickId;
00194             unsigned int Button;
00195         } JoyButton;
00196 
00200         struct
00201         {
00202             unsigned int Width;
00203             unsigned int Height;
00204         } Size;
00205     };
00206 };
00207 
00208 } // namespace sf
00209 
00210 
00211 #endif // SFML_EVENT_HPP