wg_timer.h

00001 // wg_timer.h
00002 //
00003 // CTimer class interface
00004 //
00005 //
00006 // Copyright (c) 2002-2004 Rob Wiskow
00007 // rob-dev@boxedchaos.com
00008 //
00009 // This library is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU Lesser General Public
00011 // License as published by the Free Software Foundation; either
00012 // version 2.1 of the License, or (at your option) any later version.
00013 //
00014 // This library is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017 // Lesser General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU Lesser General Public
00020 // License along with this library; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00022 //
00023 
00024 
00025 #ifndef _WG_TIMER_H_
00026 #define _WG_TIMER_H_
00027 
00028 #include "wg_message_client.h"
00029 
00030 
00031 namespace wGui
00032 {
00033 
00036 Uint32 TimerCallback(Uint32 Interval, void* param);
00037 
00038 
00040 
00042 
00043 class CTimer : public CMessageClient
00044 {
00045 public:
00048      CTimer(CMessageClient* pOwner = 0);
00049 
00051      virtual ~CTimer(void);
00052 
00056      void StartTimer(unsigned long int Interval, bool bAutoRestart = false);
00057 
00059      void StopTimer(void);
00060 
00063      bool IsRunning(void) { return m_TimerID != 0; }
00064 
00067      long int GetCount(void) const { return m_iCounter; }
00068 
00070      void ResetCount(void) { m_iCounter = 0; }
00071 
00074      CMessageClient* GetOwner(void) { return m_pOwner; }
00075 
00078      Uint32 TimerHit(Uint32 Interval);
00079 
00080 
00081      // CMessageClient overrides
00084      virtual bool HandleMessage(CMessage* pMessage);
00085 
00086 
00087 protected:
00089      SDL_TimerID m_TimerID;
00090 
00092      bool m_bAutoRestart;
00093 
00095      long int m_iCounter;
00096 
00098      CMessageClient* m_pOwner;
00099 };
00100 
00101 }
00102 
00103 
00104 #include "unit_tests/wg_timer_unittests.h"
00105 
00106 #endif // _WG_TIMER_H_
00107 

Generated on Wed May 16 23:11:26 2007 for wGui by  doxygen 1.5.1