#ifdef WXP_WITH_THREAD
-//PyThreadState* wxPyEventThreadState = NULL;
PyInterpreterState* wxPyInterpreter = NULL;
#endif
#ifdef WXP_WITH_THREAD
PyEval_InitThreads();
-// wxPyEventThreadState = PyThreadState_Get(); // PyThreadState_New(PyThreadState_Get()->interp);
wxPyInterpreter = PyThreadState_Get()->interp;
#endif
}
-PyObject* wxPyMake_wxObject(wxObject* source) {
+PyObject* wxPyMake_wxObject(wxObject* source, bool checkEvtHandler) {
PyObject* target = NULL;
bool isEvtHandler = FALSE;
if (source) {
// If it's derived from wxEvtHandler then there may
- // already be a pointer to a Python objec that we can use.
- if (wxIsKindOf(source, wxEvtHandler)) {
+ // already be a pointer to a Python object that we can use
+ // in the OOR data.
+ if (checkEvtHandler && wxIsKindOf(source, wxEvtHandler)) {
+ isEvtHandler = TRUE;
wxEvtHandler* eh = (wxEvtHandler*)source;
wxPyClientData* data = (wxPyClientData*)eh->GetClientObject();
if (data) {
Py_INCREF(target);
}
}
- else if (wxIsKindOf(source, wxSizer)) {
- // wxSizers also track the original object
- wxSizer* sz = (wxSizer*)source;
- wxPyClientData* data = (wxPyClientData*)sz->GetClientObject();
- if (data) {
- target = data->m_obj;
- Py_INCREF(target);
- }
- }
if (! target) {
// Otherwise make it the old fashioned way by making a
}
+PyObject* wxPyMake_wxSizer(wxSizer* source) {
+ PyObject* target = NULL;
+
+ if (source && wxIsKindOf(source, wxSizer)) {
+ // If it's derived from wxSizer then there may
+ // already be a pointer to a Python object that we can use
+ // in the OOR data.
+ wxSizer* sz = (wxSizer*)source;
+ wxPyClientData* data = (wxPyClientData*)sz->GetClientObject();
+ if (data) {
+ target = data->m_obj;
+ Py_INCREF(target);
+ }
+ }
+ if (! target) {
+ target = wxPyMake_wxObject(source, FALSE);
+ if (target != Py_None)
+ ((wxSizer*)source)->SetClientObject(new wxPyClientData(target));
+ }
+ return target;
+}
+
+
+
//---------------------------------------------------------------------------
PyObject* wxPyConstructObject(void* ptr,
}
+IMPLEMENT_ABSTRACT_CLASS(wxPyEvent, wxEvent);
+IMPLEMENT_ABSTRACT_CLASS(wxPyCommandEvent, wxCommandEvent);
+
+
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);
+wxPyEvent::wxPyEvent(const wxPyEvent& evt)
+ : wxEvent(evt)
+{
+ SetSelf(evt.m_self, TRUE);
}
-IMPLEMENT_DYNAMIC_CLASS(wxPyEvent, wxEvent);
+wxPyEvent::~wxPyEvent() {
+}
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);
+wxPyCommandEvent::wxPyCommandEvent(const wxPyCommandEvent& evt)
+ : wxCommandEvent(evt)
+{
+ SetSelf(evt.m_self, TRUE);
}
-IMPLEMENT_DYNAMIC_CLASS(wxPyCommandEvent, wxCommandEvent);
+wxPyCommandEvent::~wxPyCommandEvent() {
+}
+
//----------------------------------------------------------------------
+
+PyObject* wxArrayString2PyList_helper(const wxArrayString& arr) {
+
+ PyObject* list = PyList_New(0);
+ for (size_t i=0; i < arr.GetCount(); i++) {
+ PyObject* str = PyString_FromString(arr[i].c_str());
+ PyList_Append(list, str);
+ Py_DECREF(str);
+ }
+ return list;
+}
+
+
//----------------------------------------------------------------------
//----------------------------------------------------------------------