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