]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/event.h
using Run of base class
[wxWidgets.git] / include / wx / event.h
index 874d42e2746cf96859ed1b93d86c1bdd826f8e08..1dcdf333dc5db6f92172b8088051c832c5c7b521 100644 (file)
@@ -4,7 +4,6 @@
 // Author:      Julian Smart
 // Modified by:
 // Created:     01/02/97
-// RCS-ID:      $Id$
 // Copyright:   (c) wxWidgets team
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -1470,6 +1469,39 @@ private:
     const ParamType2 m_param2;
 };
 
+// This is a version for calling any functors
+template <typename T>
+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 +3426,12 @@ public:
                 static_cast<T*>(this), method, x1, x2)
         );
     }
+
+    template <typename T>
+    void CallAfter(const T& fn)
+    {
+        QueueEvent(new wxAsyncMethodCallEventFunctor<T>(this, fn));
+    }
 #endif // wxHAS_CALL_AFTER