]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/clipbrd.tex
Added missing brace in checkbox.tex
[wxWidgets.git] / docs / latex / wx / clipbrd.tex
... / ...
CommitLineData
1\section{\class{wxClipboard}}\label{wxclipboard}
2
3A class for manipulating the clipboard. Note that this is not compatible with the
4clipboard class from wxWindows 1.xx, which has the same name but a different implementation.
5
6To use the clipboard, you call member functions of the global {\bf wxTheClipboard} object.
7
8See also the \helpref{wxDataObject overview}{wxdataobjectoverview} for further information.
9
10Call \helpref{wxClipboard::Open}{wxclipboardopen} to get ownership of the clipboard. If this operation returns TRUE, you
11now own the clipboard. Call \helpref{wxClipboard::SetData}{wxclipboardsetdata} to put data
12on the clipboard, or \helpref{wxClipboard::GetData}{wxclipboardgetdata} to
13retrieve data from the clipboard. Call \helpref{wxClipboard::Close}{wxclipboardclose} to close
14the clipboard and relinquish ownership. You should keep the clipboard open only momentarily.
15
16For example:
17
18\begin{verbatim}
19 // Write some text to the clipboard
20 if (wxTheClipboard->Open())
21 {
22 // This data objects are held by the clipboard,
23 // so do not delete them in the app.
24 wxTheClipboard->SetData( new wxTextDataObject("Some text") );
25 wxTheClipboard->Close();
26 }
27
28 // Read some text
29 if (wxTheClipboard->Open())
30 {
31 if (wxTheClipboard->IsSupported( wxDF_TEXT ))
32 {
33 wxTextDataObject data;
34 wxTheClipboard->GetData( data );
35 wxMessageBox( data.GetText() );
36 }
37 wxTheClipboard->Close();
38 }
39\end{verbatim}
40
41\wxheading{Derived from}
42
43\helpref{wxObject}{wxobject}
44
45\wxheading{Include files}
46
47<wx/clipbrd.h>
48
49\wxheading{See also}
50
51\helpref{Drag and drop overview}{wxdndoverview}, \helpref{wxDataObject}{wxdataobject}
52
53\latexignore{\rtfignore{\wxheading{Members}}}
54
55\membersection{wxClipboard::wxClipboard}
56
57\func{}{wxClipboard}{\void}
58
59Constructor.
60
61\membersection{wxClipboard::\destruct{wxClipboard}}
62
63\func{}{\destruct{wxClipboard}}{\void}
64
65Destructor.
66
67\membersection{wxClipboard::AddData}\label{wxclipboardadddata}
68
69\func{bool}{AddData}{\param{wxDataObject*}{ data}}
70
71Call this function to add the data object to the clipboard. You may call
72this function repeatedly after having cleared the clipboard using \helpref{wxClipboard::Clear}{wxclipboardclear}.
73
74After this function has been called, the clipboard owns the data, so do not delete
75the data explicitly.
76
77\wxheading{See also}
78
79\helpref{wxClipboard::SetData}{wxclipboardsetdata}
80
81\membersection{wxClipboard::Clear}\label{wxclipboardclear}
82
83\func{void}{Clear}{\void}
84
85Clears the global clipboard object and the system's clipboard if possible.
86
87\membersection{wxClipboard::Close}\label{wxclipboardclose}
88
89\func{bool}{Close}{\void}
90
91Call this function to close the clipboard, having opened it with \helpref{wxClipboard::Open}{wxclipboardopen}.
92
93\membersection{wxClipboard::Flush}\label{wxclipboardflush}
94
95\func{bool}{Flush}{\void}
96
97Flushes the clipboard: this means that the data which is currently on
98clipboard will stay available even after the application exits (possibly
99eating memory), otherwise the clipboard will be emptied on exit.
100Returns FALSE if the operation is unsuccesful for any reason.
101
102\membersection{wxClipboard::GetData}\label{wxclipboardgetdata}
103
104\func{bool}{GetData}{\param{wxDataObject\&}{ data}}
105
106Call this function to fill {\it data} with data on the clipboard, if available in the required
107format. Returns TRUE on success.
108
109\membersection{wxClipboard::IsOpened}\label{wxclipboardisopened}
110
111\constfunc{bool}{IsOpened}{\void}
112
113Returns TRUE if the clipboard has been opened.
114
115\membersection{wxClipboard::IsSupported}\label{wxclipboardissupported}
116
117\func{bool}{IsSupported}{\param{const wxDataFormat\&}{ format}}
118
119Returns TRUE if the format of the given data object is available on the clipboard.
120
121\membersection{wxClipboard::Open}\label{wxclipboardopen}
122
123\func{bool}{Open}{\void}
124
125Call this function to open the clipboard before calling \helpref{wxClipboard::SetData}{wxclipboardsetdata}
126and \helpref{wxClipboard::GetData}{wxclipboardgetdata}.
127
128Call \helpref{wxClipboard::Close}{wxclipboardclose} when you have finished with the clipboard. You
129should keep the clipboard open for only a very short time.
130
131Returns TRUE on success. This should be tested (as in the sample shown above).
132
133\membersection{wxClipboard::SetData}\label{wxclipboardsetdata}
134
135\func{bool}{SetData}{\param{wxDataObject*}{ data}}
136
137Call this function to set the data object to the clipboard. This function will
138clear all previous contents in the clipboard, so calling it several times
139does not make any sense.
140
141After this function has been called, the clipboard owns the data, so do not delete
142the data explicitly.
143
144\wxheading{See also}
145
146\helpref{wxClipboard::AddData}{wxclipboardadddata}
147
148\membersection{wxClipboard::UsePrimarySelection}\label{wxclipboarduseprimary}
149
150\func{void}{UsePrimarySelection}{\param{bool}{ primary = TRUE}}
151
152On platforms supporting it (currently only GTK), selects the so called
153PRIMARY SELECTION as the clipboard as opposed to the normal clipboard,
154if {\it primary} is TRUE.
155
156