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