Woopsi 1.3
Nintendo DS Gui Framework
libwoopsi/include/woopsitimer.h
00001 #ifndef _WOOPSI_TIMER_H_
00002 #define _WOOPSI_TIMER_H_
00003 
00004 #include <nds.h>
00005 #include "gadget.h"
00006 #include "woopsi.h"
00007 
00008 namespace WoopsiUI {
00009 
00023     class WoopsiTimer : public Gadget {
00024     public:
00025 
00032         WoopsiTimer(u32 timeout, bool repeat);
00033 
00038         inline const u32 getTimeout() const { return _timeout; };
00039 
00045         inline const u32 getFrameCount() const { return _frameCount; };
00046 
00050         inline void reset() { _frameCount = 0; };
00051 
00055         inline void start() { _isRunning = true; };
00056 
00060         inline void stop() {
00061             _isRunning = false;
00062             _frameCount = 0;
00063         };
00064 
00068         inline void pause() { _isRunning = false; }
00069 
00074         inline void setTimeout(u32 timeout) { _timeout = timeout; };
00075 
00080         virtual bool run();
00081 
00086         inline bool isRunning() { return _isRunning; };
00087 
00088     protected:
00089         u32 _frameCount;            
00090         u32 _timeout;               
00091         bool _isRunning;            
00092         bool _isRepeater;           
00097         virtual inline ~WoopsiTimer() {
00098             if (woopsiApplication != NULL) {
00099 
00100                 // Prevent gadget from receiving VBLs
00101                 woopsiApplication->unregisterFromVBL(this);
00102             }
00103         };
00104 
00108         inline WoopsiTimer(const WoopsiTimer& woopsiTimer) : Gadget(woopsiTimer) { };
00109     };
00110 }
00111 
00112 #endif
 All Classes Functions Variables Enumerations Enumerator