Minimal changes needed to build/run wxPython on the 2.5 branch after

the merge.  Still need to look for and apply most changes and new
additions that have happened since the last merge.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22072 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-07-18 02:26:53 +00:00
parent fd657b8a59
commit dd116e73f0
22 changed files with 1923 additions and 197 deletions

View File

@@ -28,6 +28,9 @@
#include <wx/gtk/win_gtk.h>
#endif
#include <wx/clipbrd.h>
#include <wx/mimetype.h>
//----------------------------------------------------------------------
#if PYTHON_API_VERSION <= 1007 && wxUSE_UNICODE
@@ -36,14 +39,6 @@
//----------------------------------------------------------------------
#ifdef __WXGTK__
int WXDLLEXPORT wxEntryStart( int& argc, char** argv );
#else
int WXDLLEXPORT wxEntryStart( int argc, char** argv );
#endif
int WXDLLEXPORT wxEntryInitGui();
void WXDLLEXPORT wxEntryCleanup();
wxPyApp* wxPythonApp = NULL; // Global instance of application object
bool wxPyDoCleanup = FALSE;
bool wxPyDoingCleanup = FALSE;
@@ -334,6 +329,7 @@ void wxPyApp::SetMacHelpMenuTitleName(const wxString& val) {
//----------------------------------------------------------------------
#if 0
static char* wxPyCopyCString(const wxChar* src)
{
wxWX2MBbuf buff = (wxWX2MBbuf)wxConvCurrent->cWX2MB(src);
@@ -366,13 +362,13 @@ static wxChar* wxPyCopyWString(const wxChar *src)
return copystring(src);
}
#endif
#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.)
// This function is called when the wxc module is imported to do some initial
// setup. (Before there is a wxApp object.)
void __wxPreStart(PyObject* moduleDict)
{
@@ -386,25 +382,32 @@ void __wxPreStart(PyObject* moduleDict)
wxPyTMutex = new wxMutex;
#endif
// Restore default signal handlers, (prevents crash upon Ctrl-C in the
// console that launched a wxPython app...)
PyOS_FiniInterrupts();
// Ensure that the build options in the DLL (or whatever) match this build
wxApp::CheckBuildOptions(wxBuildOptions());
// Create an exception object to use for wxASSERTions
wxPyAssertionError = PyErr_NewException("wxPython.wxc.wxPyAssertionError",
PyExc_AssertionError, NULL);
PyDict_SetItemString(moduleDict, "wxPyAssertionError", wxPyAssertionError);
}
// Bail out if there is already a wxApp created. This means that the
// toolkit has already been initialized, as in embedding wxPython in
// a C++ wxWindows app, so we don't need to call wxEntryStart.
if (wxTheApp != NULL) {
return;
}
wxPyDoCleanup = TRUE;
// Initialize wxWindows and bootstrap the user application by calling the
// wxApp's OnInit, which is a parameter to this funciton. See wxApp.__init__
// in _extras.py to learn how the bootstrap is started.
PyObject* __wxStart(PyObject* /* self */, PyObject* args)
{
PyObject* onInitFunc = NULL;
PyObject* arglist= NULL;
PyObject* result = NULL;
PyObject* pyint = NULL;
long bResult;
if (!PyArg_ParseTuple(args, "O", &onInitFunc))
return NULL;
// Get any command-line args passed to this program from the sys module
int argc = 0;
char** argv = NULL;
PyObject* sysargv = PySys_GetObject("argv");
@@ -412,50 +415,27 @@ void __wxPreStart(PyObject* moduleDict)
argc = PyList_Size(sysargv);
argv = new char*[argc+1];
int x;
for(x=0; x<argc; x++) {
PyObject *item = PyList_GetItem(sysargv, x);
argv[x] = wxPyCopyCString(Py2wxString(item));
}
argv[argc] = NULL;
}
wxEntryStart(argc, argv);
delete [] argv;
}
// Start the user application, user App's OnInit method is a parameter here
PyObject* __wxStart(PyObject* /* self */, PyObject* args)
{
PyObject* onInitFunc = NULL;
PyObject* arglist;
PyObject* result;
long bResult;
if (!PyArg_ParseTuple(args, "O", &onInitFunc))
return NULL;
// This is the next part of the wxEntry functionality...
int argc = 0;
wxChar** argv = NULL;
PyObject* sysargv = PySys_GetObject("argv");
if (sysargv != NULL) {
argc = PyList_Size(sysargv);
argv = new wxChar*[argc+1];
int x;
for(x=0; x<argc; x++) {
PyObject *pyArg = PyList_GetItem(sysargv, x);
argv[x] = wxPyCopyWString(Py2wxString(pyArg));
argv[x] = PyString_AsString(pyArg);
}
argv[argc] = NULL;
}
wxPythonApp->argc = argc;
wxPythonApp->argv = argv;
if (! wxEntryStart(argc, argv) ) {
PyErr_SetString(PyExc_SystemError, // is this the right one?
"wxEntryStart failed!");
goto error;
}
delete [] argv;
wxEntryInitGui();
// Call the Python App's OnInit function
// The stock objects were all NULL when they were loaded into
// SWIG generated proxies, so re-init those now...
wxPy_ReinitStockObjects();
// Call the Python wxApp's OnInit function
arglist = PyTuple_New(0);
result = PyEval_CallObject(onInitFunc, arglist);
Py_DECREF(arglist);
@@ -463,7 +443,7 @@ PyObject* __wxStart(PyObject* /* self */, PyObject* args)
return NULL;
}
PyObject* pyint = PyNumber_Int(result);
pyint = PyNumber_Int(result);
if (! pyint) {
PyErr_SetString(PyExc_TypeError, "OnInit should return a boolean value");
goto error;
@@ -490,6 +470,7 @@ PyObject* __wxStart(PyObject* /* self */, PyObject* args)
}
void __wxCleanup() {
wxPyDoingCleanup = TRUE;
if (wxPyDoCleanup)
@@ -552,6 +533,102 @@ PyObject* __wxSetDictionary(PyObject* /* self */, PyObject* args)
return Py_None;
}
//---------------------------------------------------------------------------
// The stock objects are no longer created when the wxc module is imported, but
// only after the app object has been created. This function will be called before
// OnInit is called so we can hack the new pointer values into the obj.this attributes.
void wxPy_ReinitStockObjects()
{
char ptrbuf[128];
PyObject* obj;
PyObject* ptrobj;
#define REINITOBJ(name, type) \
obj = PyDict_GetItemString(wxPython_dict, #name); \
wxASSERT_MSG(obj != NULL, wxT("Unable to find stock object for " #name)); \
SWIG_MakePtr(ptrbuf, (char *) name, "_" #type "_p"); \
ptrobj = PyString_FromString(ptrbuf); \
PyObject_SetAttrString(obj, "this", ptrobj); \
Py_DECREF(ptrobj)
#define REINITOBJ2(name, type) \
obj = PyDict_GetItemString(wxPython_dict, #name); \
wxASSERT_MSG(obj != NULL, wxT("Unable to find stock object for " #name)); \
SWIG_MakePtr(ptrbuf, (char *) &name, "_" #type "_p"); \
ptrobj = PyString_FromString(ptrbuf); \
PyObject_SetAttrString(obj, "this", ptrobj); \
Py_DECREF(ptrobj)
REINITOBJ(wxNORMAL_FONT, wxFont);
REINITOBJ(wxSMALL_FONT, wxFont);
REINITOBJ(wxITALIC_FONT, wxFont);
REINITOBJ(wxSWISS_FONT, wxFont);
REINITOBJ(wxRED_PEN, wxPen);
REINITOBJ(wxCYAN_PEN, wxPen);
REINITOBJ(wxGREEN_PEN, wxPen);
REINITOBJ(wxBLACK_PEN, wxPen);
REINITOBJ(wxWHITE_PEN, wxPen);
REINITOBJ(wxTRANSPARENT_PEN, wxPen);
REINITOBJ(wxBLACK_DASHED_PEN, wxPen);
REINITOBJ(wxGREY_PEN, wxPen);
REINITOBJ(wxMEDIUM_GREY_PEN, wxPen);
REINITOBJ(wxLIGHT_GREY_PEN, wxPen);
REINITOBJ(wxBLUE_BRUSH, wxBrush);
REINITOBJ(wxGREEN_BRUSH, wxBrush);
REINITOBJ(wxWHITE_BRUSH, wxBrush);
REINITOBJ(wxBLACK_BRUSH, wxBrush);
REINITOBJ(wxTRANSPARENT_BRUSH, wxBrush);
REINITOBJ(wxCYAN_BRUSH, wxBrush);
REINITOBJ(wxRED_BRUSH, wxBrush);
REINITOBJ(wxGREY_BRUSH, wxBrush);
REINITOBJ(wxMEDIUM_GREY_BRUSH, wxBrush);
REINITOBJ(wxLIGHT_GREY_BRUSH, wxBrush);
REINITOBJ(wxBLACK, wxColour);
REINITOBJ(wxWHITE, wxColour);
REINITOBJ(wxRED, wxColour);
REINITOBJ(wxBLUE, wxColour);
REINITOBJ(wxGREEN, wxColour);
REINITOBJ(wxCYAN, wxColour);
REINITOBJ(wxLIGHT_GREY, wxColour);
REINITOBJ(wxSTANDARD_CURSOR, wxCursor);
REINITOBJ(wxHOURGLASS_CURSOR, wxCursor);
REINITOBJ(wxCROSS_CURSOR, wxCursor);
REINITOBJ2(wxNullBitmap, wxBitmap);
REINITOBJ2(wxNullIcon, wxIcon);
REINITOBJ2(wxNullCursor, wxCursor);
REINITOBJ2(wxNullPen, wxPen);
REINITOBJ2(wxNullBrush, wxBrush);
REINITOBJ2(wxNullPalette, wxPalette);
REINITOBJ2(wxNullFont, wxFont);
REINITOBJ2(wxNullColour, wxColour);
REINITOBJ(wxTheFontList, wxFontList);
REINITOBJ(wxThePenList, wxPenList);
REINITOBJ(wxTheBrushList, wxBrushList);
REINITOBJ(wxTheColourDatabase, wxColourDatabase);
REINITOBJ(wxTheClipboard, wxClipboard);
REINITOBJ(wxTheMimeTypesManager, wxMimeTypesManager);
REINITOBJ2(wxDefaultValidator, wxValidator);
REINITOBJ2(wxNullImage, wxImage);
REINITOBJ2(wxNullAcceleratorTable, wxAcceleratorTable);
#undef REINITOBJ
#undef REINITOBJ2
}
//---------------------------------------------------------------------------
void wxPyClientData_dtor(wxPyClientData* self) {