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

View File

@@ -30,6 +30,9 @@ columns are specified and work the same as in wxFlexGridSizer.
Updated XRCed from Roman Rolinsky
UNICODE!
2.3.2.1

View File

@@ -9,7 +9,7 @@ from wxPython.wx import *
class MyFrame(wxFrame):
"""
This is MyFrame. It just shows a few controls on a wxPanel,
This is MyFrame. It just shows a few controls on a wxPanel,
and has a simple menu.
"""
def __init__(self, parent, title):
@@ -24,7 +24,7 @@ class MyFrame(wxFrame):
panel = wxPanel(self, -1)
if wxPlatform == "__WXMAC__":
text = wxStaticText(panel, -1,
text = wxStaticText(panel, -1,
"Hello World!\nWhere is my menu?")
else:
text = wxStaticText(panel, -1, "Hello World!")

View File

@@ -25,12 +25,13 @@ class TestPanel(wxPanel):
mask = wxMaskColour(bmp, wxBLUE)
bmp.SetMask(mask)
##print bmp.GetWidth(), bmp.GetHeight()
wxBitmapButton(self, 30, bmp, wxPoint(140, 20),
wxSize(bmp.GetWidth()+10, bmp.GetHeight()+10))
EVT_BUTTON(self, 30, self.OnClick)
if wxUSE_UNICODE:
label = unichr(21514) + unichr(26984) + unichr(8307) + unichr(29545)
wxButton(self, -1, label+" (I have no idea what that says...)", (20, 150))
def OnClick(self, event):
self.log.WriteText("Click! (%d)\n" % event.GetId())

View File

@@ -19,7 +19,7 @@ class TestPanel(wxPanel):
# Make the controls
prompt = wxStaticText(self, -1, 'Command line:')
self.cmd = wxTextCtrl(self, -1, 'python data/echo.py')
self.cmd = wxTextCtrl(self, -1, 'python -u data/echo.py')
self.exBtn = wxButton(self, -1, 'Execute')
self.out = wxTextCtrl(self, -1, '', style=wxTE_MULTILINE|wxTE_READONLY)
@@ -91,9 +91,9 @@ class TestPanel(wxPanel):
def OnCloseStream(self, evt):
self.log.write('OnCloseStream\n')
print "b4 CloseOutput"
#print "b4 CloseOutput"
self.process.CloseOutput()
print "after CloseOutput"
#print "after CloseOutput"
def OnIdle(self, evt):
if self.process is not None:

View File

@@ -47,8 +47,9 @@ GL_ONLY = 0 # Only used when making the -gl RPM. See the "b" script
USE_SWIG = 0 # Should we actually execute SWIG, or just use the
# files already in the distribution?
USE_UNICODE = 0 # This will pass the 'wxUSE_UNICODE' flag to SWIG.
# At the moment only tested for 'CORE_ONLY = 1'
UNICODE = 0 # This will pass the 'wxUSE_UNICODE' flag to SWIG and
# will ensure that the right headers are found and the
# right libs are linked.
IN_CVS_TREE = 0 # Set to true if building in a full wxWindows CVS
# tree, otherwise will assume all needed files are
@@ -59,6 +60,8 @@ WX_CONFIG = "wx-config" # Usually you shouldn't need to touch this,
# version of wx-config or alternate flags,
# eg. as required by the .deb in-tree build.
BUILD_BASE = "build"
# Some MSW build settings
FINAL = 1 # Mirrors use of same flag in wx makefiles,
@@ -72,7 +75,7 @@ HYBRID = 0 # If set and not debug or FINAL, then build a
# wxWindows must have been built with /MD, not /MDd
# (using FINAL=hybrid will do it.)
WXDLLVER = '233' # Version part of DLL name
WXDLLVER = '233' # Version part of wxWindows DLL name
#----------------------------------------------------------------------
@@ -81,10 +84,12 @@ def msg(text):
if __name__ == "__main__":
print text
def opj(*args):
path = apply(os.path.join, args)
return os.path.normpath(path)
def libFlag():
if FINAL:
rv = ''
@@ -92,7 +97,7 @@ def libFlag():
rv = 'h'
else:
rv = 'd'
if USE_UNICODE:
if UNICODE:
rv = 'u' + rv
return rv
@@ -123,7 +128,7 @@ if bcpp_compiling:
for flag in ['BUILD_GLCANVAS', 'BUILD_OGL', 'BUILD_STC', 'BUILD_XRC',
'BUILD_GIZMOS', 'BUILD_DLLWIDGET',
'CORE_ONLY', 'USE_SWIG', 'IN_CVS_TREE', 'USE_UNICODE',
'CORE_ONLY', 'USE_SWIG', 'IN_CVS_TREE', 'UNICODE',
'FINAL', 'HYBRID', ]:
for x in range(len(sys.argv)):
if string.find(sys.argv[x], flag) == 0:
@@ -156,19 +161,28 @@ if CORE_ONLY:
BUILD_DLLWIDGET = 0
if USE_UNICODE and os.name != 'nt':
if UNICODE and os.name != 'nt':
print "UNICODE is currently only supported on Win32"
sys.exit()
if UNICODE:
BUILD_BASE = BUILD_BASE + '.unicode'
#----------------------------------------------------------------------
# Setup some platform specific stuff
#----------------------------------------------------------------------
if os.name == 'nt':
# Set compile flags and such for MSVC. These values are derived
# from the wxWindows makefiles for MSVC, others will probably
# vary...
WXDIR = os.environ['WXWIN']
# from the wxWindows makefiles for MSVC, other compilers settings
# will probably vary...
if os.environ.has_key('WXWIN'):
WXDIR = os.environ['WXWIN']
else:
msg("WARNING: WXWIN not set in environment.")
WXDIR = '..' # assumes in CVS tree
WXPLAT = '__WXMSW__'
GENDIR = 'msw'
@@ -327,7 +341,7 @@ swig_args = ['-c++', '-shadow', '-python', '-keyword',
#'-docstring', '-Sbefore',
'-I./src', '-D'+WXPLAT,
]
if USE_UNICODE:
if UNICODE:
swig_args.append('-DwxUSE_UNICODE')
swig_deps = ['src/my_typemaps.i']
@@ -873,6 +887,8 @@ if __name__ == "__main__":
ext_package = PKGDIR,
ext_modules = wxpExtensions,
options = { 'build' : { 'build_base' : BUILD_BASE }}
##data_files = TOOLS,
)

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())
//----------------------------------------------------------------------

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();

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();
}

