]> git.saurik.com Git - wxWidgets.git/blame - interface/dataobj.h
GetSocketManager() has no GUI-specific version under Darwin finally
[wxWidgets.git] / interface / dataobj.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: dataobj.h
e54c96f1 3// Purpose: interface of wxCustomDataObject
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxCustomDataObject
11 @wxheader{dataobj.h}
7c913512
FM
12
13 wxCustomDataObject is a specialization of
23324ae1
FM
14 wxDataObjectSimple for some
15 application-specific data in arbitrary (either custom or one of the standard
16 ones). The only restriction is that it is supposed that this data can be
17 copied bitwise (i.e. with @c memcpy()), so it would be a bad idea to make
18 it contain a C++ object (though C struct is fine).
7c913512 19
23324ae1 20 By default, wxCustomDataObject stores the data inside in a buffer. To put the
7c913512
FM
21 data into the buffer you may use either
22 wxCustomDataObject::SetData or
23324ae1
FM
23 wxCustomDataObject::TakeData depending on whether you want
24 the object to make a copy of data or not.
7c913512 25
23324ae1
FM
26 If you already store the data in another place, it may be more convenient and
27 efficient to provide the data on-demand which is possible too if you override
28 the virtual functions mentioned below.
7c913512 29
23324ae1
FM
30 @library{wxcore}
31 @category{dnd}
7c913512 32
e54c96f1 33 @see wxDataObject
23324ae1
FM
34*/
35class wxCustomDataObject : public wxDataObjectSimple
36{
37public:
38 /**
4cc4bfaf 39 The constructor accepts a @a format argument which specifies the (single)
7c913512 40 format supported by this object. If it isn't set here,
23324ae1
FM
41 wxDataObjectSimple::SetFormat should be used.
42 */
43 wxCustomDataObject(const wxDataFormat& format = wxFormatInvalid);
44
45 /**
46 The destructor will free the data hold by the object. Notice that although it
47 calls a virtual Free() function, the base
48 class version will always be called (C++ doesn't allow calling virtual
49 functions from constructors or destructors), so if you override @c Free(), you
50 should override the destructor in your class as well (which would probably
51 just call the derived class' version of @c Free()).
52 */
53 ~wxCustomDataObject();
54
55 /**
4cc4bfaf 56 This function is called to allocate @a size bytes of memory from SetData().
23324ae1
FM
57 The default version just uses the operator new.
58 */
4cc4bfaf 59 virtual void* Alloc(size_t size);
23324ae1
FM
60
61 /**
62 This function is called when the data is freed, you may override it to anything
63 you want (or may be nothing at all). The default version calls operator
64 delete[] on the data.
65 */
66 virtual void Free();
67
68 /**
69 Returns a pointer to the data.
70 */
328f5751 71 virtual void* GetData() const;
23324ae1
FM
72
73 /**
74 Returns the data size in bytes.
75 */
328f5751 76 virtual size_t GetSize() const;
23324ae1
FM
77
78 /**
79 Set the data. The data object will make an internal copy.
80 */
81 virtual void SetData(size_t size, const void data);
82
83 /**
84 Like SetData(), but doesn't copy the data -
85 instead the object takes ownership of the pointer.
23324ae1
FM
86 @b wxPython note: This method expects a string in wxPython. You can pass
87 nearly any object by pickling it first.
88 */
89 virtual void TakeData(size_t size, const void data);
90};
91
92
e54c96f1 93
23324ae1
FM
94/**
95 @class wxDataObjectComposite
96 @wxheader{dataobj.h}
7c913512
FM
97
98 wxDataObjectComposite is the simplest
23324ae1 99 wxDataObject derivation which may be used to support
7c913512 100 multiple formats. It contains several
23324ae1
FM
101 wxDataObjectSimple objects and supports any
102 format supported by at least one of them. Only one of these data objects is
103 @e preferred (the first one if not explicitly changed by using the second
104 parameter of wxDataObjectComposite::Add) and its format determines
105 the preferred format of the composite data object as well.
7c913512 106
23324ae1
FM
107 See wxDataObject documentation for the reasons why you
108 might prefer to use wxDataObject directly instead of wxDataObjectComposite for
109 efficiency reasons.
7c913512 110
23324ae1
FM
111 @library{wxcore}
112 @category{FIXME}
7c913512 113
e54c96f1 114 @see @ref overview_wxdndoverview "Clipboard and drag and drop overview",
23324ae1
FM
115 wxDataObject, wxDataObjectSimple, wxFileDataObject, wxTextDataObject, wxBitmapDataObject
116*/
117class wxDataObjectComposite : public wxDataObject
118{
119public:
120 /**
121 The default constructor.
122 */
123 wxDataObjectComposite();
124
125 /**
4cc4bfaf
FM
126 Adds the @a dataObject to the list of supported objects and it becomes the
127 preferred object if @a preferred is @true.
23324ae1 128 */
4cc4bfaf 129 void Add(wxDataObjectSimple dataObject, bool preferred = false);
23324ae1
FM
130
131 /**
132 Report the format passed to the SetData method. This should be the
133 format of the data object within the composite that recieved data from
134 the clipboard or the DnD operation. You can use this method to find
135 out what kind of data object was recieved.
136 */
328f5751 137 wxDataFormat GetReceivedFormat() const;
23324ae1
FM
138};
139
140
e54c96f1 141
23324ae1
FM
142/**
143 @class wxDataObjectSimple
144 @wxheader{dataobj.h}
7c913512
FM
145
146 This is the simplest possible implementation of the
23324ae1
FM
147 wxDataObject class. The data object of (a class derived
148 from) this class only supports one format, so the number of virtual functions
149 to be implemented is reduced.
7c913512 150
23324ae1
FM
151 Notice that this is still an abstract base class and cannot be used but should
152 be derived from.
7c913512 153
23324ae1
FM
154 @b wxPython note: If you wish to create a derived wxDataObjectSimple class in
155 wxPython you should derive the class from wxPyDataObjectSimple
156 in order to get Python-aware capabilities for the various virtual
157 methods.
7c913512 158
23324ae1
FM
159 @b wxPerl note: In wxPerl, you need to derive your data object class
160 from Wx::PlDataObjectSimple.
7c913512 161
23324ae1
FM
162 @library{wxcore}
163 @category{FIXME}
7c913512 164
e54c96f1 165 @see @ref overview_wxdndoverview "Clipboard and drag and drop overview", @ref
23324ae1
FM
166 overview_samplednd "DnD sample", wxFileDataObject, wxTextDataObject, wxBitmapDataObject
167*/
168class wxDataObjectSimple : public wxDataObject
169{
170public:
171 /**
172 Constructor accepts the supported format (none by default) which may also be
173 set later with SetFormat().
174 */
175 wxDataObjectSimple(const wxDataFormat& format = wxFormatInvalid);
176
177 /**
178 Copy the data to the buffer, return @true on success. Must be implemented in the
179 derived class if the object supports rendering its data.
180 */
328f5751 181 virtual bool GetDataHere(void buf) const;
23324ae1
FM
182
183 /**
184 Gets the size of our data. Must be implemented in the derived class if the
185 object supports rendering its data.
186 */
328f5751 187 virtual size_t GetDataSize() const;
23324ae1
FM
188
189 /**
190 Returns the (one and only one) format supported by this object. It is supposed
191 that the format is supported in both directions.
192 */
328f5751 193 const wxDataFormat GetFormat() const;
23324ae1
FM
194
195 /**
196 Copy the data from the buffer, return @true on success. Must be implemented in
197 the derived class if the object supports setting its data.
23324ae1
FM
198 @b wxPython note: When implementing this method in wxPython, the data comes
199 as a single string parameter rather than the two shown here.
200 */
201 virtual bool SetData(size_t len, const void buf);
202
203 /**
204 Sets the supported format.
205 */
206 void SetFormat(const wxDataFormat& format);
207};
208
209
e54c96f1 210
23324ae1
FM
211/**
212 @class wxBitmapDataObject
213 @wxheader{dataobj.h}
7c913512 214
23324ae1 215 wxBitmapDataObject is a specialization of wxDataObject for bitmap data. It can
7c913512 216 be used without change to paste data into the
23324ae1
FM
217 wxClipboard or a wxDropSource. A
218 user may wish to derive a new class from this class for providing a bitmap
219 on-demand in order to minimize memory consumption when offering data in several
220 formats, such as a bitmap and GIF.
7c913512 221
23324ae1
FM
222 @b wxPython note: If you wish to create a derived wxBitmapDataObject class in
223 wxPython you should derive the class from wxPyBitmapDataObject
224 in order to get Python-aware capabilities for the various virtual
225 methods.
7c913512 226
23324ae1
FM
227 @library{wxcore}
228 @category{dnd}
7c913512 229
e54c96f1 230 @see @ref overview_wxdndoverview "Clipboard and drag and drop overview",
23324ae1
FM
231 wxDataObject, wxDataObjectSimple, wxFileDataObject, wxTextDataObject, wxDataObject
232*/
233class wxBitmapDataObject : public wxDataObjectSimple
234{
235public:
236 /**
7c913512 237 Constructor, optionally passing a bitmap (otherwise use
23324ae1
FM
238 SetBitmap() later).
239 */
240 wxBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap);
241
242 /**
243 Returns the bitmap associated with the data object. You may wish to override
244 this method when offering data on-demand, but this is not required by
245 wxWidgets' internals. Use this method to get data in bitmap form from
246 the wxClipboard.
247 */
328f5751 248 virtual wxBitmap GetBitmap() const;
23324ae1
FM
249
250 /**
251 Sets the bitmap associated with the data object. This method is called when the
252 data object receives data. Usually there will be no reason to override this
253 function.
254 */
255 virtual void SetBitmap(const wxBitmap& bitmap);
256};
257
258
e54c96f1 259
23324ae1
FM
260/**
261 @class wxDataFormat
262 @wxheader{dataobj.h}
7c913512 263
23324ae1
FM
264 A wxDataFormat is an encapsulation of a platform-specific format handle which
265 is used by the system for the clipboard and drag and drop operations. The
266 applications are usually only interested in, for example, pasting data from the
267 clipboard only if the data is in a format the program understands and a data
268 format is something which uniquely identifies this format.
7c913512 269
23324ae1
FM
270 On the system level, a data format is usually just a number (@c CLIPFORMAT
271 under Windows or @c Atom under X11, for example) and the standard formats
272 are, indeed, just numbers which can be implicitly converted to wxDataFormat.
273 The standard formats are:
7c913512
FM
274
275
276
23324ae1 277 wxDF_INVALID
7c913512
FM
278
279
23324ae1
FM
280 An invalid format - used as default argument for
281 functions taking a wxDataFormat argument sometimes
7c913512
FM
282
283
23324ae1 284 wxDF_TEXT
7c913512
FM
285
286
23324ae1 287 Text format (wxString)
7c913512
FM
288
289
23324ae1 290 wxDF_BITMAP
7c913512
FM
291
292
23324ae1 293 A bitmap (wxBitmap)
7c913512
FM
294
295
23324ae1 296 wxDF_METAFILE
7c913512
FM
297
298
23324ae1 299 A metafile (wxMetafile, Windows only)
7c913512
FM
300
301
23324ae1 302 wxDF_FILENAME
7c913512
FM
303
304
23324ae1 305 A list of filenames
7c913512
FM
306
307
23324ae1 308 wxDF_HTML
7c913512
FM
309
310
23324ae1
FM
311 An HTML string. This is only valid when passed to wxSetClipboardData
312 when compiled with Visual C++ in non-Unicode mode
7c913512
FM
313
314
315
23324ae1
FM
316 As mentioned above, these standard formats may be passed to any function taking
317 wxDataFormat argument because wxDataFormat has an implicit conversion from
318 them (or, to be precise from the type @c wxDataFormat::NativeFormat which is
319 the type used by the underlying platform for data formats).
7c913512 320
23324ae1
FM
321 Aside the standard formats, the application may also use custom formats which
322 are identified by their names (strings) and not numeric identifiers. Although
323 internally custom format must be created (or @e registered) first, you
324 shouldn't care about it because it is done automatically the first time the
325 wxDataFormat object corresponding to a given format name is created. The only
326 implication of this is that you should avoid having global wxDataFormat objects
327 with non-default constructor because their constructors are executed before the
328 program has time to perform all necessary initialisations and so an attempt to
329 do clipboard format registration at this time will usually lead to a crash!
7c913512 330
23324ae1
FM
331 @library{wxbase}
332 @category{dnd}
7c913512 333
e54c96f1 334 @see @ref overview_wxdndoverview "Clipboard and drag and drop overview", @ref
23324ae1
FM
335 overview_samplednd "DnD sample", wxDataObject
336*/
7c913512 337class wxDataFormat
23324ae1
FM
338{
339public:
340 /**
7c913512 341 Constructs a data format object for a custom format identified by its name
23324ae1
FM
342 @e format.
343 */
344 wxDataFormat(const wxChar format);
345
346 /**
347 Returns the name of a custom format (this function will fail for a standard
348 format).
349 */
328f5751 350 wxString GetId() const;
23324ae1
FM
351
352 /**
353 Returns the platform-specific number identifying the format.
354 */
328f5751 355 NativeFormat GetType() const;
23324ae1
FM
356
357 /**
358 Sets the format to be the custom format identified by the given name.
359 */
360 void SetId(const wxChar format);
361
362 /**
363 Sets the format to the given value, which should be one of wxDF_XXX constants.
364 */
365 void SetType(NativeFormat format);
366
367 /**
368 Returns @true if the formats are different.
369 */
328f5751 370 bool operator !=(const wxDataFormat& format) const;
23324ae1
FM
371
372 /**
373 Returns @true if the formats are equal.
374 */
328f5751 375 bool operator ==(const wxDataFormat& format) const;
23324ae1
FM
376};
377
378
e54c96f1 379
23324ae1
FM
380/**
381 @class wxURLDataObject
382 @wxheader{dataobj.h}
7c913512 383
23324ae1
FM
384 wxURLDataObject is a wxDataObject containing an URL
385 and can be used e.g. when you need to put an URL on or retrieve it from the
386 clipboard:
7c913512 387
23324ae1
FM
388 @code
389 wxTheClipboard-SetData(new wxURLDataObject(url));
390 @endcode
7c913512 391
23324ae1
FM
392 @library{wxcore}
393 @category{dnd}
7c913512 394
e54c96f1
FM
395 @see @ref overview_wxdndoverview "Clipboard and drag and drop overview",
396 wxDataObject
23324ae1 397*/
7c913512 398class wxURLDataObject
23324ae1
FM
399{
400public:
401 /**
4cc4bfaf 402 Constructor, may be used to initialize the URL. If @a url is empty,
23324ae1
FM
403 SetURL() can be used later.
404 */
405 wxURLDataObject(const wxString& url = wxEmptyString);
406
407 /**
408 Returns the URL stored by this object, as a string.
409 */
328f5751 410 wxString GetURL() const;
23324ae1
FM
411
412 /**
413 Sets the URL stored by this object.
414 */
4cc4bfaf 415 void SetURL(const wxString& url);
23324ae1
FM
416};
417
418
e54c96f1 419
23324ae1
FM
420/**
421 @class wxDataObject
422 @wxheader{dataobj.h}
7c913512 423
23324ae1
FM
424 A wxDataObject represents data that can be copied to or from the clipboard, or
425 dragged and dropped. The important thing about wxDataObject is that this is a
426 'smart' piece of data unlike 'dumb' data containers such as memory
427 buffers or files. Being 'smart' here means that the data object itself should
428 know what data formats it supports and how to render itself in each of
429 its supported formats.
7c913512 430
23324ae1
FM
431 A supported format, incidentally, is exactly the format in which the data can
432 be requested from a data object or from which the data object may be set. In
433 the general case, an object may support different formats on 'input' and
434 'output', i.e. it may be able to render itself in a given format but not be
435 created from data on this format or vice versa. wxDataObject defines an
436 enumeration type
7c913512 437
23324ae1
FM
438 @code
439 enum Direction
440 {
441 Get = 0x01, // format is supported by GetDataHere()
442 Set = 0x02 // format is supported by SetData()
443 };
444 @endcode
7c913512
FM
445
446 which distinguishes between them. See
23324ae1 447 wxDataFormat documentation for more about formats.
7c913512 448
23324ae1
FM
449 Not surprisingly, being 'smart' comes at a price of added complexity. This is
450 reasonable for the situations when you really need to support multiple formats,
451 but may be annoying if you only want to do something simple like cut and paste
452 text.
7c913512 453
23324ae1 454 To provide a solution for both cases, wxWidgets has two predefined classes
7c913512
FM
455 which derive from wxDataObject: wxDataObjectSimple and
456 wxDataObjectComposite.
23324ae1
FM
457 wxDataObjectSimple is
458 the simplest wxDataObject possible and only holds data in a single format (such
459 as HTML or text) and wxDataObjectComposite is
460 the simplest way to implement a wxDataObject that does support multiple formats
461 because it achieves this by simply holding several wxDataObjectSimple objects.
7c913512 462
23324ae1
FM
463 So, you have several solutions when you need a wxDataObject class (and you need
464 one as soon as you want to transfer data via the clipboard or drag and drop):
7c913512
FM
465
466
467
23324ae1 468 @b 1. Use one of the built-in classes
7c913512
FM
469
470
23324ae1
FM
471 You may use wxTextDataObject,
472 wxBitmapDataObject or wxFileDataObject in the simplest cases when you only need
473 to support one format and your data is either text, bitmap or list of files.
7c913512
FM
474
475
23324ae1 476 @b 2. Use wxDataObjectSimple
7c913512
FM
477
478
23324ae1
FM
479 Deriving from wxDataObjectSimple is the simplest
480 solution for custom data - you will only support one format and so probably
481 won't be able to communicate with other programs, but data transfer will work
482 in your program (or between different copies of it).
7c913512
FM
483
484
23324ae1 485 @b 3. Use wxDataObjectComposite
7c913512
FM
486
487
23324ae1
FM
488 This is a simple but powerful
489 solution which allows you to support any number of formats (either
490 standard or custom if you combine it with the previous solution).
7c913512
FM
491
492
23324ae1 493 @b 4. Use wxDataObject directly
7c913512
FM
494
495
23324ae1
FM
496 This is the solution for
497 maximal flexibility and efficiency, but it is also the most difficult to
498 implement.
7c913512
FM
499
500
501
23324ae1
FM
502 Please note that the easiest way to use drag and drop and the clipboard with
503 multiple formats is by using wxDataObjectComposite, but it is not the most
504 efficient one as each wxDataObjectSimple would contain the whole data in its
505 respective formats. Now imagine that you want to paste 200 pages of text in
506 your proprietary format, as well as Word, RTF, HTML, Unicode and plain text to
507 the clipboard and even today's computers are in trouble. For this case, you
508 will have to derive from wxDataObject directly and make it enumerate its
509 formats and provide the data in the requested format on demand.
7c913512 510
23324ae1
FM
511 Note that neither the GTK+ data transfer mechanisms for clipboard and
512 drag and drop, nor OLE data transfer, copy any data until another application
513 actually requests the data. This is in contrast to the 'feel' offered to the
514 user of a program who would normally think that the data resides in the
515 clipboard after having pressed 'Copy' - in reality it is only declared to be
516 available.
7c913512 517
23324ae1 518 There are several predefined data object classes derived from
7c913512 519 wxDataObjectSimple: wxFileDataObject,
23324ae1
FM
520 wxTextDataObject,
521 wxBitmapDataObject and
522 wxURLDataObject
523 which can be used without change.
7c913512
FM
524
525 You may also derive your own data object classes from
23324ae1
FM
526 wxCustomDataObject for user-defined types. The
527 format of user-defined data is given as a mime-type string literal, such as
528 "application/word" or "image/png". These strings are used as they are under
529 Unix (so far only GTK+) to identify a format and are translated into their
530 Windows equivalent under Win32 (using the OLE IDataObject for data exchange to
531 and from the clipboard and for drag and drop). Note that the format string
532 translation under Windows is not yet finished.
7c913512 533
23324ae1 534 @b wxPython note: At this time this class is not directly usable from wxPython.
e54c96f1 535 Derive a class from wxPyDataObjectSimple()
23324ae1 536 instead.
7c913512 537
23324ae1
FM
538 @b wxPerl note: This class is not currently usable from wxPerl; you may
539 use Wx::PlDataObjectSimple instead.
7c913512 540
23324ae1
FM
541 @library{wxcore}
542 @category{dnd}
7c913512 543
e54c96f1 544 @see @ref overview_wxdndoverview "Clipboard and drag and drop overview", @ref
23324ae1
FM
545 overview_samplednd "DnD sample", wxFileDataObject, wxTextDataObject, wxBitmapDataObject, wxCustomDataObject, wxDropTarget, wxDropSource, wxTextDropTarget, wxFileDropTarget
546*/
7c913512 547class wxDataObject
23324ae1
FM
548{
549public:
550 /**
551 Constructor.
552 */
553 wxDataObject();
554
555 /**
556 Destructor.
557 */
558 ~wxDataObject();
559
560 /**
7c913512 561 Copy all supported formats in the given direction to the array pointed to by
23324ae1
FM
562 @e formats. There is enough space for GetFormatCount(dir) formats in it.
563 */
4cc4bfaf 564 virtual void GetAllFormats(wxDataFormat* formats,
328f5751 565 Direction dir = Get) const;
23324ae1
FM
566
567 /**
4cc4bfaf 568 The method will write the data of the format @a format in the buffer @a buf and
23324ae1
FM
569 return @true on success, @false on failure.
570 */
328f5751 571 virtual bool GetDataHere(const wxDataFormat& format, void buf) const;
23324ae1
FM
572
573 /**
574 Returns the data size of the given format @e format.
575 */
328f5751 576 virtual size_t GetDataSize(const wxDataFormat& format) const;
23324ae1
FM
577
578 /**
579 Returns the number of available formats for rendering or setting the data.
580 */
328f5751 581 virtual size_t GetFormatCount(Direction dir = Get) const;
23324ae1
FM
582
583 /**
4cc4bfaf 584 Returns the preferred format for either rendering the data (if @a dir is @c Get,
23324ae1
FM
585 its default value) or for setting it. Usually this will be the
586 native format of the wxDataObject.
587 */
328f5751 588 virtual wxDataFormat GetPreferredFormat(Direction dir = Get) const;
23324ae1
FM
589
590 /**
4cc4bfaf 591 Set the data in the format @a format of the length @a len provided in the
23324ae1 592 buffer @e buf.
23324ae1
FM
593 Returns @true on success, @false on failure.
594 */
595 virtual bool SetData(const wxDataFormat& format, size_t len,
596 const void buf);
597};
598
599
e54c96f1 600
23324ae1
FM
601/**
602 @class wxTextDataObject
603 @wxheader{dataobj.h}
7c913512 604
23324ae1 605 wxTextDataObject is a specialization of wxDataObject for text data. It can be
7c913512 606 used without change to paste data into the wxClipboard
23324ae1
FM
607 or a wxDropSource. A user may wish to derive a new
608 class from this class for providing text on-demand in order to minimize memory
609 consumption when offering data in several formats, such as plain text and RTF
610 because by default the text is stored in a string in this class, but it might
7c913512
FM
611 as well be generated when requested. For this,
612 wxTextDataObject::GetTextLength and
23324ae1 613 wxTextDataObject::GetText will have to be overridden.
7c913512 614
23324ae1
FM
615 Note that if you already have the text inside a string, you will not achieve
616 any efficiency gain by overriding these functions because copying wxStrings is
617 already a very efficient operation (data is not actually copied because
618 wxStrings are reference counted).
7c913512 619
23324ae1
FM
620 @b wxPython note: If you wish to create a derived wxTextDataObject class in
621 wxPython you should derive the class from wxPyTextDataObject
622 in order to get Python-aware capabilities for the various virtual
623 methods.
7c913512 624
23324ae1
FM
625 @library{wxcore}
626 @category{dnd}
7c913512 627
e54c96f1 628 @see @ref overview_wxdndoverview "Clipboard and drag and drop overview",
23324ae1
FM
629 wxDataObject, wxDataObjectSimple, wxFileDataObject, wxBitmapDataObject
630*/
631class wxTextDataObject : public wxDataObjectSimple
632{
633public:
634 /**
7c913512 635 Constructor, may be used to initialise the text (otherwise
23324ae1
FM
636 SetText() should be used later).
637 */
638 wxTextDataObject(const wxString& text = wxEmptyString);
639
640 /**
641 Returns the text associated with the data object. You may wish to override
642 this method when offering data on-demand, but this is not required by
643 wxWidgets' internals. Use this method to get data in text form from
644 the wxClipboard.
645 */
328f5751 646 virtual wxString GetText() const;
23324ae1
FM
647
648 /**
649 Returns the data size. By default, returns the size of the text data
650 set in the constructor or using SetText().
651 This can be overridden to provide text size data on-demand. It is recommended
652 to return the text length plus 1 for a trailing zero, but this is not
653 strictly required.
654 */
328f5751 655 virtual size_t GetTextLength() const;
23324ae1
FM
656
657 /**
658 Sets the text associated with the data object. This method is called
659 when the data object receives the data and, by default, copies the text into
660 the member variable. If you want to process the text on the fly you may wish to
661 override this function.
662 */
663 virtual void SetText(const wxString& strText);
664};
665
666
e54c96f1 667
23324ae1
FM
668/**
669 @class wxFileDataObject
670 @wxheader{dataobj.h}
7c913512
FM
671
672 wxFileDataObject is a specialization of wxDataObject
23324ae1
FM
673 for file names. The program works with it just as if it were a list of absolute
674 file
675 names, but internally it uses the same format as
676 Explorer and other compatible programs under Windows or GNOME/KDE filemanager
677 under Unix which makes it possible to receive files from them using this
678 class.
7c913512 679
23324ae1
FM
680 @b Warning: Under all non-Windows platforms this class is currently
681 "input-only", i.e. you can receive the files from another application, but
682 copying (or dragging) file(s) from a wxWidgets application is not currently
683 supported. PS: GTK2 should work as well.
7c913512 684
23324ae1
FM
685 @library{wxcore}
686 @category{dnd}
7c913512 687
e54c96f1 688 @see wxDataObject, wxDataObjectSimple, wxTextDataObject, wxBitmapDataObject,
23324ae1
FM
689 wxDataObject
690*/
691class wxFileDataObject : public wxDataObjectSimple
692{
693public:
694 /**
695 Constructor.
696 */
697 wxFileDataObject();
698
699 /**
700 @b MSW only: adds a file to the file list represented by this data object.
701 */
702 virtual void AddFile(const wxString& file);
703
704 /**
e54c96f1 705 Returns the array() of file names.
23324ae1 706 */
328f5751 707 const wxArrayString GetFilenames() const;
23324ae1 708};
e54c96f1 709