sdlevent.h

Go to the documentation of this file.
00001 /*
00002   libwt - Vassilis Virvilis Toolkit - a widget library
00003   Copyright (C) 2006 Vassilis Virvilis <vasvir2@fastmail.fm>
00004  
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009   
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014   
00015   You should have received a copy of the GNU Lesser General Public
00016   License along with this library; if not, write to the
00017   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018   Boston, MA  02111-1307, SA.
00019 */
00020 
00021 #ifndef WT_SDLEVENT_H
00022 #define WT_SDLEVENT_H
00023 
00024 #include <vector>
00025 
00026 #include <wt/enum.h>
00027 #include <wt/singleton.h>
00028 
00029 union SDL_Event;
00030 
00031 namespace Wt {
00032 
00033 class SDLEvent : public Singleton<SDLEvent>, public Enum<SDLEvent> {
00034     // The Singleton part
00035     friend class Singleton<SDLEvent>;
00036 public:
00037     static const Member None;
00038     static const Member Active;
00039     static const Member KeyDown;
00040     static const Member KeyUp;
00041     static const Member MouseMotion;
00042     static const Member MouseButtonDown;
00043     static const Member MouseButtonUp;
00044     static const Member JoyAxisMotion;
00045     static const Member JoyBallMotion;
00046     static const Member JoyHatMotion;
00047     static const Member JoyButtonDown;
00048     static const Member JoyButtonUp;
00049     static const Member Quit;
00050     static const Member SysWM;
00051     static const Member VideoResize;
00052     static const Member VideoExpose;
00053     static const Member Time;
00054     static const Member Audio;
00055     static const Member Net;
00056     static const Member User;
00057     static const Member NumEvents;
00058 
00059     // The handler part
00060 public:
00061     typedef void (*SDLEventHandler)(const SDL_Event *event);
00062 
00063     /// pushes an SDL event to SDL stack
00064     static void push(SDL_Event* event);
00065     /// handle the event
00066     static void handle(const SDL_Event *event);
00067     /// handle all events so far
00068     static void wait();
00069     /// register event handler
00070     SDLEventHandler& operator[](int event_type);
00071     /// get current handler
00072     const SDLEventHandler& operator[](int event_type) const;
00073 
00074 protected:
00075     SDLEvent();
00076     ~SDLEvent();
00077 
00078 private:
00079     static std::vector<SDLEventHandler> handlers;
00080 };
00081 
00082 } // namespace
00083 
00084 #endif //WT_SDLEVENT_H

Generated Fri Jul 28 19:23:00 2006.
Copyright © 1998-2003 by the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.