]>
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 | ||
23efdd02 RR |
8 | See also the \helpref{wxDataObject overview}{wxdataobjectoverview} for further information. |
9 | ||
4ce81a75 | 10 | Call \helpref{wxClipboard::Open}{wxclipboardopen} to get ownership of the clipboard. If this operation returns TRUE, you |
fc9c7c09 RR |
11 | now own the clipboard. Call \helpref{wxClipboard::SetData}{wxclipboardsetdata} to put data |
12 | on the clipboard, or \helpref{wxClipboard::GetData}{wxclipboardgetdata} to | |
dface61c JS |
13 | retrieve data from the clipboard. Call \helpref{wxClipboard::Close}{wxclipboardclose} to close |
14 | the clipboard and relinquish ownership. You should keep the clipboard open only momentarily. | |
15 | ||
16 | For example: | |
17 | ||
18 | \begin{verbatim} | |
dface61c | 19 | // Write some text to the clipboard |
4ce81a75 | 20 | if (wxTheClipboard->Open()) |
dface61c | 21 | { |
75ce0581 RR |
22 | // This data objects are held by the clipboard, |
23 | // so do not delete them in the app. | |
330d6fd0 | 24 | wxTheClipboard->SetData( new wxTextDataObject("Some text") ); |
4ce81a75 | 25 | wxTheClipboard->Close(); |
dface61c JS |
26 | } |
27 | ||
28 | // Read some text | |
75ce0581 | 29 | if (wxTheClipboard->Open()) |
dface61c | 30 | { |
fc9c7c09 | 31 | if (wxTheClipboard->IsSupported( wxDF_TEXT )) |
75ce0581 | 32 | { |
b453e1b2 | 33 | wxTextDataObject data; |
fc9c7c09 | 34 | wxTheClipboard->GetData( data ); |
b453e1b2 | 35 | wxMessageBox( data.GetText() ); |
75ce0581 | 36 | } |
4ce81a75 | 37 | wxTheClipboard->Close(); |
dface61c JS |
38 | } |
39 | \end{verbatim} | |
a660d684 KB |
40 | |
41 | \wxheading{Derived from} | |
42 | ||
43 | \helpref{wxObject}{wxobject} | |
44 | ||
954b8ae6 JS |
45 | \wxheading{Include files} |
46 | ||
47 | <wx/clipbrd.h> | |
48 | ||
a660d684 KB |
49 | \wxheading{See also} |
50 | ||
dface61c | 51 | \helpref{Drag and drop overview}{wxdndoverview}, \helpref{wxDataObject}{wxdataobject} |
a660d684 KB |
52 | |
53 | \latexignore{\rtfignore{\wxheading{Members}}} | |
54 | ||
dface61c | 55 | \membersection{wxClipboard::wxClipboard} |
a660d684 | 56 | |
dface61c | 57 | \func{}{wxClipboard}{\void} |
a660d684 | 58 | |
dface61c | 59 | Constructor. |
a660d684 | 60 | |
dface61c | 61 | \membersection{wxClipboard::\destruct{wxClipboard}} |
a660d684 | 62 | |
dface61c | 63 | \func{}{\destruct{wxClipboard}}{\void} |
a660d684 | 64 | |
dface61c | 65 | Destructor. |
a660d684 | 66 | |
40219523 JS |
67 | \membersection{wxClipboard::AddData}\label{wxclipboardadddata} |
68 | ||
69 | \func{bool}{AddData}{\param{wxDataObject*}{ data}} | |
70 | ||
71 | Call this function to add the data object to the clipboard. You may call | |
72 | this function repeatedly after having cleared the clipboard using \helpref{wxClipboard::Clear}{wxclipboardclear}. | |
73 | ||
74 | After this function has been called, the clipboard owns the data, so do not delete | |
75 | the data explicitly. | |
76 | ||
77 | \wxheading{See also} | |
78 | ||
79 | \helpref{wxClipboard::SetData}{wxclipboardsetdata} | |
80 | ||
dface61c | 81 | \membersection{wxClipboard::Clear}\label{wxclipboardclear} |
a660d684 | 82 | |
dface61c | 83 | \func{void}{Clear}{\void} |
a660d684 | 84 | |
dface61c | 85 | Clears the global clipboard object and the system's clipboard if possible. |
a660d684 | 86 | |
dface61c | 87 | \membersection{wxClipboard::Close}\label{wxclipboardclose} |
a660d684 | 88 | |
dface61c | 89 | \func{bool}{Close}{\void} |
a660d684 | 90 | |
75ce0581 | 91 | Call this function to close the clipboard, having opened it with \helpref{wxClipboard::Open}{wxclipboardopen}. |
a660d684 | 92 | |
dface61c | 93 | \membersection{wxClipboard::GetData}\label{wxclipboardgetdata} |
a660d684 | 94 | |
fc9c7c09 | 95 | \func{bool}{GetData}{\param{wxDataObject\&}{ data}} |
a660d684 | 96 | |
dface61c | 97 | Call this function to fill {\it data} with data on the clipboard, if available in the required |
75ce0581 | 98 | format. Returns TRUE on success. |
a660d684 | 99 | |
40219523 JS |
100 | \membersection{wxClipboard::IsOpened}\label{wxclipboardisopened} |
101 | ||
102 | \constfunc{bool}{IsOpened}{\void} | |
103 | ||
104 | Returns TRUE if the clipboard has been opened. | |
105 | ||
75ce0581 | 106 | \membersection{wxClipboard::IsSupported}\label{wxclipboardissupported} |
a660d684 | 107 | |
fc9c7c09 | 108 | \func{bool}{IsSupported}{\param{const wxDataFormat\&}{ format}} |
a660d684 | 109 | |
75ce0581 | 110 | Returns TRUE if the format of the given data object is available on the clipboard. |
a660d684 | 111 | |
dface61c | 112 | \membersection{wxClipboard::Open}\label{wxclipboardopen} |
a660d684 | 113 | |
dface61c | 114 | \func{bool}{Open}{\void} |
a660d684 | 115 | |
dface61c JS |
116 | Call this function to open the clipboard before calling \helpref{wxClipboard::SetData}{wxclipboardsetdata} |
117 | and \helpref{wxClipboard::GetData}{wxclipboardgetdata}. | |
a660d684 | 118 | |
dface61c JS |
119 | Call \helpref{wxClipboard::Close}{wxclipboardclose} when you have finished with the clipboard. You |
120 | should keep the clipboard open for only a very short time. | |
a660d684 | 121 | |
75ce0581 RR |
122 | Returns TRUE on success. This should be tested (as in the sample shown above). |
123 | ||
f9b1708c | 124 | \membersection{wxClipboard::SetData}\label{wxclipboardsetdata} |
a660d684 | 125 | |
dface61c | 126 | \func{bool}{SetData}{\param{wxDataObject*}{ data}} |
a660d684 | 127 | |
75ce0581 RR |
128 | Call this function to set the data object to the clipboard. This function will |
129 | clear all previous contents in the clipboard, so calling it several times | |
130 | does not make any sense. | |
a660d684 | 131 | |
40219523 JS |
132 | After this function has been called, the clipboard owns the data, so do not delete |
133 | the data explicitly. | |
134 | ||
135 | \wxheading{See also} | |
136 | ||
137 | \helpref{wxClipboard::AddData}{wxclipboardadddata} | |
138 | ||
7ff14117 | 139 | \membersection{wxClipboard::UsePrimarySelection}\label{wxclipboarduseprimary} |
b453e1b2 | 140 | |
7ff14117 | 141 | \func{void}{UsePrimarySelection}{\param{bool}{ primary = TRUE}} |
b453e1b2 RR |
142 | |
143 | On platforms supporting it (currently only GTK), selects the so called | |
144 | PRIMARY SELECTION as the clipboard as opposed to the normal clipboard, | |
7ff14117 | 145 | if {\it primary} is TRUE. |
b453e1b2 RR |
146 | |
147 |