⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tclipbrd.tex

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 TEX
字号:
\section{wxDataObject overview}\label{wxdataobjectoverview}Classes: \helpref{wxDataObject}{wxdataobject}, \helpref{wxClipboard}{wxclipboard}, \helpref{wxDataFormat}{wxdataformat}, \helpref{wxDropSource}{wxdropsource}, \helpref{wxDropTarget}{wxdroptarget}See also: \helpref{Drag and drop overview}{wxdndoverview} and \helpref{DnD sample}{samplednd}This overview discusses data transfer through clipboard or drag and drop. InwxWidgets, these two ways to transfer data (either between differentapplications or inside one and the same) are very similar which allows toimplement both of them using almost the same code - or, in otherwords, if you implement drag and drop support for your application, you getclipboard support for free and vice versa.At the heart of both clipboard and drag and drop operations lies the \helpref{wxDataObject}{wxdataobject} class. The objects of this class (or, tobe precise, classes derived from it) represent the data which is being carriedby the mouse during drag and drop operation or copied to or pasted from theclipboard. wxDataObject is a "smart" piece of data because it knows whichformats it supports (see GetFormatCount and GetAllFormats) and knows how torender itself in any of them (see GetDataHere). It can also receive its valuefrom the outside in a format it supports if it implements the SetData method.Please see the documentation of this class for more details.Both clipboard and drag and drop operations have two sides: the source andtarget, the data provider and the data receiver. These which may be in the sameapplication and even the same window when, for example, you drag some text fromone position to another in a word processor. Let us describe what each of themshould do.\subsection{The data provider (source) duties}\label{wxdataobjectsource}The data provider is responsible for creating a \helpref{wxDataObject}{wxdataobject} containing the data to betransferred. Then it should either pass it to the clipboard using \helpref{SetData}{wxclipboardsetdata} function or to \helpref{wxDropSource}{wxdropsource} and call \helpref{DoDragDrop}{wxdropsourcedodragdrop} function.The only (but important) difference is that the object for the clipboardtransfer must always be created on the heap (i.e. using {\tt new}) and it willbe freed by the clipboard when it is no longer needed (indeed, it is not knownin advance when, if ever, the data will be pasted from the clipboard). On theother hand, the object for drag and drop operation must only exist while \helpref{DoDragDrop}{wxdropsourcedodragdrop} executes and may be safely deletedafterwards and so can be created either on heap or on stack (i.e. as a localvariable).Another small difference is that in the case of clipboard operation, theapplication usually knows in advance whether it copies or cuts (i.e. copies anddeletes) data - in fact, this usually depends on which menu item the userchose. But for drag and drop it can only know it after \helpref{DoDragDrop}{wxdropsourcedodragdrop} returns (from its return value).\subsection{The data receiver (target) duties}\label{wxdataobjecttarget}To receive (paste in usual terminology) data from the clipboard, you shouldcreate a \helpref{wxDataObject}{wxdataobject} derived class which supports thedata formats you need and pass it as argument to \helpref{wxClipboard::GetData}{wxclipboardgetdata}. If it returns {\tt false},no data in (any of) the supported format(s) is available. If it returns {\tttrue}, the data has been successfully transferred to wxDataObject.For drag and drop case, the \helpref{wxDropTarget::OnData}{wxdroptargetondata} virtual function will be called when a data object is dropped, from which thedata itself may be requested by calling \helpref{wxDropTarget::GetData}{wxdroptargetwxdroptarget} method which fillsthe data object.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -