contents up previous next

wxtextdataobject

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 because by default the text is stored in a string in this class, but it might as well be generated when requested. for this, gettextlength and gettext will have to be overridden.

note that if you already have the text inside a string, you will not achieve any efficiency gain by overriding these functions because copying wxstrings is already a very efficient operation (data is not actually copied because wxstrings are reference counted).

wxpython note: if you wish to create a derived wxtextdataobject class in wxpython you should derive the class from wxpytextdataobject in order to get python-aware capabilities for the various virtual methods.

virtual functions to override

this class may be used as is, but all of the data transfer functions may be overridden to increase efficiency.

derived from

wxdataobjectsimple
wxdataobject

include files

<wx/dataobj.h>

see also

clipboard and drag and drop overview, wxdataobject, wxdataobjectsimple, wxfiledataobject, wxbitmapdataobject

members

wxtextdataobject::wxtextdataobject
wxtextdataobject::gettextlength
wxtextdataobject::gettext
wxtextdataobject::settext


wxtextdataobject::wxtextdataobject

wxtextdataobject(const wxstring& text = wxemptystring)

constructor, may be used to initialise the text (otherwise settext should be used later).


wxtextdataobject::gettextlength

virtual size_t gettextlength() 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.


wxtextdataobject::gettext

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 wxwidgets' internals. use this method to get data in text form from the wxclipboard.


wxtextdataobject::settext

virtual void settext(const wxstring& strtext)

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.