]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/clipbrd.tex
1. wxGetOsDescription() function added
[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 Call \helpref{wxClipboard::Open}{wxclipboardopen} to get ownership of the clipboard. If this operation returns TRUE, you
9 now own the clipboard. Call \helpref{wxClipboard::SetData}{wxclipboardsetdata} to put data
10 on the clipboard, 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}
17 // Write some text to the clipboard
18 if (wxTheClipboard->Open())
19 {
20 // This data objects are held by the clipboard,
21 // so do not delete them in the app.
22 wxTheClipboard->SetData( new wxTextDataObject("Some text") );
23 wxTheClipboard->Close();
24 }
25
26 // Read some text
27 if (wxTheClipboard->Open())
28 {
29 if (wxTheClipboard->IsSupported( wxDF_TEXT ))
30 {
31 wxTextDataObject data;
32 wxTheClipboard->GetData( data );
33 wxMessageBox( data.GetText() );
34 }
35 wxTheClipboard->Close();
36 }
37 \end{verbatim}
38
39 \wxheading{Derived from}
40
41 \helpref{wxObject}{wxobject}
42
43 \wxheading{Include files}
44
45 <wx/clipbrd.h>
46
47 \wxheading{See also}
48
49 \helpref{Drag and drop overview}{wxdndoverview}, \helpref{wxDataObject}{wxdataobject}
50
51 \latexignore{\rtfignore{\wxheading{Members}}}
52
53 \membersection{wxClipboard::wxClipboard}
54
55 \func{}{wxClipboard}{\void}
56
57 Constructor.
58
59 \membersection{wxClipboard::\destruct{wxClipboard}}
60
61 \func{}{\destruct{wxClipboard}}{\void}
62
63 Destructor.
64
65 \membersection{wxClipboard::Clear}\label{wxclipboardclear}
66
67 \func{void}{Clear}{\void}
68
69 Clears the global clipboard object and the system's clipboard if possible.
70
71 \membersection{wxClipboard::Close}\label{wxclipboardclose}
72
73 \func{bool}{Close}{\void}
74
75 Call this function to close the clipboard, having opened it with \helpref{wxClipboard::Open}{wxclipboardopen}.
76
77 \membersection{wxClipboard::GetData}\label{wxclipboardgetdata}
78
79 \func{bool}{GetData}{\param{wxDataObject\&}{ data}}
80
81 Call this function to fill {\it data} with data on the clipboard, if available in the required
82 format. Returns TRUE on success.
83
84 \membersection{wxClipboard::IsSupported}\label{wxclipboardissupported}
85
86 \func{bool}{IsSupported}{\param{const wxDataFormat\&}{ format}}
87
88 Returns TRUE if the format of the given data object is available on the clipboard.
89
90 \membersection{wxClipboard::Open}\label{wxclipboardopen}
91
92 \func{bool}{Open}{\void}
93
94 Call this function to open the clipboard before calling \helpref{wxClipboard::SetData}{wxclipboardsetdata}
95 and \helpref{wxClipboard::GetData}{wxclipboardgetdata}.
96
97 Call \helpref{wxClipboard::Close}{wxclipboardclose} when you have finished with the clipboard. You
98 should keep the clipboard open for only a very short time.
99
100 Returns TRUE on success. This should be tested (as in the sample shown above).
101
102 \membersection{wxClipboard::SetData}\label{wxclipboardsetdata}
103
104 \func{bool}{SetData}{\param{wxDataObject*}{ data}}
105
106 Call this function to set the data object to the clipboard. This function will
107 clear all previous contents in the clipboard, so calling it several times
108 does not make any sense.
109
110 \membersection{wxClipboard::UsePrimarySelection}\label{wxclipboarduseprimary}
111
112 \func{void}{UsePrimarySelection}{\param{bool}{ primary = TRUE}}
113
114 On platforms supporting it (currently only GTK), selects the so called
115 PRIMARY SELECTION as the clipboard as opposed to the normal clipboard,
116 if {\it primary} is TRUE.
117
118