+//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
+// These classes can be derived from in Python and passed through the event
+// system without loosing anything. They do this by keeping a reference to
+// themselves and some special case handling in wxPyCallback::EventThunker.
+
+
+wxPyEvtSelfRef::wxPyEvtSelfRef() {
+ //m_self = Py_None; // **** We don't do normal ref counting to prevent
+ //Py_INCREF(m_self); // circular loops...
+ m_cloned = FALSE;
+}
+
+wxPyEvtSelfRef::~wxPyEvtSelfRef() {
+ bool doSave = wxPyRestoreThread();
+ if (m_cloned)
+ Py_DECREF(m_self);
+ wxPySaveThread(doSave);
+}
+
+void wxPyEvtSelfRef::SetSelf(PyObject* self, bool clone) {
+ bool doSave = wxPyRestoreThread();
+ if (m_cloned)
+ Py_DECREF(m_self);
+ m_self = self;
+ if (clone) {
+ Py_INCREF(m_self);
+ m_cloned = TRUE;
+ }
+ wxPySaveThread(doSave);
+}
+
+PyObject* wxPyEvtSelfRef::GetSelf() const {
+ Py_INCREF(m_self);
+ return m_self;
+}
+
+
+wxPyEvent::wxPyEvent(int id)
+ : wxEvent(id) {
+}
+
+wxPyEvent::~wxPyEvent() {
+}
+
+// This one is so the event object can be Cloned...
+void wxPyEvent::CopyObject(wxObject& dest) const {
+ wxEvent::CopyObject(dest);
+ ((wxPyEvent*)&dest)->SetSelf(m_self, TRUE);
+}
+
+
+IMPLEMENT_DYNAMIC_CLASS(wxPyEvent, wxEvent);
+
+
+wxPyCommandEvent::wxPyCommandEvent(wxEventType commandType, int id)
+ : wxCommandEvent(commandType, id) {
+}
+
+wxPyCommandEvent::~wxPyCommandEvent() {
+}
+
+void wxPyCommandEvent::CopyObject(wxObject& dest) const {
+ wxCommandEvent::CopyObject(dest);
+ ((wxPyCommandEvent*)&dest)->SetSelf(m_self, TRUE);
+}
+
+
+IMPLEMENT_DYNAMIC_CLASS(wxPyCommandEvent, wxCommandEvent);
+
+
+