From a07a67e664e859ac42c5505e5714934cd968e14a Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sat, 22 May 2004 03:44:04 +0000 Subject: [PATCH] reSWIGged git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27394 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/contrib/xrc/msw/xrc.py | 2 +- wxPython/src/gtk/_misc_wrap.cpp | 3 +- wxPython/src/mac/_misc_wrap.cpp | 3 +- wxPython/src/msw/_controls.py | 6 +- wxPython/src/msw/_controls_wrap.cpp | 40 ++- wxPython/src/msw/_core.py | 10 +- wxPython/src/msw/_core_wrap.cpp | 22 -- wxPython/src/msw/_gdi.py | 11 +- wxPython/src/msw/_gdi_wrap.cpp | 7 +- wxPython/src/msw/_misc.py | 381 +++++++++++++++++++++++++--- wxPython/src/msw/_misc_wrap.cpp | 273 ++++++++++++++------ wxPython/src/msw/grid.py | 15 ++ wxPython/src/msw/grid_wrap.cpp | 107 ++++++++ 13 files changed, 724 insertions(+), 156 deletions(-) diff --git a/wxPython/contrib/xrc/msw/xrc.py b/wxPython/contrib/xrc/msw/xrc.py index ae353c6bb0..4dedbfea2d 100644 --- a/wxPython/contrib/xrc/msw/xrc.py +++ b/wxPython/contrib/xrc/msw/xrc.py @@ -3,7 +3,7 @@ """ The `XmlResource` class allows program resources defining menus, layout of -controls on a panel, etc. +controls on a panel, etc. to be loaded from an XML file. """ import _xrc diff --git a/wxPython/src/gtk/_misc_wrap.cpp b/wxPython/src/gtk/_misc_wrap.cpp index 9aa013a15c..a6589a0d28 100644 --- a/wxPython/src/gtk/_misc_wrap.cpp +++ b/wxPython/src/gtk/_misc_wrap.cpp @@ -1475,7 +1475,8 @@ PyObject *wxCustomDataObject_GetData(wxCustomDataObject *self){ PyObject* obj; bool blocked = wxPyBeginBlockThreads(); obj = PyString_FromStringAndSize((char*)self->GetData(), self->GetSize()); - wxPyEndBlockThreads(blocked); + wxPyEndBlockThreads(blocked); + return obj; } class wxMetafileDataObject : public wxDataObjectSimple diff --git a/wxPython/src/mac/_misc_wrap.cpp b/wxPython/src/mac/_misc_wrap.cpp index ce0010e519..a1ac992a05 100644 --- a/wxPython/src/mac/_misc_wrap.cpp +++ b/wxPython/src/mac/_misc_wrap.cpp @@ -1470,7 +1470,8 @@ PyObject *wxCustomDataObject_GetData(wxCustomDataObject *self){ PyObject* obj; bool blocked = wxPyBeginBlockThreads(); obj = PyString_FromStringAndSize((char*)self->GetData(), self->GetSize()); - wxPyEndBlockThreads(blocked); + wxPyEndBlockThreads(blocked); + return obj; } #include diff --git a/wxPython/src/msw/_controls.py b/wxPython/src/msw/_controls.py index 1c09bf3c39..28b41c104f 100644 --- a/wxPython/src/msw/_controls.py +++ b/wxPython/src/msw/_controls.py @@ -1496,7 +1496,7 @@ class TextAttr(object): return _controls_.TextAttr_SetTabs(*args, **kwargs) def SetLeftIndent(*args, **kwargs): - """SetLeftIndent(self, int indent)""" + """SetLeftIndent(self, int indent, int subIndent=0)""" return _controls_.TextAttr_SetLeftIndent(*args, **kwargs) def SetRightIndent(*args, **kwargs): @@ -1563,6 +1563,10 @@ class TextAttr(object): """GetLeftIndent(self) -> long""" return _controls_.TextAttr_GetLeftIndent(*args, **kwargs) + def GetLeftSubIndent(*args, **kwargs): + """GetLeftSubIndent(self) -> long""" + return _controls_.TextAttr_GetLeftSubIndent(*args, **kwargs) + def GetRightIndent(*args, **kwargs): """GetRightIndent(self) -> long""" return _controls_.TextAttr_GetRightIndent(*args, **kwargs) diff --git a/wxPython/src/msw/_controls_wrap.cpp b/wxPython/src/msw/_controls_wrap.cpp index 4f73f52a80..4ac5055b94 100644 --- a/wxPython/src/msw/_controls_wrap.cpp +++ b/wxPython/src/msw/_controls_wrap.cpp @@ -895,6 +895,7 @@ PyObject *wxPyTreeCtrl_GetSelections(wxPyTreeCtrl *self){ wxTreeItemId *tii = new wxTreeItemId(array.Item(x)); PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), True); PyList_Append(rval, item); + Py_DECREF(item); } wxPyEndBlockThreads(blocked); return rval; @@ -7260,20 +7261,26 @@ static PyObject *_wrap_TextAttr_SetLeftIndent(PyObject *self, PyObject *args, Py PyObject *resultobj; wxTextAttr *arg1 = (wxTextAttr *) 0 ; int arg2 ; + int arg3 = (int) 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; char *kwnames[] = { - (char *) "self",(char *) "indent", NULL + (char *) "self",(char *) "indent",(char *) "subIndent", NULL }; - if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:TextAttr_SetLeftIndent",kwnames,&obj0,&obj1)) goto fail; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO|O:TextAttr_SetLeftIndent",kwnames,&obj0,&obj1,&obj2)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **)(&arg1),SWIGTYPE_p_wxTextAttr, SWIG_POINTER_EXCEPTION | 0)) == -1) SWIG_fail; arg2 = (int) SWIG_AsInt(obj1); if (PyErr_Occurred()) SWIG_fail; + if (obj2) { + arg3 = (int) SWIG_AsInt(obj2); + if (PyErr_Occurred()) SWIG_fail; + } { PyThreadState* __tstate = wxPyBeginAllowThreads(); - (arg1)->SetLeftIndent(arg2); + (arg1)->SetLeftIndent(arg2,arg3); wxPyEndAllowThreads(__tstate); if (PyErr_Occurred()) SWIG_fail; @@ -7750,6 +7757,32 @@ static PyObject *_wrap_TextAttr_GetLeftIndent(PyObject *self, PyObject *args, Py } +static PyObject *_wrap_TextAttr_GetLeftSubIndent(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject *resultobj; + wxTextAttr *arg1 = (wxTextAttr *) 0 ; + long result; + PyObject * obj0 = 0 ; + char *kwnames[] = { + (char *) "self", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:TextAttr_GetLeftSubIndent",kwnames,&obj0)) goto fail; + if ((SWIG_ConvertPtr(obj0,(void **)(&arg1),SWIGTYPE_p_wxTextAttr, + SWIG_POINTER_EXCEPTION | 0)) == -1) SWIG_fail; + { + PyThreadState* __tstate = wxPyBeginAllowThreads(); + result = (long)((wxTextAttr const *)arg1)->GetLeftSubIndent(); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) SWIG_fail; + } + resultobj = SWIG_FromLong((long)result); + return resultobj; + fail: + return NULL; +} + + static PyObject *_wrap_TextAttr_GetRightIndent(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject *resultobj; wxTextAttr *arg1 = (wxTextAttr *) 0 ; @@ -31382,6 +31415,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"TextAttr_GetAlignment", (PyCFunction) _wrap_TextAttr_GetAlignment, METH_VARARGS | METH_KEYWORDS }, { (char *)"TextAttr_GetTabs", (PyCFunction) _wrap_TextAttr_GetTabs, METH_VARARGS | METH_KEYWORDS }, { (char *)"TextAttr_GetLeftIndent", (PyCFunction) _wrap_TextAttr_GetLeftIndent, METH_VARARGS | METH_KEYWORDS }, + { (char *)"TextAttr_GetLeftSubIndent", (PyCFunction) _wrap_TextAttr_GetLeftSubIndent, METH_VARARGS | METH_KEYWORDS }, { (char *)"TextAttr_GetRightIndent", (PyCFunction) _wrap_TextAttr_GetRightIndent, METH_VARARGS | METH_KEYWORDS }, { (char *)"TextAttr_GetFlags", (PyCFunction) _wrap_TextAttr_GetFlags, METH_VARARGS | METH_KEYWORDS }, { (char *)"TextAttr_IsDefault", (PyCFunction) _wrap_TextAttr_IsDefault, METH_VARARGS | METH_KEYWORDS }, diff --git a/wxPython/src/msw/_core.py b/wxPython/src/msw/_core.py index 83754ec274..90e5b299a5 100644 --- a/wxPython/src/msw/_core.py +++ b/wxPython/src/msw/_core.py @@ -2322,10 +2322,13 @@ def Image_GetImageExtWildcard(*args, **kwargs): """Image_GetImageExtWildcard() -> String""" return _core_.Image_GetImageExtWildcard(*args, **kwargs) +def InitAllImageHandlers(): + """ + The former functionality of InitAllImageHanders is now done internal to + the _core_ extension module and so this function has become a simple NOP. + """ + pass -def InitAllImageHandlers(*args, **kwargs): - """InitAllImageHandlers()""" - return _core_.InitAllImageHandlers(*args, **kwargs) IMAGE_RESOLUTION_INCHES = _core_.IMAGE_RESOLUTION_INCHES IMAGE_RESOLUTION_CM = _core_.IMAGE_RESOLUTION_CM BMP_24BPP = _core_.BMP_24BPP @@ -5198,7 +5201,6 @@ class PySimpleApp(wx.App): wx.App.__init__(self, redirect, filename, useBestVisual, clearSigInt) def OnInit(self): - wx.InitAllImageHandlers() return True diff --git a/wxPython/src/msw/_core_wrap.cpp b/wxPython/src/msw/_core_wrap.cpp index fad663c8b6..3b5a328ffd 100644 --- a/wxPython/src/msw/_core_wrap.cpp +++ b/wxPython/src/msw/_core_wrap.cpp @@ -11273,27 +11273,6 @@ static PyObject * Image_swigregister(PyObject *self, PyObject *args) { Py_INCREF(obj); return Py_BuildValue((char *)""); } -static PyObject *_wrap_InitAllImageHandlers(PyObject *self, PyObject *args, PyObject *kwargs) { - PyObject *resultobj; - char *kwnames[] = { - NULL - }; - - if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)":InitAllImageHandlers",kwnames)) goto fail; - { - PyThreadState* __tstate = wxPyBeginAllowThreads(); - wxInitAllImageHandlers(); - - wxPyEndAllowThreads(__tstate); - if (PyErr_Occurred()) SWIG_fail; - } - Py_INCREF(Py_None); resultobj = Py_None; - return resultobj; - fail: - return NULL; -} - - static int _wrap_NullImage_set(PyObject *_val) { PyErr_SetString(PyExc_TypeError,"Variable NullImage is read-only."); return 1; @@ -40959,7 +40938,6 @@ static PyMethodDef SwigMethods[] = { { (char *)"Image_ConvertToBitmap", (PyCFunction) _wrap_Image_ConvertToBitmap, METH_VARARGS | METH_KEYWORDS }, { (char *)"Image_ConvertToMonoBitmap", (PyCFunction) _wrap_Image_ConvertToMonoBitmap, METH_VARARGS | METH_KEYWORDS }, { (char *)"Image_swigregister", Image_swigregister, METH_VARARGS }, - { (char *)"InitAllImageHandlers", (PyCFunction) _wrap_InitAllImageHandlers, METH_VARARGS | METH_KEYWORDS }, { (char *)"new_BMPHandler", (PyCFunction) _wrap_new_BMPHandler, METH_VARARGS | METH_KEYWORDS }, { (char *)"BMPHandler_swigregister", BMPHandler_swigregister, METH_VARARGS }, { (char *)"new_ICOHandler", (PyCFunction) _wrap_new_ICOHandler, METH_VARARGS | METH_KEYWORDS }, diff --git a/wxPython/src/msw/_gdi.py b/wxPython/src/msw/_gdi.py index d16853e71c..3952c23680 100644 --- a/wxPython/src/msw/_gdi.py +++ b/wxPython/src/msw/_gdi.py @@ -2394,16 +2394,7 @@ def EncodingConverter_CanConvert(*args, **kwargs): return _gdi_.EncodingConverter_CanConvert(*args, **kwargs) #---------------------------------------------------------------------------- -# wxGTK sets the locale when initialized. Doing this at the Python -# level should set it up to match what GTK is doing at the C level. -if wx.Platform == "__WXGTK__": - try: - import locale - locale.setlocale(locale.LC_ALL, "") - except: - pass - -# On MSW add the directory where the wxWindows catalogs were installed +# On MSW add the directory where the wxWidgets catalogs were installed # to the default catalog path. if wx.Platform == "__WXMSW__": import os diff --git a/wxPython/src/msw/_gdi_wrap.cpp b/wxPython/src/msw/_gdi_wrap.cpp index 0cd9f40c6d..f2826055d5 100644 --- a/wxPython/src/msw/_gdi_wrap.cpp +++ b/wxPython/src/msw/_gdi_wrap.cpp @@ -535,8 +535,11 @@ PyObject *wxPen_GetDashes(wxPen *self){ int count = self->GetDashes(&dashes); bool blocked = wxPyBeginBlockThreads(); PyObject* retval = PyList_New(0); - for (int x=0; x bool""" + """ + GetKeyState(int key) -> bool + + Get the state of a key (true if pressed or toggled on, false if not.) + This is generally most useful getting the state of the modifier or + toggle keys. On some platforms those may be the only keys that work. + + """ return _misc_.GetKeyState(*args, **kwargs) def WakeUpMainThread(*args, **kwargs): @@ -4362,6 +4369,20 @@ def CustomDataFormat(*args, **kwargs): return val class DataObject(object): + """ + A wx.DataObject represents data that can be copied to or from the + clipboard, or dragged and dropped. The important thing about + wx.DataObject is that this is a 'smart' piece of data unlike usual + 'dumb' data containers such as memory buffers or files. Being 'smart' + here means that the data object itself should know what data formats + it supports and how to render itself in each of supported formats. + + **NOTE**: This class is an abstract base class and can not be used + directly from Python. If you need a custom type of data object then + you should instead derive from `wx.PyDataObjectSimple` or use + `wx.CustomDataObject`. + + """ def __init__(self): raise RuntimeError, "No constructor defined" def __repr__(self): return "<%s.%s; proxy of C++ wxDataObject instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) @@ -4375,31 +4396,65 @@ class DataObject(object): except: pass def GetPreferredFormat(*args, **kwargs): - """GetPreferredFormat(self, int dir=Get) -> DataFormat""" + """ + GetPreferredFormat(self, int dir=Get) -> DataFormat + + Returns the preferred format for either rendering the data (if dir is + Get, its default value) or for setting it. Usually this will be the + native format of the wx.DataObject. + """ return _misc_.DataObject_GetPreferredFormat(*args, **kwargs) def GetFormatCount(*args, **kwargs): - """GetFormatCount(self, int dir=Get) -> size_t""" + """ + GetFormatCount(self, int dir=Get) -> size_t + + Returns the number of available formats for rendering or setting the + data. + """ return _misc_.DataObject_GetFormatCount(*args, **kwargs) def IsSupported(*args, **kwargs): - """IsSupported(self, DataFormat format, int dir=Get) -> bool""" + """ + IsSupported(self, DataFormat format, int dir=Get) -> bool + + Returns True if this format is supported. + """ return _misc_.DataObject_IsSupported(*args, **kwargs) def GetDataSize(*args, **kwargs): - """GetDataSize(self, DataFormat format) -> size_t""" + """ + GetDataSize(self, DataFormat format) -> size_t + + Get the (total) size of data for the given format + """ return _misc_.DataObject_GetDataSize(*args, **kwargs) def GetAllFormats(*args, **kwargs): - """GetAllFormats(self, DataFormat formats, int dir=Get)""" + """ + GetAllFormats(self, int dir=Get) -> [formats] + + Returns a list of all the wx.DataFormats that this dataobject supports + in the given direction. + """ return _misc_.DataObject_GetAllFormats(*args, **kwargs) def GetDataHere(*args, **kwargs): - """GetDataHere(self, DataFormat format, void buf) -> bool""" + """ + GetDataHere(self, DataFormat format) -> String + + Get the data bytes in the specified format, returns None on failure. + + """ return _misc_.DataObject_GetDataHere(*args, **kwargs) def SetData(*args, **kwargs): - """SetData(self, DataFormat format, size_t len, void buf) -> bool""" + """ + SetData(self, DataFormat format, String data) -> bool + + Set the data in the specified format from the bytes in the the data string. + + """ return _misc_.DataObject_SetData(*args, **kwargs) @@ -4412,22 +4467,73 @@ _misc_.DataObject_swigregister(DataObjectPtr) FormatInvalid = cvar.FormatInvalid class DataObjectSimple(DataObject): + """ + wx.DataObjectSimple is a `wx.DataObject` which only supports one + format. This is the simplest possible `wx.DataObject` implementation. + + This is still an "abstract base class" meaning that you can't use it + directly. You either need to use one of the predefined base classes, + or derive your own class from `wx.PyDataObjectSimple`. + + """ def __repr__(self): return "<%s.%s; proxy of C++ wxDataObjectSimple instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): - """__init__(self, DataFormat format=FormatInvalid) -> DataObjectSimple""" + """ + __init__(self, DataFormat format=FormatInvalid) -> DataObjectSimple + + Constructor accepts the supported format (none by default) which may + also be set later with `SetFormat`. + """ newobj = _misc_.new_DataObjectSimple(*args, **kwargs) self.this = newobj.this self.thisown = 1 del newobj.thisown def GetFormat(*args, **kwargs): - """GetFormat(self) -> DataFormat""" + """ + GetFormat(self) -> DataFormat + + Returns the (one and only one) format supported by this object. It is + assumed that the format is supported in both directions. + """ return _misc_.DataObjectSimple_GetFormat(*args, **kwargs) def SetFormat(*args, **kwargs): - """SetFormat(self, DataFormat format)""" + """ + SetFormat(self, DataFormat format) + + Sets the supported format. + """ return _misc_.DataObjectSimple_SetFormat(*args, **kwargs) + def GetDataSize(*args, **kwargs): + """ + GetDataSize(self) -> size_t + + Get the size of our data. + """ + return _misc_.DataObjectSimple_GetDataSize(*args, **kwargs) + + def GetDataHere(*args, **kwargs): + """ + GetDataHere(self) -> String + + Returns the data bytes from the data object as a string, returns None + on failure. Must be implemented in the derived class if the object + supports rendering its data. + """ + return _misc_.DataObjectSimple_GetDataHere(*args, **kwargs) + + def SetData(*args, **kwargs): + """ + SetData(self, String data) -> bool + + Copy the data value to the data object. Must be implemented in the + derived class if the object supports setting its data. + + """ + return _misc_.DataObjectSimple_SetData(*args, **kwargs) + class DataObjectSimplePtr(DataObjectSimple): def __init__(self, this): @@ -4437,10 +4543,27 @@ class DataObjectSimplePtr(DataObjectSimple): _misc_.DataObjectSimple_swigregister(DataObjectSimplePtr) class PyDataObjectSimple(DataObjectSimple): + """ + wx.PyDataObjectSimple is a version of `wx.DataObjectSimple` that is + Python-aware and knows how to reflect calls to its C++ virtual methods + to methods in the Python derived class. You should derive from this + class and overload `GetDataSize`, `GetDataHere` and `SetData` when you + need to create your own simple single-format type of `wx.DataObject`. + + """ def __repr__(self): return "<%s.%s; proxy of C++ wxPyDataObjectSimple instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): - """__init__(self, DataFormat format=FormatInvalid) -> PyDataObjectSimple""" + """ + __init__(self, DataFormat format=FormatInvalid) -> PyDataObjectSimple + + wx.PyDataObjectSimple is a version of `wx.DataObjectSimple` that is + Python-aware and knows how to reflect calls to its C++ virtual methods + to methods in the Python derived class. You should derive from this + class and overload `GetDataSize`, `GetDataHere` and `SetData` when you + need to create your own simple single-format type of `wx.DataObject`. + + """ newobj = _misc_.new_PyDataObjectSimple(*args, **kwargs) self.this = newobj.this self.thisown = 1 @@ -4460,16 +4583,50 @@ class PyDataObjectSimplePtr(PyDataObjectSimple): _misc_.PyDataObjectSimple_swigregister(PyDataObjectSimplePtr) class DataObjectComposite(DataObject): + """ + wx.DataObjectComposite is the simplest `wx.DataObject` derivation + which may be sued to support multiple formats. It contains several + 'wx.DataObjectSimple` objects and supports any format supported by at + least one of them. Only one of these data objects is *preferred* (the + first one if not explicitly changed by using the second parameter of + `Add`) and its format determines the preferred format of the composite + data object as well. + + See `wx.DataObject` documentation for the reasons why you might prefer + to use wx.DataObject directly instead of wx.DataObjectComposite for + efficiency reasons. + + """ def __repr__(self): return "<%s.%s; proxy of C++ wxDataObjectComposite instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): - """__init__(self) -> DataObjectComposite""" + """ + __init__(self) -> DataObjectComposite + + wx.DataObjectComposite is the simplest `wx.DataObject` derivation + which may be sued to support multiple formats. It contains several + 'wx.DataObjectSimple` objects and supports any format supported by at + least one of them. Only one of these data objects is *preferred* (the + first one if not explicitly changed by using the second parameter of + `Add`) and its format determines the preferred format of the composite + data object as well. + + See `wx.DataObject` documentation for the reasons why you might prefer + to use wx.DataObject directly instead of wx.DataObjectComposite for + efficiency reasons. + + """ newobj = _misc_.new_DataObjectComposite(*args, **kwargs) self.this = newobj.this self.thisown = 1 del newobj.thisown def Add(*args, **kwargs): - """Add(self, DataObjectSimple dataObject, int preferred=False)""" + """ + Add(self, DataObjectSimple dataObject, bool preferred=False) + + Adds the dataObject to the list of supported objects and it becomes + the preferred object if preferred is True. + """ return _misc_.DataObjectComposite_Add(*args, **kwargs) @@ -4481,24 +4638,62 @@ class DataObjectCompositePtr(DataObjectComposite): _misc_.DataObjectComposite_swigregister(DataObjectCompositePtr) class TextDataObject(DataObjectSimple): + """ + wx.TextDataObject is a specialization of `wx.DataObject` for text + data. It can be used without change to paste data into the `wx.Clipboard` + or a `wx.DropSource`. + + Alternativly, you may wish to derive a new class from the + `wx.PyTextDataObject` class for providing text on-demand in order to + minimize memory consumption when offering data in several formats, + such as plain text and RTF, because by default the text is stored in a + string in this class, but it might as well be generated on demand when + requested. For this, `GetTextLength` and `GetText` will have to be + overridden. + """ def __repr__(self): return "<%s.%s; proxy of C++ wxTextDataObject instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): - """__init__(self, String text=EmptyString) -> TextDataObject""" + """ + __init__(self, String text=EmptyString) -> TextDataObject + + Constructor, may be used to initialise the text (otherwise `SetText` + should be used later). + """ newobj = _misc_.new_TextDataObject(*args, **kwargs) self.this = newobj.this self.thisown = 1 del newobj.thisown def GetTextLength(*args, **kwargs): - """GetTextLength(self) -> size_t""" + """ + GetTextLength(self) -> size_t + + Returns the data size. By default, returns the size of the text data + set in the constructor or using `SetText`. This can be overridden (via + `wx.PyTextDataObject`) to provide text size data on-demand. It is + recommended to return the text length plus 1 for a trailing zero, but + this is not strictly required. + """ return _misc_.TextDataObject_GetTextLength(*args, **kwargs) def GetText(*args, **kwargs): - """GetText(self) -> String""" + """ + GetText(self) -> String + + Returns the text associated with the data object. + """ return _misc_.TextDataObject_GetText(*args, **kwargs) def SetText(*args, **kwargs): - """SetText(self, String text)""" + """ + SetText(self, String text) + + Sets the text associated with the data object. This method is called + when the data object receives the data and, by default, copies the + text into the member variable. If you want to process the text on the + fly you may wish to override this function (via + `wx.PyTextDataObject`.) + """ return _misc_.TextDataObject_SetText(*args, **kwargs) @@ -4510,10 +4705,27 @@ class TextDataObjectPtr(TextDataObject): _misc_.TextDataObject_swigregister(TextDataObjectPtr) class PyTextDataObject(TextDataObject): + """ + wx.PyTextDataObject is a version of `wx.TextDataObject` that is + Python-aware and knows how to reflect calls to its C++ virtual methods + to methods in the Python derived class. You should derive from this + class and overload `GetTextLength`, `GetText`, and `SetText` when you + want to be able to provide text on demand instead of preloading it + into the data object. + """ def __repr__(self): return "<%s.%s; proxy of C++ wxPyTextDataObject instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): - """__init__(self, String text=EmptyString) -> PyTextDataObject""" + """ + __init__(self, String text=EmptyString) -> PyTextDataObject + + wx.PyTextDataObject is a version of `wx.TextDataObject` that is + Python-aware and knows how to reflect calls to its C++ virtual methods + to methods in the Python derived class. You should derive from this + class and overload `GetTextLength`, `GetText`, and `SetText` when you + want to be able to provide text on demand instead of preloading it + into the data object. + """ newobj = _misc_.new_PyTextDataObject(*args, **kwargs) self.this = newobj.this self.thisown = 1 @@ -4533,20 +4745,45 @@ class PyTextDataObjectPtr(PyTextDataObject): _misc_.PyTextDataObject_swigregister(PyTextDataObjectPtr) class BitmapDataObject(DataObjectSimple): + """ + wx.BitmapDataObject is a specialization of wxDataObject for bitmap + data. It can be used without change to paste data into the `wx.Clipboard` + or a `wx.DropSource`. + + """ def __repr__(self): return "<%s.%s; proxy of C++ wxBitmapDataObject instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): - """__init__(self, Bitmap bitmap=wxNullBitmap) -> BitmapDataObject""" + """ + __init__(self, Bitmap bitmap=wxNullBitmap) -> BitmapDataObject + + Constructor, optionally passing a bitmap (otherwise use `SetBitmap` + later). + """ newobj = _misc_.new_BitmapDataObject(*args, **kwargs) self.this = newobj.this self.thisown = 1 del newobj.thisown def GetBitmap(*args, **kwargs): - """GetBitmap(self) -> Bitmap""" + """ + GetBitmap(self) -> Bitmap + + Returns the bitmap associated with the data object. You may wish to + override this method (by deriving from `wx.PyBitmapDataObject`) when + offering data on-demand, but this is not required by wxWidgets' + internals. Use this method to get data in bitmap form from the + `wx.Clipboard`. + """ return _misc_.BitmapDataObject_GetBitmap(*args, **kwargs) def SetBitmap(*args, **kwargs): - """SetBitmap(self, Bitmap bitmap)""" + """ + SetBitmap(self, Bitmap bitmap) + + Sets the bitmap associated with the data object. This method is called + when the data object receives data. Usually there will be no reason to + override this function. + """ return _misc_.BitmapDataObject_SetBitmap(*args, **kwargs) @@ -4558,10 +4795,23 @@ class BitmapDataObjectPtr(BitmapDataObject): _misc_.BitmapDataObject_swigregister(BitmapDataObjectPtr) class PyBitmapDataObject(BitmapDataObject): + """ + wx.PyBitmapDataObject is a version of `wx.BitmapDataObject` that is + Python-aware and knows how to reflect calls to its C++ virtual methods + to methods in the Python derived class. To be able to provide bitmap + data on demand derive from this class and overload `GetBitmap`. + """ def __repr__(self): return "<%s.%s; proxy of C++ wxPyBitmapDataObject instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): - """__init__(self, Bitmap bitmap=wxNullBitmap) -> PyBitmapDataObject""" + """ + __init__(self, Bitmap bitmap=wxNullBitmap) -> PyBitmapDataObject + + wx.PyBitmapDataObject is a version of `wx.BitmapDataObject` that is + Python-aware and knows how to reflect calls to its C++ virtual methods + to methods in the Python derived class. To be able to provide bitmap + data on demand derive from this class and overload `GetBitmap`. + """ newobj = _misc_.new_PyBitmapDataObject(*args, **kwargs) self.this = newobj.this self.thisown = 1 @@ -4581,6 +4831,20 @@ class PyBitmapDataObjectPtr(PyBitmapDataObject): _misc_.PyBitmapDataObject_swigregister(PyBitmapDataObjectPtr) class FileDataObject(DataObjectSimple): + """ + wx.FileDataObject is a specialization of `wx.DataObjectSimple` for + file names. The program works with it just as if it were a list of + absolute file names, but internally it uses the same format as + Explorer and other compatible programs under Windows or GNOME/KDE + filemanager under Unix which makes it possible to receive files from + them using this class. + + :Warning: Under all non-Windows platforms this class is currently + "input-only", i.e. you can receive the files from another + application, but copying (or dragging) file(s) from a wxWidgets + application is not currently supported. + + """ def __repr__(self): return "<%s.%s; proxy of C++ wxFileDataObject instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): @@ -4590,11 +4854,15 @@ class FileDataObject(DataObjectSimple): self.thisown = 1 del newobj.thisown def GetFilenames(*args, **kwargs): - """GetFilenames(self) -> wxArrayString""" + """GetFilenames(self) -> [names]""" return _misc_.FileDataObject_GetFilenames(*args, **kwargs) def AddFile(*args, **kwargs): - """AddFile(self, String filename)""" + """ + AddFile(self, String filename) + + Adds a file to the list of files represented by this data object. + """ return _misc_.FileDataObject_AddFile(*args, **kwargs) @@ -4606,28 +4874,52 @@ class FileDataObjectPtr(FileDataObject): _misc_.FileDataObject_swigregister(FileDataObjectPtr) class CustomDataObject(DataObjectSimple): + """ + wx.CustomDataObject is a specialization of `wx.DataObjectSimple` for + some application-specific data in arbitrary format. Python strings + are used for getting and setting data, but any picklable object can + easily be transfered via strings. A copy of the data is stored in the + data object. + """ def __repr__(self): return "<%s.%s; proxy of C++ wxCustomDataObject instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): - """__init__(self, DataFormat format=FormatInvalid) -> CustomDataObject""" + """ + __init__(self, DataFormat format=FormatInvalid) -> CustomDataObject + + wx.CustomDataObject is a specialization of `wx.DataObjectSimple` for + some application-specific data in arbitrary format. Python strings + are used for getting and setting data, but any picklable object can + easily be transfered via strings. A copy of the data is stored in the + data object. + """ newobj = _misc_.new_CustomDataObject(*args, **kwargs) self.this = newobj.this self.thisown = 1 del newobj.thisown - def TakeData(*args, **kwargs): - """TakeData(self, PyObject data)""" - return _misc_.CustomDataObject_TakeData(*args, **kwargs) - def SetData(*args, **kwargs): - """SetData(self, PyObject data) -> bool""" + """ + SetData(self, String data) -> bool + + Copy the data value to the data object. + """ return _misc_.CustomDataObject_SetData(*args, **kwargs) + TakeData = SetData def GetSize(*args, **kwargs): - """GetSize(self) -> size_t""" + """ + GetSize(self) -> size_t + + Get the size of the data. + """ return _misc_.CustomDataObject_GetSize(*args, **kwargs) def GetData(*args, **kwargs): - """GetData(self) -> PyObject""" + """ + GetData(self) -> String + + Returns the data bytes from the data object as a string. + """ return _misc_.CustomDataObject_GetData(*args, **kwargs) @@ -4639,20 +4931,37 @@ class CustomDataObjectPtr(CustomDataObject): _misc_.CustomDataObject_swigregister(CustomDataObjectPtr) class URLDataObject(DataObjectComposite): + """ + This data object holds a URL in a format that is compatible with some + browsers such that it is able to be dragged to or from them. + """ def __repr__(self): return "<%s.%s; proxy of C++ wxURLDataObject instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): - """__init__(self) -> URLDataObject""" + """ + __init__(self) -> URLDataObject + + This data object holds a URL in a format that is compatible with some + browsers such that it is able to be dragged to or from them. + """ newobj = _misc_.new_URLDataObject(*args, **kwargs) self.this = newobj.this self.thisown = 1 del newobj.thisown def GetURL(*args, **kwargs): - """GetURL(self) -> String""" + """ + GetURL(self) -> String + + Returns a string containing the current URL. + """ return _misc_.URLDataObject_GetURL(*args, **kwargs) def SetURL(*args, **kwargs): - """SetURL(self, String url)""" + """ + SetURL(self, String url) + + Set the URL. + """ return _misc_.URLDataObject_SetURL(*args, **kwargs) diff --git a/wxPython/src/msw/_misc_wrap.cpp b/wxPython/src/msw/_misc_wrap.cpp index fd6a680755..72cac58dd5 100644 --- a/wxPython/src/msw/_misc_wrap.cpp +++ b/wxPython/src/msw/_misc_wrap.cpp @@ -1267,6 +1267,85 @@ bool wxDateSpan___ne__(wxDateSpan *self,wxDateSpan const *other){ return other ? #include +PyObject *wxDataObject_GetAllFormats(wxDataObject *self,wxDataObject::Direction dir){ + size_t count = self->GetFormatCount(dir); + wxDataFormat* formats = new wxDataFormat[count]; + self->GetAllFormats(formats, dir); + + bool blocked = wxPyBeginBlockThreads(); + PyObject* list = PyList_New(count); + for (size_t i=0; iGetDataSize(format); + bool blocked = wxPyBeginBlockThreads(); + if (size) { + char* buf = new char[size]; + if (self->GetDataHere(format, buf)) + rval = PyString_FromStringAndSize(buf, size); + delete [] buf; + } + if (! rval) { + rval = Py_None; + Py_INCREF(rval); + } + wxPyEndBlockThreads(blocked); + return rval; + } +bool wxDataObject_SetData(wxDataObject *self,wxDataFormat const &format,PyObject *data){ + bool rval; + bool blocked = wxPyBeginBlockThreads(); + if (PyString_Check(data)) { + rval = self->SetData(format, PyString_Size(data), PyString_AsString(data)); + } + else { + // raise a TypeError if not a string + PyErr_SetString(PyExc_TypeError, "String expected."); + rval = False; + } + wxPyEndBlockThreads(blocked); + return rval; + } +PyObject *wxDataObjectSimple_GetDataHere(wxDataObjectSimple *self){ + PyObject* rval = NULL; + size_t size = self->GetDataSize(); + bool blocked = wxPyBeginBlockThreads(); + if (size) { + char* buf = new char[size]; + if (self->GetDataHere(buf)) + rval = PyString_FromStringAndSize(buf, size); + delete [] buf; + } + if (! rval) { + rval = Py_None; + Py_INCREF(rval); + } + wxPyEndBlockThreads(blocked); + return rval; + } +bool wxDataObjectSimple_SetData(wxDataObjectSimple *self,PyObject *data){ + bool rval; + bool blocked = wxPyBeginBlockThreads(); + if (PyString_Check(data)) { + rval = self->SetData(PyString_Size(data), PyString_AsString(data)); + } + else { + // raise a TypeError if not a string + PyErr_SetString(PyExc_TypeError, "String expected."); + rval = False; + } + wxPyEndBlockThreads(blocked); + return rval; + } // Create a new class for wxPython to use class wxPyDataObjectSimple : public wxDataObjectSimple { public: @@ -1361,7 +1440,7 @@ wxBitmap wxPyBitmapDataObject::GetBitmap() const { wxPyEndBlockThreads(blocked); return *rval; } - + void wxPyBitmapDataObject::SetBitmap(const wxBitmap& bitmap) { bool blocked = wxPyBeginBlockThreads(); if (wxPyCBH_findCallback(m_myInst, "SetBitmap")) { @@ -1372,28 +1451,26 @@ void wxPyBitmapDataObject::SetBitmap(const wxBitmap& bitmap) { wxPyEndBlockThreads(blocked); } -void wxCustomDataObject_TakeData(wxCustomDataObject *self,PyObject *data){ - if (PyString_Check(data)) { - // for Python we just call SetData here since we always need it to make a copy. - self->SetData(PyString_Size(data), PyString_AsString(data)); - } - else { - // raise a TypeError if not a string - PyErr_SetString(PyExc_TypeError, "String expected."); - } - } bool wxCustomDataObject_SetData(wxCustomDataObject *self,PyObject *data){ + bool rval; + bool blocked = wxPyBeginBlockThreads(); if (PyString_Check(data)) { - return self->SetData(PyString_Size(data), PyString_AsString(data)); + rval = self->SetData(PyString_Size(data), PyString_AsString(data)); } else { // raise a TypeError if not a string PyErr_SetString(PyExc_TypeError, "String expected."); - return False; + rval = False; } + wxPyEndBlockThreads(blocked); + return rval; } PyObject *wxCustomDataObject_GetData(wxCustomDataObject *self){ - return PyString_FromStringAndSize((char*)self->GetData(), self->GetSize()); + PyObject* obj; + bool blocked = wxPyBeginBlockThreads(); + obj = PyString_FromStringAndSize((char*)self->GetData(), self->GetSize()); + wxPyEndBlockThreads(blocked); + return obj; } #include @@ -1487,6 +1564,7 @@ PyObject *wxDisplay_GetModes(wxDisplay *self,wxVideoMode const &mode){ wxVideoMode* m = new wxVideoMode(arr.Item(i)); PyObject* pyObj = wxPyConstructObject(m, wxT("wxVideoMode"), true); PyList_Append(pyList, pyObj); + Py_DECREF(pyObj); } wxPyEndBlockThreads(blocked); return pyList; @@ -24369,32 +24447,29 @@ static PyObject *_wrap_DataObject_GetDataSize(PyObject *self, PyObject *args, Py static PyObject *_wrap_DataObject_GetAllFormats(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject *resultobj; wxDataObject *arg1 = (wxDataObject *) 0 ; - wxDataFormat *arg2 = (wxDataFormat *) 0 ; - int arg3 = (int) wxDataObject::Get ; + int arg2 = (int) wxDataObject::Get ; + PyObject *result; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; char *kwnames[] = { - (char *) "self",(char *) "formats",(char *) "dir", NULL + (char *) "self",(char *) "dir", NULL }; - if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO|O:DataObject_GetAllFormats",kwnames,&obj0,&obj1,&obj2)) goto fail; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|O:DataObject_GetAllFormats",kwnames,&obj0,&obj1)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **)(&arg1),SWIGTYPE_p_wxDataObject, SWIG_POINTER_EXCEPTION | 0)) == -1) SWIG_fail; - if ((SWIG_ConvertPtr(obj1,(void **)(&arg2),SWIGTYPE_p_wxDataFormat, - SWIG_POINTER_EXCEPTION | 0)) == -1) SWIG_fail; - if (obj2) { - arg3 = (wxDataObject::Direction) SWIG_AsInt(obj2); + if (obj1) { + arg2 = (wxDataObject::Direction) SWIG_AsInt(obj1); if (PyErr_Occurred()) SWIG_fail; } { PyThreadState* __tstate = wxPyBeginAllowThreads(); - ((wxDataObject const *)arg1)->GetAllFormats(arg2,(wxDataObject::Direction )arg3); + result = (PyObject *)wxDataObject_GetAllFormats(arg1,(wxDataObject::Direction )arg2); wxPyEndAllowThreads(__tstate); if (PyErr_Occurred()) SWIG_fail; } - Py_INCREF(Py_None); resultobj = Py_None; + resultobj = result; return resultobj; fail: return NULL; @@ -24405,16 +24480,14 @@ static PyObject *_wrap_DataObject_GetDataHere(PyObject *self, PyObject *args, Py PyObject *resultobj; wxDataObject *arg1 = (wxDataObject *) 0 ; wxDataFormat *arg2 = 0 ; - void *arg3 = (void *) 0 ; - bool result; + PyObject *result; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; char *kwnames[] = { - (char *) "self",(char *) "format",(char *) "buf", NULL + (char *) "self",(char *) "format", NULL }; - if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:DataObject_GetDataHere",kwnames,&obj0,&obj1,&obj2)) goto fail; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:DataObject_GetDataHere",kwnames,&obj0,&obj1)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **)(&arg1),SWIGTYPE_p_wxDataObject, SWIG_POINTER_EXCEPTION | 0)) == -1) SWIG_fail; if ((SWIG_ConvertPtr(obj1,(void **)(&arg2),SWIGTYPE_p_wxDataFormat, @@ -24424,17 +24497,14 @@ static PyObject *_wrap_DataObject_GetDataHere(PyObject *self, PyObject *args, Py PyErr_SetString(PyExc_TypeError,"null reference"); SWIG_fail; } - if ((SWIG_ConvertPtr(obj2,&arg3,0,SWIG_POINTER_EXCEPTION | 0)) == -1) SWIG_fail; { PyThreadState* __tstate = wxPyBeginAllowThreads(); - result = (bool)((wxDataObject const *)arg1)->GetDataHere((wxDataFormat const &)*arg2,arg3); + result = (PyObject *)wxDataObject_GetDataHere(arg1,(wxDataFormat const &)*arg2); wxPyEndAllowThreads(__tstate); if (PyErr_Occurred()) SWIG_fail; } - { - resultobj = result ? Py_True : Py_False; Py_INCREF(resultobj); - } + resultobj = result; return resultobj; fail: return NULL; @@ -24445,18 +24515,16 @@ static PyObject *_wrap_DataObject_SetData(PyObject *self, PyObject *args, PyObje PyObject *resultobj; wxDataObject *arg1 = (wxDataObject *) 0 ; wxDataFormat *arg2 = 0 ; - size_t arg3 ; - void *arg4 = (void *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; bool result; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; char *kwnames[] = { - (char *) "self",(char *) "format",(char *) "len",(char *) "buf", NULL + (char *) "self",(char *) "format",(char *) "data", NULL }; - if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:DataObject_SetData",kwnames,&obj0,&obj1,&obj2,&obj3)) goto fail; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:DataObject_SetData",kwnames,&obj0,&obj1,&obj2)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **)(&arg1),SWIGTYPE_p_wxDataObject, SWIG_POINTER_EXCEPTION | 0)) == -1) SWIG_fail; if ((SWIG_ConvertPtr(obj1,(void **)(&arg2),SWIGTYPE_p_wxDataFormat, @@ -24466,12 +24534,10 @@ static PyObject *_wrap_DataObject_SetData(PyObject *self, PyObject *args, PyObje PyErr_SetString(PyExc_TypeError,"null reference"); SWIG_fail; } - arg3 = (size_t) SWIG_AsUnsignedLong(obj2); - if (PyErr_Occurred()) SWIG_fail; - if ((SWIG_ConvertPtr(obj3,&arg4,0,SWIG_POINTER_EXCEPTION | 0)) == -1) SWIG_fail; + arg3 = obj2; { PyThreadState* __tstate = wxPyBeginAllowThreads(); - result = (bool)(arg1)->SetData((wxDataFormat const &)*arg2,arg3,(void const *)arg4); + result = (bool)wxDataObject_SetData(arg1,(wxDataFormat const &)*arg2,arg3); wxPyEndAllowThreads(__tstate); if (PyErr_Occurred()) SWIG_fail; @@ -24589,6 +24655,89 @@ static PyObject *_wrap_DataObjectSimple_SetFormat(PyObject *self, PyObject *args } +static PyObject *_wrap_DataObjectSimple_GetDataSize(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject *resultobj; + wxDataObjectSimple *arg1 = (wxDataObjectSimple *) 0 ; + size_t result; + PyObject * obj0 = 0 ; + char *kwnames[] = { + (char *) "self", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:DataObjectSimple_GetDataSize",kwnames,&obj0)) goto fail; + if ((SWIG_ConvertPtr(obj0,(void **)(&arg1),SWIGTYPE_p_wxDataObjectSimple, + SWIG_POINTER_EXCEPTION | 0)) == -1) SWIG_fail; + { + PyThreadState* __tstate = wxPyBeginAllowThreads(); + result = (size_t)((wxDataObjectSimple const *)arg1)->GetDataSize(); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) SWIG_fail; + } + resultobj = SWIG_FromUnsignedLong((unsigned long)result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_DataObjectSimple_GetDataHere(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject *resultobj; + wxDataObjectSimple *arg1 = (wxDataObjectSimple *) 0 ; + PyObject *result; + PyObject * obj0 = 0 ; + char *kwnames[] = { + (char *) "self", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:DataObjectSimple_GetDataHere",kwnames,&obj0)) goto fail; + if ((SWIG_ConvertPtr(obj0,(void **)(&arg1),SWIGTYPE_p_wxDataObjectSimple, + SWIG_POINTER_EXCEPTION | 0)) == -1) SWIG_fail; + { + PyThreadState* __tstate = wxPyBeginAllowThreads(); + result = (PyObject *)wxDataObjectSimple_GetDataHere(arg1); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) SWIG_fail; + } + resultobj = result; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_DataObjectSimple_SetData(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject *resultobj; + wxDataObjectSimple *arg1 = (wxDataObjectSimple *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + bool result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "data", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:DataObjectSimple_SetData",kwnames,&obj0,&obj1)) goto fail; + if ((SWIG_ConvertPtr(obj0,(void **)(&arg1),SWIGTYPE_p_wxDataObjectSimple, + SWIG_POINTER_EXCEPTION | 0)) == -1) SWIG_fail; + arg2 = obj1; + { + PyThreadState* __tstate = wxPyBeginAllowThreads(); + result = (bool)wxDataObjectSimple_SetData(arg1,arg2); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) SWIG_fail; + } + { + resultobj = result ? Py_True : Py_False; Py_INCREF(resultobj); + } + return resultobj; + fail: + return NULL; +} + + static PyObject * DataObjectSimple_swigregister(PyObject *self, PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; @@ -24694,7 +24843,7 @@ static PyObject *_wrap_DataObjectComposite_Add(PyObject *self, PyObject *args, P PyObject *resultobj; wxDataObjectComposite *arg1 = (wxDataObjectComposite *) 0 ; wxDataObjectSimple *arg2 = (wxDataObjectSimple *) 0 ; - int arg3 = (int) False ; + bool arg3 = (bool) False ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -24708,7 +24857,7 @@ static PyObject *_wrap_DataObjectComposite_Add(PyObject *self, PyObject *args, P if ((SWIG_ConvertPtr(obj1,(void **)(&arg2),SWIGTYPE_p_wxDataObjectSimple, SWIG_POINTER_EXCEPTION | SWIG_POINTER_DISOWN)) == -1) SWIG_fail; if (obj2) { - arg3 = (int) SWIG_AsInt(obj2); + arg3 = (bool) SWIG_AsBool(obj2); if (PyErr_Occurred()) SWIG_fail; } { @@ -25270,34 +25419,6 @@ static PyObject *_wrap_new_CustomDataObject(PyObject *self, PyObject *args, PyOb } -static PyObject *_wrap_CustomDataObject_TakeData(PyObject *self, PyObject *args, PyObject *kwargs) { - PyObject *resultobj; - wxCustomDataObject *arg1 = (wxCustomDataObject *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - char *kwnames[] = { - (char *) "self",(char *) "data", NULL - }; - - if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:CustomDataObject_TakeData",kwnames,&obj0,&obj1)) goto fail; - if ((SWIG_ConvertPtr(obj0,(void **)(&arg1),SWIGTYPE_p_wxCustomDataObject, - SWIG_POINTER_EXCEPTION | 0)) == -1) SWIG_fail; - arg2 = obj1; - { - PyThreadState* __tstate = wxPyBeginAllowThreads(); - wxCustomDataObject_TakeData(arg1,arg2); - - wxPyEndAllowThreads(__tstate); - if (PyErr_Occurred()) SWIG_fail; - } - Py_INCREF(Py_None); resultobj = Py_None; - return resultobj; - fail: - return NULL; -} - - static PyObject *_wrap_CustomDataObject_SetData(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject *resultobj; wxCustomDataObject *arg1 = (wxCustomDataObject *) 0 ; @@ -28676,6 +28797,9 @@ static PyMethodDef SwigMethods[] = { { (char *)"new_DataObjectSimple", (PyCFunction) _wrap_new_DataObjectSimple, METH_VARARGS | METH_KEYWORDS }, { (char *)"DataObjectSimple_GetFormat", (PyCFunction) _wrap_DataObjectSimple_GetFormat, METH_VARARGS | METH_KEYWORDS }, { (char *)"DataObjectSimple_SetFormat", (PyCFunction) _wrap_DataObjectSimple_SetFormat, METH_VARARGS | METH_KEYWORDS }, + { (char *)"DataObjectSimple_GetDataSize", (PyCFunction) _wrap_DataObjectSimple_GetDataSize, METH_VARARGS | METH_KEYWORDS }, + { (char *)"DataObjectSimple_GetDataHere", (PyCFunction) _wrap_DataObjectSimple_GetDataHere, METH_VARARGS | METH_KEYWORDS }, + { (char *)"DataObjectSimple_SetData", (PyCFunction) _wrap_DataObjectSimple_SetData, METH_VARARGS | METH_KEYWORDS }, { (char *)"DataObjectSimple_swigregister", DataObjectSimple_swigregister, METH_VARARGS }, { (char *)"new_PyDataObjectSimple", (PyCFunction) _wrap_new_PyDataObjectSimple, METH_VARARGS | METH_KEYWORDS }, { (char *)"PyDataObjectSimple__setCallbackInfo", (PyCFunction) _wrap_PyDataObjectSimple__setCallbackInfo, METH_VARARGS | METH_KEYWORDS }, @@ -28703,7 +28827,6 @@ static PyMethodDef SwigMethods[] = { { (char *)"FileDataObject_AddFile", (PyCFunction) _wrap_FileDataObject_AddFile, METH_VARARGS | METH_KEYWORDS }, { (char *)"FileDataObject_swigregister", FileDataObject_swigregister, METH_VARARGS }, { (char *)"new_CustomDataObject", (PyCFunction) _wrap_new_CustomDataObject, METH_VARARGS | METH_KEYWORDS }, - { (char *)"CustomDataObject_TakeData", (PyCFunction) _wrap_CustomDataObject_TakeData, METH_VARARGS | METH_KEYWORDS }, { (char *)"CustomDataObject_SetData", (PyCFunction) _wrap_CustomDataObject_SetData, METH_VARARGS | METH_KEYWORDS }, { (char *)"CustomDataObject_GetSize", (PyCFunction) _wrap_CustomDataObject_GetSize, METH_VARARGS | METH_KEYWORDS }, { (char *)"CustomDataObject_GetData", (PyCFunction) _wrap_CustomDataObject_GetData, METH_VARARGS | METH_KEYWORDS }, diff --git a/wxPython/src/msw/grid.py b/wxPython/src/msw/grid.py index d7e6d31102..ddf9fe322c 100644 --- a/wxPython/src/msw/grid.py +++ b/wxPython/src/msw/grid.py @@ -1227,6 +1227,14 @@ class Grid(_windows.ScrolledWindow): del newobj.thisown self._setOORInfo(self) + def Create(*args, **kwargs): + """ + Create(self, Window parent, int id, Point pos=DefaultPosition, Size size=DefaultSize, + long style=WANTS_CHARS, + String name=PanelNameStr) -> bool + """ + return _grid.Grid_Create(*args, **kwargs) + wxGridSelectCells = _grid.Grid_wxGridSelectCells wxGridSelectRows = _grid.Grid_wxGridSelectRows wxGridSelectColumns = _grid.Grid_wxGridSelectColumns @@ -2014,6 +2022,13 @@ class GridPtr(Grid): self.__class__ = Grid _grid.Grid_swigregister(GridPtr) +def PreGrid(*args, **kwargs): + """PreGrid() -> Grid""" + val = _grid.new_PreGrid(*args, **kwargs) + val.thisown = 1 + self._setOORInfo(self) + return val + def Grid_GetClassDefaultAttributes(*args, **kwargs): """ Grid_GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes diff --git a/wxPython/src/msw/grid_wrap.cpp b/wxPython/src/msw/grid_wrap.cpp index 91bec8fbcc..93965c65a1 100644 --- a/wxPython/src/msw/grid_wrap.cpp +++ b/wxPython/src/msw/grid_wrap.cpp @@ -8091,6 +8091,111 @@ static PyObject *_wrap_new_Grid(PyObject *self, PyObject *args, PyObject *kwargs } +static PyObject *_wrap_new_PreGrid(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject *resultobj; + wxGrid *result; + char *kwnames[] = { + NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)":new_PreGrid",kwnames)) goto fail; + { + PyThreadState* __tstate = wxPyBeginAllowThreads(); + result = (wxGrid *)new wxGrid(); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) SWIG_fail; + } + { + resultobj = wxPyMake_wxObject(result); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Grid_Create(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject *resultobj; + wxGrid *arg1 = (wxGrid *) 0 ; + wxWindow *arg2 = (wxWindow *) 0 ; + int arg3 ; + wxPoint const &arg4_defvalue = wxDefaultPosition ; + wxPoint *arg4 = (wxPoint *) &arg4_defvalue ; + wxSize const &arg5_defvalue = wxDefaultSize ; + wxSize *arg5 = (wxSize *) &arg5_defvalue ; + long arg6 = (long) wxWANTS_CHARS ; + wxString const &arg7_defvalue = wxPyPanelNameStr ; + wxString *arg7 = (wxString *) &arg7_defvalue ; + bool result; + wxPoint temp4 ; + wxSize temp5 ; + bool temp7 = False ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "parent",(char *) "id",(char *) "pos",(char *) "size",(char *) "style",(char *) "name", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|OOOO:Grid_Create",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) goto fail; + if ((SWIG_ConvertPtr(obj0,(void **)(&arg1),SWIGTYPE_p_wxGrid, + SWIG_POINTER_EXCEPTION | 0)) == -1) SWIG_fail; + if ((SWIG_ConvertPtr(obj1,(void **)(&arg2),SWIGTYPE_p_wxWindow, + SWIG_POINTER_EXCEPTION | 0)) == -1) SWIG_fail; + arg3 = (int) SWIG_AsInt(obj2); + if (PyErr_Occurred()) SWIG_fail; + if (obj3) { + { + arg4 = &temp4; + if ( ! wxPoint_helper(obj3, &arg4)) SWIG_fail; + } + } + if (obj4) { + { + arg5 = &temp5; + if ( ! wxSize_helper(obj4, &arg5)) SWIG_fail; + } + } + if (obj5) { + arg6 = (long) SWIG_AsLong(obj5); + if (PyErr_Occurred()) SWIG_fail; + } + if (obj6) { + { + arg7 = wxString_in_helper(obj6); + if (arg7 == NULL) SWIG_fail; + temp7 = True; + } + } + { + PyThreadState* __tstate = wxPyBeginAllowThreads(); + result = (bool)(arg1)->Create(arg2,arg3,(wxPoint const &)*arg4,(wxSize const &)*arg5,arg6,(wxString const &)*arg7); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) SWIG_fail; + } + { + resultobj = result ? Py_True : Py_False; Py_INCREF(resultobj); + } + { + if (temp7) + delete arg7; + } + return resultobj; + fail: + { + if (temp7) + delete arg7; + } + return NULL; +} + + static PyObject *_wrap_Grid_CreateGrid(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject *resultobj; wxGrid *arg1 = (wxGrid *) 0 ; @@ -15700,6 +15805,8 @@ static PyMethodDef SwigMethods[] = { { (char *)"GridCellCoords_Get", (PyCFunction) _wrap_GridCellCoords_Get, METH_VARARGS | METH_KEYWORDS }, { (char *)"GridCellCoords_swigregister", GridCellCoords_swigregister, METH_VARARGS }, { (char *)"new_Grid", (PyCFunction) _wrap_new_Grid, METH_VARARGS | METH_KEYWORDS }, + { (char *)"new_PreGrid", (PyCFunction) _wrap_new_PreGrid, METH_VARARGS | METH_KEYWORDS }, + { (char *)"Grid_Create", (PyCFunction) _wrap_Grid_Create, METH_VARARGS | METH_KEYWORDS }, { (char *)"Grid_CreateGrid", (PyCFunction) _wrap_Grid_CreateGrid, METH_VARARGS | METH_KEYWORDS }, { (char *)"Grid_SetSelectionMode", (PyCFunction) _wrap_Grid_SetSelectionMode, METH_VARARGS | METH_KEYWORDS }, { (char *)"Grid_GetSelectionMode", (PyCFunction) _wrap_Grid_GetSelectionMode, METH_VARARGS | METH_KEYWORDS }, -- 2.45.2