+// ----------------------------------------------------------------------------
+// wxDataObjectSimple is a wxDataObject which only supports one format (in
+// both Get and Set directions, but you may return FALSE from GetDataHere() or
+// SetData() if one of them is not supported). This is the simplest possible
+// wxDataObject implementation.
+//
+// This is still an "abstract base class" (although it doesn't have any pure
+// virtual functions), to use it you should derive from it and implement
+// GetDataSize(), GetDataHere() and SetData() functions because the base class
+// versions don't do anything - they just return "not implemented".
+//
+// This class should be used when you provide data in only one format (no
+// conversion to/from other formats), either a standard or a custom one.
+// Otherwise, you should use wxDataObjectComposite or wxDataObject directly.
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxDataObjectSimple : public wxDataObject
+{
+public:
+ // ctor takes the format we support, but it can also be set later with
+ // SetFormat()
+ wxDataObjectSimple(const wxDataFormat& format = wxFormatInvalid)
+ : m_format(format)
+ {
+ }
+
+ // get/set the format we support
+ const wxDataFormat& GetFormat() const { return m_format; }
+ void SetFormat(const wxDataFormat& format) { m_format = format; }
+
+ // virtual functions to override in derived class (the base class versions
+ // just return "not implemented")
+ // -----------------------------------------------------------------------
+
+ // get the size of our data
+ virtual size_t GetDataSize() const
+ { return 0; }
+
+ // copy our data to the buffer
+ virtual bool GetDataHere(void *WXUNUSED(buf)) const
+ { return FALSE; }
+
+ // copy data from buffer to our data
+ virtual bool SetData(size_t WXUNUSED(len), const void *WXUNUSED(buf))
+ { return FALSE; }
+
+ // implement base class pure virtuals
+ // ----------------------------------
+ virtual wxDataFormat GetPreferredFormat(wxDataObjectBase::Direction WXUNUSED(dir) = Get) const
+ { return m_format; }
+ virtual size_t GetFormatCount(wxDataObjectBase::Direction WXUNUSED(dir) = Get) const
+ { return 1; }
+ virtual void GetAllFormats(wxDataFormat *formats,
+ wxDataObjectBase::Direction WXUNUSED(dir) = Get) const
+ { *formats = m_format; }
+ virtual size_t GetDataSize(const wxDataFormat& WXUNUSED(format)) const
+ { return GetDataSize(); }
+ virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format),
+ void *buf) const
+ { return GetDataHere(buf); }
+ virtual bool SetData(const wxDataFormat& WXUNUSED(format),
+ size_t len, const void *buf)
+ { return SetData(len, buf); }
+
+private:
+ // the one and only format we support
+ wxDataFormat m_format;
+
+ DECLARE_NO_COPY_CLASS(wxDataObjectSimple)
+};
+
+// ----------------------------------------------------------------------------
+// wxDataObjectComposite is the simplest way to implement wxDataObject
+// supporting multiple formats. It contains several wxDataObjectSimple and
+// supports all formats supported by any of them.
+//
+// This class shouldn't be (normally) derived from, but may be used directly.
+// If you need more flexibility than what it provides, you should probably use
+// wxDataObject directly.
+// ----------------------------------------------------------------------------
+
+WX_DECLARE_EXPORTED_LIST(wxDataObjectSimple, wxSimpleDataObjectList);