View File

@@ -125,40 +125,43 @@ int wxPyApp::MainLoop() {
//---------------------------------------------------------------------
//----------------------------------------------------------------------
static char* wxPyCopyCString(const wxChar* src)
{
wxWX2MBbuf buff = (wxWX2MBbuf)wxConvCurrent->cWX2MB(src);
size_t len = strlen(buff);
char* dest = new char[len+1];
strcpy(dest, buff);
return dest;
}
#if wxUSE_UNICODE
// TODO: Is this really the right way to do these????
static char* copyUniString(const wxChar *s)
static char* wxPyCopyCString(const char* src) // we need a char version too
{
if (s == NULL) s = wxT("");
wxString tmpStr = wxString(s);
char *news = new char[tmpStr.Len()+1];
for (unsigned int i=0; i<tmpStr.Len(); i++)
news[i] = tmpStr[i];
news[i] = '\0';
return news;
}
static char* copyCString(const char *s)
{
if (s == NULL) s = "";
int len = strlen(s);
char *news = new char[len+1];
memcpy(news, s, len+1);
return news;
}
static wxChar* wCharFromCStr(const char *s)
{
if (s == NULL) s = "";
size_t len = strlen(s) + 1;
wxChar *news = new wxChar[len];
for (size_t i=0; i<len; i++) {
news[i] = (wxChar)s[i];
}
return news;
size_t len = strlen(src);
char* dest = new char[len+1];
strcpy(dest, src);
return dest;
}
#endif
static wxChar* wxPyCopyWString(const char *src)
{
//wxMB2WXbuf buff = wxConvCurrent->cMB2WX(src);
wxString str(src, *wxConvCurrent);
return copystring(str);
}
#if wxUSE_UNICODE
static wxChar* wxPyCopyWString(const wxChar *src)
{
return copystring(src);
}
#endif
//----------------------------------------------------------------------
// This is where we pick up the first part of the wxEntry functionality...
// The rest is in __wxStart and __wxCleanup. This function is called when
// wxcmodule is imported. (Before there is a wxApp object.)
@@ -193,12 +196,10 @@ void __wxPreStart()
PyObject *item = PyList_GetItem(sysargv, x);
#if wxUSE_UNICODE
if (PyUnicode_Check(item))
argv[x] = copyUniString(PyUnicode_AS_UNICODE(item));
else
argv[x] = copyCString(PyString_AsString(item));
#else
argv[x] = copystring(PyString_AsString(item));
argv[x] = wxPyCopyCString(PyUnicode_AS_UNICODE(item));
else
#endif
argv[x] = wxPyCopyCString(PyString_AsString(item));
}
argv[argc] = NULL;
}
@@ -238,15 +239,11 @@ PyObject* __wxStart(PyObject* /* self */, PyObject* args)
for(x=0; x<argc; x++) {
PyObject *pyArg = PyList_GetItem(sysargv, x);
#if wxUSE_UNICODE
if (PyUnicode_Check(pyArg)) {
argv[x] = copystring(PyUnicode_AS_UNICODE(pyArg));
} else {
assert(PyString_Check(pyArg));
argv[x] = wCharFromCStr(PyString_AsString(pyArg));
}
#else
argv[x] = copystring(PyString_AsString(pyArg));
if (PyUnicode_Check(pyArg))
argv[x] = wxPyCopyWString(PyUnicode_AS_UNICODE(pyArg));
else
#endif
argv[x] = wxPyCopyWString(PyString_AsString(pyArg));
}
argv[argc] = NULL;
}
@@ -333,7 +330,6 @@ PyObject* __wxSetDictionary(PyObject* /* self */, PyObject* args)
PyDict_SetItemString(wxPython_dict, "wxPlatform", PyString_FromString(wxPlatform));
PyDict_SetItemString(wxPython_dict, "wxUSE_UNICODE", PyInt_FromLong(wxUSE_UNICODE));
Py_INCREF(Py_None);
return Py_None;
}
@@ -358,42 +354,20 @@ void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName) {
PyObject* wxPyClassExists(const char* className) {
PyObject* wxPyClassExists(const wxString& className) {
if (!className)
return NULL;
char buff[64]; // should always be big enough...
sprintf(buff, "%sPtr", className);
sprintf(buff, "%sPtr", className.mbc_str());
PyObject* classobj = PyDict_GetItemString(wxPython_dict, buff);
return classobj; // returns NULL if not found
}
#if wxUSE_UNICODE
void unicodeToChar(const wxString *src, char *dest)
{
for (unsigned int i=0; i<src->Len(); i++) {
dest[i] = (char)(*src)[i];
}
dest[i] = '\0';
}
PyObject* wxPyClassExistsUnicode(const wxString *className) {
if (!className->Len())
return NULL;
char buff[64]; // should always be big enough...
char *nameBuf = new char[className->Len()+1];
unicodeToChar(className, nameBuf);
sprintf(buff, "%sPtr", nameBuf);
PyObject* classobj = PyDict_GetItemString(wxPython_dict, buff);
delete [] nameBuf;
return classobj; // returns NULL if not found
}
#endif
PyObject* wxPyMake_wxObject(wxObject* source, bool checkEvtHandler) {
PyObject* target = NULL;
bool isEvtHandler = FALSE;
@@ -412,7 +386,6 @@ PyObject* wxPyMake_wxObject(wxObject* source, bool checkEvtHandler) {
}
}
// TODO: unicode fix
if (! target) {
// Otherwise make it the old fashioned way by making a
// new shadow object and putting this pointer in it.
@@ -431,7 +404,7 @@ PyObject* wxPyMake_wxObject(wxObject* source, bool checkEvtHandler) {
} else {
wxString msg("wxPython class not found for ");
msg += source->GetClassInfo()->GetClassName();
PyErr_SetString(PyExc_NameError, msg.c_str());
PyErr_SetString(PyExc_NameError, msg.mbc_str());
target = NULL;
}
}
@@ -469,20 +442,21 @@ PyObject* wxPyMake_wxSizer(wxSizer* source) {
//---------------------------------------------------------------------------
PyObject* wxPyConstructObject(void* ptr,
const char* className,
const wxString& className,
PyObject* klass,
int setThisOwn) {
PyObject* obj;
PyObject* arg;
PyObject* item;
wxString name(className);
char swigptr[64]; // should always be big enough...
char buff[64];
if ((item = PyDict_GetItemString(wxPyPtrTypeMap, (char*)className)) != NULL) {
className = PyString_AsString(item);
if ((item = PyDict_GetItemString(wxPyPtrTypeMap, (char*)(const char*)name.mbc_str())) != NULL) {
name = wxString(PyString_AsString(item), *wxConvCurrent);
}
sprintf(buff, "_%s_p", className);
sprintf(buff, "_%s_p", (const char*)name.mbc_str());
SWIG_MakePtr(swigptr, ptr, buff);
arg = Py_BuildValue("(s)", swigptr);
@@ -500,7 +474,7 @@ PyObject* wxPyConstructObject(void* ptr,
PyObject* wxPyConstructObject(void* ptr,
const char* className,
const wxString& className,
int setThisOwn) {
PyObject* obj;
@@ -510,9 +484,9 @@ PyObject* wxPyConstructObject(void* ptr,
}
char buff[64]; // should always be big enough...
sprintf(buff, "%sPtr", className);
sprintf(buff, "%sPtr", (const char*)className.mbc_str());
wxASSERT_MSG(wxPython_dict, "wxPython_dict is not set yet!!");
wxASSERT_MSG(wxPython_dict, wxT("wxPython_dict is not set yet!!"));
PyObject* classobj = PyDict_GetItemString(wxPython_dict, buff);
if (! classobj) {
@@ -527,6 +501,7 @@ PyObject* wxPyConstructObject(void* ptr,
return wxPyConstructObject(ptr, className, classobj, setThisOwn);
}
//---------------------------------------------------------------------------
@@ -554,7 +529,7 @@ PyThreadState* wxPyGetThreadState() {
}
}
wxPyTMutex->Unlock();
wxASSERT_MSG(tstate, "PyThreadState should not be NULL!");
wxASSERT_MSG(tstate, wxT("PyThreadState should not be NULL!"));
return tstate;
}
@@ -625,16 +600,13 @@ void wxPyEndBlockThreads() {
//---------------------------------------------------------------------------
// wxPyInputStream and wxPyCBInputStream methods
#include <wx/listimpl.cpp>
WX_DEFINE_LIST(wxStringPtrList);
void wxPyInputStream::close() {
/* do nothing */
/* do nothing for now */
}
void wxPyInputStream::flush() {
/* do nothing */
/* do nothing for now */
}
bool wxPyInputStream::eof() {
@@ -648,8 +620,12 @@ wxPyInputStream::~wxPyInputStream() {
/* do nothing */
}
wxString* wxPyInputStream::read(int size) {
wxString* s = NULL;
PyObject* wxPyInputStream::read(int size) {
PyObject* obj = NULL;
wxMemoryBuffer buf;
const int BUFSIZE = 1024;
// check if we have a real wxInputStream to work with
@@ -659,88 +635,62 @@ wxString* wxPyInputStream::read(int size) {
}
if (size < 0) {
// init buffers
char * buf = new char[BUFSIZE];
if (!buf) {
PyErr_NoMemory();
return NULL;
}
s = new wxString();
if (!s) {
delete buf;
PyErr_NoMemory();
return NULL;
}
// read until EOF
while (! m_wxis->Eof()) {
m_wxis->Read(buf, BUFSIZE);
s->Append(buf, m_wxis->LastRead());
}
delete buf;
// error check
if (m_wxis->LastError() == wxSTREAM_READ_ERROR) {
delete s;
PyErr_SetString(PyExc_IOError,"IOError in wxInputStream");
return NULL;
m_wxis->Read(buf.GetAppendBuf(BUFSIZE), BUFSIZE);
buf.UngetAppendBuf(m_wxis->LastRead());
}
} else { // Read only size number of characters
s = new wxString;
if (!s) {
PyErr_NoMemory();
return NULL;
}
// read size bytes
m_wxis->Read(s->GetWriteBuf(size+1), size);
s->UngetWriteBuf(m_wxis->LastRead());
// error check
if (m_wxis->LastError() == wxSTREAM_READ_ERROR) {
delete s;
PyErr_SetString(PyExc_IOError,"IOError in wxInputStream");
return NULL;
}
m_wxis->Read(buf.GetWriteBuf(size), size);
buf.UngetWriteBuf(m_wxis->LastRead());
}
return s;
// error check
if (m_wxis->LastError() == wxSTREAM_READ_ERROR) {
PyErr_SetString(PyExc_IOError,"IOError in wxInputStream");
}
else {
// We use only strings for the streams, not unicode
obj = PyString_FromStringAndSize(buf, buf.GetDataLen());
}
return obj;
}
wxString* wxPyInputStream::readline (int size) {
PyObject* wxPyInputStream::readline(int size) {
PyObject* obj = NULL;
wxMemoryBuffer buf;
int i;
char ch;
// check if we have a real wxInputStream to work with
if (!m_wxis) {
PyErr_SetString(PyExc_IOError,"no valid C-wxInputStream");
return NULL;
}
// init buffer
int i;
char ch;
wxString* s = new wxString;
if (!s) {
PyErr_NoMemory();
return NULL;
}
// read until \n or byte limit reached
for (i=ch=0; (ch != '\n') && (!m_wxis->Eof()) && ((size < 0) || (i < size)); i++) {
*s += ch = m_wxis->GetC();
ch = m_wxis->GetC();
buf.AppendByte(ch);
}
// errorcheck
if (m_wxis->LastError() == wxSTREAM_READ_ERROR) {
delete s;
PyErr_SetString(PyExc_IOError,"IOError in wxInputStream");
return NULL;
}
return s;
else {
// We use only strings for the streams, not unicode
obj = PyString_FromStringAndSize((char*)buf.GetData(), buf.GetDataLen());
}
return obj;
}
wxStringPtrList* wxPyInputStream::readlines (int sizehint) {
PyObject* wxPyInputStream::readlines(int sizehint) {
PyObject* pylist;
// check if we have a real wxInputStream to work with
if (!m_wxis) {
PyErr_SetString(PyExc_IOError,"no valid C-wxInputStream below");
@@ -748,8 +698,8 @@ wxStringPtrList* wxPyInputStream::readlines (int sizehint) {
}
// init list
wxStringPtrList* l = new wxStringPtrList();
if (!l) {
pylist = PyList_New(0);
if (!pylist) {
PyErr_NoMemory();
return NULL;
}
@@ -757,24 +707,23 @@ wxStringPtrList* wxPyInputStream::readlines (int sizehint) {
// read sizehint bytes or until EOF
int i;
for (i=0; (!m_wxis->Eof()) && ((sizehint < 0) || (i < sizehint));) {
wxString* s = readline();
PyObject* s = this->readline();
if (s == NULL) {
l->DeleteContents(TRUE);
l->Clear();
Py_DECREF(pylist);
return NULL;
}
l->Append(s);
i = i + s->Length();
PyList_Append(pylist, s);
i += PyString_Size(s);
}
// error check
if (m_wxis->LastError() == wxSTREAM_READ_ERROR) {
l->DeleteContents(TRUE);
l->Clear();
Py_DECREF(pylist);
PyErr_SetString(PyExc_IOError,"IOError in wxInputStream");
return NULL;
}
return l;
return pylist;
}
@@ -861,13 +810,13 @@ size_t wxPyCBInputStream::OnSysRead(void *buffer, size_t bufsize) {
Py_DECREF(arglist);
size_t o = 0;
if ((result != NULL) && PyString_Check(result)) { // TODO: unicode?
if ((result != NULL) && PyString_Check(result)) {
o = PyString_Size(result);
if (o == 0)
m_lasterror = wxSTREAM_EOF;
if (o > bufsize)
o = bufsize;
memcpy((char*)buffer, PyString_AsString(result), o);
memcpy((char*)buffer, PyString_AsString(result), o); // strings only, not unicode...
Py_DECREF(result);
}
@@ -946,16 +895,7 @@ void wxPyCallback::EventThunker(wxEvent& event) {
else if (className == "wxPyCommandEvent")
arg = ((wxPyCommandEvent*)&event)->GetSelf();
else {
// TODO: get rid of this ifdef by changing wxPyConstructObject to take a wxString
#if wxUSE_UNICODE
char *classNameAsChrStr = new char[className.Len()+1];
unicodeToChar(&className, classNameAsChrStr);
arg = wxPyConstructObject((void*)&event, classNameAsChrStr);
delete [] classNameAsChrStr;
#else
arg = wxPyConstructObject((void*)&event, className);
#endif
arg = wxPyConstructObject((void*)&event, className);
}
tuple = PyTuple_New(1);
@@ -1340,10 +1280,10 @@ wxString* wxString_in_helper(PyObject* source) {
if (PyUnicode_Check(source)) {
target = new wxString(PyUnicode_AS_UNICODE(source));
} else {
// It is a string, transform to unicode
PyObject *tempUniStr = PyObject_Unicode(source);
target = new wxString(PyUnicode_AS_UNICODE(tempUniStr));
Py_DECREF(tempUniStr);
// It is a string, get pointers to it and transform to unicode
char* tmpPtr; int tmpSize;
PyString_AsStringAndSize(source, &tmpPtr, &tmpSize);
target = new wxString(tmpPtr, *wxConvCurrent, tmpSize);
}
#else
char* tmpPtr; int tmpSize;
@@ -1365,6 +1305,64 @@ wxString* wxString_in_helper(PyObject* source) {
}
// Similar to above except doesn't use "new" and doesn't set an exception
wxString Py2wxString(PyObject* source)
{
wxString target;
bool doDecRef = FALSE;
#if PYTHON_API_VERSION >= 1009 // Have Python unicode API
if (!PyString_Check(source) && !PyUnicode_Check(source)) {
// Convert to String if not one already... (TODO: Unicode too?)
source = PyObject_Str(source);
doDecRef = TRUE;
}
#if wxUSE_UNICODE
if (PyUnicode_Check(source)) {
target = PyUnicode_AS_UNICODE(source);
} else {
// It is a string, get pointers to it and transform to unicode
char* tmpPtr; int tmpSize;
PyString_AsStringAndSize(source, &tmpPtr, &tmpSize);
target = wxString(tmpPtr, *wxConvCurrent, tmpSize);
}
#else
char* tmpPtr; int tmpSize;
PyString_AsStringAndSize(source, &tmpPtr, &tmpSize);
target = wxString(tmpPtr, tmpSize);
#endif // wxUSE_UNICODE
#else // No Python unicode API (1.5.2)
if (!PyString_Check(source)) {
// Convert to String if not one already...
source = PyObject_Str(source);
doDecRef = TRUE;
}
target = wxString(PyString_AS_STRING(source), PyString_GET_SIZE(source));
#endif
if (doDecRef)
Py_DECREF(source);
return target;
}
// Make either a Python String or Unicode object, depending on build mode
PyObject* wx2PyString(const wxString& src)
{
PyObject* str;
#if wxUSE_UNICODE
str = PyUnicode_FromUnicode(src.c_str(), src.Len());
#else
str = PyString_FromStringAndSize(src.c_str(), src.Len());
#endif
return str;
}
//----------------------------------------------------------------------
byte* byte_LIST_helper(PyObject* source) {
if (!PyList_Check(source)) {
@@ -1618,25 +1616,16 @@ wxString* wxString_LIST_helper(PyObject* source) {
PyErr_SetString(PyExc_TypeError, "Expected a list of string or unicode objects.");
return NULL;
}
char* buff;
int length;
if (PyString_AsStringAndSize(o, &buff, &length) == -1)
return NULL;
#if wxUSE_UNICODE // TODO: unicode fix. this is wrong!
wxChar *uniBuff = wCharFromCStr(buff);
temp[x] = wxString(uniBuff, length);
delete [] uniBuff;
#else
temp[x] = wxString(buff, length);
#endif //wxUSE_UNICODE
#else
if (! PyString_Check(o)) {
PyErr_SetString(PyExc_TypeError, "Expected a list of strings.");
return NULL;
}
temp[x] = PyString_AsString(o);
#endif
wxString* pStr = wxString_in_helper(o);
temp[x] = *pStr;
delete pStr;
}
return temp;
}
@@ -1895,25 +1884,15 @@ bool wxColour_helper(PyObject* source, wxColour** obj) {
}
// otherwise a string is expected
else if (PyString_Check(source)) {
wxString spec = PyString_AS_STRING(source);
if (spec[0U] == '#' && spec.Length() == 7) { // It's #RRGGBB
char* junk;
#if wxUSE_UNICODE // TODO: unicode fix.
// This ifdef can be removed by using wxString methods to
// convert to long instead of strtol
char *tmpAsChar = new char[spec.Len()+1];
unicodeToChar(&spec.Mid(1,2), tmpAsChar);
int red = strtol(tmpAsChar, &junk, 16);
unicodeToChar(&spec.Mid(3,2), tmpAsChar);
int green = strtol(tmpAsChar, &junk, 16);
unicodeToChar(&spec.Mid(5,2), tmpAsChar);
int blue = strtol(tmpAsChar, &junk, 16);
delete [] tmpAsChar;
#else
int red = strtol(spec.Mid(1,2), &junk, 16);
int green = strtol(spec.Mid(3,2), &junk, 16);
int blue = strtol(spec.Mid(5,2), &junk, 16);
#endif
wxString spec(PyString_AS_STRING(source), *wxConvCurrent);
if (spec.GetChar(0) == '#' && spec.Length() == 7) { // It's #RRGGBB
long red, green, blue;
red = green = blue = 0;
spec.Mid(1,2).ToLong(&red, 16);
spec.Mid(3,2).ToLong(&green, 16);
spec.Mid(5,2).ToLong(&blue, 16);
**obj = wxColour(red, green, blue);
return TRUE;
}
@@ -1924,7 +1903,9 @@ bool wxColour_helper(PyObject* source, wxColour** obj) {
}
error:
PyErr_SetString(PyExc_TypeError, "Expected a wxColour object or a string containing a colour name or '#RRGGBB'.");
PyErr_SetString(PyExc_TypeError,
"Expected a wxColour object or a string containing a colour "
"name or '#RRGGBB'.");
return FALSE;
}

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); \
}

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 {

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);

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();

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();
}

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 {

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 }
};

View File

@@ -993,6 +993,10 @@ class wxFileHistory(wxFileHistoryPtr):
wxFileSelector = misc2c.wxFileSelector
wxLoadFileSelector = misc2c.wxLoadFileSelector
wxSaveFileSelector = misc2c.wxSaveFileSelector
wxGetTextFromUser = misc2c.wxGetTextFromUser
wxGetPasswordFromUser = misc2c.wxGetPasswordFromUser

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;
}

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 },

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

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,

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();

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);
}
}
};

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();

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,

View File

@@ -209,7 +209,7 @@ class wxpTagHandler(wxHtmlWinTagHandler):
except:
pass
self.ctx.kwargs[name] = value
self.ctx.kwargs[str(name)] = value
return false