Core wxPython (non-contrib) now fully works with Unicode!

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14586 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-03-13 22:30:20 +00:00
parent e5dd90b137
commit a541c32586
26 changed files with 638 additions and 566 deletions
+41 -38
View File
@@ -27,54 +27,57 @@ static void wxPyCoreAPI_IMPORT() {
wxPyCoreAPIPtr = (wxPyCoreAPI*)PyCObject_Import("wxc", "wxPyCoreAPI");
}
#define SWIG_MakePtr(a, b, c) (wxPyCoreAPIPtr->p_SWIG_MakePtr(a, b, c))
#define SWIG_GetPtr(a, b, c) (wxPyCoreAPIPtr->p_SWIG_GetPtr(a, b, c))
#define SWIG_GetPtrObj(a, b, c) (wxPyCoreAPIPtr->p_SWIG_GetPtrObj(a, b, c))
#define SWIG_RegisterMapping(a, b, c) (wxPyCoreAPIPtr->p_SWIG_RegisterMapping(a, b, c))
#define SWIG_addvarlink(a, b, c, d) (wxPyCoreAPIPtr->p_SWIG_addvarlink(a, b, c, d))
#define SWIG_MakePtr(a, b, c) (wxPyCoreAPIPtr->p_SWIG_MakePtr(a, b, c))
#define SWIG_GetPtr(a, b, c) (wxPyCoreAPIPtr->p_SWIG_GetPtr(a, b, c))
#define SWIG_GetPtrObj(a, b, c) (wxPyCoreAPIPtr->p_SWIG_GetPtrObj(a, b, c))
#define SWIG_RegisterMapping(a, b, c) (wxPyCoreAPIPtr->p_SWIG_RegisterMapping(a, b, c))
#define SWIG_addvarlink(a, b, c, d) (wxPyCoreAPIPtr->p_SWIG_addvarlink(a, b, c, d))
#define wxPyBeginAllowThreads() (wxPyCoreAPIPtr->p_wxPyBeginAllowThreads())
#define wxPyEndAllowThreads(a) (wxPyCoreAPIPtr->p_wxPyEndAllowThreads(a))
#define wxPyBeginBlockThreads() (wxPyCoreAPIPtr->p_wxPyBeginBlockThreads())
#define wxPyEndBlockThreads() (wxPyCoreAPIPtr->p_wxPyEndBlockThreads())
#define wxPyBeginAllowThreads() (wxPyCoreAPIPtr->p_wxPyBeginAllowThreads())
#define wxPyEndAllowThreads(a) (wxPyCoreAPIPtr->p_wxPyEndAllowThreads(a))
#define wxPyBeginBlockThreads() (wxPyCoreAPIPtr->p_wxPyBeginBlockThreads())
#define wxPyEndBlockThreads() (wxPyCoreAPIPtr->p_wxPyEndBlockThreads())
#define wxPyConstructObject(a,b,c) (wxPyCoreAPIPtr->p_wxPyConstructObject(a,b,c))
#define wxPy_ConvertList(a,b) (wxPyCoreAPIPtr->p_wxPy_ConvertList(a,b))
#define wxPyConstructObject(a,b,c) (wxPyCoreAPIPtr->p_wxPyConstructObject(a,b,c))
#define wxPy_ConvertList(a,b) (wxPyCoreAPIPtr->p_wxPy_ConvertList(a,b))
#define wxString_in_helper(a) (wxPyCoreAPIPtr->p_wxString_in_helper(a))
#define byte_LIST_helper(a) (wxPyCoreAPIPtr->p_byte_LIST_helper(a))
#define int_LIST_helper(a) (wxPyCoreAPIPtr->p_int_LIST_helper(a))
#define long_LIST_helper(a) (wxPyCoreAPIPtr->p_long_LIST_helper(a))
#define string_LIST_helper(a) (wxPyCoreAPIPtr->p_string_LIST_helper(a))
#define wxPoint_LIST_helper(a,b) (wxPyCoreAPIPtr->p_wxPoint_LIST_helper(a, b))
#define wxBitmap_LIST_helper(a) (wxPyCoreAPIPtr->p_wxBitmap_LIST_helper(a))
#define wxString_LIST_helper(a) (wxPyCoreAPIPtr->p_wxString_LIST_helper(a))
#define wxAcceleratorEntry_LIST_helper(a) (wxPyCoreAPIPtr->p_wxAcceleratorEntry_LIST_helper(a))
#define wxString_in_helper(a) (wxPyCoreAPIPtr->p_wxString_in_helper(a))
#define Py2wxString(a) (wxPyCoreAPIPtr->p_Py2wxString(a))
#define wx2PyString(a) (wxPyCoreAPIPtr->p_wx2PyString(a))
#define wxSize_helper(a,b) (wxPyCoreAPIPtr->p_wxSize_helper(a,b))
#define wxPoint_helper(a,b) (wxPyCoreAPIPtr->p_wxPoint_helper(a,b))
#define wxRealPoint_helper(a,b) (wxPyCoreAPIPtr->p_wxRealPoint_helper(a,b))
#define wxRect_helper(a,b) (wxPyCoreAPIPtr->p_wxRect_helper(a,b))
#define wxColour_helper(a,b) (wxPyCoreAPIPtr->p_wxColour_helper(a,b))
#define byte_LIST_helper(a) (wxPyCoreAPIPtr->p_byte_LIST_helper(a))
#define int_LIST_helper(a) (wxPyCoreAPIPtr->p_int_LIST_helper(a))
#define long_LIST_helper(a) (wxPyCoreAPIPtr->p_long_LIST_helper(a))
#define string_LIST_helper(a) (wxPyCoreAPIPtr->p_string_LIST_helper(a))
#define wxPoint_LIST_helper(a,b) (wxPyCoreAPIPtr->p_wxPoint_LIST_helper(a, b))
#define wxBitmap_LIST_helper(a) (wxPyCoreAPIPtr->p_wxBitmap_LIST_helper(a))
#define wxString_LIST_helper(a) (wxPyCoreAPIPtr->p_wxString_LIST_helper(a))
#define wxAcceleratorEntry_LIST_helper(a) (wxPyCoreAPIPtr->p_wxAcceleratorEntry_LIST_helper(a))
#define wxPyCBH_setCallbackInfo(a, b, c, d) (wxPyCoreAPIPtr->p_wxPyCBH_setCallbackInfo(a,b,c,d))
#define wxPyCBH_findCallback(a, b) (wxPyCoreAPIPtr->p_wxPyCBH_findCallback(a, b))
#define wxPyCBH_callCallback(a, b) (wxPyCoreAPIPtr->p_wxPyCBH_callCallback(a, b))
#define wxPyCBH_callCallbackObj(a, b) (wxPyCoreAPIPtr->p_wxPyCBH_callCallbackObj(a, b))
#define wxPyCBH_delete(a) (wxPyCoreAPIPtr->p_wxPyCBH_delete(a))
#define wxSize_helper(a,b) (wxPyCoreAPIPtr->p_wxSize_helper(a,b))
#define wxPoint_helper(a,b) (wxPyCoreAPIPtr->p_wxPoint_helper(a,b))
#define wxRealPoint_helper(a,b) (wxPyCoreAPIPtr->p_wxRealPoint_helper(a,b))
#define wxRect_helper(a,b) (wxPyCoreAPIPtr->p_wxRect_helper(a,b))
#define wxColour_helper(a,b) (wxPyCoreAPIPtr->p_wxColour_helper(a,b))
#define wxPyClassExists(a) (wxPyCoreAPIPtr->p_wxPyClassExists(a))
#define wxPyMake_wxObject(a) (wxPyCoreAPIPtr->p_wxPyMake_wxObject(a,TRUE))
#define wxPyMake_wxObject2(a,b) (wxPyCoreAPIPtr->p_wxPyMake_wxObject(a,b))
#define wxPyMake_wxSizer(a) (wxPyCoreAPIPtr->p_wxPyMake_wxSizer(a))
#define wxPyPtrTypeMap_Add(a, b) (wxPyCoreAPIPtr->p_wxPyPtrTypeMap_Add(a, b))
#define wxArrayString2PyList_helper(a) (wxPyCoreAPIPtr->p_wxArrayString2PyList_helper(a))
#define wxArrayInt2PyList_helper(a) (wxPyCoreAPIPtr->p_wxArrayInt2PyList_helper(a))
#define wxPyCBH_setCallbackInfo(a, b, c, d) (wxPyCoreAPIPtr->p_wxPyCBH_setCallbackInfo(a,b,c,d))
#define wxPyCBH_findCallback(a, b) (wxPyCoreAPIPtr->p_wxPyCBH_findCallback(a, b))
#define wxPyCBH_callCallback(a, b) (wxPyCoreAPIPtr->p_wxPyCBH_callCallback(a, b))
#define wxPyCBH_callCallbackObj(a, b) (wxPyCoreAPIPtr->p_wxPyCBH_callCallbackObj(a, b))
#define wxPyCBH_delete(a) (wxPyCoreAPIPtr->p_wxPyCBH_delete(a))
#define wxPyClassExists(a) (wxPyCoreAPIPtr->p_wxPyClassExists(a))
#define wxPyMake_wxObject(a) (wxPyCoreAPIPtr->p_wxPyMake_wxObject(a,TRUE))
#define wxPyMake_wxObject2(a,b) (wxPyCoreAPIPtr->p_wxPyMake_wxObject(a,b))
#define wxPyMake_wxSizer(a) (wxPyCoreAPIPtr->p_wxPyMake_wxSizer(a))
#define wxPyPtrTypeMap_Add(a, b) (wxPyCoreAPIPtr->p_wxPyPtrTypeMap_Add(a, b))
#define wxArrayString2PyList_helper(a) (wxPyCoreAPIPtr->p_wxArrayString2PyList_helper(a))
#define wxArrayInt2PyList_helper(a) (wxPyCoreAPIPtr->p_wxArrayInt2PyList_helper(a))
// This one is special. It's the first function called in SWIG generated
// modules, so we'll use it to also import the API.
#define SWIG_newvarlink() (wxPyCoreAPI_IMPORT(), wxPyCoreAPIPtr->p_SWIG_newvarlink())
#define SWIG_newvarlink() (wxPyCoreAPI_IMPORT(), wxPyCoreAPIPtr->p_SWIG_newvarlink())
//----------------------------------------------------------------------
+1 -1
View File
@@ -654,7 +654,7 @@ public:
wxString cName = name;
cName.MakeUpper();
wxString cName2 = cName;
if ( !cName2.Replace("GRAY", "GREY") )
if ( !cName2.Replace(wxT("GRAY"), wxT("GREY")) )
cName2.clear();
wxNode *node = self->First();
+34 -53
View File
@@ -131,50 +131,46 @@
}
// TODO: unicode fix
#define PYCALLBACK_STRING_INTINT_pure(CBNAME) \
wxString CBNAME(int a, int b) { \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
wxString rval; \
if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
PyObject* ro; \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \
if (ro) { \
PyObject* str = PyObject_Str(ro); \
rval = PyString_AsString(str); \
Py_DECREF(ro); Py_DECREF(str); \
rval = Py2wxString(ro); \
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
return rval; \
}
// TODO: unicode fix
#define PYCALLBACK__INTINTSTRING_pure(CBNAME) \
void CBNAME(int a, int b, const wxString& c) { \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\
wxPyEndBlockThreads(); \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,wx2PyString(c)));\
wxPyEndBlockThreads(); \
}
// TODO: unicode fix
#define PYCALLBACK_STRING_INTINT(PCLASS, CBNAME) \
wxString CBNAME(int a, int b) { \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
wxString rval; \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* ro; \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \
if (ro) { \
PyObject* str = PyObject_Str(ro); \
rval = PyString_AsString(str); \
Py_DECREF(ro); Py_DECREF(str); \
rval = Py2wxString(ro); \
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(a, b); \
return rval; \
@@ -184,15 +180,14 @@
}
// TODO: unicode fix
#define PYCALLBACK_BOOL_INTINTSTRING(PCLASS, CBNAME) \
bool CBNAME(int a, int b, const wxString& c) { \
bool rval = 0; \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)", a,b,c.c_str()));\
wxPyEndBlockThreads(); \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", a,b,wx2PyString(c)));\
wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(a,b,c); \
return rval; \
@@ -317,22 +312,20 @@
}
// TODO: unicode fix
#define PYCALLBACK_STRING_INT(PCLASS, CBNAME) \
wxString CBNAME(int a) { \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
wxString rval; \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* ro; \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a)); \
if (ro) { \
PyObject* str = PyObject_Str(ro); \
rval = PyString_AsString(str); \
Py_DECREF(ro); Py_DECREF(str); \
rval = Py2wxString(ro); \
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(a); \
return rval; \
@@ -342,14 +335,13 @@
}
// TODO: unicode fix
#define PYCALLBACK__INTSTRING(PCLASS, CBNAME) \
void CBNAME(int a, const wxString& c) { \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(is)", a,c.c_str())); \
wxPyEndBlockThreads(); \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)", a, wx2PyString(c))); \
wxPyEndBlockThreads(); \
if (! found) \
PCLASS::CBNAME(a,c); \
} \
@@ -364,10 +356,10 @@
bool CBNAME() { \
bool rval = 0; \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(); \
return rval; \
@@ -381,10 +373,10 @@
#define PYCALLBACK__SIZETINT(PCLASS, CBNAME) \
void CBNAME(size_t a, int b) { \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
PCLASS::CBNAME(a,b); \
} \
@@ -398,10 +390,10 @@
#define PYCALLBACK__INTINTLONG(PCLASS, CBNAME) \
void CBNAME(int a, int b, long c) { \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
PCLASS::CBNAME(a,b,c); \
} \
@@ -415,10 +407,10 @@
#define PYCALLBACK__INTINTDOUBLE(PCLASS, CBNAME) \
void CBNAME(int a, int b, double c) { \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iif)", a,b,c)); \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
PCLASS::CBNAME(a,b,c); \
} \
@@ -431,10 +423,10 @@
#define PYCALLBACK__INTINTBOOL(PCLASS, CBNAME) \
void CBNAME(int a, int b, bool c) { \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
PCLASS::CBNAME(a,b,c); \
} \
@@ -1070,15 +1062,8 @@ public:
PyObject* ro;
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",row,col));
if (ro) {
#if wxUSE_UNICODE
PyObject* str = PyObject_Unicode(ro);
rval = PyUnicode_AS_UNICODE(str);
#else
PyObject* str = PyObject_Str(ro);
rval = PyString_AsString(str);
#endif
rval = Py2wxString(ro);
Py_DECREF(ro);
Py_DECREF(str);
}
}
wxPyEndBlockThreads();
@@ -1088,11 +1073,7 @@ public:
void SetValue(int row, int col, const wxString& val) {
wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
#if wxUSE_UNICODE
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiu)",row,col,val.c_str()));
#else
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",row,col,val.c_str()));
#endif
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",row,col,wx2PyString(val)));
}
wxPyEndBlockThreads();
}
+180 -199
View File
File diff suppressed because it is too large Load Diff
+87 -97
View File
@@ -44,19 +44,23 @@ PyObject* __wxSetDictionary(PyObject*, PyObject* args);
void wxPyEventThunker(wxObject*, wxEvent& event);
PyObject* wxPyConstructObject(void* ptr,
const char* className,
const wxString& className,
int setThisOwn=0);
PyObject* wxPyConstructObject(void* ptr,
const char* className,
const wxString& className,
PyObject* klass,
int setThisOwn=0);
PyObject* wxPyClassExists(const char* className);
PyObject* wxPyMake_wxObject(wxObject* source, bool checkEvtHandler=TRUE);
PyObject* wxPyMake_wxSizer(wxSizer* source);
void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName);
PyObject* wx2PyString(const wxString& src);
wxString Py2wxString(PyObject* source);
PyObject* wxPyClassExists(const wxString& className);
PyObject* wxPyMake_wxObject(wxObject* source, bool checkEvtHandler=TRUE);
PyObject* wxPyMake_wxSizer(wxSizer* source);
void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName);
PyObject* wxPy_ConvertList(wxListBase* list, const char* className);
long wxPyGetWinHandle(wxWindow* win);
long wxPyGetWinHandle(wxWindow* win);
//----------------------------------------------------------------------
@@ -217,10 +221,12 @@ struct wxPyCoreAPI {
void (*p_wxPyBeginBlockThreads)();
void (*p_wxPyEndBlockThreads)();
PyObject* (*p_wxPyConstructObject)(void *, const char *, int);
PyObject* (*p_wxPyConstructObject)(void *, const wxString&, int);
PyObject* (*p_wxPy_ConvertList)(wxListBase* list, const char* className);
wxString* (*p_wxString_in_helper)(PyObject* source);
wxString (*p_Py2wxString)(PyObject* source);
PyObject* (*p_wx2PyString)(const wxString& src);
byte* (*p_byte_LIST_helper)(PyObject* source);
int* (*p_int_LIST_helper)(PyObject* source);
@@ -243,7 +249,7 @@ struct wxPyCoreAPI {
PyObject* (*p_wxPyCBH_callCallbackObj)(const wxPyCallbackHelper& cbh, PyObject* argTuple);
void (*p_wxPyCBH_delete)(wxPyCallbackHelper* cbh);
PyObject* (*p_wxPyClassExists)(const char* className);
PyObject* (*p_wxPyClassExists)(const wxString& className);
PyObject* (*p_wxPyMake_wxObject)(wxObject* source, bool checkEvtHandler);
PyObject* (*p_wxPyMake_wxSizer)(wxSizer* source);
void (*p_wxPyPtrTypeMap_Add)(const char* commonName, const char* ptrName);
@@ -806,13 +812,12 @@ public:
void CBNAME(const wxString& a); \
void base_##CBNAME(const wxString& a);
// TODO: unicode fix
#define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(const wxString& a) { \
bool found; \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", wx2PyString(a))); \
wxPyEndBlockThreads(); \
if (! found) \
PCLASS::CBNAME(a); \
@@ -827,14 +832,13 @@ public:
bool CBNAME(const wxString& a); \
bool base_##CBNAME(const wxString& a);
// TODO: unicode fix
#define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
bool CLASS::CBNAME(const wxString& a) { \
bool rval=FALSE; \
bool found; \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str()));\
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", wx2PyString(a)));\
wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(a); \
@@ -849,13 +853,12 @@ public:
#define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
bool CBNAME(const wxString& a);
// TODO: unicode fix
#define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
bool CLASS::CBNAME(const wxString& a) { \
bool rval=FALSE; \
wxPyBeginBlockThreads(); \
if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", wx2PyString(a))); \
wxPyEndBlockThreads(); \
return rval; \
} \
@@ -865,21 +868,19 @@ public:
#define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
wxString CBNAME(const wxString& a); \
// TODO: unicode fix
#define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
wxString CLASS::CBNAME(const wxString& a) { \
wxString rval; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
PyObject* ro; \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(s)", a.c_str()));\
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", wx2PyString(a)));\
if (ro) { \
PyObject* str = PyObject_Str(ro); \
rval = PyString_AsString(str); \
Py_DECREF(ro); Py_DECREF(str); \
rval = Py2wxString(ro); \
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
return rval; \
} \
@@ -888,21 +889,19 @@ public:
#define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
wxString CBNAME(const wxString& a,int b); \
// TODO: unicode fix
#define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
wxString CLASS::CBNAME(const wxString& a,int b) { \
wxString rval; \
wxPyBeginBlockThreads(); \
if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
PyObject* ro; \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(si)", a.c_str(),b)); \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)", wx2PyString(a),b)); \
if (ro) { \
PyObject* str = PyObject_Str(ro); \
rval = PyString_AsString(str); \
Py_DECREF(ro); Py_DECREF(str); \
rval = Py2wxString(ro); \
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
return rval; \
} \
@@ -912,16 +911,15 @@ public:
bool CBNAME(const wxString& a, const wxString& b); \
bool base_##CBNAME(const wxString& a, const wxString& b);
// TODO: unicode fix
#define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
bool rval=FALSE; \
bool found; \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ss)", \
a.c_str(), b.c_str())); \
wxPyEndBlockThreads(); \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", \
wx2PyString(a), wx2PyString(b))); \
wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(a, b); \
return rval; \
@@ -936,7 +934,6 @@ public:
wxString CBNAME(); \
wxString base_##CBNAME();
// TODO: unicode fix
#define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
wxString CLASS::CBNAME() { \
wxString rval; \
@@ -946,12 +943,11 @@ public:
PyObject* ro; \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
if (ro) { \
PyObject* str = PyObject_Str(ro); \
rval = PyString_AsString(str); \
Py_DECREF(ro); Py_DECREF(str); \
rval = Py2wxString(ro); \
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(); \
return rval; \
@@ -965,7 +961,6 @@ public:
#define DEC_PYCALLBACK_STRING__pure(CBNAME) \
wxString CBNAME();
// TODO: unicode fix
#define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
wxString CLASS::CBNAME() { \
wxString rval; \
@@ -974,12 +969,11 @@ public:
PyObject* ro; \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
if (ro) { \
PyObject* str = PyObject_Str(ro); \
rval = PyString_AsString(str); \
Py_DECREF(ro); Py_DECREF(str); \
rval = Py2wxString(ro); \
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
return rval; \
}
@@ -1168,7 +1162,6 @@ public:
#define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location); \
// TODO: unicode fix
#define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
wxPyBeginBlockThreads(); \
@@ -1176,8 +1169,8 @@ public:
if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
PyObject* ro; \
PyObject* obj = wxPyMake_wxObject(&a); \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Os)",\
obj, b.c_str())); \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)",\
obj, wx2PyString)); \
if (ro) { \
SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \
Py_DECREF(ro); \
@@ -1199,10 +1192,10 @@ public:
bool CLASS::CBNAME(wxDragResult a) { \
bool rval=FALSE; \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(a); \
return rval; \
@@ -1219,11 +1212,11 @@ public:
#define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
int rval=0; \
if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
return (wxDragResult)rval; \
} \
@@ -1232,14 +1225,13 @@ public:
#define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
bool CBNAME(int a, int b, const wxString& c);
// TODO: unicode fix
#define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
bool CLASS::CBNAME(int a, int b, const wxString& c) { \
bool rval=FALSE; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\
wxPyEndBlockThreads(); \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b, wx2PyString(c)));\
wxPyEndBlockThreads(); \
return rval; \
} \
@@ -1254,10 +1246,10 @@ public:
size_t CLASS::CBNAME() { \
size_t rval=0; \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(); \
return rval; \
@@ -1277,7 +1269,7 @@ public:
wxDataFormat CLASS::CBNAME(size_t a) { \
wxDataFormat rval=0; \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* ro; \
wxDataFormat* ptr; \
@@ -1288,7 +1280,7 @@ public:
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(a); \
return rval; \
@@ -1307,13 +1299,13 @@ public:
#define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
void CLASS::CBNAME(const Type& a) { \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
Py_DECREF(obj); \
} \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
PCLASS::CBNAME(a); \
} \
@@ -1332,13 +1324,13 @@ public:
#define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
void CLASS::CBNAME(Type& a) { \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
Py_DECREF(obj); \
} \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
PCLASS::CBNAME(a); \
} \
@@ -1357,13 +1349,13 @@ public:
bool CLASS::CBNAME(Type& a) { \
bool rv=FALSE; \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
Py_DECREF(obj); \
} \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
rv = PCLASS::CBNAME(a); \
return rv; \
@@ -1378,22 +1370,20 @@ public:
wxString CBNAME(long a, long b) const; \
wxString base_##CBNAME(long a, long b)const ;
// TODO: unicode fix
#define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
wxString CLASS::CBNAME(long a, long b) const { \
wxString rval; \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* ro; \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
if (ro) { \
PyObject* str = PyObject_Str(ro); \
rval = PyString_AsString(str); \
Py_DECREF(ro); Py_DECREF(str); \
rval = Py2wxString(ro); \
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(a,b); \
return rval; \
@@ -1413,7 +1403,7 @@ public:
int CLASS::CBNAME(long a) const { \
int rval=-1; \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* ro; \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
@@ -1422,7 +1412,7 @@ public:
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(a); \
return rval; \
@@ -1443,7 +1433,7 @@ public:
wxListItemAttr *CLASS::CBNAME(long a) const { \
wxListItemAttr *rval = NULL; \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* ro; \
wxListItemAttr* ptr; \
@@ -1454,7 +1444,7 @@ public:
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(a); \
return rval; \
@@ -1465,32 +1455,32 @@ public:
//---------------------------------------------------------------------------
#define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
bool CBNAME(wxMouseEvent& e); \
#define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
bool CBNAME(wxMouseEvent& e); \
bool base_##CBNAME(wxMouseEvent& e);
#define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
bool CLASS::CBNAME(wxMouseEvent& e) { \
bool rval=FALSE; \
bool found; \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* ro; \
PyObject* obj = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
if (ro) { \
rval = PyInt_AsLong(ro); \
Py_DECREF(ro); \
} \
Py_DECREF(obj); \
} \
wxPyEndBlockThreads(); \
if (! found) \
return PCLASS::CBNAME(e); \
return rval; \
} \
bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
return PCLASS::CBNAME(e); \
#define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
bool CLASS::CBNAME(wxMouseEvent& e) { \
bool rval=FALSE; \
bool found; \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* ro; \
PyObject* obj = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
if (ro) { \
rval = PyInt_AsLong(ro); \
Py_DECREF(ro); \
} \
Py_DECREF(obj); \
} \
wxPyEndBlockThreads(); \
if (! found) \
return PCLASS::CBNAME(e); \
return rval; \
} \
bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
return PCLASS::CBNAME(e); \
}
+2 -4
View File
@@ -498,15 +498,13 @@ wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type,
wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) {
PyObject* ro;
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(is)", type, url.c_str()));
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, wx2PyString(url)));
if (PyString_Check(ro)
#if PYTHON_API_VERSION >= 1009
|| PyUnicode_Check(ro)
#endif
) {
PyObject* str = PyObject_Str(ro);
*redirect = PyString_AsString(str);
Py_DECREF(str);
*redirect = Py2wxString(ro);
rval = wxHTML_REDIRECT;
}
else {
+16 -13
View File
@@ -53,7 +53,6 @@
//---------------------------------------------------------------------------
// Dialog Functions
#ifdef wxUSE_UNICODE
wxString wxFileSelector(const wxChar* message = wxFileSelectorPromptStr,
const wxChar* default_path = NULL,
const wxChar* default_filename = NULL,
@@ -62,16 +61,18 @@ wxString wxFileSelector(const wxChar* message = wxFileSelectorPromptStr,
int flags = 0,
wxWindow *parent = NULL,
int x = -1, int y = -1);
#else
wxString wxFileSelector(const char* message = wxFileSelectorPromptStr,
const char* default_path = NULL,
const char* default_filename = NULL,
const char* default_extension = NULL,
const char* wildcard = wxFileSelectorDefaultWildcardStr,
int flags = 0,
wxWindow *parent = NULL,
int x = -1, int y = -1);
#endif
// Ask for filename to load
wxString wxLoadFileSelector(const wxChar *what,
const wxChar *extension,
const wxChar *default_name = NULL,
wxWindow *parent = NULL);
// Ask for filename to save
wxString wxSaveFileSelector(const wxChar *what,
const wxChar *extension,
const wxChar *default_name = NULL,
wxWindow *parent = NULL);
wxString wxGetTextFromUser(const wxString& message,
const wxString& caption = wxEmptyString,
@@ -702,7 +703,8 @@ public:
bool found;
wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "DoLog")))
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(isi)", level, szString, t)); // TODO: unicode fix
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iOi)", level,
wx2PyString(szString), t));
wxPyEndBlockThreads();
if (! found)
wxLog::DoLog(level, szString, t);
@@ -712,7 +714,8 @@ public:
bool found;
wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "DoLogString")))
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(si)", szString, t)); // TODO: unicode fix
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)",
wx2PyString(szString), t));
wxPyEndBlockThreads();
if (! found)
wxLog::DoLogString(szString, t);
+1 -1
View File
@@ -5631,7 +5631,7 @@ static void wxColourDatabase_Append(wxColourDatabase *self,const wxString & nam
wxString cName = name;
cName.MakeUpper();
wxString cName2 = cName;
if ( !cName2.Replace("GRAY", "GREY") )
if ( !cName2.Replace(wxT("GRAY"), wxT("GREY")) )
cName2.clear();
wxNode *node = self->First();
+34 -53
View File
@@ -173,50 +173,46 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) {
}
// TODO: unicode fix
#define PYCALLBACK_STRING_INTINT_pure(CBNAME) \
wxString CBNAME(int a, int b) { \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
wxString rval; \
if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
PyObject* ro; \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \
if (ro) { \
PyObject* str = PyObject_Str(ro); \
rval = PyString_AsString(str); \
Py_DECREF(ro); Py_DECREF(str); \
rval = Py2wxString(ro); \
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
return rval; \
}
// TODO: unicode fix
#define PYCALLBACK__INTINTSTRING_pure(CBNAME) \
void CBNAME(int a, int b, const wxString& c) { \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\
wxPyEndBlockThreads(); \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,wx2PyString(c)));\
wxPyEndBlockThreads(); \
}
// TODO: unicode fix
#define PYCALLBACK_STRING_INTINT(PCLASS, CBNAME) \
wxString CBNAME(int a, int b) { \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
wxString rval; \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* ro; \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \
if (ro) { \
PyObject* str = PyObject_Str(ro); \
rval = PyString_AsString(str); \
Py_DECREF(ro); Py_DECREF(str); \
rval = Py2wxString(ro); \
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(a, b); \
return rval; \
@@ -226,15 +222,14 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) {
}
// TODO: unicode fix
#define PYCALLBACK_BOOL_INTINTSTRING(PCLASS, CBNAME) \
bool CBNAME(int a, int b, const wxString& c) { \
bool rval = 0; \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)", a,b,c.c_str()));\
wxPyEndBlockThreads(); \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", a,b,wx2PyString(c)));\
wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(a,b,c); \
return rval; \
@@ -359,22 +354,20 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) {
}
// TODO: unicode fix
#define PYCALLBACK_STRING_INT(PCLASS, CBNAME) \
wxString CBNAME(int a) { \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
wxString rval; \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* ro; \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a)); \
if (ro) { \
PyObject* str = PyObject_Str(ro); \
rval = PyString_AsString(str); \
Py_DECREF(ro); Py_DECREF(str); \
rval = Py2wxString(ro); \
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(a); \
return rval; \
@@ -384,14 +377,13 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) {
}
// TODO: unicode fix
#define PYCALLBACK__INTSTRING(PCLASS, CBNAME) \
void CBNAME(int a, const wxString& c) { \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(is)", a,c.c_str())); \
wxPyEndBlockThreads(); \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)", a, wx2PyString(c))); \
wxPyEndBlockThreads(); \
if (! found) \
PCLASS::CBNAME(a,c); \
} \
@@ -406,10 +398,10 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) {
bool CBNAME() { \
bool rval = 0; \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(); \
return rval; \
@@ -423,10 +415,10 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) {
#define PYCALLBACK__SIZETINT(PCLASS, CBNAME) \
void CBNAME(size_t a, int b) { \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
PCLASS::CBNAME(a,b); \
} \
@@ -440,10 +432,10 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) {
#define PYCALLBACK__INTINTLONG(PCLASS, CBNAME) \
void CBNAME(int a, int b, long c) { \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
PCLASS::CBNAME(a,b,c); \
} \
@@ -457,10 +449,10 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) {
#define PYCALLBACK__INTINTDOUBLE(PCLASS, CBNAME) \
void CBNAME(int a, int b, double c) { \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iif)", a,b,c)); \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
PCLASS::CBNAME(a,b,c); \
} \
@@ -473,10 +465,10 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) {
#define PYCALLBACK__INTINTBOOL(PCLASS, CBNAME) \
void CBNAME(int a, int b, bool c) { \
bool found; \
wxPyBeginBlockThreads(); \
wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \
wxPyEndBlockThreads(); \
wxPyEndBlockThreads(); \
if (! found) \
PCLASS::CBNAME(a,b,c); \
} \
@@ -724,15 +716,8 @@ public:
PyObject* ro;
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",row,col));
if (ro) {
#if wxUSE_UNICODE
PyObject* str = PyObject_Unicode(ro);
rval = PyUnicode_AS_UNICODE(str);
#else
PyObject* str = PyObject_Str(ro);
rval = PyString_AsString(str);
#endif
rval = Py2wxString(ro);
Py_DECREF(ro);
Py_DECREF(str);
}
}
wxPyEndBlockThreads();
@@ -742,11 +727,7 @@ public:
void SetValue(int row, int col, const wxString& val) {
wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
#if wxUSE_UNICODE
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiu)",row,col,val.c_str()));
#else
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",row,col,val.c_str()));
#endif
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",row,col,wx2PyString(val)));
}
wxPyEndBlockThreads();
}
+2 -4
View File
@@ -252,15 +252,13 @@ wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type,
wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) {
PyObject* ro;
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(is)", type, url.c_str()));
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, wx2PyString(url)));
if (PyString_Check(ro)
#if PYTHON_API_VERSION >= 1009
|| PyUnicode_Check(ro)
#endif
) {
PyObject* str = PyObject_Str(ro);
*redirect = PyString_AsString(str);
Py_DECREF(str);
*redirect = Py2wxString(ro);
rval = wxHTML_REDIRECT;
}
else {
+89 -7
View File
@@ -156,7 +156,8 @@ public:
bool found;
wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "DoLog")))
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(isi)", level, szString, t)); // TODO: unicode fix
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iOi)", level,
wx2PyString(szString), t));
wxPyEndBlockThreads();
if (! found)
wxLog::DoLog(level, szString, t);
@@ -166,7 +167,8 @@ public:
bool found;
wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "DoLogString")))
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(si)", szString, t)); // TODO: unicode fix
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)",
wx2PyString(szString), t));
wxPyEndBlockThreads();
if (! found)
wxLog::DoLogString(szString, t);
@@ -287,11 +289,11 @@ extern "C" {
static PyObject *_wrap_wxFileSelector(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxString * _result;
char * _arg0 = (char *) wxFileSelectorPromptStr;
char * _arg1 = (char *) NULL;
char * _arg2 = (char *) NULL;
char * _arg3 = (char *) NULL;
char * _arg4 = (char *) wxFileSelectorDefaultWildcardStr;
wxChar * _arg0 = (wxChar *) wxFileSelectorPromptStr;
wxChar * _arg1 = (wxChar *) NULL;
wxChar * _arg2 = (wxChar *) NULL;
wxChar * _arg3 = (wxChar *) NULL;
wxChar * _arg4 = (wxChar *) wxFileSelectorDefaultWildcardStr;
int _arg5 = (int ) 0;
wxWindow * _arg6 = (wxWindow *) NULL;
int _arg7 = (int ) -1;
@@ -328,6 +330,84 @@ static PyObject *_wrap_wxFileSelector(PyObject *self, PyObject *args, PyObject *
return _resultobj;
}
static PyObject *_wrap_wxLoadFileSelector(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxString * _result;
wxChar * _arg0;
wxChar * _arg1;
wxChar * _arg2 = (wxChar *) NULL;
wxWindow * _arg3 = (wxWindow *) NULL;
PyObject * _argo3 = 0;
char *_kwnames[] = { "what","extension","default_name","parent", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"ss|sO:wxLoadFileSelector",_kwnames,&_arg0,&_arg1,&_arg2,&_argo3))
return NULL;
if (_argo3) {
if (_argo3 == Py_None) { _arg3 = NULL; }
else if (SWIG_GetPtrObj(_argo3,(void **) &_arg3,"_wxWindow_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 4 of wxLoadFileSelector. Expected _wxWindow_p.");
return NULL;
}
}
{
PyThreadState* __tstate = wxPyBeginAllowThreads();
_result = new wxString (wxLoadFileSelector(_arg0,_arg1,_arg2,_arg3));
wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) return NULL;
}{
#if wxUSE_UNICODE
_resultobj = PyUnicode_FromUnicode(_result->c_str(), _result->Len());
#else
_resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len());
#endif
}
{
delete _result;
}
return _resultobj;
}
static PyObject *_wrap_wxSaveFileSelector(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxString * _result;
wxChar * _arg0;
wxChar * _arg1;
wxChar * _arg2 = (wxChar *) NULL;
wxWindow * _arg3 = (wxWindow *) NULL;
PyObject * _argo3 = 0;
char *_kwnames[] = { "what","extension","default_name","parent", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"ss|sO:wxSaveFileSelector",_kwnames,&_arg0,&_arg1,&_arg2,&_argo3))
return NULL;
if (_argo3) {
if (_argo3 == Py_None) { _arg3 = NULL; }
else if (SWIG_GetPtrObj(_argo3,(void **) &_arg3,"_wxWindow_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 4 of wxSaveFileSelector. Expected _wxWindow_p.");
return NULL;
}
}
{
PyThreadState* __tstate = wxPyBeginAllowThreads();
_result = new wxString (wxSaveFileSelector(_arg0,_arg1,_arg2,_arg3));
wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) return NULL;
}{
#if wxUSE_UNICODE
_resultobj = PyUnicode_FromUnicode(_result->c_str(), _result->Len());
#else
_resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len());
#endif
}
{
delete _result;
}
return _resultobj;
}
static PyObject *_wrap_wxGetTextFromUser(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxString * _result;
@@ -10091,6 +10171,8 @@ static PyMethodDef misc2cMethods[] = {
{ "wxGetSingleChoice", (PyCFunction) _wrap_wxGetSingleChoice, METH_VARARGS | METH_KEYWORDS },
{ "wxGetPasswordFromUser", (PyCFunction) _wrap_wxGetPasswordFromUser, METH_VARARGS | METH_KEYWORDS },
{ "wxGetTextFromUser", (PyCFunction) _wrap_wxGetTextFromUser, METH_VARARGS | METH_KEYWORDS },
{ "wxSaveFileSelector", (PyCFunction) _wrap_wxSaveFileSelector, METH_VARARGS | METH_KEYWORDS },
{ "wxLoadFileSelector", (PyCFunction) _wrap_wxLoadFileSelector, METH_VARARGS | METH_KEYWORDS },
{ "wxFileSelector", (PyCFunction) _wrap_wxFileSelector, METH_VARARGS | METH_KEYWORDS },
{ NULL, NULL }
};
+4
View File
@@ -993,6 +993,10 @@ class wxFileHistory(wxFileHistoryPtr):
wxFileSelector = misc2c.wxFileSelector
wxLoadFileSelector = misc2c.wxLoadFileSelector
wxSaveFileSelector = misc2c.wxSaveFileSelector
wxGetTextFromUser = misc2c.wxGetTextFromUser
wxGetPasswordFromUser = misc2c.wxGetPasswordFromUser
+23 -45
View File
@@ -214,7 +214,7 @@ static PyObject *_wrap_wxInputStream_eof(PyObject *self, PyObject *args, PyObjec
#define wxInputStream_read(_swigobj,_swigarg0) (_swigobj->read(_swigarg0))
static PyObject *_wrap_wxInputStream_read(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxString * _result;
PyObject * _result;
wxPyInputStream * _arg0;
int _arg1 = (int ) -1;
PyObject * _argo0 = 0;
@@ -232,16 +232,12 @@ static PyObject *_wrap_wxInputStream_read(PyObject *self, PyObject *args, PyObje
}
{
PyThreadState* __tstate = wxPyBeginAllowThreads();
_result = (wxString *)wxInputStream_read(_arg0,_arg1);
_result = (PyObject *)wxInputStream_read(_arg0,_arg1);
wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) return NULL;
}{
#if wxUSE_UNICODE
_resultobj = PyUnicode_FromUnicode(_result->c_str(), _result->Len());
#else
_resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len());
#endif
_resultobj = _result;
}
return _resultobj;
}
@@ -249,7 +245,7 @@ static PyObject *_wrap_wxInputStream_read(PyObject *self, PyObject *args, PyObje
#define wxInputStream_readline(_swigobj,_swigarg0) (_swigobj->readline(_swigarg0))
static PyObject *_wrap_wxInputStream_readline(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxString * _result;
PyObject * _result;
wxPyInputStream * _arg0;
int _arg1 = (int ) -1;
PyObject * _argo0 = 0;
@@ -267,16 +263,12 @@ static PyObject *_wrap_wxInputStream_readline(PyObject *self, PyObject *args, Py
}
{
PyThreadState* __tstate = wxPyBeginAllowThreads();
_result = (wxString *)wxInputStream_readline(_arg0,_arg1);
_result = (PyObject *)wxInputStream_readline(_arg0,_arg1);
wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) return NULL;
}{
#if wxUSE_UNICODE
_resultobj = PyUnicode_FromUnicode(_result->c_str(), _result->Len());
#else
_resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len());
#endif
_resultobj = _result;
}
return _resultobj;
}
@@ -284,7 +276,7 @@ static PyObject *_wrap_wxInputStream_readline(PyObject *self, PyObject *args, Py
#define wxInputStream_readlines(_swigobj,_swigarg0) (_swigobj->readlines(_swigarg0))
static PyObject *_wrap_wxInputStream_readlines(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxStringPtrList * _result;
PyObject * _result;
wxPyInputStream * _arg0;
int _arg1 = (int ) -1;
PyObject * _argo0 = 0;
@@ -302,28 +294,12 @@ static PyObject *_wrap_wxInputStream_readlines(PyObject *self, PyObject *args, P
}
{
PyThreadState* __tstate = wxPyBeginAllowThreads();
_result = (wxStringPtrList *)wxInputStream_readlines(_arg0,_arg1);
_result = (PyObject *)wxInputStream_readlines(_arg0,_arg1);
wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) return NULL;
}{
if (_result) {
_resultobj = PyList_New(_result->GetCount());
wxStringPtrList::Node *node = _result->GetFirst();
for (int i=0; node; i++) {
wxString *s = node->GetData();
#if wxUSE_UNICODE
PyList_SetItem(_resultobj, i, PyUnicode_FromUnicode(s->c_str(), s->Len()));
#else
PyList_SetItem(_resultobj, i, PyString_FromStringAndSize(s->c_str(), s->Len()));
#endif
node = node->GetNext();
delete s;
}
delete _result;
}
else
_resultobj=0;
_resultobj = _result;
}
return _resultobj;
}
@@ -386,16 +362,24 @@ static PyObject *_wrap_wxInputStream_tell(PyObject *self, PyObject *args, PyObje
return _resultobj;
}
static void wxOutputStream_write(wxOutputStream *self,const wxString & str) {
self->Write(str.c_str(), str.Length());
static void wxOutputStream_write(wxOutputStream *self,PyObject * obj) {
// We use only strings for the streams, not unicode
PyObject* str = PyObject_Str(obj);
if (! str) {
PyErr_SetString(PyExc_TypeError, "Unable to convert to string");
return;
}
self->Write(PyString_AS_STRING(str),
PyString_GET_SIZE(str));
Py_DECREF(str);
}
static PyObject *_wrap_wxOutputStream_write(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxOutputStream * _arg0;
wxString * _arg1;
PyObject * _arg1;
PyObject * _argo0 = 0;
PyObject * _obj1 = 0;
char *_kwnames[] = { "self","str", NULL };
char *_kwnames[] = { "self","obj", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxOutputStream_write",_kwnames,&_argo0,&_obj1))
@@ -408,22 +392,16 @@ static PyObject *_wrap_wxOutputStream_write(PyObject *self, PyObject *args, PyOb
}
}
{
_arg1 = wxString_in_helper(_obj1);
if (_arg1 == NULL)
return NULL;
_arg1 = _obj1;
}
{
PyThreadState* __tstate = wxPyBeginAllowThreads();
wxOutputStream_write(_arg0,*_arg1);
wxOutputStream_write(_arg0,_arg1);
wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) return NULL;
} Py_INCREF(Py_None);
_resultobj = Py_None;
{
if (_obj1)
delete _arg1;
}
return _resultobj;
}
+38 -4
View File
@@ -5119,17 +5119,19 @@ static PyObject *_wrap_wxWindow_GetToolTip(PyObject *self, PyObject *args, PyObj
return _resultobj;
}
#define wxWindow_SetSizer(_swigobj,_swigarg0) (_swigobj->SetSizer(_swigarg0))
#define wxWindow_SetSizer(_swigobj,_swigarg0,_swigarg1) (_swigobj->SetSizer(_swigarg0,_swigarg1))
static PyObject *_wrap_wxWindow_SetSizer(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxWindow * _arg0;
wxSizer * _arg1;
bool _arg2 = (bool ) TRUE;
PyObject * _argo0 = 0;
PyObject * _argo1 = 0;
char *_kwnames[] = { "self","sizer", NULL };
int tempbool2 = (int) TRUE;
char *_kwnames[] = { "self","sizer","deleteOld", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxWindow_SetSizer",_kwnames,&_argo0,&_argo1))
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO|i:wxWindow_SetSizer",_kwnames,&_argo0,&_argo1,&tempbool2))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
@@ -5145,9 +5147,10 @@ static PyObject *_wrap_wxWindow_SetSizer(PyObject *self, PyObject *args, PyObjec
return NULL;
}
}
_arg2 = (bool ) tempbool2;
{
PyThreadState* __tstate = wxPyBeginAllowThreads();
wxWindow_SetSizer(_arg0,_arg1);
wxWindow_SetSizer(_arg0,_arg1,_arg2);
wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) return NULL;
@@ -5416,6 +5419,36 @@ static PyObject *_wrap_wxWindow_GetBestSize(PyObject *self, PyObject *args, PyOb
return _resultobj;
}
#define wxWindow_GetMaxSize(_swigobj) (_swigobj->GetMaxSize())
static PyObject *_wrap_wxWindow_GetMaxSize(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxSize * _result;
wxWindow * _arg0;
PyObject * _argo0 = 0;
char *_kwnames[] = { "self", NULL };
char _ptemp[128];
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxWindow_GetMaxSize",_kwnames,&_argo0))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxWindow_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxWindow_GetMaxSize. Expected _wxWindow_p.");
return NULL;
}
}
{
PyThreadState* __tstate = wxPyBeginAllowThreads();
_result = new wxSize (wxWindow_GetMaxSize(_arg0));
wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) return NULL;
} SWIG_MakePtr(_ptemp, (void *) _result,"_wxSize_p");
_resultobj = Py_BuildValue("s",_ptemp);
return _resultobj;
}
#define wxWindow_SetCaret(_swigobj,_swigarg0) (_swigobj->SetCaret(_swigarg0))
static PyObject *_wrap_wxWindow_SetCaret(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
@@ -10577,6 +10610,7 @@ static PyMethodDef windowscMethods[] = {
{ "wxWindow_Freeze", (PyCFunction) _wrap_wxWindow_Freeze, METH_VARARGS | METH_KEYWORDS },
{ "wxWindow_GetCaret", (PyCFunction) _wrap_wxWindow_GetCaret, METH_VARARGS | METH_KEYWORDS },
{ "wxWindow_SetCaret", (PyCFunction) _wrap_wxWindow_SetCaret, METH_VARARGS | METH_KEYWORDS },
{ "wxWindow_GetMaxSize", (PyCFunction) _wrap_wxWindow_GetMaxSize, METH_VARARGS | METH_KEYWORDS },
{ "wxWindow_GetBestSize", (PyCFunction) _wrap_wxWindow_GetBestSize, METH_VARARGS | METH_KEYWORDS },
{ "wxWindow_GetDropTarget", (PyCFunction) _wrap_wxWindow_GetDropTarget, METH_VARARGS | METH_KEYWORDS },
{ "wxWindow_SetDropTarget", (PyCFunction) _wrap_wxWindow_SetDropTarget, METH_VARARGS | METH_KEYWORDS },
+4
View File
@@ -538,6 +538,10 @@ class wxWindowPtr(wxEvtHandlerPtr):
val = apply(windowsc.wxWindow_GetBestSize,(self,) + _args, _kwargs)
if val: val = wxSizePtr(val) ; val.thisown = 1
return val
def GetMaxSize(self, *_args, **_kwargs):
val = apply(windowsc.wxWindow_GetMaxSize,(self,) + _args, _kwargs)
if val: val = wxSizePtr(val) ; val.thisown = 1
return val
def SetCaret(self, *_args, **_kwargs):
val = apply(windowsc.wxWindow_SetCaret,(self,) + _args, _kwargs)
return val
+3
View File
@@ -647,6 +647,9 @@ static wxPyCoreAPI API = {
wxPy_ConvertList,
wxString_in_helper,
Py2wxString,
wx2PyString,
byte_LIST_helper,
int_LIST_helper,
long_LIST_helper,
+3 -3
View File
@@ -37,9 +37,9 @@ public:
void close();
void flush();
bool eof();
wxString* read(int size=-1);
wxString* readline(int size=-1);
wxStringPtrList* readlines(int sizehint=-1);
PyObject* read(int size=-1);
PyObject* readline(int size=-1);
PyObject* readlines(int sizehint=-1);
void seek(int offset, int whence=0);
int tell();
+33 -25
View File
@@ -67,26 +67,26 @@
//----------------------------------------------------------------------
// wxStringPtrList* to python list of strings typemap
%typemap(python, out) wxStringPtrList* {
if ($source) {
$target = PyList_New($source->GetCount());
wxStringPtrList::Node *node = $source->GetFirst();
for (int i=0; node; i++) {
wxString *s = node->GetData();
#if wxUSE_UNICODE
PyList_SetItem($target, i, PyUnicode_FromUnicode(s->c_str(), s->Len()));
#else
PyList_SetItem($target, i, PyString_FromStringAndSize(s->c_str(), s->Len()));
#endif
node = node->GetNext();
delete s;
}
delete $source;
}
else
$target=0;
}
// // wxStringPtrList* to python list of strings typemap
// %typemap(python, out) wxStringPtrList* {
// if ($source) {
// $target = PyList_New($source->GetCount());
// wxStringPtrList::Node *node = $source->GetFirst();
// for (int i=0; node; i++) {
// wxString *s = node->GetData();
// #if wxUSE_UNICODE
// PyList_SetItem($target, i, PyUnicode_FromUnicode(s->c_str(), s->Len()));
// #else
// PyList_SetItem($target, i, PyString_FromStringAndSize(s->c_str(), s->Len()));
// #endif
// node = node->GetNext();
// delete s;
// }
// delete $source;
// }
// else
// $target=0;
// }
@@ -105,9 +105,9 @@ public:
void close();
void flush();
bool eof();
wxString* read(int size=-1);
wxString* readline(int size=-1);
wxStringPtrList* readlines(int sizehint=-1);
PyObject* read(int size=-1);
PyObject* readline(int size=-1);
PyObject* readlines(int sizehint=-1);
void seek(int offset, int whence=0);
int tell();
@@ -141,8 +141,16 @@ public:
*/
%addmethods {
void write(const wxString& str) {
self->Write(str.c_str(), str.Length());
void write(PyObject* obj) {
// We use only strings for the streams, not unicode
PyObject* str = PyObject_Str(obj);
if (! str) {
PyErr_SetString(PyExc_TypeError, "Unable to convert to string");
return;
}
self->Write(PyString_AS_STRING(str),
PyString_GET_SIZE(str));
Py_DECREF(str);
}
}
};
+2 -1
View File
@@ -371,7 +371,7 @@ public:
void SetToolTip(wxToolTip *tooltip);
wxToolTip* GetToolTip();
void SetSizer(wxSizer* sizer);
void SetSizer(wxSizer* sizer, bool deleteOld=TRUE);
wxSizer* GetSizer();
// Track if this window is a member of a sizer
@@ -388,6 +388,7 @@ public:
#endif
wxSize GetBestSize();
wxSize GetMaxSize();
void SetCaret(wxCaret *caret);
wxCaret *GetCaret();
+3
View File
@@ -176,6 +176,9 @@ static wxPyCoreAPI API = {
wxPy_ConvertList,
wxString_in_helper,
Py2wxString,
wx2PyString,
byte_LIST_helper,
int_LIST_helper,
long_LIST_helper,