1 /////////////////////////////////////////////////////////////////////////////
 
   3 // Purpose:     SWIG definitions for the Data Object classes
 
   7 // Created:     31-October-1999
 
   9 // Copyright:   (c) 2003 by Total Control Software
 
  10 // Licence:     wxWindows license
 
  11 /////////////////////////////////////////////////////////////////////////////
 
  16 //---------------------------------------------------------------------------
 
  19 #include <wx/dataobj.h>
 
  22 //---------------------------------------------------------------------------
 
  52 "A wx.DataFormat is an encapsulation of a platform-specific format
 
  53 handle which is used by the system for the clipboard and drag and drop
 
  54 operations. The applications are usually only interested in, for
 
  55 example, pasting data from the clipboard only if the data is in a
 
  56 format the program understands.  A data format is is used to uniquely
 
  57 identify this format.",
 
  59 On the system level, a data format is usually just a number, (which
 
  60 may be the CLIPFORMAT under Windows or Atom under X11, for example.)
 
  62 The standard format IDs are:
 
  64     ================    =====================================
 
  65     wx.DF_INVALID       An invalid format
 
  66     wx.DF_TEXT          Text format 
 
  67     wx.DF_BITMAP        A bitmap (wx.Bitmap)
 
  68     wx.DF_METAFILE      A metafile (wx.Metafile, Windows only)
 
  69     wx.DF_FILENAME      A list of filenames
 
  70     wx.DF_HTML          An HTML string. This is only valid on
 
  71                         Windows and non-unicode builds
 
  72     ================    =====================================
 
  74 Besies the standard formats, the application may also use custom
 
  75 formats which are identified by their names (strings) and not numeric
 
  76 identifiers. Although internally custom format must be created (or
 
  77 registered) first, you shouldn\'t care about it because it is done
 
  78 automatically the first time the wxDataFormat object corresponding to
 
  79 a given format name is created.
 
  86         wxDataFormat( wxDataFormatId type ),
 
  87         "Constructs a data format object for one of the standard data formats
 
  88 or an empty data object (use SetType or SetId later in this case)", "");
 
  91         wxDataFormat(const wxString& format),
 
  92         "Constructs a data format object for a custom format identified by its
 
 100     %nokwargs operator!=;
 
 101     bool operator==(wxDataFormatId format) const;
 
 102     bool operator!=(wxDataFormatId format) const;
 
 103     bool operator==(const wxDataFormat& format) const;
 
 104     bool operator!=(const wxDataFormat& format) const;
 
 108         void , SetType(wxDataFormatId format),
 
 109         "Sets the format to the given value, which should be one of wx.DF_XXX
 
 113         wxDataFormatId , GetType() const,
 
 114         "Returns the platform-specific number identifying the format.", "");
 
 117     %Rename(_GetId, wxString , GetId() const);
 
 120             """Returns the name of a custom format (this function will fail for a
 
 127         void , SetId(const wxString& format),
 
 128         "Sets the format to be the custom format identified by the given name.", "");    
 
 130     %property(Id, GetId, SetId, doc="See `GetId` and `SetId`");
 
 131     %property(Type, GetType, SetType, doc="See `GetType` and `SetType`");
 
 136 const wxDataFormat wxFormatInvalid;
 
 139 //---------------------------------------------------------------------------
 
 143 "A wx.DataObject represents data that can be copied to or from the
 
 144 clipboard, or dragged and dropped. The important thing about
 
 145 wx.DataObject is that this is a 'smart' piece of data unlike usual
 
 146 'dumb' data containers such as memory buffers or files. Being 'smart'
 
 147 here means that the data object itself should know what data formats
 
 148 it supports and how to render itself in each of supported formats.
 
 150 **NOTE**: This class is an abstract base class and can not be used
 
 151 directly from Python.  If you need a custom type of data object then
 
 152 you should instead derive from `wx.PyDataObjectSimple` or use
 
 153 `wx.CustomDataObject`.
 
 155 Not surprisingly, being 'smart' comes at a price of added
 
 156 complexity. This is reasonable for the situations when you really need
 
 157 to support multiple formats, but may be annoying if you only want to
 
 158 do something simple like cut and paste text.
 
 160 To provide a solution for both cases, wxWidgets has two predefined
 
 161 classes which derive from wx.DataObject: `wx.DataObjectSimple` and
 
 162 `wx.DataObjectComposite`.  `wx.DataObjectSimple` is the simplest
 
 163 wx.DataObject possible and only holds data in a single format (such as
 
 164 text or bitmap) and `wx.DataObjectComposite` is the simplest way to
 
 165 implement a wx.DataObject which supports multiple simultaneous formats
 
 166 because it achievs this by simply holding several
 
 167 `wx.DataObjectSimple` objects.
 
 169 Please note that the easiest way to use drag and drop and the
 
 170 clipboard with multiple formats is by using `wx.DataObjectComposite`,
 
 171 but it is not the most efficient one as each `wx.DataObjectSimple`
 
 172 would contain the whole data in its respective formats. Now imagine
 
 173 that you want to paste 200 pages of text in your proprietary format,
 
 174 as well as Word, RTF, HTML, Unicode and plain text to the clipboard
 
 175 and even today's computers are in trouble. For this case, you will
 
 176 have to derive from wx.DataObject directly and make it enumerate its
 
 177 formats and provide the data in the requested format on
 
 178 demand. (**TODO**: This is currently not possible from Python.  Make
 
 181 Note that the platform transfer mechanisms for the clipboard and drag
 
 182 and drop, do not copy any data out of the source application until
 
 183 another application actually requests the data. This is in contrast to
 
 184 the 'feel' offered to the user of a program who would normally think
 
 185 that the data resides in the clipboard after having pressed 'Copy' -
 
 186 in reality it is only declared to be available.
 
 190 // There are several predefined data object classes derived from
 
 191 // wxDataObjectSimple: wxFileDataObject, wxTextDataObject and
 
 192 // wxBitmapDataObject which can be used without change.
 
 194 // You may also derive your own data object classes from
 
 195 // wxCustomDataObject for user-defined types. The format of user-defined
 
 196 // data is given as mime-type string literal, such as 'application/word'
 
 197 // or 'image/png'. These strings are used as they are under Unix (so far
 
 198 // only GTK) to identify a format and are translated into their Windows
 
 199 // equivalent under Win32 (using the OLE IDataObject for data exchange to
 
 200 // and from the clipboard and for drag and drop). Note that the format
 
 201 // string translation under Windows is not yet finished.
 
 208         Get  = 0x01,    // format is supported by GetDataHere()
 
 209         Set  = 0x02,    // format is supported by SetData()
 
 210         Both = 0x03     // format is supported by both (unused currently)
 
 213     // wxDataObject();  // ***  It's an ABC.
 
 217         virtual wxDataFormat , GetPreferredFormat(Direction dir = Get) const,
 
 218         "Returns the preferred format for either rendering the data (if dir is
 
 219 Get, its default value) or for setting it. Usually this will be the
 
 220 native format of the wx.DataObject.", "");
 
 224         virtual size_t , GetFormatCount(Direction dir = Get) const,
 
 225         "Returns the number of available formats for rendering or setting the
 
 230         bool , IsSupported(const wxDataFormat& format, Direction dir = Get) const,
 
 231         "Returns True if this format is supported.", "");
 
 235         virtual size_t , GetDataSize(const wxDataFormat& format) const,
 
 236         "Get the (total) size of data for the given format", "");
 
 241         DocAStr(GetAllFormats,
 
 242                 "GetAllFormats(self, int dir=Get) -> [formats]",
 
 243                 "Returns a list of all the wx.DataFormats that this dataobject supports
 
 244 in the given direction.", "");
 
 245         PyObject* GetAllFormats(Direction dir = Get) {
 
 246             size_t count = self->GetFormatCount(dir);
 
 247             wxDataFormat* formats = new wxDataFormat[count];
 
 248             self->GetAllFormats(formats, dir);
 
 250             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 251             PyObject* list = PyList_New(count);
 
 252             for (size_t i=0; i<count; i++) {
 
 253                 wxDataFormat* format = new wxDataFormat(formats[i]);
 
 254                 PyObject* obj = wxPyConstructObject((void*)format, wxT("wxDataFormat"), true);
 
 255                 PyList_SET_ITEM(list, i, obj); // PyList_SET_ITEM steals a reference
 
 257             wxPyEndBlockThreads(blocked);
 
 265     // copy raw data (in the specified format) to the provided buffer, return
 
 266     // True if data copied successfully, False otherwise
 
 267     // virtual bool GetDataHere(const wxDataFormat& format, void *buf) const;
 
 271                 "GetDataHere(self, DataFormat format) -> String",
 
 272                 "Get the data bytes in the specified format, returns None on failure.", "
 
 273 :todo: This should use the python buffer interface isntead...");
 
 274         PyObject* GetDataHere(const wxDataFormat& format) {
 
 275             PyObject* rval = NULL;
 
 276             size_t size = self->GetDataSize(format);            
 
 277             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 279                 char* buf = new char[size];
 
 280                 if (self->GetDataHere(format, buf)) 
 
 281                     rval = PyString_FromStringAndSize(buf, size);
 
 288             wxPyEndBlockThreads(blocked);
 
 294     // get data from the buffer of specified length (in the given format),
 
 295     // return True if the data was read successfully, False otherwise
 
 296     //virtual bool SetData(const wxDataFormat& format,
 
 297     //                     size_t len, const void * buf);
 
 299             "SetData(self, DataFormat format, String data) -> bool",
 
 300             "Set the data in the specified format from the bytes in the the data string.
 
 302 :todo: This should use the python buffer interface isntead...");
 
 304         bool SetData(const wxDataFormat& format, PyObject* data) {
 
 306             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 307             if (PyString_Check(data)) {
 
 308                 rval = self->SetData(format, PyString_Size(data), PyString_AsString(data));
 
 311                 // raise a TypeError if not a string
 
 312                 PyErr_SetString(PyExc_TypeError, "String expected.");
 
 315             wxPyEndBlockThreads(blocked);
 
 320     %property(AllFormats, GetAllFormats, doc="See `GetAllFormats`");
 
 321     %property(DataHere, GetDataHere, doc="See `GetDataHere`");
 
 322     %property(DataSize, GetDataSize, doc="See `GetDataSize`");
 
 323     %property(FormatCount, GetFormatCount, doc="See `GetFormatCount`");
 
 324     %property(PreferredFormat, GetPreferredFormat, doc="See `GetPreferredFormat`");
 
 329 //---------------------------------------------------------------------------
 
 332 DocStr(wxDataObjectSimple,
 
 333 "wx.DataObjectSimple is a `wx.DataObject` which only supports one
 
 334 format.  This is the simplest possible `wx.DataObject` implementation.
 
 336 This is still an \"abstract base class\" meaning that you can't use it
 
 337 directly.  You either need to use one of the predefined base classes,
 
 338 or derive your own class from `wx.PyDataObjectSimple`.
 
 341 class wxDataObjectSimple : public wxDataObject {
 
 344         wxDataObjectSimple(const wxDataFormat& format = wxFormatInvalid),
 
 345         "Constructor accepts the supported format (none by default) which may
 
 346 also be set later with `SetFormat`.","");
 
 350         const wxDataFormat& , GetFormat(),
 
 351         "Returns the (one and only one) format supported by this object. It is
 
 352 assumed that the format is supported in both directions.", "");
 
 355         void , SetFormat(const wxDataFormat& format),
 
 356         "Sets the supported format.", "");   
 
 359         virtual size_t , GetDataSize() const,
 
 360         "Get the size of our data.", "");
 
 366                 "GetDataHere(self) -> String",
 
 367                 "Returns the data bytes from the data object as a string, returns None
 
 368 on failure.  Must be implemented in the derived class if the object
 
 369 supports rendering its data.", "");
 
 370         PyObject* GetDataHere() {
 
 371             PyObject* rval = NULL;
 
 372             size_t size = self->GetDataSize();            
 
 373             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 375                 char* buf = new char[size];
 
 376                 if (self->GetDataHere(buf)) 
 
 377                     rval = PyString_FromStringAndSize(buf, size);
 
 384             wxPyEndBlockThreads(blocked);
 
 392                 "SetData(self, String data) -> bool",
 
 393                 "Copy the data value to the data object.  Must be implemented in the
 
 394 derived class if the object supports setting its data.
 
 396         bool SetData(PyObject* data) {
 
 398             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 399             if (PyString_Check(data)) {
 
 400                 rval = self->SetData(PyString_Size(data), PyString_AsString(data));
 
 403                 // raise a TypeError if not a string
 
 404                 PyErr_SetString(PyExc_TypeError, "String expected.");
 
 407             wxPyEndBlockThreads(blocked);
 
 412     %property(Format, GetFormat, SetFormat, doc="See `GetFormat` and `SetFormat`");
 
 418 %{  // Create a new class for wxPython to use
 
 419 class wxPyDataObjectSimple : public wxDataObjectSimple {
 
 421     wxPyDataObjectSimple(const wxDataFormat& format = wxFormatInvalid)
 
 422         : wxDataObjectSimple(format) {}
 
 424     DEC_PYCALLBACK_SIZET__const(GetDataSize);
 
 425     bool GetDataHere(void *buf) const;
 
 426     bool SetData(size_t len, const void *buf);
 
 430 IMP_PYCALLBACK_SIZET__const(wxPyDataObjectSimple, wxDataObjectSimple, GetDataSize);
 
 432 bool wxPyDataObjectSimple::GetDataHere(void *buf) const {
 
 433     // We need to get the data for this object and write it to buf.  I think
 
 434     // the best way to do this for wxPython is to have the Python method
 
 435     // return either a string or None and then act appropriately with the
 
 439     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 440     if (wxPyCBH_findCallback(m_myInst, "GetDataHere")) {
 
 442         ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
 
 444             rval = (ro != Py_None && PyString_Check(ro));
 
 446                 memcpy(buf, PyString_AsString(ro), PyString_Size(ro));
 
 450     wxPyEndBlockThreads(blocked);
 
 454 bool wxPyDataObjectSimple::SetData(size_t len, const void *buf) {
 
 455     // For this one we simply need to make a string from buf and len
 
 456     // and send it to the Python method.
 
 458     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 459     if (wxPyCBH_findCallback(m_myInst, "SetData")) {
 
 460         PyObject* data = PyString_FromStringAndSize((char*)buf, len);
 
 461         rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", data));
 
 464     wxPyEndBlockThreads(blocked);
 
 471 // Now define it for SWIG
 
 472 DocStr(wxPyDataObjectSimple,
 
 473 "wx.PyDataObjectSimple is a version of `wx.DataObjectSimple` that is
 
 474 Python-aware and knows how to reflect calls to its C++ virtual methods
 
 475 to methods in the Python derived class.  You should derive from this
 
 476 class and overload `GetDataSize`, `GetDataHere` and `SetData` when you
 
 477 need to create your own simple single-format type of `wx.DataObject`.
 
 479 Here is a simple example::
 
 481     class MyDataObject(wx.PyDataObjectSimple):
 
 483             wx.PyDataObjectSimple.__init__(
 
 484                 self, wx.CustomDataFormat('MyDOFormat'))
 
 487         def GetDataSize(self):
 
 488             return len(self.data)
 
 489         def GetDataHere(self):
 
 490             return self.data  # returns a string  
 
 491         def SetData(self, data):
 
 495 Note that there is already a `wx.CustomDataObject` class that behaves
 
 496 very similarly to this example.  The value of creating your own
 
 497 derived class like this is to be able to do additional things when the
 
 498 data is requested or given via the clipboard or drag and drop
 
 499 operation, such as generate the data value or decode it into needed
 
 502 class wxPyDataObjectSimple : public wxDataObjectSimple {
 
 504     %pythonAppend wxPyDataObjectSimple   setCallbackInfo(PyDataObjectSimple)
 
 506     wxPyDataObjectSimple(const wxDataFormat& format = wxFormatInvalid);
 
 507     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 511 //---------------------------------------------------------------------------
 
 514 DocStr(wxDataObjectComposite,
 
 515 "wx.DataObjectComposite is the simplest `wx.DataObject` derivation
 
 516 which may be sued to support multiple formats. It contains several
 
 517 'wx.DataObjectSimple` objects and supports any format supported by at
 
 518 least one of them. Only one of these data objects is *preferred* (the
 
 519 first one if not explicitly changed by using the second parameter of
 
 520 `Add`) and its format determines the preferred format of the composite
 
 523 See `wx.DataObject` documentation for the reasons why you might prefer
 
 524 to use wx.DataObject directly instead of wx.DataObjectComposite for
 
 528 class wxDataObjectComposite : public wxDataObject {
 
 530     wxDataObjectComposite();
 
 532     %disownarg( wxDataObjectSimple *dataObject );
 
 535         void , Add(wxDataObjectSimple *dataObject, bool preferred = false),
 
 536         "Adds the dataObject to the list of supported objects and it becomes
 
 537 the preferred object if preferred is True.", "");
 
 539     %cleardisown( wxDataObjectSimple *dataObject );
 
 542         wxDataFormat , GetReceivedFormat() const,
 
 543         "Report the format passed to the `SetData` method.  This should be the
 
 544 format of the data object within the composite that recieved data from
 
 545 the clipboard or the DnD operation.  You can use this method to find
 
 546 out what kind of data object was recieved.", "");
 
 548     %property(ReceivedFormat, GetReceivedFormat, doc="See `GetReceivedFormat`");
 
 551 //---------------------------------------------------------------------------
 
 553 DocStr(wxTextDataObject,
 
 554 "wx.TextDataObject is a specialization of `wx.DataObject` for text
 
 555 data. It can be used without change to paste data into the `wx.Clipboard`
 
 556 or a `wx.DropSource`.
 
 558 Alternativly, you may wish to derive a new class from the
 
 559 `wx.PyTextDataObject` class for providing text on-demand in order to
 
 560 minimize memory consumption when offering data in several formats,
 
 561 such as plain text and RTF, because by default the text is stored in a
 
 562 string in this class, but it might as well be generated on demand when
 
 563 requested. For this, `GetTextLength` and `GetText` will have to be
 
 565 class wxTextDataObject : public wxDataObjectSimple {
 
 568         wxTextDataObject(const wxString& text = wxPyEmptyString),
 
 569         "Constructor, may be used to initialise the text (otherwise `SetText`
 
 570 should be used later).", "");
 
 573         size_t , GetTextLength(),
 
 574         "Returns the data size.  By default, returns the size of the text data
 
 575 set in the constructor or using `SetText`.  This can be overridden (via
 
 576 `wx.PyTextDataObject`) to provide text size data on-demand. It is
 
 577 recommended to return the text length plus 1 for a trailing zero, but
 
 578 this is not strictly required.", "");
 
 581         wxString , GetText(),
 
 582         "Returns the text associated with the data object.", "");
 
 585         void , SetText(const wxString& text),
 
 586         "Sets the text associated with the data object. This method is called
 
 587 when the data object receives the data and, by default, copies the
 
 588 text into the member variable. If you want to process the text on the
 
 589 fly you may wish to override this function (via
 
 590 `wx.PyTextDataObject`.)", "");
 
 592     %property(Text, GetText, SetText, doc="See `GetText` and `SetText`");
 
 593     %property(TextLength, GetTextLength, doc="See `GetTextLength`");
 
 601 %{  // Create a new class for wxPython to use
 
 602 class wxPyTextDataObject : public wxTextDataObject {
 
 604     wxPyTextDataObject(const wxString& text = wxPyEmptyString)
 
 605         : wxTextDataObject(text) {}
 
 607     DEC_PYCALLBACK_SIZET__const(GetTextLength);
 
 608     DEC_PYCALLBACK_STRING__const(GetText);
 
 609     DEC_PYCALLBACK__STRING(SetText);
 
 613 IMP_PYCALLBACK_SIZET__const(wxPyTextDataObject, wxTextDataObject, GetTextLength);
 
 614 IMP_PYCALLBACK_STRING__const(wxPyTextDataObject, wxTextDataObject, GetText);
 
 615 IMP_PYCALLBACK__STRING(wxPyTextDataObject, wxTextDataObject, SetText);
 
 620 // Now define it for SWIG
 
 622 DocStr(wxPyTextDataObject,
 
 623 "wx.PyTextDataObject is a version of `wx.TextDataObject` that is
 
 624 Python-aware and knows how to reflect calls to its C++ virtual methods
 
 625 to methods in the Python derived class.  You should derive from this
 
 626 class and overload `GetTextLength`, `GetText`, and `SetText` when you
 
 627 want to be able to provide text on demand instead of preloading it
 
 628 into the data object.", "");
 
 630 class wxPyTextDataObject : public wxTextDataObject {
 
 632     %pythonAppend wxPyTextDataObject   setCallbackInfo(PyTextDataObject)
 
 634     wxPyTextDataObject(const wxString& text = wxPyEmptyString);
 
 635     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 638 //---------------------------------------------------------------------------
 
 640 DocStr(wxBitmapDataObject,
 
 641 "wx.BitmapDataObject is a specialization of wxDataObject for bitmap
 
 642 data. It can be used without change to paste data into the `wx.Clipboard`
 
 643 or a `wx.DropSource`.
 
 645 :see: `wx.PyBitmapDataObject` if you wish to override `GetBitmap` to increase efficiency.");
 
 647 class wxBitmapDataObject : public wxDataObjectSimple {
 
 650         wxBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap),
 
 651         "Constructor, optionally passing a bitmap (otherwise use `SetBitmap`
 
 655         wxBitmap , GetBitmap() const,
 
 656         "Returns the bitmap associated with the data object.  You may wish to
 
 657 override this method (by deriving from `wx.PyBitmapDataObject`) when
 
 658 offering data on-demand, but this is not required by wxWidgets'
 
 659 internals. Use this method to get data in bitmap form from the
 
 660 `wx.Clipboard`.", "");
 
 663         void , SetBitmap(const wxBitmap& bitmap),
 
 664         "Sets the bitmap associated with the data object. This method is called
 
 665 when the data object receives data. Usually there will be no reason to
 
 666 override this function.", "");
 
 668     %property(Bitmap, GetBitmap, SetBitmap, doc="See `GetBitmap` and `SetBitmap`");
 
 675 %{  // Create a new class for wxPython to use
 
 676 class wxPyBitmapDataObject : public wxBitmapDataObject {
 
 678     wxPyBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap)
 
 679         : wxBitmapDataObject(bitmap) {}
 
 681     wxBitmap GetBitmap() const;
 
 682     void SetBitmap(const wxBitmap& bitmap);
 
 686 wxBitmap wxPyBitmapDataObject::GetBitmap() const {
 
 687     wxBitmap* rval = &wxNullBitmap;
 
 688     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 689     if (wxPyCBH_findCallback(m_myInst, "GetBitmap")) {
 
 692         ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
 
 694             if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap")))
 
 699     wxPyEndBlockThreads(blocked);
 
 703 void wxPyBitmapDataObject::SetBitmap(const wxBitmap& bitmap) {
 
 704     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 705     if (wxPyCBH_findCallback(m_myInst, "SetBitmap")) {
 
 706         PyObject* bo = wxPyConstructObject((void*)&bitmap, wxT("wxBitmap"), false);
 
 707         wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", bo));
 
 710     wxPyEndBlockThreads(blocked);
 
 717 DocStr(wxPyBitmapDataObject,
 
 718 "wx.PyBitmapDataObject is a version of `wx.BitmapDataObject` that is
 
 719 Python-aware and knows how to reflect calls to its C++ virtual methods
 
 720 to methods in the Python derived class. To be able to provide bitmap
 
 721 data on demand derive from this class and overload `GetBitmap`.", "");
 
 723 class wxPyBitmapDataObject : public wxBitmapDataObject {
 
 725     %pythonAppend wxPyBitmapDataObject   setCallbackInfo(PyBitmapDataObject)
 
 727     wxPyBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap);
 
 728     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 731 //---------------------------------------------------------------------------
 
 734 DocStr(wxFileDataObject,
 
 735 "wx.FileDataObject is a specialization of `wx.DataObjectSimple` for
 
 736 file names. The program works with it just as if it were a list of
 
 737 absolute file names, but internally it uses the same format as
 
 738 Explorer and other compatible programs under Windows or GNOME/KDE
 
 739 filemanager under Unix which makes it possible to receive files from
 
 740 them using this class.", "");
 
 742 class wxFileDataObject : public wxDataObjectSimple
 
 750         const wxArrayString& , GetFilenames(),
 
 751         "GetFilenames(self) -> [names]",
 
 752         "Returns a list of file names.", "");
 
 755         void , AddFile(const wxString &filename),
 
 756         "Adds a file to the list of files represented by this data object.", "");
 
 758     %property(Filenames, GetFilenames, doc="See `GetFilenames`");
 
 761 //---------------------------------------------------------------------------
 
 763 DocStr(wxCustomDataObject,
 
 764 "wx.CustomDataObject is a specialization of `wx.DataObjectSimple` for
 
 765 some application-specific data in arbitrary format.  Python strings
 
 766 are used for getting and setting data, but any picklable object can
 
 767 easily be transfered via strings.  A copy of the data is stored in the
 
 770 class wxCustomDataObject : public wxDataObjectSimple {
 
 772     %nokwargs wxCustomDataObject;
 
 773     wxCustomDataObject(const wxDataFormat& format);
 
 775         wxCustomDataObject(const wxString& formatName) {
 
 776             return new wxCustomDataObject(wxDataFormat(formatName));
 
 779     wxCustomDataObject();
 
 784                 "SetData(self, String data) -> bool",
 
 785                 "Copy the data value to the data object.", "");
 
 786         bool SetData(PyObject* data) {
 
 788             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 789             if (PyString_Check(data)) {
 
 790                 rval = self->SetData(PyString_Size(data), PyString_AsString(data));
 
 793                 // raise a TypeError if not a string
 
 794                 PyErr_SetString(PyExc_TypeError, "String expected.");
 
 797             wxPyEndBlockThreads(blocked);
 
 801     %pythoncode { TakeData = SetData }
 
 805         "Get the size of the data.", "");
 
 810                 "GetData(self) -> String",
 
 811                 "Returns the data bytes from the data object as a string.", "");
 
 812         PyObject* GetData() {
 
 814             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 815             obj = PyString_FromStringAndSize((char*)self->GetData(), self->GetSize());
 
 816             wxPyEndBlockThreads(blocked);
 
 821     %property(Data, GetData, SetData, doc="See `GetData` and `SetData`");
 
 822     %property(Size, GetSize, doc="See `GetSize`");
 
 827 //---------------------------------------------------------------------------
 
 829 DocStr(wxURLDataObject,
 
 830 "This data object holds a URL in a format that is compatible with some
 
 831 browsers such that it is able to be dragged to or from them.", "");
 
 832 class wxURLDataObject : public wxDataObject/*Composite*/ {
 
 834     wxURLDataObject(const wxString& url = wxPyEmptyString);
 
 838         "Returns a string containing the current URL.", "");
 
 841         void , SetURL(const wxString& url),
 
 844     %property(URL, GetURL, SetURL, doc="See `GetURL` and `SetURL`");
 
 847 //---------------------------------------------------------------------------
 
 849 #if defined(__WXMSW__) || defined(__WXMAC__)
 
 852 #include <wx/metafile.h>
 
 855 class wxMetafileDataObject : public wxDataObjectSimple
 
 858     wxMetafileDataObject();
 
 860     void SetMetafile(const wxMetafile& metafile);
 
 861     wxMetafile GetMetafile() const;
 
 867 class wxMetafileDataObject : public wxDataObjectSimple
 
 870     wxMetafileDataObject() { wxPyRaiseNotImplemented(); }
 
 874 class wxMetafileDataObject : public wxDataObjectSimple
 
 877     wxMetafileDataObject();
 
 882 //---------------------------------------------------------------------------
 
 883 //---------------------------------------------------------------------------