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