Event.hpp
00001 
00002 //
00003 // SFML - Simple and Fast Multimedia Library
00004 // Copyright (C) 2007-2009 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 #include <SFML/Window/Joystick.hpp>
00033 #include <SFML/Window/Keyboard.hpp>
00034 #include <SFML/Window/Mouse.hpp>
00035 
00036 
00037 namespace sf
00038 {
00043 class Event
00044 {
00045 public :
00046 
00051     struct SizeEvent
00052     {
00053         unsigned int Width;  
00054         unsigned int Height; 
00055     };
00056 
00061     struct KeyEvent
00062     {
00063         Keyboard::Key Code;    
00064         bool          Alt;     
00065         bool          Control; 
00066         bool          Shift;   
00067         bool          System;  
00068     };
00069 
00074     struct TextEvent
00075     {
00076         Uint32 Unicode; 
00077     };
00078 
00083     struct MouseMoveEvent
00084     {
00085         int X; 
00086         int Y; 
00087     };
00088 
00094     struct MouseButtonEvent
00095     {
00096         Mouse::Button Button; 
00097         int           X;      
00098         int           Y;      
00099     };
00100 
00105     struct MouseWheelEvent
00106     {
00107         int Delta; 
00108         int X;     
00109         int Y;     
00110     };
00111 
00117     struct JoystickConnectEvent
00118     {
00119         unsigned int JoystickId; 
00120     };
00121 
00126     struct JoystickMoveEvent
00127     {
00128         unsigned int   JoystickId; 
00129         Joystick::Axis Axis;       
00130         float          Position;   
00131     };
00132 
00138     struct JoystickButtonEvent
00139     {
00140         unsigned int JoystickId; 
00141         unsigned int Button;     
00142     };
00143 
00148     enum EventType
00149     {
00150         Closed,                 
00151         Resized,                
00152         LostFocus,              
00153         GainedFocus,            
00154         TextEntered,            
00155         KeyPressed,             
00156         KeyReleased,            
00157         MouseWheelMoved,        
00158         MouseButtonPressed,     
00159         MouseButtonReleased,    
00160         MouseMoved,             
00161         MouseEntered,           
00162         MouseLeft,              
00163         JoystickButtonPressed,  
00164         JoystickButtonReleased, 
00165         JoystickMoved,          
00166         JoystickConnected,      
00167         JoystickDisconnected,   
00168 
00169         Count                   
00170     };
00171 
00173     // Member data
00175     EventType Type; 
00176 
00177     union
00178     {
00179         SizeEvent            Size;            
00180         KeyEvent             Key;             
00181         TextEvent            Text;            
00182         MouseMoveEvent       MouseMove;       
00183         MouseButtonEvent     MouseButton;     
00184         MouseWheelEvent      MouseWheel;      
00185         JoystickMoveEvent    JoystickMove;    
00186         JoystickButtonEvent  JoystickButton;  
00187         JoystickConnectEvent JoystickConnect; 
00188     };
00189 };
00190 
00191 } // namespace sf
00192 
00193 
00194 #endif // SFML_EVENT_HPP
00195 
00196