00001 #ifndef RXTIMER_HH_ 00002 # define RXTIMER_HH_ 00003 00004 # include <windows.h> 00005 00006 # define RXTIMER_WND "RxTimer" 00007 00008 namespace rxtimer 00009 { 00010 class RxTimerInit 00011 { 00012 public: 00013 RxTimerInit(); 00014 ~RxTimerInit(); 00015 HWND get_wnd(); 00016 00017 protected: 00018 HWND _wnd; 00019 }; 00020 00021 class RxTimer 00022 { 00023 public: 00024 RxTimer(int interval = 1000, bool enabled = false); 00025 ~RxTimer(); 00026 00027 void time(); 00028 00029 void set_interval(int milliseconds); 00030 int get_interval(); 00031 void set_enabled(bool enabled); 00032 bool get_enabled(); 00033 00034 protected: 00035 int _id; 00036 int _interval; 00037 bool _enabled; 00038 00039 void setup_timer(); 00040 void cleanup_timer(); 00041 00042 virtual void on_time() = 0; 00043 }; 00044 00045 class RxAutoTimer : public RxTimer 00046 { 00047 public: 00048 typedef void (*OnTimeFunction)(RxAutoTimer *timer); 00049 00050 public: 00051 RxAutoTimer(OnTimeFunction on_time_function, 00052 int interval = 1000, 00053 bool enabled = false); 00054 00055 protected: 00056 OnTimeFunction _on_time_function; 00057 00058 void on_time(); 00059 }; 00060 }; 00061 00062 #endif