]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/clipbrd.tex
added wxEncodingConverter
[wxWidgets.git] / docs / latex / wx / clipbrd.tex
1 \section{\class{wxClipboard}}\label{wxclipboard}
2
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
6 To use the clipboard, you call member functions of the global {\bf wxTheClipboard} object.
7
8 See also the \helpref{wxDataObject overview}{wxdataobjectoverview} for further information.
9
10 Call \helpref{wxClipboard::Open}{wxclipboardopen} to get ownership of the clipboard. If this operation returns TRUE, you
11 now own the clipboard. Call \helpref{wxClipboard::SetData}{wxclipboardsetdata} to put data
12 on the clipboard, or \helpref{wxClipboard::GetData}{wxclipboardgetdata} to
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}
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
59 Constructor.
60
61 \membersection{wxClipboard::\destruct{wxClipboard}}
62
63 \func{}{\destruct{wxClipboard}}{\void}
64
65 Destructor.
66
67 \membersection{wxClipboard::Clear}\label{wxclipboardclear}
68
69 \func{void}{Clear}{\void}
70
71 Clears the global clipboard object and the system's clipboard if possible.
72
73 \membersection{wxClipboard::Close}\label{wxclipboardclose}
74
75 \func{bool}{Close}{\void}
76
77 Call this function to close the clipboard, having opened it with \helpref{wxClipboard::Open}{wxclipboardopen}.
78
79 \membersection{wxClipboard::GetData}\label{wxclipboardgetdata}
80
81 \func{bool}{GetData}{\param{wxDataObject\&}{ data}}
82
83 Call this function to fill {\it data} with data on the clipboard, if available in the required
84 format. Returns TRUE on success.
85
86 \membersection{wxClipboard::IsSupported}\label{wxclipboardissupported}
87
88 \func{bool}{IsSupported}{\param{const wxDataFormat\&}{ format}}
89
90 Returns TRUE if the format of the given data object is available on the clipboard.
91
92 \membersection{wxClipboard::Open}\label{wxclipboardopen}
93
94 \func{bool}{Open}{\void}
95
96 Call this function to open the clipboard before calling \helpref{wxClipboard::SetData}{wxclipboardsetdata}
97 and \helpref{wxClipboard::GetData}{wxclipboardgetdata}.
98
99 Call \helpref{wxClipboard::Close}{wxclipboardclose} when you have finished with the clipboard. You
100 should keep the clipboard open for only a very short time.
101
102 Returns TRUE on success. This should be tested (as in the sample shown above).
103
104 \membersection{wxClipboard::SetData}\label{wxclipboardsetdata}
105
106 \func{bool}{SetData}{\param{wxDataObject*}{ data}}
107
108 Call this function to set the data object to the clipboard. This function will
109 clear all previous contents in the clipboard, so calling it several times
110 does not make any sense.
111
112 \membersection{wxClipboard::UsePrimarySelection}\label{wxclipboarduseprimary}
113
114 \func{void}{UsePrimarySelection}{\param{bool}{ primary = TRUE}}
115
116 On platforms supporting it (currently only GTK), selects the so called
117 PRIMARY SELECTION as the clipboard as opposed to the normal clipboard,
118 if {\it primary} is TRUE.
119
120