]> git.saurik.com Git - wxWidgets.git/blob - include/wx/private/timer.h
Update vc10 build file versions to 3.0.0.
[wxWidgets.git] / include / wx / private / timer.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/private/timer.h
3 // Purpose: Base class for wxTimer implementations
4 // Author: Lukasz Michalski <lmichalski@sf.net>
5 // Created: 31.10.2006
6 // Copyright: (c) 2006-2007 wxWidgets dev team
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_TIMERIMPL_H_BASE_
11 #define _WX_TIMERIMPL_H_BASE_
12
13 #include "wx/defs.h"
14 #include "wx/event.h"
15 #include "wx/timer.h"
16
17 // ----------------------------------------------------------------------------
18 // wxTimerImpl: abstract base class for wxTimer implementations
19 // ----------------------------------------------------------------------------
20
21 class WXDLLIMPEXP_BASE wxTimerImpl
22 {
23 public:
24 // default ctor, SetOwner() must be called after it (wxTimer does it)
25 wxTimerImpl(wxTimer *owner);
26
27 // this must be called initially but may be also called later
28 void SetOwner(wxEvtHandler *owner, int timerid);
29
30 // empty but virtual base class dtor, the caller is responsible for
31 // stopping the timer before it's destroyed (it can't be done from here as
32 // it's too late)
33 virtual ~wxTimerImpl() { }
34
35
36 // start the timer. When overriding call base version first.
37 virtual bool Start(int milliseconds = -1, bool oneShot = false);
38
39 // stop the timer, only called if the timer is really running (unlike
40 // wxTimer::Stop())
41 virtual void Stop() = 0;
42
43 // return true if the timer is running
44 virtual bool IsRunning() const = 0;
45
46 // this should be called by the port-specific code when the timer expires
47 virtual void Notify() { m_timer->Notify(); }
48
49 // the default implementation of wxTimer::Notify(): generate a wxEVT_TIMER
50 void SendEvent();
51
52
53 // accessors for wxTimer:
54 wxEvtHandler *GetOwner() const { return m_owner; }
55 int GetId() const { return m_idTimer; }
56 int GetInterval() const { return m_milli; }
57 bool IsOneShot() const { return m_oneShot; }
58
59 protected:
60 wxTimer *m_timer;
61
62 wxEvtHandler *m_owner;
63
64 int m_idTimer; // id passed to wxTimerEvent
65 int m_milli; // the timer interval
66 bool m_oneShot; // true if one shot
67
68
69 wxDECLARE_NO_COPY_CLASS(wxTimerImpl);
70 };
71
72 #endif // _WX_TIMERIMPL_H_BASE_