wxTextDataObject is a specialization of wxDataObject for text data. It can be used without change to paste data into the wxClipboard or a wxDropSource. A user may wish to derive a new class from this class for providing text on-demand in order to minimize memory consumption when offering data in several formats, such as plain text and RTF.
In order to offer text data on-demand GetSize and WriteData will have to be overridden.
Derived from
Include files
<wx/dataobj.h>
See also
Members
wxTextDataObject::wxTextDataObject
wxTextDataObject::GetSize
wxTextDataObject::GetText
wxTextDataObject::SetText
wxTextDataObject::WriteData
wxTextDataObject::WriteString
wxTextDataObject()
Default constructor. Call SetText later or override WriteData and GetSize for providing data on-demand.
wxTextDataObject(const wxString& strText)
Constructor, passing text.
virtual size_t GetSize() const
Returns the data size. By default, returns the size of the text data set in the constructor or using SetText. This can be overridden 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.
virtual wxString GetText() const
Returns the text associated with the data object. You may wish to override this method when offering data on-demand, but this is not required by wxWindows' internals. Use this method to get data in text form from the wxClipboard.
virtual void SetText(const wxString& strText)
Sets the text associated with the data object. This method is called internally when retrieving data from the wxClipboard and may be used to paste data to the clipboard directly (instead of on-demand).
virtual void WriteData(void*dest ) const
Write the data owned by this class to dest. By default, this calls WriteString with the string set in the constructor or using SetText. This can be overridden to provide text data on-demand; in this case WriteString must be called from within the overriding WriteData() method.
void WriteString(const wxString& strvoid*dest ) const
Writes the the string str to dest. This method must be called from WriteData.