From 313feadc84cdf5501da71c41178c35bb7bed32eb Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 10 May 2004 20:53:25 +0000 Subject: [PATCH] Add GetOwner accessor and fix wxRTTI inheritance for wxTimer. Set the timer as the event object in wxTimerEvents. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27196 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/timer.h | 1 + src/common/timercmn.cpp | 1 + src/generic/timer.cpp | 2 +- src/gtk/timer.cpp | 2 +- src/gtk1/timer.cpp | 2 +- src/mac/carbon/timer.cpp | 2 +- src/mac/classic/timer.cpp | 2 +- src/motif/timer.cpp | 2 +- src/msw/timer.cpp | 2 +- src/os2/timer.cpp | 2 +- wxPython/include/wx/wxPython/pyclasses.h | 1 + wxPython/src/_timer.i | 10 ++++++++-- 12 files changed, 19 insertions(+), 10 deletions(-) diff --git a/include/wx/timer.h b/include/wx/timer.h index 9e9ed4e523..fa4e88b205 100644 --- a/include/wx/timer.h +++ b/include/wx/timer.h @@ -58,6 +58,7 @@ public: // same as ctor above void SetOwner(wxEvtHandler *owner, int timerid = -1) { m_owner = owner; m_idTimer = timerid; } + wxEvtHandler* GetOwner() const { return m_owner; } virtual ~wxTimerBase(); diff --git a/src/common/timercmn.cpp b/src/common/timercmn.cpp index ffcf0358a9..5fd7fd4767 100644 --- a/src/common/timercmn.cpp +++ b/src/common/timercmn.cpp @@ -57,6 +57,7 @@ void wxTimerBase::Notify() wxCHECK_RET( m_owner, _T("wxTimer::Notify() should be overridden.") ); wxTimerEvent event(m_idTimer, m_milli); + event.SetEventObject(this); (void)m_owner->ProcessEvent(event); } diff --git a/src/generic/timer.cpp b/src/generic/timer.cpp index 2f0df9a975..495ca2111c 100644 --- a/src/generic/timer.cpp +++ b/src/generic/timer.cpp @@ -175,7 +175,7 @@ void wxTimerScheduler::NotifyTimers() // wxTimer // ---------------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxTimer,wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxEvtHandler) wxTimerScheduler *gs_scheduler = NULL; diff --git a/src/gtk/timer.cpp b/src/gtk/timer.cpp index 0353bede8b..3b28f1d1c2 100644 --- a/src/gtk/timer.cpp +++ b/src/gtk/timer.cpp @@ -25,7 +25,7 @@ // wxTimer // ---------------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxEvtHandler) extern "C" gint timeout_callback( gpointer data ) { diff --git a/src/gtk1/timer.cpp b/src/gtk1/timer.cpp index 0353bede8b..3b28f1d1c2 100644 --- a/src/gtk1/timer.cpp +++ b/src/gtk1/timer.cpp @@ -25,7 +25,7 @@ // wxTimer // ---------------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxEvtHandler) extern "C" gint timeout_callback( gpointer data ) { diff --git a/src/mac/carbon/timer.cpp b/src/mac/carbon/timer.cpp index fe935003ca..fd06d47dfb 100644 --- a/src/mac/carbon/timer.cpp +++ b/src/mac/carbon/timer.cpp @@ -16,7 +16,7 @@ #include "wx/timer.h" #if !USE_SHARED_LIBRARY -IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxEvtHandler) #endif #ifdef __WXMAC__ diff --git a/src/mac/classic/timer.cpp b/src/mac/classic/timer.cpp index a639e2c464..26cf3cc150 100644 --- a/src/mac/classic/timer.cpp +++ b/src/mac/classic/timer.cpp @@ -16,7 +16,7 @@ #include "wx/timer.h" #if !USE_SHARED_LIBRARY -IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxEvtHandler) #endif #ifdef __WXMAC__ diff --git a/src/motif/timer.cpp b/src/motif/timer.cpp index ef99ffeed0..8fab6d35c1 100644 --- a/src/motif/timer.cpp +++ b/src/motif/timer.cpp @@ -30,7 +30,7 @@ #include "wx/motif/private.h" -IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject); +IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxEvtHandler); WX_DECLARE_VOIDPTR_HASH_MAP(wxTimer*, wxTimerHashMap); diff --git a/src/msw/timer.cpp b/src/msw/timer.cpp index 796db83d7a..b1e23fca66 100644 --- a/src/msw/timer.cpp +++ b/src/msw/timer.cpp @@ -62,7 +62,7 @@ void WINAPI wxTimerProc(HWND hwnd, WORD, int idTimer, DWORD); // macros // ---------------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxEvtHandler) // ============================================================================ // implementation diff --git a/src/os2/timer.cpp b/src/os2/timer.cpp index e01bedb552..1aebce5ee1 100644 --- a/src/os2/timer.cpp +++ b/src/os2/timer.cpp @@ -46,7 +46,7 @@ ULONG wxTimerProc(HWND hwnd, ULONG, int nIdTimer, ULONG); // macros // ---------------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxEvtHandler) void wxTimer::Init() { diff --git a/wxPython/include/wx/wxPython/pyclasses.h b/wxPython/include/wx/wxPython/pyclasses.h index 085b41be42..8a3429c77b 100644 --- a/wxPython/include/wx/wxPython/pyclasses.h +++ b/wxPython/include/wx/wxPython/pyclasses.h @@ -87,6 +87,7 @@ public: DEC_PYCALLBACK__(Notify); PYPRIVATE; + DECLARE_ABSTRACT_CLASS(wxPyTimer) }; diff --git a/wxPython/src/_timer.i b/wxPython/src/_timer.i index b613bbc630..1042c7f52f 100644 --- a/wxPython/src/_timer.i +++ b/wxPython/src/_timer.i @@ -34,6 +34,8 @@ enum { %{ //IMP_PYCALLBACK__(wxPyTimer, wxTimer, Notify); +IMPLEMENT_ABSTRACT_CLASS(wxPyTimer, wxTimer); + void wxPyTimer::Notify() { bool found; bool blocked = wxPyBeginBlockThreads(); @@ -54,7 +56,7 @@ void wxPyTimer::base_Notify() { %name(Timer) class wxPyTimer : public wxEvtHandler { public: - %pythonAppend wxPyTimer "self._setCallbackInfo(self, Timer, 0)" + %pythonAppend wxPyTimer "self._setCallbackInfo(self, Timer, 0); self._setOORInfo(self)" // if you don't call SetOwner() or provide an owner in the contstructor @@ -69,7 +71,7 @@ public: // Set the owner instance that will receive the EVT_TIMER events using the // given id. void SetOwner(wxEvtHandler *owner, int id = -1); - + wxEvtHandler* GetOwner(); // start the timer: if milliseconds == -1, use the same value as for the // last Start() @@ -141,3 +143,7 @@ public: //--------------------------------------------------------------------------- +%init %{ + wxPyPtrTypeMap_Add("wxTimer", "wxPyTimer"); +%} +//--------------------------------------------------------------------------- -- 2.47.2