]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dataobj.h
Updates to the wxPython distribution builders
[wxWidgets.git] / include / wx / dataobj.h
CommitLineData
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
VZ
16// ----------------------------------------------------------------------------
17// wxDataFormat identifies the single format of data
18// ----------------------------------------------------------------------------
19
20class WXDLLEXPORT wxDataFormat
21{
22public:
23 // the clipboard formats under Win32 are UINTs
24 typedef unsigned int NativeFormat;
25
26 wxDataFormat(NativeFormat format = wxDF_INVALID) { m_format = format; }
27 wxDataFormat& operator=(NativeFormat format)
28 { m_format = format; return *this; }
29
30 // defautl copy ctor/assignment operators ok
31
32 // comparison (must have both versions)
33 bool operator==(wxDataFormatId format) const
34 { return m_format == (NativeFormat)format; }
35 bool operator!=(wxDataFormatId format) const
36 { return m_format != (NativeFormat)format; }
37 bool operator==(const wxDataFormat& format) const
38 { return m_format == format.m_format; }
39 bool operator!=(const wxDataFormat& format) const
40 { return m_format != format.m_format; }
41
42 // explicit and implicit conversions to NativeFormat which is one of
43 // standard data types (implicit conversion is useful for preserving the
44 // compatibility with old code)
45 NativeFormat GetFormatId() const { return m_format; }
46 operator NativeFormat() const { return m_format; }
47
48 // this only works with standard ids
49 void SetId(wxDataFormatId format) { m_format = format; }
50
51 // string ids are used for custom types - this SetId() must be used for
52 // application-specific formats
53 wxString GetId() const;
54 void SetId(const wxChar *format);
55
56private:
57 // returns TRUE if the format is one of those defined in wxDataFormatId
58 bool IsStandard() const { return m_format > 0 && m_format < wxDF_MAX; }
59
60 NativeFormat m_format;
61};
62
63 #include "wx/msw/ole/dataobj.h"
8b53e5a2 64#elif defined(__WXMOTIF__)
3f480da3 65 #include "wx/motif/dataobj.h"
8b53e5a2 66#elif defined(__WXGTK__)
3f480da3 67 #include "wx/gtk/dataobj.h"
8b53e5a2 68#elif defined(__WXQT__)
3f480da3 69 #include "wx/qt/dnd.h"
8b53e5a2 70#elif defined(__WXMAC__)
3f480da3 71 #include "wx/mac/dnd.h"
8b53e5a2 72#elif defined(__WXSTUBS__)
3f480da3 73 #include "wx/stubs/dnd.h"
8b53e5a2
RR
74#endif
75
3f480da3
VZ
76// ---------------------------------------------------------------------------
77// wxPrivateDataObject is a specialization of wxDataObject for app specific
78// data (of some given kind, derive directly from wxDataObject if you wish to
79// efficiently support multiple formats)
80// ---------------------------------------------------------------------------
81
82class WXDLLEXPORT wxPrivateDataObject : public wxDataObject
83{
910f1f8c
RR
84#ifdef __WXGTK__
85 DECLARE_DYNAMIC_CLASS( wxPrivateDataObject )
86#endif
3f480da3
VZ
87
88public:
89 wxPrivateDataObject();
90 virtual ~wxPrivateDataObject() { Free(); }
91
92 // get the format object - it is used to decide whether we support the
93 // given output format or not
94 wxDataFormat& GetFormat() { return m_format; }
95
96 // set data. will make copy of the data
97 void SetData( const void *data, size_t size );
98
99 // returns pointer to data
100 void *GetData() const { return m_data; }
101
102 // get the size of the data
103 virtual size_t GetSize() const;
104
105 // copy data to the given buffer
106 virtual void WriteData( void *dest ) const;
107
108 // these functions are provided for wxGTK compatibility, their usage is
109 // deprecated - use GetFormat().SetId() instead
110 void SetId( const wxString& id ) { m_format.SetId(id); }
111 wxString GetId() const { return m_format.GetId(); }
112
113 // implement the base class pure virtuals
b8e25d73 114 virtual wxDataFormat GetPreferredFormat() const
3f480da3
VZ
115 { return m_format; }
116 virtual bool IsSupportedFormat(wxDataFormat format) const
117 { return m_format == format; }
118 virtual size_t GetDataSize() const
119 { return m_size; }
120 virtual void GetDataHere(void *dest) const
121 { WriteData(dest); }
122
3f480da3
VZ
123 // the function which really copies the data - called by WriteData() above
124 // and uses GetSize() to get the size of the data
3f480da3
VZ
125 void WriteData( const void *data, void *dest ) const;
126
127private:
128 // free the data
27db7200 129 void Free();
3f480da3
VZ
130
131 // the data
132 size_t m_size;
133 void *m_data;
134
135 // the data format
136 wxDataFormat m_format;
137};
138
139
8b53e5a2
RR
140#endif
141 // _WX_DATAOBJ_H_BASE_