X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5ac5e40e4181aaf7fd79ca445113d7a228a70cb8..9c34a216817028bc533e07873d047208a96b05a2:/include/wx/event.h diff --git a/include/wx/event.h b/include/wx/event.h index 874d42e274..1bad23740b 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -1470,6 +1470,39 @@ private: const ParamType2 m_param2; }; +// This is a version for calling any functors +template +class wxAsyncMethodCallEventFunctor : public wxAsyncMethodCallEvent +{ +public: + typedef T FunctorType; + + wxAsyncMethodCallEventFunctor(wxObject *object, const FunctorType& fn) + : wxAsyncMethodCallEvent(object), + m_fn(fn) + { + } + + wxAsyncMethodCallEventFunctor(const wxAsyncMethodCallEventFunctor& other) + : wxAsyncMethodCallEvent(other), + m_fn(other.m_fn) + { + } + + virtual wxEvent *Clone() const + { + return new wxAsyncMethodCallEventFunctor(*this); + } + + virtual void Execute() + { + m_fn(); + } + +private: + FunctorType m_fn; +}; + #endif // wxHAS_CALL_AFTER @@ -3394,6 +3427,12 @@ public: static_cast(this), method, x1, x2) ); } + + template + void CallAfter(const T& fn) + { + QueueEvent(new wxAsyncMethodCallEventFunctor(this, fn)); + } #endif // wxHAS_CALL_AFTER