Package wx :: Class DataObject
[frames | no frames]

Type DataObject

object --+
         |
        DataObject

Known Subclasses:
DataObjectComposite, DataObjectSimple, URLDataObject

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.

Not surprisingly, being 'smart' comes at a price of added complexity. This is reasonable for the situations when you really need to support multiple formats, but may be annoying if you only want to do something simple like cut and paste text.

To provide a solution for both cases, wxWidgets has two predefined classes which derive from wx.DataObject: wx.DataObjectSimple and wx.DataObjectComposite. wx.DataObjectSimple is the simplest wx.DataObject possible and only holds data in a single format (such as text or bitmap) and wx.DataObjectComposite is the simplest way to implement a wx.DataObject which supports multiple simultaneous formats because it achievs this by simply holding several wx.DataObjectSimple objects.

Please note that the easiest way to use drag and drop and the clipboard with multiple formats is by using wx.DataObjectComposite, but it is not the most efficient one as each wx.DataObjectSimple would contain the whole data in its respective formats. Now imagine that you want to paste 200 pages of text in your proprietary format, as well as Word, RTF, HTML, Unicode and plain text to the clipboard and even today's computers are in trouble. For this case, you will have to derive from wx.DataObject directly and make it enumerate its formats and provide the data in the requested format on demand. (TODO: This is currently not possible from Python. Make it so.)

Note that the platform transfer mechanisms for the clipboard and drag and drop, do not copy any data out of the source application until another application actually requests the data. This is in contrast to the 'feel' offered to the user of a program who would normally think that the data resides in the clipboard after having pressed 'Copy' - in reality it is only declared to be available.


Method Summary
  __init__(self)
  __del__(self)
[formats] GetAllFormats(self, dir)
Returns a list of all the wx.DataFormats that this dataobject supports in the given direction.
String GetDataHere(self, format)
Get the data bytes in the specified format, returns None on failure.
size_t GetDataSize(self, format)
Get the (total) size of data for the given format
size_t GetFormatCount(self, dir)
Returns the number of available formats for rendering or setting the data.
DataFormat GetPreferredFormat(self, dir)
Returns the preferred format for either rendering the data (if dir is Get, its default value) or for setting it.
bool IsSupported(self, format, dir)
Returns True if this format is supported.
bool SetData(self, format, data)
Set the data in the specified format from the bytes in the the data string.

Property Summary
  AllFormats: See GetAllFormats
  DataHere: See GetDataHere
  DataSize: See GetDataSize
  FormatCount: See GetFormatCount
  PreferredFormat: See GetPreferredFormat
  thisown: The membership flag

Class Variable Summary
int Both = 3                                                                     
int Get = 1                                                                     
int Set = 2                                                                     

Method Details

GetAllFormats(self, dir=Get)

Returns a list of all the wx.DataFormats that this dataobject supports in the given direction.

Parameters:
dir
           (type=int)

Returns:
[formats]

GetDataHere(self, format)

Get the data bytes in the specified format, returns None on failure. :todo: This should use the python buffer interface isntead...

Parameters:
format
           (type=DataFormat)

Returns:
String

GetDataSize(self, format)

Get the (total) size of data for the given format

Parameters:
format
           (type=DataFormat)

Returns:
size_t

GetFormatCount(self, dir=Get)

Returns the number of available formats for rendering or setting the data.

Parameters:
dir
           (type=int)

Returns:
size_t

GetPreferredFormat(self, dir=Get)

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.

Parameters:
dir
           (type=int)

Returns:
DataFormat

IsSupported(self, format, dir=Get)

Returns True if this format is supported.

Parameters:
format
           (type=DataFormat)

dir
           (type=int)

Returns:
bool

SetData(self, format, data)

Set the data in the specified format from the bytes in the the data string.

Parameters:
format
           (type=DataFormat)

data
           (type=String)

Returns:
bool

To Do:

This should use the python buffer interface isntead...


Property Details

AllFormats

See GetAllFormats

Get Method:
GetAllFormats(self, dir)

DataHere

See GetDataHere

Get Method:
GetDataHere(self, format)

DataSize

See GetDataSize

Get Method:
GetDataSize(self, format)

FormatCount

See GetFormatCount

Get Method:
GetFormatCount(self, dir)

PreferredFormat

See GetPreferredFormat

Get Method:
GetPreferredFormat(self, dir)

thisown

The membership flag


Class Variable Details

Both

Type:
int
Value:
3                                                                     

Get

Type:
int
Value:
1                                                                     

Set

Type:
int
Value:
2                                                                     

Generated by Epydoc 2.1.20050511.rpd on Thu Mar 22 12:10:32 2007 http://epydoc.sf.net