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_SDLTIMER_H 00022 #define WT_SDLTIMER_H 00023 00024 /// \todo get rid of SDL/SDL_timer.h inclusion 00025 #include <SDL/SDL_timer.h> 00026 00027 union SDL_Event; 00028 00029 namespace Wt { 00030 00031 class Object; 00032 00033 class SDLTimer { 00034 public: 00035 SDLTimer(Object *receiver, int id, int interval); 00036 ~SDLTimer(); 00037 void scheduleNext(); 00038 int interval() const { 00039 return interval_; 00040 } 00041 00042 static void init(); 00043 static void quit(); 00044 00045 class Event { 00046 public: 00047 Event(Object *receiver, int id) : 00048 receiver_(receiver), 00049 id_(id) {} 00050 00051 Object *receiver() const { 00052 return receiver_; 00053 } 00054 00055 int id() const { 00056 return id_; 00057 } 00058 00059 private: 00060 Object *receiver_; 00061 int id_; 00062 }; 00063 00064 private: 00065 Event sdl_timer_event; 00066 SDL_TimerID timerid_; 00067 int interval_; 00068 00069 static void handleTimerEvent(const SDL_Event *event); 00070 }; 00071 00072 } // namespace 00073 00074 #endif //WT_SDLTIMER_H
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.