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.", "");
 
 118         wxString , GetId() const,
 
 119         "Returns the name of a custom format (this function will fail for a
 
 120 standard format).", "");
 
 123         void , SetId(const wxString& format),
 
 124         "Sets the format to be the custom format identified by the given name.", "");    
 
 126     %property(Id, GetId, SetId, doc="See `GetId` and `SetId`");
 
 127     %property(Type, GetType, SetType, doc="See `GetType` and `SetType`");
 
 132 const wxDataFormat wxFormatInvalid;
 
 135 //---------------------------------------------------------------------------
 
 139 "A wx.DataObject represents data that can be copied to or from the
 
 140 clipboard, or dragged and dropped. The important thing about
 
 141 wx.DataObject is that this is a 'smart' piece of data unlike usual
 
 142 'dumb' data containers such as memory buffers or files. Being 'smart'
 
 143 here means that the data object itself should know what data formats
 
 144 it supports and how to render itself in each of supported formats.
 
 146 **NOTE**: This class is an abstract base class and can not be used
 
 147 directly from Python.  If you need a custom type of data object then
 
 148 you should instead derive from `wx.PyDataObjectSimple` or use
 
 149 `wx.CustomDataObject`.
 
 151 Not surprisingly, being 'smart' comes at a price of added
 
 152 complexity. This is reasonable for the situations when you really need
 
 153 to support multiple formats, but may be annoying if you only want to
 
 154 do something simple like cut and paste text.
 
 156 To provide a solution for both cases, wxWidgets has two predefined
 
 157 classes which derive from wx.DataObject: `wx.DataObjectSimple` and
 
 158 `wx.DataObjectComposite`.  `wx.DataObjectSimple` is the simplest
 
 159 wx.DataObject possible and only holds data in a single format (such as
 
 160 text or bitmap) and `wx.DataObjectComposite` is the simplest way to
 
 161 implement a wx.DataObject which supports multiple simultaneous formats
 
 162 because it achievs this by simply holding several
 
 163 `wx.DataObjectSimple` objects.
 
 165 Please note that the easiest way to use drag and drop and the
 
 166 clipboard with multiple formats is by using `wx.DataObjectComposite`,
 
 167 but it is not the most efficient one as each `wx.DataObjectSimple`
 
 168 would contain the whole data in its respective formats. Now imagine
 
 169 that you want to paste 200 pages of text in your proprietary format,
 
 170 as well as Word, RTF, HTML, Unicode and plain text to the clipboard
 
 171 and even today's computers are in trouble. For this case, you will
 
 172 have to derive from wx.DataObject directly and make it enumerate its
 
 173 formats and provide the data in the requested format on
 
 174 demand. (**TODO**: This is currently not possible from Python.  Make
 
 177 Note that the platform transfer mechanisms for the clipboard and drag
 
 178 and drop, do not copy any data out of the source application until
 
 179 another application actually requests the data. This is in contrast to
 
 180 the 'feel' offered to the user of a program who would normally think
 
 181 that the data resides in the clipboard after having pressed 'Copy' -
 
 182 in reality it is only declared to be available.
 
 186 // There are several predefined data object classes derived from
 
 187 // wxDataObjectSimple: wxFileDataObject, wxTextDataObject and
 
 188 // wxBitmapDataObject which can be used without change.
 
 190 // You may also derive your own data object classes from
 
 191 // wxCustomDataObject for user-defined types. The format of user-defined
 
 192 // data is given as mime-type string literal, such as 'application/word'
 
 193 // or 'image/png'. These strings are used as they are under Unix (so far
 
 194 // only GTK) to identify a format and are translated into their Windows
 
 195 // equivalent under Win32 (using the OLE IDataObject for data exchange to
 
 196 // and from the clipboard and for drag and drop). Note that the format
 
 197 // string translation under Windows is not yet finished.
 
 204         Get  = 0x01,    // format is supported by GetDataHere()
 
 205         Set  = 0x02,    // format is supported by SetData()
 
 206         Both = 0x03     // format is supported by both (unused currently)
 
 209     // wxDataObject();  // ***  It's an ABC.
 
 213         virtual wxDataFormat , GetPreferredFormat(Direction dir = Get) const,
 
 214         "Returns the preferred format for either rendering the data (if dir is
 
 215 Get, its default value) or for setting it. Usually this will be the
 
 216 native format of the wx.DataObject.", "");
 
 220         virtual size_t , GetFormatCount(Direction dir = Get) const,
 
 221         "Returns the number of available formats for rendering or setting the
 
 226         bool , IsSupported(const wxDataFormat& format, Direction dir = Get) const,
 
 227         "Returns True if this format is supported.", "");
 
 231         virtual size_t , GetDataSize(const wxDataFormat& format) const,
 
 232         "Get the (total) size of data for the given format", "");
 
 237         DocAStr(GetAllFormats,
 
 238                 "GetAllFormats(self, int dir=Get) -> [formats]",
 
 239                 "Returns a list of all the wx.DataFormats that this dataobject supports
 
 240 in the given direction.", "");
 
 241         PyObject* GetAllFormats(Direction dir = Get) {
 
 242             size_t count = self->GetFormatCount(dir);
 
 243             wxDataFormat* formats = new wxDataFormat[count];
 
 244             self->GetAllFormats(formats, dir);
 
 246             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 247             PyObject* list = PyList_New(count);
 
 248             for (size_t i=0; i<count; i++) {
 
 249                 wxDataFormat* format = new wxDataFormat(formats[i]);
 
 250                 PyObject* obj = wxPyConstructObject((void*)format, wxT("wxDataFormat"), true);
 
 251                 PyList_SET_ITEM(list, i, obj); // PyList_SET_ITEM steals a reference
 
 253             wxPyEndBlockThreads(blocked);
 
 261     // copy raw data (in the specified format) to the provided buffer, return
 
 262     // True if data copied successfully, False otherwise
 
 263     // virtual bool GetDataHere(const wxDataFormat& format, void *buf) const;
 
 267                 "GetDataHere(self, DataFormat format) -> String",
 
 268                 "Get the data bytes in the specified format, returns None on failure.", "
 
 269 :todo: This should use the python buffer interface isntead...");
 
 270         PyObject* GetDataHere(const wxDataFormat& format) {
 
 271             PyObject* rval = NULL;
 
 272             size_t size = self->GetDataSize(format);            
 
 273             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 275                 char* buf = new char[size];
 
 276                 if (self->GetDataHere(format, buf)) 
 
 277                     rval = PyString_FromStringAndSize(buf, size);
 
 284             wxPyEndBlockThreads(blocked);
 
 290     // get data from the buffer of specified length (in the given format),
 
 291     // return True if the data was read successfully, False otherwise
 
 292     //virtual bool SetData(const wxDataFormat& format,
 
 293     //                     size_t len, const void * buf);
 
 295             "SetData(self, DataFormat format, String data) -> bool",
 
 296             "Set the data in the specified format from the bytes in the the data string.
 
 298 :todo: This should use the python buffer interface isntead...");
 
 300         bool SetData(const wxDataFormat& format, PyObject* data) {
 
 302             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 303             if (PyString_Check(data)) {
 
 304                 rval = self->SetData(format, PyString_Size(data), PyString_AsString(data));
 
 307                 // raise a TypeError if not a string
 
 308                 PyErr_SetString(PyExc_TypeError, "String expected.");
 
 311             wxPyEndBlockThreads(blocked);
 
 316     %property(AllFormats, GetAllFormats, doc="See `GetAllFormats`");
 
 317     %property(DataHere, GetDataHere, doc="See `GetDataHere`");
 
 318     %property(DataSize, GetDataSize, doc="See `GetDataSize`");
 
 319     %property(FormatCount, GetFormatCount, doc="See `GetFormatCount`");
 
 320     %property(PreferredFormat, GetPreferredFormat, doc="See `GetPreferredFormat`");
 
 325 //---------------------------------------------------------------------------
 
 328 DocStr(wxDataObjectSimple,
 
 329 "wx.DataObjectSimple is a `wx.DataObject` which only supports one
 
 330 format.  This is the simplest possible `wx.DataObject` implementation.
 
 332 This is still an \"abstract base class\" meaning that you can't use it
 
 333 directly.  You either need to use one of the predefined base classes,
 
 334 or derive your own class from `wx.PyDataObjectSimple`.
 
 337 class wxDataObjectSimple : public wxDataObject {
 
 340         wxDataObjectSimple(const wxDataFormat& format = wxFormatInvalid),
 
 341         "Constructor accepts the supported format (none by default) which may
 
 342 also be set later with `SetFormat`.","");
 
 346         const wxDataFormat& , GetFormat(),
 
 347         "Returns the (one and only one) format supported by this object. It is
 
 348 assumed that the format is supported in both directions.", "");
 
 351         void , SetFormat(const wxDataFormat& format),
 
 352         "Sets the supported format.", "");   
 
 355         virtual size_t , GetDataSize() const,
 
 356         "Get the size of our data.", "");
 
 362                 "GetDataHere(self) -> String",
 
 363                 "Returns the data bytes from the data object as a string, returns None
 
 364 on failure.  Must be implemented in the derived class if the object
 
 365 supports rendering its data.", "");
 
 366         PyObject* GetDataHere() {
 
 367             PyObject* rval = NULL;
 
 368             size_t size = self->GetDataSize();            
 
 369             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 371                 char* buf = new char[size];
 
 372                 if (self->GetDataHere(buf)) 
 
 373                     rval = PyString_FromStringAndSize(buf, size);
 
 380             wxPyEndBlockThreads(blocked);
 
 388                 "SetData(self, String data) -> bool",
 
 389                 "Copy the data value to the data object.  Must be implemented in the
 
 390 derived class if the object supports setting its data.
 
 392         bool SetData(PyObject* data) {
 
 394             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 395             if (PyString_Check(data)) {
 
 396                 rval = self->SetData(PyString_Size(data), PyString_AsString(data));
 
 399                 // raise a TypeError if not a string
 
 400                 PyErr_SetString(PyExc_TypeError, "String expected.");
 
 403             wxPyEndBlockThreads(blocked);
 
 408     %property(Format, GetFormat, SetFormat, doc="See `GetFormat` and `SetFormat`");
 
 414 %{  // Create a new class for wxPython to use
 
 415 class wxPyDataObjectSimple : public wxDataObjectSimple {
 
 417     wxPyDataObjectSimple(const wxDataFormat& format = wxFormatInvalid)
 
 418         : wxDataObjectSimple(format) {}
 
 420     DEC_PYCALLBACK_SIZET__const(GetDataSize);
 
 421     bool GetDataHere(void *buf) const;
 
 422     bool SetData(size_t len, const void *buf);
 
 426 IMP_PYCALLBACK_SIZET__const(wxPyDataObjectSimple, wxDataObjectSimple, GetDataSize);
 
 428 bool wxPyDataObjectSimple::GetDataHere(void *buf) const {
 
 429     // We need to get the data for this object and write it to buf.  I think
 
 430     // the best way to do this for wxPython is to have the Python method
 
 431     // return either a string or None and then act appropriately with the
 
 435     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 436     if (wxPyCBH_findCallback(m_myInst, "GetDataHere")) {
 
 438         ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
 
 440             rval = (ro != Py_None && PyString_Check(ro));
 
 442                 memcpy(buf, PyString_AsString(ro), PyString_Size(ro));
 
 446     wxPyEndBlockThreads(blocked);
 
 450 bool wxPyDataObjectSimple::SetData(size_t len, const void *buf) {
 
 451     // For this one we simply need to make a string from buf and len
 
 452     // and send it to the Python method.
 
 454     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 455     if (wxPyCBH_findCallback(m_myInst, "SetData")) {
 
 456         PyObject* data = PyString_FromStringAndSize((char*)buf, len);
 
 457         rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", data));
 
 460     wxPyEndBlockThreads(blocked);
 
 467 // Now define it for SWIG
 
 468 DocStr(wxPyDataObjectSimple,
 
 469 "wx.PyDataObjectSimple is a version of `wx.DataObjectSimple` that is
 
 470 Python-aware and knows how to reflect calls to its C++ virtual methods
 
 471 to methods in the Python derived class.  You should derive from this
 
 472 class and overload `GetDataSize`, `GetDataHere` and `SetData` when you
 
 473 need to create your own simple single-format type of `wx.DataObject`.
 
 475 Here is a simple example::
 
 477     class MyDataObject(wx.PyDataObjectSimple):
 
 479             wx.PyDataObjectSimple.__init__(
 
 480                 self, wx.CustomDataFormat('MyDOFormat'))
 
 483         def GetDataSize(self):
 
 484             return len(self.data)
 
 485         def GetDataHere(self):
 
 486             return self.data  # returns a string  
 
 487         def SetData(self, data):
 
 491 Note that there is already a `wx.CustomDataObject` class that behaves
 
 492 very similarly to this example.  The value of creating your own
 
 493 derived class like this is to be able to do additional things when the
 
 494 data is requested or given via the clipboard or drag and drop
 
 495 operation, such as generate the data value or decode it into needed
 
 498 class wxPyDataObjectSimple : public wxDataObjectSimple {
 
 500     %pythonAppend wxPyDataObjectSimple   "self._setCallbackInfo(self, PyDataObjectSimple)"
 
 502     wxPyDataObjectSimple(const wxDataFormat& format = wxFormatInvalid);
 
 503     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 507 //---------------------------------------------------------------------------
 
 510 DocStr(wxDataObjectComposite,
 
 511 "wx.DataObjectComposite is the simplest `wx.DataObject` derivation
 
 512 which may be sued to support multiple formats. It contains several
 
 513 'wx.DataObjectSimple` objects and supports any format supported by at
 
 514 least one of them. Only one of these data objects is *preferred* (the
 
 515 first one if not explicitly changed by using the second parameter of
 
 516 `Add`) and its format determines the preferred format of the composite
 
 519 See `wx.DataObject` documentation for the reasons why you might prefer
 
 520 to use wx.DataObject directly instead of wx.DataObjectComposite for
 
 524 class wxDataObjectComposite : public wxDataObject {
 
 526     wxDataObjectComposite();
 
 528     %disownarg( wxDataObjectSimple *dataObject );
 
 531         void , Add(wxDataObjectSimple *dataObject, bool preferred = false),
 
 532         "Adds the dataObject to the list of supported objects and it becomes
 
 533 the preferred object if preferred is True.", "");
 
 535     %cleardisown( wxDataObjectSimple *dataObject );
 
 538         wxDataFormat , GetReceivedFormat() const,
 
 539         "Report the format passed to the `SetData` method.  This should be the
 
 540 format of the data object within the composite that recieved data from
 
 541 the clipboard or the DnD operation.  You can use this method to find
 
 542 out what kind of data object was recieved.", "");
 
 544     %property(ReceivedFormat, GetReceivedFormat, doc="See `GetReceivedFormat`");
 
 547 //---------------------------------------------------------------------------
 
 549 DocStr(wxTextDataObject,
 
 550 "wx.TextDataObject is a specialization of `wx.DataObject` for text
 
 551 data. It can be used without change to paste data into the `wx.Clipboard`
 
 552 or a `wx.DropSource`.
 
 554 Alternativly, you may wish to derive a new class from the
 
 555 `wx.PyTextDataObject` class for providing text on-demand in order to
 
 556 minimize memory consumption when offering data in several formats,
 
 557 such as plain text and RTF, because by default the text is stored in a
 
 558 string in this class, but it might as well be generated on demand when
 
 559 requested. For this, `GetTextLength` and `GetText` will have to be
 
 561 class wxTextDataObject : public wxDataObjectSimple {
 
 564         wxTextDataObject(const wxString& text = wxPyEmptyString),
 
 565         "Constructor, may be used to initialise the text (otherwise `SetText`
 
 566 should be used later).", "");
 
 569         size_t , GetTextLength(),
 
 570         "Returns the data size.  By default, returns the size of the text data
 
 571 set in the constructor or using `SetText`.  This can be overridden (via
 
 572 `wx.PyTextDataObject`) to provide text size data on-demand. It is
 
 573 recommended to return the text length plus 1 for a trailing zero, but
 
 574 this is not strictly required.", "");
 
 577         wxString , GetText(),
 
 578         "Returns the text associated with the data object.", "");
 
 581         void , SetText(const wxString& text),
 
 582         "Sets the text associated with the data object. This method is called
 
 583 when the data object receives the data and, by default, copies the
 
 584 text into the member variable. If you want to process the text on the
 
 585 fly you may wish to override this function (via
 
 586 `wx.PyTextDataObject`.)", "");
 
 588     %property(Text, GetText, SetText, doc="See `GetText` and `SetText`");
 
 589     %property(TextLength, GetTextLength, doc="See `GetTextLength`");
 
 597 %{  // Create a new class for wxPython to use
 
 598 class wxPyTextDataObject : public wxTextDataObject {
 
 600     wxPyTextDataObject(const wxString& text = wxPyEmptyString)
 
 601         : wxTextDataObject(text) {}
 
 603     DEC_PYCALLBACK_SIZET__const(GetTextLength);
 
 604     DEC_PYCALLBACK_STRING__const(GetText);
 
 605     DEC_PYCALLBACK__STRING(SetText);
 
 609 IMP_PYCALLBACK_SIZET__const(wxPyTextDataObject, wxTextDataObject, GetTextLength);
 
 610 IMP_PYCALLBACK_STRING__const(wxPyTextDataObject, wxTextDataObject, GetText);
 
 611 IMP_PYCALLBACK__STRING(wxPyTextDataObject, wxTextDataObject, SetText);
 
 616 // Now define it for SWIG
 
 618 DocStr(wxPyTextDataObject,
 
 619 "wx.PyTextDataObject is a version of `wx.TextDataObject` that is
 
 620 Python-aware and knows how to reflect calls to its C++ virtual methods
 
 621 to methods in the Python derived class.  You should derive from this
 
 622 class and overload `GetTextLength`, `GetText`, and `SetText` when you
 
 623 want to be able to provide text on demand instead of preloading it
 
 624 into the data object.", "");
 
 626 class wxPyTextDataObject : public wxTextDataObject {
 
 628     %pythonAppend wxPyTextDataObject   "self._setCallbackInfo(self, PyTextDataObject)"
 
 630     wxPyTextDataObject(const wxString& text = wxPyEmptyString);
 
 631     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 634 //---------------------------------------------------------------------------
 
 636 DocStr(wxBitmapDataObject,
 
 637 "wx.BitmapDataObject is a specialization of wxDataObject for bitmap
 
 638 data. It can be used without change to paste data into the `wx.Clipboard`
 
 639 or a `wx.DropSource`.
 
 641 :see: `wx.PyBitmapDataObject` if you wish to override `GetBitmap` to increase efficiency.");
 
 643 class wxBitmapDataObject : public wxDataObjectSimple {
 
 646         wxBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap),
 
 647         "Constructor, optionally passing a bitmap (otherwise use `SetBitmap`
 
 651         wxBitmap , GetBitmap() const,
 
 652         "Returns the bitmap associated with the data object.  You may wish to
 
 653 override this method (by deriving from `wx.PyBitmapDataObject`) when
 
 654 offering data on-demand, but this is not required by wxWidgets'
 
 655 internals. Use this method to get data in bitmap form from the
 
 656 `wx.Clipboard`.", "");
 
 659         void , SetBitmap(const wxBitmap& bitmap),
 
 660         "Sets the bitmap associated with the data object. This method is called
 
 661 when the data object receives data. Usually there will be no reason to
 
 662 override this function.", "");
 
 664     %property(Bitmap, GetBitmap, SetBitmap, doc="See `GetBitmap` and `SetBitmap`");
 
 671 %{  // Create a new class for wxPython to use
 
 672 class wxPyBitmapDataObject : public wxBitmapDataObject {
 
 674     wxPyBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap)
 
 675         : wxBitmapDataObject(bitmap) {}
 
 677     wxBitmap GetBitmap() const;
 
 678     void SetBitmap(const wxBitmap& bitmap);
 
 682 wxBitmap wxPyBitmapDataObject::GetBitmap() const {
 
 683     wxBitmap* rval = &wxNullBitmap;
 
 684     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 685     if (wxPyCBH_findCallback(m_myInst, "GetBitmap")) {
 
 688         ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
 
 690             if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap")))
 
 695     wxPyEndBlockThreads(blocked);
 
 699 void wxPyBitmapDataObject::SetBitmap(const wxBitmap& bitmap) {
 
 700     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 701     if (wxPyCBH_findCallback(m_myInst, "SetBitmap")) {
 
 702         PyObject* bo = wxPyConstructObject((void*)&bitmap, wxT("wxBitmap"), false);
 
 703         wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", bo));
 
 706     wxPyEndBlockThreads(blocked);
 
 713 DocStr(wxPyBitmapDataObject,
 
 714 "wx.PyBitmapDataObject is a version of `wx.BitmapDataObject` that is
 
 715 Python-aware and knows how to reflect calls to its C++ virtual methods
 
 716 to methods in the Python derived class. To be able to provide bitmap
 
 717 data on demand derive from this class and overload `GetBitmap`.", "");
 
 719 class wxPyBitmapDataObject : public wxBitmapDataObject {
 
 721     %pythonAppend wxPyBitmapDataObject   "self._setCallbackInfo(self, PyBitmapDataObject)"
 
 723     wxPyBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap);
 
 724     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 727 //---------------------------------------------------------------------------
 
 730 DocStr(wxFileDataObject,
 
 731 "wx.FileDataObject is a specialization of `wx.DataObjectSimple` for
 
 732 file names. The program works with it just as if it were a list of
 
 733 absolute file names, but internally it uses the same format as
 
 734 Explorer and other compatible programs under Windows or GNOME/KDE
 
 735 filemanager under Unix which makes it possible to receive files from
 
 736 them using this class.", "");
 
 738 class wxFileDataObject : public wxDataObjectSimple
 
 746         const wxArrayString& , GetFilenames(),
 
 747         "GetFilenames(self) -> [names]",
 
 748         "Returns a list of file names.", "");
 
 751         void , AddFile(const wxString &filename),
 
 752         "Adds a file to the list of files represented by this data object.", "");
 
 754     %property(Filenames, GetFilenames, doc="See `GetFilenames`");
 
 757 //---------------------------------------------------------------------------
 
 759 DocStr(wxCustomDataObject,
 
 760 "wx.CustomDataObject is a specialization of `wx.DataObjectSimple` for
 
 761 some application-specific data in arbitrary format.  Python strings
 
 762 are used for getting and setting data, but any picklable object can
 
 763 easily be transfered via strings.  A copy of the data is stored in the
 
 766 class wxCustomDataObject : public wxDataObjectSimple {
 
 768     %nokwargs wxCustomDataObject;
 
 769     wxCustomDataObject(const wxDataFormat& format);
 
 771         wxCustomDataObject(const wxString& formatName) {
 
 772             return new wxCustomDataObject(wxDataFormat(formatName));
 
 775     wxCustomDataObject();
 
 780                 "SetData(self, String data) -> bool",
 
 781                 "Copy the data value to the data object.", "");
 
 782         bool SetData(PyObject* data) {
 
 784             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 785             if (PyString_Check(data)) {
 
 786                 rval = self->SetData(PyString_Size(data), PyString_AsString(data));
 
 789                 // raise a TypeError if not a string
 
 790                 PyErr_SetString(PyExc_TypeError, "String expected.");
 
 793             wxPyEndBlockThreads(blocked);
 
 797     %pythoncode { TakeData = SetData }
 
 801         "Get the size of the data.", "");
 
 806                 "GetData(self) -> String",
 
 807                 "Returns the data bytes from the data object as a string.", "");
 
 808         PyObject* GetData() {
 
 810             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 811             obj = PyString_FromStringAndSize((char*)self->GetData(), self->GetSize());
 
 812             wxPyEndBlockThreads(blocked);
 
 817     %property(Data, GetData, SetData, doc="See `GetData` and `SetData`");
 
 818     %property(Size, GetSize, doc="See `GetSize`");
 
 823 //---------------------------------------------------------------------------
 
 825 DocStr(wxURLDataObject,
 
 826 "This data object holds a URL in a format that is compatible with some
 
 827 browsers such that it is able to be dragged to or from them.", "");
 
 828 class wxURLDataObject : public wxDataObject/*Composite*/ {
 
 830     wxURLDataObject(const wxString& url = wxPyEmptyString);
 
 834         "Returns a string containing the current URL.", "");
 
 837         void , SetURL(const wxString& url),
 
 840     %property(URL, GetURL, SetURL, doc="See `GetURL` and `SetURL`");
 
 843 //---------------------------------------------------------------------------
 
 845 #if defined(__WXMSW__) || defined(__WXMAC__)
 
 848 #include <wx/metafile.h>
 
 851 class wxMetafileDataObject : public wxDataObjectSimple
 
 854     wxMetafileDataObject();
 
 856     void SetMetafile(const wxMetafile& metafile);
 
 857     wxMetafile GetMetafile() const;
 
 863 class wxMetafileDataObject : public wxDataObjectSimple
 
 866     wxMetafileDataObject() { wxPyRaiseNotImplemented(); }
 
 870 class wxMetafileDataObject : public wxDataObjectSimple
 
 873     wxMetafileDataObject();
 
 878 //---------------------------------------------------------------------------
 
 879 //---------------------------------------------------------------------------