From 301dfd6748f54e3a6719fef85ca1f1b0787db884 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 10 Apr 2002 19:27:53 +0000 Subject: [PATCH] SWIGged updates for wxGTK git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15083 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/src/gtk/controls2.cpp | 2 +- wxPython/src/gtk/controls2.py | 2 +- wxPython/src/gtk/frames.py | 2 + wxPython/src/gtk/gdi.cpp | 29 ++++++++++++++ wxPython/src/gtk/gdi.py | 5 +++ wxPython/src/gtk/misc.cpp | 8 ++++ wxPython/src/gtk/misc2.cpp | 73 +++++++++++++++++++++++++++++++++- wxPython/src/gtk/misc2.py | 2 + wxPython/src/gtk/sizers.cpp | 2 +- wxPython/src/gtk/utils.cpp | 5 +-- wxPython/src/gtk/windows.cpp | 2 +- wxPython/src/gtk/wx.cpp | 7 +++- wxPython/src/gtk/wx.py | 37 +++++++++++++++-- 13 files changed, 163 insertions(+), 13 deletions(-) diff --git a/wxPython/src/gtk/controls2.cpp b/wxPython/src/gtk/controls2.cpp index 4054e0ff60..2f0b0f1b33 100644 --- a/wxPython/src/gtk/controls2.cpp +++ b/wxPython/src/gtk/controls2.cpp @@ -11183,7 +11183,7 @@ SWIGEXPORT(void) initcontrols2c() { PyDict_SetItemString(d,"wxDIRCTRL_SELECT_FIRST", PyInt_FromLong((long) wxDIRCTRL_SELECT_FIRST)); PyDict_SetItemString(d,"wxDIRCTRL_SHOW_FILTERS", PyInt_FromLong((long) wxDIRCTRL_SHOW_FILTERS)); PyDict_SetItemString(d,"wxDIRCTRL_3D_INTERNAL", PyInt_FromLong((long) wxDIRCTRL_3D_INTERNAL)); - PyDict_SetItemString(d,"wxDIRCTRL_EDITABLE", PyInt_FromLong((long) wxDIRCTRL_EDITABLE)); + PyDict_SetItemString(d,"wxDIRCTRL_EDIT_LABELS", PyInt_FromLong((long) wxDIRCTRL_EDIT_LABELS)); PyDict_SetItemString(d,"wxID_TREECTRL", PyInt_FromLong((long) wxID_TREECTRL)); PyDict_SetItemString(d,"wxID_FILTERLISTCTRL", PyInt_FromLong((long) wxID_FILTERLISTCTRL)); diff --git a/wxPython/src/gtk/controls2.py b/wxPython/src/gtk/controls2.py index dd7d2d4ffb..20795adaef 100644 --- a/wxPython/src/gtk/controls2.py +++ b/wxPython/src/gtk/controls2.py @@ -1415,6 +1415,6 @@ wxDIRCTRL_DIR_ONLY = controls2c.wxDIRCTRL_DIR_ONLY wxDIRCTRL_SELECT_FIRST = controls2c.wxDIRCTRL_SELECT_FIRST wxDIRCTRL_SHOW_FILTERS = controls2c.wxDIRCTRL_SHOW_FILTERS wxDIRCTRL_3D_INTERNAL = controls2c.wxDIRCTRL_3D_INTERNAL -wxDIRCTRL_EDITABLE = controls2c.wxDIRCTRL_EDITABLE +wxDIRCTRL_EDIT_LABELS = controls2c.wxDIRCTRL_EDIT_LABELS wxID_TREECTRL = controls2c.wxID_TREECTRL wxID_FILTERLISTCTRL = controls2c.wxID_FILTERLISTCTRL diff --git a/wxPython/src/gtk/frames.py b/wxPython/src/gtk/frames.py index 0e4465a5da..d2ac054f6a 100644 --- a/wxPython/src/gtk/frames.py +++ b/wxPython/src/gtk/frames.py @@ -234,6 +234,7 @@ class wxSplashScreenWindow(wxSplashScreenWindowPtr): def __init__(self,*_args,**_kwargs): self.this = apply(framesc.new_wxSplashScreenWindow,_args,_kwargs) self.thisown = 1 + self._setOORInfo(self) @@ -258,6 +259,7 @@ class wxSplashScreen(wxSplashScreenPtr): def __init__(self,*_args,**_kwargs): self.this = apply(framesc.new_wxSplashScreen,_args,_kwargs) self.thisown = 1 + self._setOORInfo(self) diff --git a/wxPython/src/gtk/gdi.cpp b/wxPython/src/gtk/gdi.cpp index 0402b0c83b..35417a80ba 100644 --- a/wxPython/src/gtk/gdi.cpp +++ b/wxPython/src/gtk/gdi.cpp @@ -7910,6 +7910,34 @@ static PyObject *_wrap_new_wxBufferedDCInternalBuffer(PyObject *self, PyObject * return _resultobj; } +#define wxBufferedDC_UnMask(_swigobj) (_swigobj->UnMask()) +static PyObject *_wrap_wxBufferedDC_UnMask(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxBufferedDC * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxBufferedDC_UnMask",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxBufferedDC_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxBufferedDC_UnMask. Expected _wxBufferedDC_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + wxBufferedDC_UnMask(_arg0); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + static void *SwigwxBufferedPaintDCTowxBufferedDC(void *ptr) { wxBufferedPaintDC *src; wxBufferedDC *dest; @@ -10082,6 +10110,7 @@ static PyMethodDef gdicMethods[] = { { "wxScreenDC_StartDrawingOnTopWin", (PyCFunction) _wrap_wxScreenDC_StartDrawingOnTopWin, METH_VARARGS | METH_KEYWORDS }, { "new_wxScreenDC", (PyCFunction) _wrap_new_wxScreenDC, METH_VARARGS | METH_KEYWORDS }, { "new_wxBufferedPaintDC", (PyCFunction) _wrap_new_wxBufferedPaintDC, METH_VARARGS | METH_KEYWORDS }, + { "wxBufferedDC_UnMask", (PyCFunction) _wrap_wxBufferedDC_UnMask, METH_VARARGS | METH_KEYWORDS }, { "new_wxBufferedDCInternalBuffer", (PyCFunction) _wrap_new_wxBufferedDCInternalBuffer, METH_VARARGS | METH_KEYWORDS }, { "new_wxBufferedDC", (PyCFunction) _wrap_new_wxBufferedDC, METH_VARARGS | METH_KEYWORDS }, { "wxMemoryDC_SelectObject", (PyCFunction) _wrap_wxMemoryDC_SelectObject, METH_VARARGS | METH_KEYWORDS }, diff --git a/wxPython/src/gtk/gdi.py b/wxPython/src/gtk/gdi.py index 957b775bd3..e4412749e4 100644 --- a/wxPython/src/gtk/gdi.py +++ b/wxPython/src/gtk/gdi.py @@ -789,18 +789,23 @@ class wxBufferedDCPtr(wxMemoryDCPtr): def __init__(self,this): self.this = this self.thisown = 0 + def UnMask(self, *_args, **_kwargs): + val = apply(gdic.wxBufferedDC_UnMask,(self,) + _args, _kwargs) + return val def __repr__(self): return "" % (self.this,) class wxBufferedDC(wxBufferedDCPtr): def __init__(self,*_args,**_kwargs): self.this = apply(gdic.new_wxBufferedDC,_args,_kwargs) self.thisown = 1 + self._dc = _args[0] # save a ref so the other dc won't be deleted before self def wxBufferedDCInternalBuffer(*_args,**_kwargs): val = wxBufferedDCPtr(apply(gdic.new_wxBufferedDCInternalBuffer,_args,_kwargs)) val.thisown = 1 + val._dc = _args[0] # save a ref so the other dc won't be deleted before self return val diff --git a/wxPython/src/gtk/misc.cpp b/wxPython/src/gtk/misc.cpp index 32a48df4cd..abe4cf77a9 100644 --- a/wxPython/src/gtk/misc.cpp +++ b/wxPython/src/gtk/misc.cpp @@ -1383,9 +1383,11 @@ static PyObject *_wrap_wxSize_SetHeight(PyObject *self, PyObject *args, PyObject } static PyObject * wxSize_asTuple(wxSize *self) { + wxPyBeginBlockThreads(); PyObject* tup = PyTuple_New(2); PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x)); PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y)); + wxPyEndBlockThreads(); return tup; } static PyObject *_wrap_wxSize_asTuple(PyObject *self, PyObject *args, PyObject *kwargs) { @@ -1653,9 +1655,11 @@ static PyObject *_wrap_wxRealPoint_Set(PyObject *self, PyObject *args, PyObject } static PyObject * wxRealPoint_asTuple(wxRealPoint *self) { + wxPyBeginBlockThreads(); PyObject* tup = PyTuple_New(2); PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x)); PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y)); + wxPyEndBlockThreads(); return tup; } static PyObject *_wrap_wxRealPoint_asTuple(PyObject *self, PyObject *args, PyObject *kwargs) { @@ -2003,9 +2007,11 @@ static PyObject *_wrap_wxPoint_Set(PyObject *self, PyObject *args, PyObject *kwa } static PyObject * wxPoint_asTuple(wxPoint *self) { + wxPyBeginBlockThreads(); PyObject* tup = PyTuple_New(2); PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x)); PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y)); + wxPyEndBlockThreads(); return tup; } static PyObject *_wrap_wxPoint_asTuple(PyObject *self, PyObject *args, PyObject *kwargs) { @@ -2989,11 +2995,13 @@ static PyObject *_wrap_wxRect_height_get(PyObject *self, PyObject *args, PyObjec } static PyObject * wxRect_asTuple(wxRect *self) { + wxPyBeginBlockThreads(); PyObject* tup = PyTuple_New(4); PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x)); PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y)); PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width)); PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height)); + wxPyEndBlockThreads(); return tup; } static PyObject *_wrap_wxRect_asTuple(PyObject *self, PyObject *args, PyObject *kwargs) { diff --git a/wxPython/src/gtk/misc2.cpp b/wxPython/src/gtk/misc2.cpp index a8ce121836..a47f87d338 100644 --- a/wxPython/src/gtk/misc2.cpp +++ b/wxPython/src/gtk/misc2.cpp @@ -103,7 +103,7 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) { // Put some wx default wxChar* values into wxStrings. DECLARE_DEF_STRING(FileSelectorPromptStr); DECLARE_DEF_STRING(FileSelectorDefaultWildcardStr); - + DECLARE_DEF_STRING(DirSelectorPromptStr); static const wxString wxPyEmptyString(wxT("")); int wxCaret_GetBlinkTime() { @@ -515,6 +515,76 @@ static PyObject *_wrap_wxSaveFileSelector(PyObject *self, PyObject *args, PyObje return _resultobj; } +static PyObject *_wrap_wxDirSelector(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxString * _result; + wxString * _arg0 = (wxString *) &wxPyDirSelectorPromptStr; + wxString * _arg1 = (wxString *) &wxPyEmptyString; + long _arg2 = (long ) wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxDD_NEW_DIR_BUTTON; + wxPoint * _arg3 = (wxPoint *) &wxDefaultPosition; + wxWindow * _arg4 = (wxWindow *) NULL; + PyObject * _obj0 = 0; + PyObject * _obj1 = 0; + wxPoint temp; + PyObject * _obj3 = 0; + PyObject * _argo4 = 0; + char *_kwnames[] = { "message","defaultPath","style","pos","parent", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"|OOlOO:wxDirSelector",_kwnames,&_obj0,&_obj1,&_arg2,&_obj3,&_argo4)) + return NULL; + if (_obj0) +{ + _arg0 = wxString_in_helper(_obj0); + if (_arg0 == NULL) + return NULL; +} + if (_obj1) +{ + _arg1 = wxString_in_helper(_obj1); + if (_arg1 == NULL) + return NULL; +} + if (_obj3) +{ + _arg3 = &temp; + if (! wxPoint_helper(_obj3, &_arg3)) + return NULL; +} + if (_argo4) { + if (_argo4 == Py_None) { _arg4 = NULL; } + else if (SWIG_GetPtrObj(_argo4,(void **) &_arg4,"_wxWindow_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 5 of wxDirSelector. Expected _wxWindow_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = new wxString (wxDirSelector(*_arg0,*_arg1,_arg2,*_arg3,_arg4)); + + 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 +} +{ + if (_obj0) + delete _arg0; +} +{ + if (_obj1) + delete _arg1; +} +{ + delete _result; +} + return _resultobj; +} + static PyObject *_wrap_wxGetTextFromUser(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; wxString * _result; @@ -9990,6 +10060,7 @@ 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 }, + { "wxDirSelector", (PyCFunction) _wrap_wxDirSelector, 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 }, diff --git a/wxPython/src/gtk/misc2.py b/wxPython/src/gtk/misc2.py index 6d76b60b3d..ed4dcf89ef 100644 --- a/wxPython/src/gtk/misc2.py +++ b/wxPython/src/gtk/misc2.py @@ -963,6 +963,8 @@ wxLoadFileSelector = misc2c.wxLoadFileSelector wxSaveFileSelector = misc2c.wxSaveFileSelector +wxDirSelector = misc2c.wxDirSelector + wxGetTextFromUser = misc2c.wxGetTextFromUser wxGetPasswordFromUser = misc2c.wxGetPasswordFromUser diff --git a/wxPython/src/gtk/sizers.cpp b/wxPython/src/gtk/sizers.cpp index 95e66e5394..14b85b2724 100644 --- a/wxPython/src/gtk/sizers.cpp +++ b/wxPython/src/gtk/sizers.cpp @@ -860,7 +860,7 @@ static void *SwigwxSizerTowxObject(void *ptr) { } static void wxSizer__setOORInfo(wxSizer *self,PyObject * _self) { - self->SetClientObject(new wxPyClientData(_self)); + self->SetClientObject(new wxPyOORClientData(_self)); } static PyObject *_wrap_wxSizer__setOORInfo(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; diff --git a/wxPython/src/gtk/utils.cpp b/wxPython/src/gtk/utils.cpp index 18b44d4935..847a5fd1ee 100644 --- a/wxPython/src/gtk/utils.cpp +++ b/wxPython/src/gtk/utils.cpp @@ -55,14 +55,13 @@ extern PyObject *SWIG_newvarlink(void); #define SWIG_name "utilsc" -#include "export.h" +#include "helpers.h" #include #include #include // Put some wx default wxChar* values into wxStrings. - static const wxChar* wxDateFormatStr = wxT("sashWindow"); - DECLARE_DEF_STRING(DateFormatStr); + DECLARE_DEF_STRING2(DateFormatStr, wxT("sashWindow")); static const wxString wxPyEmptyString(wxT("")); diff --git a/wxPython/src/gtk/windows.cpp b/wxPython/src/gtk/windows.cpp index 1ecd65a494..03076984e3 100644 --- a/wxPython/src/gtk/windows.cpp +++ b/wxPython/src/gtk/windows.cpp @@ -522,7 +522,7 @@ static PyObject *_wrap_wxEvtHandler_Disconnect(PyObject *self, PyObject *args, P } static void wxEvtHandler__setOORInfo(wxEvtHandler *self,PyObject * _self) { - self->SetClientObject(new wxPyClientData(_self)); + self->SetClientObject(new wxPyOORClientData(_self)); } static PyObject *_wrap_wxEvtHandler__setOORInfo(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; diff --git a/wxPython/src/gtk/wx.cpp b/wxPython/src/gtk/wx.cpp index 5ea08d388f..4548449654 100644 --- a/wxPython/src/gtk/wx.cpp +++ b/wxPython/src/gtk/wx.cpp @@ -677,7 +677,11 @@ static wxPyCoreAPI API = { wxPyMake_wxSizer, wxPyPtrTypeMap_Add, wxArrayString2PyList_helper, - wxArrayInt2PyList_helper + wxArrayInt2PyList_helper, + + wxPyClientData_dtor, + wxPyUserData_dtor, + wxPyOORClientData_dtor }; @@ -2064,6 +2068,7 @@ SWIGEXPORT(void) initwxc() { PyDict_SetItemString(d,"wxPD_ELAPSED_TIME", PyInt_FromLong((long) wxPD_ELAPSED_TIME)); PyDict_SetItemString(d,"wxPD_ESTIMATED_TIME", PyInt_FromLong((long) wxPD_ESTIMATED_TIME)); PyDict_SetItemString(d,"wxPD_REMAINING_TIME", PyInt_FromLong((long) wxPD_REMAINING_TIME)); + PyDict_SetItemString(d,"wxDD_NEW_DIR_BUTTON", PyInt_FromLong((long) wxDD_NEW_DIR_BUTTON)); PyDict_SetItemString(d,"wxMENU_TEAROFF", PyInt_FromLong((long) wxMENU_TEAROFF)); PyDict_SetItemString(d,"wxMB_DOCKABLE", PyInt_FromLong((long) wxMB_DOCKABLE)); PyDict_SetItemString(d,"wxNO_FULL_REPAINT_ON_RESIZE", PyInt_FromLong((long) wxNO_FULL_REPAINT_ON_RESIZE)); diff --git a/wxPython/src/gtk/wx.py b/wxPython/src/gtk/wx.py index e959bcb357..8b4caa410d 100644 --- a/wxPython/src/gtk/wx.py +++ b/wxPython/src/gtk/wx.py @@ -409,6 +409,7 @@ wxPD_CAN_ABORT = wxc.wxPD_CAN_ABORT wxPD_ELAPSED_TIME = wxc.wxPD_ELAPSED_TIME wxPD_ESTIMATED_TIME = wxc.wxPD_ESTIMATED_TIME wxPD_REMAINING_TIME = wxc.wxPD_REMAINING_TIME +wxDD_NEW_DIR_BUTTON = wxc.wxDD_NEW_DIR_BUTTON wxMENU_TEAROFF = wxc.wxMENU_TEAROFF wxMB_DOCKABLE = wxc.wxMB_DOCKABLE wxNO_FULL_REPAINT_ON_RESIZE = wxc.wxNO_FULL_REPAINT_ON_RESIZE @@ -1548,6 +1549,34 @@ def wxPyTypeCast(obj, typeStr): return theObj +#---------------------------------------------------------------------------- + +class wxPyDeadObjectError(AttributeError): + pass + +class _wxPyDeadObject: + """ + Instances of wx objects that are OOR capable will have their __class__ + changed to this class when the C++ object is deleted. This should help + prevent crashes due to referencing a bogus C++ pointer. + """ + reprStr = "wxPython wrapper for DELETED %s object! (The C++ object no longer exists.)" + attrStr = "The C++ %s object has been deleted, attribute access no longer allowed." + + def __repr__( self ): + if not hasattr(self, "_name"): + self._name = "[unknown]" + return self.reprStr % self._name + + def __getattr__( self, *args ): + if not hasattr(self, "_name"): + self._name = "[unknown]" + raise wxPyDeadObjectError( self.attrStr % self._name ) + + def __nonzero__(self): + return 0 + + #---------------------------------------------------------------------- #---------------------------------------------------------------------- @@ -1664,10 +1693,10 @@ class wxPyWidgetTester(wxApp): self.frame.Show(true) #---------------------------------------------------------------------------- -# DO NOT hold any other references to this object. This is how we know when -# to cleanup system resources that wxWin is holding. When this module is -# unloaded, the refcount on __cleanMeUp goes to zero and it calls the -# wxApp_CleanUp function. +# DO NOT hold any other references to this object. This is how we +# know when to cleanup system resources that wxWin is holding. When +# the sys module is unloaded, the refcount on sys.__wxPythonCleanup +# goes to zero and it calls the wxApp_CleanUp function. class __wxPyCleanup: def __init__(self): -- 2.45.2