File: timer.h

package info (click to toggle)
wxpython3.0 3.0.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 482,760 kB
  • ctags: 518,293
  • sloc: cpp: 2,127,226; python: 294,045; makefile: 51,942; ansic: 19,033; sh: 3,013; xml: 1,629; perl: 17
file content (72 lines) | stat: -rw-r--r-- 2,343 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/////////////////////////////////////////////////////////////////////////////
// Name:        wx/private/timer.h
// Purpose:     Base class for wxTimer implementations
// Author:      Lukasz Michalski <lmichalski@sf.net>
// Created:     31.10.2006
// Copyright:   (c) 2006-2007 wxWidgets dev team
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

#ifndef _WX_TIMERIMPL_H_BASE_
#define _WX_TIMERIMPL_H_BASE_

#include "wx/defs.h"
#include "wx/event.h"
#include "wx/timer.h"

// ----------------------------------------------------------------------------
// wxTimerImpl: abstract base class for wxTimer implementations
// ----------------------------------------------------------------------------

class WXDLLIMPEXP_BASE wxTimerImpl
{
public:
    // default ctor, SetOwner() must be called after it (wxTimer does it)
    wxTimerImpl(wxTimer *owner);

    // this must be called initially but may be also called later
    void SetOwner(wxEvtHandler *owner, int timerid);

    // empty but virtual base class dtor, the caller is responsible for
    // stopping the timer before it's destroyed (it can't be done from here as
    // it's too late)
    virtual ~wxTimerImpl() { }


    // start the timer. When overriding call base version first.
    virtual bool Start(int milliseconds = -1, bool oneShot = false);

    // stop the timer, only called if the timer is really running (unlike
    // wxTimer::Stop())
    virtual void Stop() = 0;

    // return true if the timer is running
    virtual bool IsRunning() const = 0;

    // this should be called by the port-specific code when the timer expires
    virtual void Notify() { m_timer->Notify(); }

    // the default implementation of wxTimer::Notify(): generate a wxEVT_TIMER
    void SendEvent();


    // accessors for wxTimer:
    wxEvtHandler *GetOwner() const { return m_owner; }
    int GetId() const { return m_idTimer; }
    int GetInterval() const { return m_milli; }
    bool IsOneShot() const { return m_oneShot; }

protected:
    wxTimer *m_timer;

    wxEvtHandler *m_owner;

    int     m_idTimer;      // id passed to wxTimerEvent
    int     m_milli;        // the timer interval
    bool    m_oneShot;      // true if one shot


    wxDECLARE_NO_COPY_CLASS(wxTimerImpl);
};

#endif // _WX_TIMERIMPL_H_BASE_