]> git.saurik.com Git - wxWidgets.git/blame - interface/clipbrd.h
Added the function and macro group pages for Doxygen.
[wxWidgets.git] / interface / clipbrd.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: clipbrd.h
e54c96f1 3// Purpose: interface of wxClipboard
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxClipboard
11 @wxheader{clipbrd.h}
7c913512 12
23324ae1
FM
13 A class for manipulating the clipboard. Note that this is not compatible with
14 the
15 clipboard class from wxWidgets 1.xx, which has the same name but a different
16 implementation.
7c913512 17
23324ae1
FM
18 To use the clipboard, you call member functions of the global @b wxTheClipboard
19 object.
7c913512 20
4cc4bfaf 21 See also the @ref overview_wxdataobjectoverview for further information.
7c913512 22
23324ae1
FM
23 Call wxClipboard::Open to get ownership of the clipboard. If this operation
24 returns @true, you
25 now own the clipboard. Call wxClipboard::SetData to put data
26 on the clipboard, or wxClipboard::GetData to
27 retrieve data from the clipboard. Call wxClipboard::Close to close
28 the clipboard and relinquish ownership. You should keep the clipboard open only
29 momentarily.
7c913512 30
23324ae1 31 For example:
7c913512 32
23324ae1
FM
33 @code
34 // Write some text to the clipboard
35 if (wxTheClipboard-Open())
36 {
7c913512 37 // This data objects are held by the clipboard,
23324ae1
FM
38 // so do not delete them in the app.
39 wxTheClipboard-SetData( new wxTextDataObject("Some text") );
40 wxTheClipboard-Close();
41 }
7c913512 42
23324ae1
FM
43 // Read some text
44 if (wxTheClipboard-Open())
45 {
46 if (wxTheClipboard-IsSupported( wxDF_TEXT ))
47 {
48 wxTextDataObject data;
49 wxTheClipboard-GetData( data );
50 wxMessageBox( data.GetText() );
7c913512 51 }
23324ae1
FM
52 wxTheClipboard-Close();
53 }
54 @endcode
7c913512 55
23324ae1
FM
56 @library{wxcore}
57 @category{dnd}
7c913512 58
e54c96f1 59 @see @ref overview_wxdndoverview, wxDataObject
23324ae1
FM
60*/
61class wxClipboard : public wxObject
62{
63public:
64 /**
65 Constructor.
66 */
67 wxClipboard();
68
69 /**
70 Destructor.
71 */
72 ~wxClipboard();
73
74 /**
75 Call this function to add the data object to the clipboard. You may call
76 this function repeatedly after having cleared the clipboard using Clear().
23324ae1
FM
77 After this function has been called, the clipboard owns the data, so do not
78 delete
79 the data explicitly.
80
4cc4bfaf 81 @see SetData()
23324ae1
FM
82 */
83 bool AddData(wxDataObject* data);
84
85 /**
86 Clears the global clipboard object and the system's clipboard if possible.
87 */
88 void Clear();
89
90 /**
91 Call this function to close the clipboard, having opened it with Open().
92 */
93 void Close();
94
95 /**
96 Flushes the clipboard: this means that the data which is currently on
97 clipboard will stay available even after the application exits (possibly
98 eating memory), otherwise the clipboard will be emptied on exit.
99 Returns @false if the operation is unsuccessful for any reason.
100 */
101 bool Flush();
102
103 /**
4cc4bfaf 104 Call this function to fill @a data with data on the clipboard, if available in
23324ae1
FM
105 the required
106 format. Returns @true on success.
107 */
108 bool GetData(wxDataObject& data);
109
110 /**
111 Returns @true if the clipboard has been opened.
112 */
328f5751 113 bool IsOpened() const;
23324ae1
FM
114
115 /**
116 Returns @true if there is data which matches the data format of the given data
117 object currently @b available (IsSupported sounds like a misnomer, FIXME: better deprecate this name?) on the clipboard.
118 */
119 bool IsSupported(const wxDataFormat& format);
120
121 /**
122 Returns @true if we are using the primary selection, @false if clipboard
123 one.
124 See @ref useprimary() UsePrimarySelection for more information.
125 */
328f5751 126 bool IsUsingPrimarySelection() const;
23324ae1
FM
127
128 /**
7c913512 129 Call this function to open the clipboard before calling SetData()
23324ae1 130 and GetData().
23324ae1
FM
131 Call Close() when you have finished with the clipboard. You
132 should keep the clipboard open for only a very short time.
23324ae1
FM
133 Returns @true on success. This should be tested (as in the sample shown above).
134 */
135 bool Open();
136
137 /**
138 Call this function to set the data object to the clipboard. This function will
139 clear all previous contents in the clipboard, so calling it several times
140 does not make any sense.
23324ae1
FM
141 After this function has been called, the clipboard owns the data, so do not
142 delete
143 the data explicitly.
144
4cc4bfaf 145 @see AddData()
23324ae1
FM
146 */
147 bool SetData(wxDataObject* data);
148
149 /**
150 On platforms supporting it (all X11-based ports), wxClipboard uses the
151 CLIPBOARD X11 selection by default. When this function is called with @true
152 argument, all subsequent clipboard operations will use PRIMARY selection until
153 this function is called again with @false.
23324ae1
FM
154 On the other platforms, there is no PRIMARY selection and so all clipboard
155 operations will fail. This allows to implement the standard X11 handling of the
156 clipboard which consists in copying data to the CLIPBOARD selection only when
157 the user explicitly requests it (i.e. by selection @c "Copy" menu
158 command) but putting the currently selected text into the PRIMARY selection
159 automatically, without overwriting the normal clipboard contents with the
160 currently selected text on the other platforms.
161 */
4cc4bfaf 162 void UsePrimarySelection(bool primary = true);
23324ae1 163};
e54c96f1 164