]>
git.saurik.com Git - wxWidgets.git/blob - src/stubs/clipbrd.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Clipboard functionality
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation
14 #pragma implementation "clipbrd.h"
19 #include "wx/bitmap.h"
21 #include "wx/metafile.h"
22 #include "wx/clipbrd.h"
26 IMPLEMENT_DYNAMIC_CLASS(wxClipboard
, wxObject
)
27 IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient
, wxObject
)
29 bool wxOpenClipboard()
35 bool wxCloseClipboard()
41 bool wxEmptyClipboard()
47 bool wxClipboardOpen()
53 bool wxIsClipboardFormatAvailable(int dataFormat
)
59 bool wxSetClipboardData(int dataFormat
, wxObject
*obj
, int width
, int height
)
65 wxObject
*wxGetClipboardData(int dataFormat
, long *len
)
71 int wxEnumClipboardFormats(int dataFormat
)
77 int wxRegisterClipboardFormat(char *formatName
)
83 bool wxGetClipboardFormatName(int dataFormat
, char *formatName
, int maxCount
)
90 * Generalized clipboard implementation by Matthew Flatt
93 wxClipboard
*wxTheClipboard
= NULL
;
95 void wxInitClipboard()
98 wxTheClipboard
= new wxClipboard
;
101 wxClipboard::wxClipboard()
107 wxClipboard::~wxClipboard()
110 clipOwner
->BeingReplaced();
115 static int FormatStringToID(char *str
)
117 if (!strcmp(str
, "TEXT"))
120 return wxRegisterClipboardFormat(str
);
123 void wxClipboard::SetClipboardClient(wxClipboardClient
*client
, long time
)
128 clipOwner
->BeingReplaced();
135 if (wxOpenClipboard()) {
136 char **formats
, *data
;
141 formats
= clipOwner
->formats
.ListToArray(FALSE
);
142 for (i
= clipOwner
->formats
.Number(); i
--; ) {
143 ftype
= FormatStringToID(formats
[i
]);
144 data
= clipOwner
->GetData(formats
[i
], &size
);
145 if (!wxSetClipboardData(ftype
, (wxObject
*)data
, size
, 1)) {
146 got_selection
= FALSE
;
152 got_selection
= wxCloseClipboard();
154 got_selection
= FALSE
;
156 got_selection
= FALSE
; // Assume another process takes over
158 if (!got_selection
) {
159 clipOwner
->BeingReplaced();
164 wxClipboardClient
*wxClipboard::GetClipboardClient()
169 void wxClipboard::SetClipboardString(char *str
, long time
)
174 clipOwner
->BeingReplaced();
182 if (wxOpenClipboard()) {
183 if (!wxSetClipboardData(wxDF_TEXT
, (wxObject
*)str
))
184 got_selection
= FALSE
;
186 got_selection
= wxCloseClipboard();
188 got_selection
= FALSE
;
190 got_selection
= FALSE
; // Assume another process takes over
192 if (!got_selection
) {
198 char *wxClipboard::GetClipboardString(long time
)
203 str
= GetClipboardData("TEXT", &length
, time
);
212 char *wxClipboard::GetClipboardData(char *format
, long *length
, long time
)
215 if (clipOwner
->formats
.Member(format
))
216 return clipOwner
->GetData(format
, length
);
219 } else if (cbString
) {
220 if (!strcmp(format
, "TEXT"))
221 return copystring(cbString
);
225 if (wxOpenClipboard()) {
226 receivedString
= (char *)wxGetClipboardData(FormatStringToID(format
),
230 receivedString
= NULL
;
232 return receivedString
;