1 \section{\class{wxTextDataObject
}}\label{wxtextdataobject
}
3 wxTextDataObject is a specialization of wxDataObject for text data. It can be
4 used without change to paste data into the
\helpref{wxClipboard
}{wxclipboard
}
5 or a
\helpref{wxDropSource
}{wxdropsource
}. A user may wish to derive a new
6 class from this class for providing text on-demand in order to minimize memory
7 consumption when offering data in several formats, such as plain text and RTF
8 because by default the text is stored in a string in this class, but it might
9 as well be generated when requested. For this,
10 \helpref{GetTextLength
}{wxtextdataobjectgettextlength
} and
11 \helpref{GetText
}{wxtextdataobjectgettext
} will have to be overridden.
13 Note that if you already have the text inside a string, you will not achieve
14 any efficiency gain by overriding these functions because copying wxStrings is
15 already a very efficient operation (data is not actualyl copied because
16 wxStrings are reference counted).
18 \wxheading{Virtual functions to override
}
20 This class may be used as is, but all of data transfer functions may be
21 overridden to increase efficiency.
23 \wxheading{Derived from
}
25 \helpref{wxDataObjectSimple
}{wxdataobjectsimple
}\\
26 \helpref{wxDataObject
}{wxdataobject
}
28 \wxheading{Include files
}
34 \helpref{Clipboard and drag and drop overview
}{wxdndoverview
},
35 \helpref{wxDataObject
}{wxdataobject
},
36 \helpref{wxDataObjectSimple
}{wxdataobjectsimple
},
37 \helpref{wxFileDataObject
}{wxfiledataobject
},
38 \helpref{wxBitmapDataObject
}{wxbitmapdataobject
}
40 \latexignore{\rtfignore{\wxheading{Members
}}}
42 \membersection{wxTextDataObject::wxTextDataObject
}\label{wxtextdataobjectwxtextdataobject
}
44 \func{}{wxTextDataObject
}{\param{const wxString\&
}{text = wxEmptyString
}}
46 Constructor, may be used to initialise the text (otherwise
47 \helpref{SetText
}{wxtextdataobjectsettext
} should be used later).
49 \membersection{wxTextDataObject::GetTextLength
}\label{wxtextdataobjectgettextlength
}
51 \constfunc{virtual size
\_t}{GetTextLength
}{\void}
53 Returns the data size. By default, returns the size of the text data
54 set in the constructor or using
\helpref{SetText
}{wxtextdataobjectsettext
}.
55 This can be overridden to provide text size data on-demand. It is recommended
56 to return the text length plus
1 for a trailing zero, but this is not
59 \membersection{wxTextDataObject::GetText
}\label{wxtextdataobjectgettext
}
61 \constfunc{virtual wxString
}{GetText
}{\void}
63 Returns the text associated with the data object. You may wish to override
64 this method when offering data on-demand, but this is not required by
65 wxWindows' internals. Use this method to get data in text form from
66 the
\helpref{wxClipboard
}{wxclipboard
}.
68 \membersection{wxTextDataObject::SetText
}\label{wxtextdataobjectsettext
}
70 \func{virtual void
}{SetText
}{\param{const wxString\&
}{strText
}}
72 Sets the text associated with the data object. This method is called
73 when the data object receives the data and, by default, copies the text into
74 the member variable. If you want to process the text on the fly you may wish to
75 override this function.