Updated XRCed from Roman Rolinsky
+UNICODE!
+
+
2.3.2.1
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):
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!")
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())
# 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)
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:
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
# 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,
# 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
#----------------------------------------------------------------------
if __name__ == "__main__":
print text
+
def opj(*args):
path = apply(os.path.join, args)
return os.path.normpath(path)
+
def libFlag():
if FINAL:
rv = ''
rv = 'h'
else:
rv = 'd'
- if USE_UNICODE:
+ if UNICODE:
rv = 'u' + rv
return rv
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:
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'
#'-docstring', '-Sbefore',
'-I./src', '-D'+WXPLAT,
]
-if USE_UNICODE:
+if UNICODE:
swig_args.append('-DwxUSE_UNICODE')
swig_deps = ['src/my_typemaps.i']
ext_package = PKGDIR,
ext_modules = wxpExtensions,
+ options = { 'build' : { 'build_base' : BUILD_BASE }}
+
##data_files = TOOLS,
)
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 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 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 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 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))
+#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 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 Py2wxString(a) (wxPyCoreAPIPtr->p_Py2wxString(a))
+#define wx2PyString(a) (wxPyCoreAPIPtr->p_wx2PyString(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 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 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())
//----------------------------------------------------------------------
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();
}
-// 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; \
}
-// 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; \
}
-// 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; \
}
-// 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); \
} \
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; \
#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); \
} \
#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); \
} \
#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); \
} \
#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); \
} \
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();
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();
}
//---------------------------------------------------------------------
//----------------------------------------------------------------------
+
+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;
+ size_t len = strlen(src);
+ char* dest = new char[len+1];
+ strcpy(dest, src);
+ return dest;
}
+#endif
-static char* copyCString(const char *s)
+static wxChar* wxPyCopyWString(const char *src)
{
- if (s == NULL) s = "";
- int len = strlen(s);
- char *news = new char[len+1];
- memcpy(news, s, len+1);
- return news;
+ //wxMB2WXbuf buff = wxConvCurrent->cMB2WX(src);
+ wxString str(src, *wxConvCurrent);
+ return copystring(str);
}
-static wxChar* wCharFromCStr(const char *s)
+#if wxUSE_UNICODE
+static wxChar* wxPyCopyWString(const wxChar *src)
{
- 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;
+ 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.)
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;
}
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;
}
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;
}
-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;
}
}
- // TODO: unicode fix
if (! target) {
// Otherwise make it the old fashioned way by making a
// new shadow object and putting this pointer in it.
} 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;
}
}
//---------------------------------------------------------------------------
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);
PyObject* wxPyConstructObject(void* ptr,
- const char* className,
+ const wxString& className,
int setThisOwn) {
PyObject* obj;
}
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) {
return wxPyConstructObject(ptr, className, classobj, setThisOwn);
}
+
//---------------------------------------------------------------------------
}
}
wxPyTMutex->Unlock();
- wxASSERT_MSG(tstate, "PyThreadState should not be NULL!");
+ wxASSERT_MSG(tstate, wxT("PyThreadState should not be NULL!"));
return tstate;
}
//---------------------------------------------------------------------------
// 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() {
/* 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
}
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());
+ m_wxis->Read(buf.GetWriteBuf(size), size);
+ buf.UngetWriteBuf(m_wxis->LastRead());
+ }
- // error check
- if (m_wxis->LastError() == wxSTREAM_READ_ERROR) {
- delete s;
- PyErr_SetString(PyExc_IOError,"IOError in wxInputStream");
- return NULL;
- }
+ // 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 s;
+ 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");
}
// init list
- wxStringPtrList* l = new wxStringPtrList();
- if (!l) {
+ pylist = PyList_New(0);
+ if (!pylist) {
PyErr_NoMemory();
return NULL;
}
// 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;
}
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);
}
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);
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;
}
+// 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)) {
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;
}
}
// 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;
}
}
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;
}
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);
//----------------------------------------------------------------------
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);
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);
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); \
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); \
#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; \
} \
#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; \
} \
#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; \
} \
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; \
wxString CBNAME(); \
wxString base_##CBNAME();
-// TODO: unicode fix
#define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
wxString CLASS::CBNAME() { \
wxString rval; \
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; \
#define DEC_PYCALLBACK_STRING__pure(CBNAME) \
wxString CBNAME();
-// TODO: unicode fix
#define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
wxString CLASS::CBNAME() { \
wxString rval; \
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; \
}
#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(); \
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); \
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; \
#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; \
} \
#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; \
} \
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; \
wxDataFormat CLASS::CBNAME(size_t a) { \
wxDataFormat rval=0; \
bool found; \
- wxPyBeginBlockThreads(); \
+ wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* ro; \
wxDataFormat* ptr; \
Py_DECREF(ro); \
} \
} \
- wxPyEndBlockThreads(); \
+ wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(a); \
return rval; \
#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); \
} \
#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); \
} \
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; \
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; \
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)); \
Py_DECREF(ro); \
} \
} \
- wxPyEndBlockThreads(); \
+ wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(a); \
return rval; \
wxListItemAttr *CLASS::CBNAME(long a) const { \
wxListItemAttr *rval = NULL; \
bool found; \
- wxPyBeginBlockThreads(); \
+ wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* ro; \
wxListItemAttr* ptr; \
Py_DECREF(ro); \
} \
} \
- wxPyEndBlockThreads(); \
+ wxPyEndBlockThreads(); \
if (! found) \
rval = PCLASS::CBNAME(a); \
return rval; \
//---------------------------------------------------------------------------
-#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); \
}
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 {
//---------------------------------------------------------------------------
// Dialog Functions
-#ifdef wxUSE_UNICODE
wxString wxFileSelector(const wxChar* message = wxFileSelectorPromptStr,
const wxChar* default_path = NULL,
const wxChar* default_filename = NULL,
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,
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);
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);
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();
}
-// 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; \
}
-// 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; \
}
-// 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; \
}
-// 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); \
} \
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; \
#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); \
} \
#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); \
} \
#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); \
} \
#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); \
} \
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();
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();
}
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 {
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);
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);
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;
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;
{ "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 }
};
wxFileSelector = misc2c.wxFileSelector
+wxLoadFileSelector = misc2c.wxLoadFileSelector
+
+wxSaveFileSelector = misc2c.wxSaveFileSelector
+
wxGetTextFromUser = misc2c.wxGetTextFromUser
wxGetPasswordFromUser = misc2c.wxGetPasswordFromUser
#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;
}
{
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;
}
#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;
}
{
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;
}
#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;
}
{
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;
}
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))
}
}
{
- _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;
}
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; }
return NULL;
}
}
+ _arg2 = (bool ) tempbool2;
{
PyThreadState* __tstate = wxPyBeginAllowThreads();
- wxWindow_SetSizer(_arg0,_arg1);
+ wxWindow_SetSizer(_arg0,_arg1,_arg2);
wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) return NULL;
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;
{ "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 },
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
wxPy_ConvertList,
wxString_in_helper,
+ Py2wxString,
+ wx2PyString,
+
byte_LIST_helper,
int_LIST_helper,
long_LIST_helper,
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();
//----------------------------------------------------------------------
-// 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;
+// }
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();
*/
%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);
}
}
};
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
#endif
wxSize GetBestSize();
+ wxSize GetMaxSize();
void SetCaret(wxCaret *caret);
wxCaret *GetCaret();
wxPy_ConvertList,
wxString_in_helper,
+ Py2wxString,
+ wx2PyString,
+
byte_LIST_helper,
int_LIST_helper,
long_LIST_helper,
except:
pass
- self.ctx.kwargs[name] = value
+ self.ctx.kwargs[str(name)] = value
return false