]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxClipboard}}\label{wxclipboard} |
2 | ||
dface61c JS |
3 | A class for manipulating the clipboard. Note that this is not compatible with the |
4 | clipboard class from wxWindows 1.xx, which has the same name but a different implementation. | |
5 | ||
4ce81a75 JS |
6 | To use the clipboard, you call member functions of the global {\bf wxTheClipboard} object. |
7 | ||
8 | Call \helpref{wxClipboard::Open}{wxclipboardopen} to get ownership of the clipboard. If this operation returns TRUE, you | |
75ce0581 | 9 | now own the clipboard. Call \helpref{wxClipboard::AddData}{wxclipboardadddata} to put data |
dface61c JS |
10 | on the clipboard (one or more times), or \helpref{wxClipboard::GetData}{wxclipboardgetdata} to |
11 | retrieve data from the clipboard. Call \helpref{wxClipboard::Close}{wxclipboardclose} to close | |
12 | the clipboard and relinquish ownership. You should keep the clipboard open only momentarily. | |
13 | ||
14 | For example: | |
15 | ||
16 | \begin{verbatim} | |
dface61c | 17 | // Write some text to the clipboard |
4ce81a75 | 18 | if (wxTheClipboard->Open()) |
dface61c | 19 | { |
75ce0581 RR |
20 | // This data objects are held by the clipboard, |
21 | // so do not delete them in the app. | |
22 | wxTheClipboard->AddData( new wxTextDataObject("Some text") ); | |
4ce81a75 | 23 | wxTheClipboard->Close(); |
dface61c JS |
24 | } |
25 | ||
26 | // Read some text | |
75ce0581 | 27 | if (wxTheClipboard->Open()) |
dface61c | 28 | { |
75ce0581 RR |
29 | wxTextDataObject data; |
30 | if (wxTheClipboard->IsSupported(data)) | |
31 | { | |
32 | wxTheClipboard->GetData(data); | |
33 | wxMessageBox(data.GetText()); | |
34 | } | |
4ce81a75 | 35 | wxTheClipboard->Close(); |
dface61c JS |
36 | } |
37 | \end{verbatim} | |
a660d684 KB |
38 | |
39 | \wxheading{Derived from} | |
40 | ||
41 | \helpref{wxObject}{wxobject} | |
42 | ||
43 | \wxheading{See also} | |
44 | ||
dface61c | 45 | \helpref{Drag and drop overview}{wxdndoverview}, \helpref{wxDataObject}{wxdataobject} |
a660d684 KB |
46 | |
47 | \latexignore{\rtfignore{\wxheading{Members}}} | |
48 | ||
dface61c | 49 | \membersection{wxClipboard::wxClipboard} |
a660d684 | 50 | |
dface61c | 51 | \func{}{wxClipboard}{\void} |
a660d684 | 52 | |
dface61c | 53 | Constructor. |
a660d684 | 54 | |
dface61c | 55 | \membersection{wxClipboard::\destruct{wxClipboard}} |
a660d684 | 56 | |
dface61c | 57 | \func{}{\destruct{wxClipboard}}{\void} |
a660d684 | 58 | |
dface61c | 59 | Destructor. |
a660d684 | 60 | |
75ce0581 RR |
61 | \membersection{wxClipboard::AddData}\label{wxclipboardadddata} |
62 | ||
63 | \func{bool}{AddData}{\param{wxDataObject*}{ data}} | |
64 | ||
65 | Call this function to add a data object to the clipboard. This function can be called several times | |
66 | to put different formats on the clipboard. | |
67 | ||
dface61c | 68 | \membersection{wxClipboard::Clear}\label{wxclipboardclear} |
a660d684 | 69 | |
dface61c | 70 | \func{void}{Clear}{\void} |
a660d684 | 71 | |
dface61c | 72 | Clears the global clipboard object and the system's clipboard if possible. |
a660d684 | 73 | |
dface61c | 74 | \membersection{wxClipboard::Close}\label{wxclipboardclose} |
a660d684 | 75 | |
dface61c | 76 | \func{bool}{Close}{\void} |
a660d684 | 77 | |
75ce0581 | 78 | Call this function to close the clipboard, having opened it with \helpref{wxClipboard::Open}{wxclipboardopen}. |
a660d684 | 79 | |
dface61c | 80 | \membersection{wxClipboard::GetData}\label{wxclipboardgetdata} |
a660d684 | 81 | |
75ce0581 | 82 | \func{bool}{GetData}{\param{wxDataObject&}{ data}} |
a660d684 | 83 | |
dface61c | 84 | Call this function to fill {\it data} with data on the clipboard, if available in the required |
75ce0581 | 85 | format. Returns TRUE on success. |
a660d684 | 86 | |
75ce0581 | 87 | \membersection{wxClipboard::IsSupported}\label{wxclipboardissupported} |
a660d684 | 88 | |
75ce0581 | 89 | \func{bool}{IsSupported}{\param{wxDataObject&}{ data}} |
a660d684 | 90 | |
75ce0581 | 91 | Returns TRUE if the format of the given data object is available on the clipboard. |
a660d684 | 92 | |
dface61c | 93 | \membersection{wxClipboard::Open}\label{wxclipboardopen} |
a660d684 | 94 | |
dface61c | 95 | \func{bool}{Open}{\void} |
a660d684 | 96 | |
dface61c JS |
97 | Call this function to open the clipboard before calling \helpref{wxClipboard::SetData}{wxclipboardsetdata} |
98 | and \helpref{wxClipboard::GetData}{wxclipboardgetdata}. | |
a660d684 | 99 | |
dface61c JS |
100 | Call \helpref{wxClipboard::Close}{wxclipboardclose} when you have finished with the clipboard. You |
101 | should keep the clipboard open for only a very short time. | |
a660d684 | 102 | |
75ce0581 RR |
103 | Returns TRUE on success. This should be tested (as in the sample shown above). |
104 | ||
105 | \membersection{wxClipboard::SetData}\label{wxclipboardadddata} | |
a660d684 | 106 | |
dface61c | 107 | \func{bool}{SetData}{\param{wxDataObject*}{ data}} |
a660d684 | 108 | |
75ce0581 RR |
109 | Call this function to set the data object to the clipboard. This function will |
110 | clear all previous contents in the clipboard, so calling it several times | |
111 | does not make any sense. | |
a660d684 | 112 |