]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxClipboard}}\label{wxclipboard} |
2 | ||
dface61c | 3 | A class for manipulating the clipboard. Note that this is not compatible with the |
fc2171bd | 4 | clipboard class from wxWidgets 1.xx, which has the same name but a different implementation. |
dface61c | 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 | ||
cc81d32f | 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 | ||
a7af285d VZ |
49 | \wxheading{Library} |
50 | ||
51 | \helpref{wxCore}{librarieslist} | |
52 | ||
a660d684 KB |
53 | \wxheading{See also} |
54 | ||
dface61c | 55 | \helpref{Drag and drop overview}{wxdndoverview}, \helpref{wxDataObject}{wxdataobject} |
a660d684 KB |
56 | |
57 | \latexignore{\rtfignore{\wxheading{Members}}} | |
58 | ||
9005f2ed | 59 | |
f510b7b2 | 60 | \membersection{wxClipboard::wxClipboard}\label{wxclipboardctor} |
a660d684 | 61 | |
dface61c | 62 | \func{}{wxClipboard}{\void} |
a660d684 | 63 | |
dface61c | 64 | Constructor. |
a660d684 | 65 | |
9005f2ed | 66 | |
f510b7b2 | 67 | \membersection{wxClipboard::\destruct{wxClipboard}}\label{wxclipboarddtor} |
a660d684 | 68 | |
dface61c | 69 | \func{}{\destruct{wxClipboard}}{\void} |
a660d684 | 70 | |
dface61c | 71 | Destructor. |
a660d684 | 72 | |
9005f2ed | 73 | |
40219523 JS |
74 | \membersection{wxClipboard::AddData}\label{wxclipboardadddata} |
75 | ||
76 | \func{bool}{AddData}{\param{wxDataObject*}{ data}} | |
77 | ||
78 | Call this function to add the data object to the clipboard. You may call | |
79 | this function repeatedly after having cleared the clipboard using \helpref{wxClipboard::Clear}{wxclipboardclear}. | |
80 | ||
81 | After this function has been called, the clipboard owns the data, so do not delete | |
82 | the data explicitly. | |
83 | ||
84 | \wxheading{See also} | |
85 | ||
86 | \helpref{wxClipboard::SetData}{wxclipboardsetdata} | |
87 | ||
9005f2ed | 88 | |
dface61c | 89 | \membersection{wxClipboard::Clear}\label{wxclipboardclear} |
a660d684 | 90 | |
dface61c | 91 | \func{void}{Clear}{\void} |
a660d684 | 92 | |
dface61c | 93 | Clears the global clipboard object and the system's clipboard if possible. |
a660d684 | 94 | |
9005f2ed | 95 | |
dface61c | 96 | \membersection{wxClipboard::Close}\label{wxclipboardclose} |
a660d684 | 97 | |
2f930c85 | 98 | \func{void}{Close}{\void} |
a660d684 | 99 | |
75ce0581 | 100 | Call this function to close the clipboard, having opened it with \helpref{wxClipboard::Open}{wxclipboardopen}. |
a660d684 | 101 | |
9005f2ed | 102 | |
741ed114 MB |
103 | \membersection{wxClipboard::Flush}\label{wxclipboardflush} |
104 | ||
105 | \func{bool}{Flush}{\void} | |
106 | ||
107 | Flushes the clipboard: this means that the data which is currently on | |
108 | clipboard will stay available even after the application exits (possibly | |
109 | eating memory), otherwise the clipboard will be emptied on exit. | |
dbd94b75 | 110 | Returns false if the operation is unsuccessful for any reason. |
741ed114 | 111 | |
9005f2ed | 112 | |
dface61c | 113 | \membersection{wxClipboard::GetData}\label{wxclipboardgetdata} |
a660d684 | 114 | |
fc9c7c09 | 115 | \func{bool}{GetData}{\param{wxDataObject\&}{ data}} |
a660d684 | 116 | |
dface61c | 117 | Call this function to fill {\it data} with data on the clipboard, if available in the required |
cc81d32f | 118 | format. Returns true on success. |
a660d684 | 119 | |
9005f2ed | 120 | |
40219523 JS |
121 | \membersection{wxClipboard::IsOpened}\label{wxclipboardisopened} |
122 | ||
123 | \constfunc{bool}{IsOpened}{\void} | |
124 | ||
cc81d32f | 125 | Returns true if the clipboard has been opened. |
40219523 | 126 | |
9005f2ed | 127 | |
75ce0581 | 128 | \membersection{wxClipboard::IsSupported}\label{wxclipboardissupported} |
a660d684 | 129 | |
fc9c7c09 | 130 | \func{bool}{IsSupported}{\param{const wxDataFormat\&}{ format}} |
a660d684 | 131 | |
3980000c | 132 | Returns true if there is data which matches the data format of the given data object currently {\bf available} (IsSupported sounds like a misnomer, FIXME: better deprecate this name?) on the clipboard. |
a660d684 | 133 | |
9005f2ed VZ |
134 | |
135 | \membersection{wxClipboard::IsUsingPrimarySelection}\label{wxclipboardisusingprimaryselection} | |
136 | ||
137 | \constfunc{bool}{IsUsingPrimarySelection}{\void} | |
138 | ||
139 | Returns \true if we are using the primary selection, \false if clipboard one. | |
140 | See \helpref{UsePrimarySelection}{wxclipboarduseprimary} for more information. | |
141 | ||
142 | ||
dface61c | 143 | \membersection{wxClipboard::Open}\label{wxclipboardopen} |
a660d684 | 144 | |
dface61c | 145 | \func{bool}{Open}{\void} |
a660d684 | 146 | |
dface61c JS |
147 | Call this function to open the clipboard before calling \helpref{wxClipboard::SetData}{wxclipboardsetdata} |
148 | and \helpref{wxClipboard::GetData}{wxclipboardgetdata}. | |
a660d684 | 149 | |
dface61c JS |
150 | Call \helpref{wxClipboard::Close}{wxclipboardclose} when you have finished with the clipboard. You |
151 | should keep the clipboard open for only a very short time. | |
a660d684 | 152 | |
cc81d32f | 153 | Returns true on success. This should be tested (as in the sample shown above). |
75ce0581 | 154 | |
9005f2ed | 155 | |
f9b1708c | 156 | \membersection{wxClipboard::SetData}\label{wxclipboardsetdata} |
a660d684 | 157 | |
dface61c | 158 | \func{bool}{SetData}{\param{wxDataObject*}{ data}} |
a660d684 | 159 | |
75ce0581 RR |
160 | Call this function to set the data object to the clipboard. This function will |
161 | clear all previous contents in the clipboard, so calling it several times | |
162 | does not make any sense. | |
a660d684 | 163 | |
40219523 JS |
164 | After this function has been called, the clipboard owns the data, so do not delete |
165 | the data explicitly. | |
166 | ||
167 | \wxheading{See also} | |
168 | ||
169 | \helpref{wxClipboard::AddData}{wxclipboardadddata} | |
170 | ||
9005f2ed | 171 | |
7ff14117 | 172 | \membersection{wxClipboard::UsePrimarySelection}\label{wxclipboarduseprimary} |
b453e1b2 | 173 | |
cc81d32f | 174 | \func{void}{UsePrimarySelection}{\param{bool}{ primary = true}} |
b453e1b2 | 175 | |
9005f2ed VZ |
176 | On platforms supporting it (all X11-based ports), wxClipboard uses the |
177 | CLIPBOARD X11 selection by default. When this function is called with \true | |
178 | argument, all subsequent clipboard operations will use PRIMARY selection until | |
179 | this function is called again with \false. | |
180 | ||
181 | On the other platforms, there is no PRIMARY selection and so all clipboard | |
182 | operations will fail. This allows to implement the standard X11 handling of the | |
183 | clipboard which consists in copying data to the CLIPBOARD selection only when | |
184 | the user explicitly requests it (i.e. by selection \texttt{"Copy"} menu | |
185 | command) but putting the currently selected text into the PRIMARY selection | |
186 | automatically, without overwriting the normal clipboard contents with the | |
187 | currently selected text on the other platforms. | |
b453e1b2 | 188 |