]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: dataobj.h | |
3 | // Purpose: common data object classes | |
4 | // Author: Robert Roebling, Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 26.05.99 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) wxWindows Team | |
9 | // Licence: wxWindows license | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_DATAOBJ_H_BASE_ | |
13 | #define _WX_DATAOBJ_H_BASE_ | |
14 | ||
15 | #if defined(__WXMSW__) | |
16 | #include "wx/msw/ole/dataobj.h" | |
17 | #elif defined(__WXMOTIF__) | |
18 | #include "wx/motif/dataobj.h" | |
19 | #elif defined(__WXGTK__) | |
20 | #include "wx/gtk/dataobj.h" | |
21 | #elif defined(__WXQT__) | |
22 | #include "wx/qt/dnd.h" | |
23 | #elif defined(__WXMAC__) | |
24 | #include "wx/mac/dnd.h" | |
25 | #elif defined(__WXPM__) | |
26 | #include "wx/os2/dataobj.h" | |
27 | #elif defined(__WXSTUBS__) | |
28 | #include "wx/stubs/dnd.h" | |
29 | #endif | |
30 | ||
31 | // --------------------------------------------------------------------------- | |
32 | // wxPrivateDataObject is a specialization of wxDataObject for app specific | |
33 | // data (of some given kind, derive directly from wxDataObject if you wish to | |
34 | // efficiently support multiple formats) | |
35 | // --------------------------------------------------------------------------- | |
36 | ||
37 | class WXDLLEXPORT wxPrivateDataObject : public wxDataObject | |
38 | { | |
39 | #if defined(__WXGTK__) || defined(__WXMOTIF__) | |
40 | DECLARE_DYNAMIC_CLASS( wxPrivateDataObject ) | |
41 | #endif | |
42 | ||
43 | public: | |
44 | wxPrivateDataObject(); | |
45 | virtual ~wxPrivateDataObject() { Free(); } | |
46 | ||
47 | // get the format object - it is used to decide whether we support the | |
48 | // given output format or not | |
49 | wxDataFormat& GetFormat() { return m_format; } | |
50 | ||
51 | // set data. will make copy of the data | |
52 | void SetData( const void *data, size_t size ); | |
53 | ||
54 | // returns pointer to data | |
55 | void *GetData() const { return m_data; } | |
56 | ||
57 | // get the size of the data | |
58 | virtual size_t GetSize() const; | |
59 | ||
60 | // copy data to the given buffer | |
61 | virtual void WriteData( void *dest ) const; | |
62 | ||
63 | // these functions are provided for wxGTK compatibility, their usage is | |
64 | // deprecated - use GetFormat().SetId() instead | |
65 | void SetId( const wxString& id ) { m_format.SetId(id); } | |
66 | wxString GetId() const { return m_format.GetId(); } | |
67 | ||
68 | // implement the base class pure virtuals | |
69 | virtual wxDataFormat GetPreferredFormat() const | |
70 | { return m_format; } | |
71 | virtual bool IsSupportedFormat(wxDataFormat format) const | |
72 | { return m_format == format; } | |
73 | virtual size_t GetDataSize() const | |
74 | { return m_size; } | |
75 | virtual void GetDataHere(void *dest) const | |
76 | { WriteData(dest); } | |
77 | ||
78 | // the function which really copies the data - called by WriteData() above | |
79 | // and uses GetSize() to get the size of the data | |
80 | void WriteData( const void *data, void *dest ) const; | |
81 | ||
82 | private: | |
83 | // free the data | |
84 | void Free(); | |
85 | ||
86 | // the data | |
87 | size_t m_size; | |
88 | void *m_data; | |
89 | ||
90 | #if !defined(__WXGTK__) && !defined(__WXMOTIF__) | |
91 | // the data format | |
92 | wxDataFormat m_format; | |
93 | #endif | |
94 | }; | |
95 | ||
96 | ||
97 | #endif | |
98 | // _WX_DATAOBJ_H_BASE_ |