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