📄 txtdatob.tex
字号:
\section{\class{wxTextDataObject}}\label{wxtextdataobject}wxTextDataObject is a specialization of wxDataObject for text data. It can beused without change to paste data into the \helpref{wxClipboard}{wxclipboard} or a \helpref{wxDropSource}{wxdropsource}. A user may wish to derive a newclass from this class for providing text on-demand in order to minimize memoryconsumption when offering data in several formats, such as plain text and RTFbecause by default the text is stored in a string in this class, but it mightas well be generated when requested. For this, \helpref{GetTextLength}{wxtextdataobjectgettextlength} and \helpref{GetText}{wxtextdataobjectgettext} will have to be overridden.Note that if you already have the text inside a string, you will not achieveany efficiency gain by overriding these functions because copying wxStrings isalready a very efficient operation (data is not actually copied becausewxStrings are reference counted).\pythonnote{If you wish to create a derived wxTextDataObject class inwxPython you should derive the class from wxPyTextDataObjectin order to get Python-aware capabilities for the various virtualmethods.}\wxheading{Virtual functions to override}This class may be used as is, but all of the data transfer functions may beoverridden to increase efficiency.\wxheading{Derived from}\helpref{wxDataObjectSimple}{wxdataobjectsimple}\\\helpref{wxDataObject}{wxdataobject}\wxheading{Include files}<wx/dataobj.h>\wxheading{See also}\helpref{Clipboard and drag and drop overview}{wxdndoverview}, \helpref{wxDataObject}{wxdataobject}, \helpref{wxDataObjectSimple}{wxdataobjectsimple}, \helpref{wxFileDataObject}{wxfiledataobject}, \helpref{wxBitmapDataObject}{wxbitmapdataobject}\latexignore{\rtfignore{\wxheading{Members}}}\membersection{wxTextDataObject::wxTextDataObject}\label{wxtextdataobjectwxtextdataobject}\func{}{wxTextDataObject}{\param{const wxString\& }{text = wxEmptyString}}Constructor, may be used to initialise the text (otherwise \helpref{SetText}{wxtextdataobjectsettext} should be used later).\membersection{wxTextDataObject::GetTextLength}\label{wxtextdataobjectgettextlength}\constfunc{virtual size\_t}{GetTextLength}{\void}Returns the data size. By default, returns the size of the text dataset in the constructor or using \helpref{SetText}{wxtextdataobjectsettext}.This can be overridden to provide text size data on-demand. It is recommendedto return the text length plus 1 for a trailing zero, but this is notstrictly required.\membersection{wxTextDataObject::GetText}\label{wxtextdataobjectgettext}\constfunc{virtual wxString}{GetText}{\void}Returns the text associated with the data object. You may wish to overridethis method when offering data on-demand, but this is not required bywxWidgets' internals. Use this method to get data in text form fromthe \helpref{wxClipboard}{wxclipboard}.\membersection{wxTextDataObject::SetText}\label{wxtextdataobjectsettext}\func{virtual void}{SetText}{\param{const wxString\& }{strText}}Sets the text associated with the data object. This method is calledwhen the data object receives the data and, by default, copies the text intothe member variable. If you want to process the text on the fly you may wish tooverride this function.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -