]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/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 #if !USE_SHARED_LIBRARY
27 IMPLEMENT_DYNAMIC_CLASS(wxClipboard
, wxObject
)
28 IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient
, wxObject
)
31 bool wxOpenClipboard()
37 bool wxCloseClipboard()
43 bool wxEmptyClipboard()
49 bool wxClipboardOpen()
55 bool wxIsClipboardFormatAvailable(int dataFormat
)
61 bool wxSetClipboardData(int dataFormat
, wxObject
*obj
, int width
, int height
)
67 wxObject
*wxGetClipboardData(int dataFormat
, long *len
)
73 int wxEnumClipboardFormats(int dataFormat
)
79 int wxRegisterClipboardFormat(char *formatName
)
85 bool wxGetClipboardFormatName(int dataFormat
, char *formatName
, int maxCount
)
92 * Generalized clipboard implementation by Matthew Flatt
95 wxClipboard
*wxTheClipboard
= NULL
;
97 void wxInitClipboard()
100 wxTheClipboard
= new wxClipboard
;
103 wxClipboard::wxClipboard()
109 wxClipboard::~wxClipboard()
112 clipOwner
->BeingReplaced();
117 static int FormatStringToID(char *str
)
119 if (!strcmp(str
, "TEXT"))
122 return wxRegisterClipboardFormat(str
);
125 void wxClipboard::SetClipboardClient(wxClipboardClient
*client
, long time
)
130 clipOwner
->BeingReplaced();
137 if (wxOpenClipboard()) {
138 char **formats
, *data
;
143 formats
= clipOwner
->formats
.ListToArray(FALSE
);
144 for (i
= clipOwner
->formats
.Number(); i
--; ) {
145 ftype
= FormatStringToID(formats
[i
]);
146 data
= clipOwner
->GetData(formats
[i
], &size
);
147 if (!wxSetClipboardData(ftype
, (wxObject
*)data
, size
, 1)) {
148 got_selection
= FALSE
;
154 got_selection
= wxCloseClipboard();
156 got_selection
= FALSE
;
158 got_selection
= FALSE
; // Assume another process takes over
160 if (!got_selection
) {
161 clipOwner
->BeingReplaced();
166 wxClipboardClient
*wxClipboard::GetClipboardClient()
171 void wxClipboard::SetClipboardString(char *str
, long time
)
176 clipOwner
->BeingReplaced();
184 if (wxOpenClipboard()) {
185 if (!wxSetClipboardData(wxDF_TEXT
, (wxObject
*)str
))
186 got_selection
= FALSE
;
188 got_selection
= wxCloseClipboard();
190 got_selection
= FALSE
;
192 got_selection
= FALSE
; // Assume another process takes over
194 if (!got_selection
) {
200 char *wxClipboard::GetClipboardString(long time
)
205 str
= GetClipboardData("TEXT", &length
, time
);
214 char *wxClipboard::GetClipboardData(char *format
, long *length
, long time
)
217 if (clipOwner
->formats
.Member(format
))
218 return clipOwner
->GetData(format
, length
);
221 } else if (cbString
) {
222 if (!strcmp(format
, "TEXT"))
223 return copystring(cbString
);
227 if (wxOpenClipboard()) {
228 receivedString
= (char *)wxGetClipboardData(FormatStringToID(format
),
232 receivedString
= NULL
;
234 return receivedString
;