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 
00037 struct sfKey
00038 {
00039     enum Code
00040     {
00041         A = 'a', Z = 'z', E = 'e', R = 'r', T = 't', Y = 'y', U = 'u', I = 'i', O = 'o', P = 'p',
00042         Q = 'q', S = 's', D = 'd', F = 'f', G = 'g', H = 'h', J = 'j', K = 'k', L = 'l', M = 'm',
00043         W = 'w', X = 'x', C = 'c', V = 'v', B = 'b', N = 'n',
00044         Num0 = '0', Num1 = '1', Num2 = '2', Num3 = '3', Num4 = '4',
00045         Num5 = '5', Num6 = '6', Num7 = '7', Num8 = '8', Num9 = '9', 
00046         Escape = 256,
00047         Space, Return, Back, Tab, PageUp, PageDown, End, Home, Insert, Delete, Add, Subtract, Multiply, Divide,
00048         Left, Right, Up, Down,
00049         Numpad0, Numpad1, Numpad2, Numpad3, Numpad4, Numpad5, Numpad6, Numpad7, Numpad8, Numpad9,
00050         F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15,
00051 
00052         Count // For internal use
00053     };
00054 };
00055 
00056 
00060 struct sfMouse
00061 {
00062     enum Button
00063     {
00064         Left   = 1 << 1,
00065         Right  = 1 << 2,
00066         Middle = 1 << 3
00067     };
00068 };
00069 
00070 
00074 class sfEvent
00075 {
00076 public :
00077 
00081     enum EventType
00082     {
00083         Close,
00084         Resize,
00085         LostFocus,
00086         GainedFocus,
00087         TextEntered,
00088         KeyPressed,
00089         KeyReleased,
00090         MouseButtonPressed,
00091         MouseButtonReleased,
00092         MouseMove,
00093         JoystickButtonPressed,
00094         JoystickButtonReleased,
00095         JoystickMove
00096     };
00097 
00099     // Member data
00101     EventType Type; 
00102 
00103     union
00104     {
00105 
00109         struct
00110         {
00111             sfUint16 Unicode;
00112         } Text;
00113 
00117         struct
00118         {
00119             sfKey::Code Code;
00120             bool        Alt;
00121             bool        Control;
00122             bool        Shift;
00123         } Key;
00124 
00128         struct
00129         {
00130             unsigned int Buttons;
00131             unsigned int X;
00132             unsigned int Y;
00133         } Mouse;
00134 
00138         struct
00139         {
00140             unsigned int JoystickId;
00141             unsigned int Button;
00142             int          X;
00143             int          Y;
00144             int          Z;
00145         } Joystick;
00146 
00150         struct
00151         {
00152             unsigned int Width;
00153             unsigned int Height;
00154         } Size;
00155     };
00156 };
00157 
00158 
00159 #endif // SFML_EVENT_HPP