]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/ole/dataobj.h
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: declaration of the wxDataObject class
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
15 // ----------------------------------------------------------------------------
16 // forward declarations
17 // ----------------------------------------------------------------------------
20 // ----------------------------------------------------------------------------
21 // wxDataObject is a "smart" and polymorphic piece of data.
23 // @@@ it's currently "read-only" from COM point of view, i.e. we don't support
24 // SetData. We don't support all advise functions neither (but it's easy to
25 // do if we really want them)
26 // ----------------------------------------------------------------------------
31 // all data formats (values are the same as in windows.h, do not change!)
55 // function to return symbolic name of clipboard format (debug messages)
56 static const char *GetFormatName(wxDataFormat format
);
57 #else // not used in release mode
58 inline const char* GetFormatName(wxDataFormat format
) { return ""; }
65 // pure virtuals to override
66 // get the best suited format for our data
67 virtual wxDataFormat
GetPreferredFormat() const = 0;
68 // decide if we support this format (should be one of values of
69 // StdFormat enumerations or a user-defined format)
70 virtual bool IsSupportedFormat(wxDataFormat format
) const = 0;
71 // get the (total) size of data
72 virtual uint
GetDataSize() const = 0;
73 // copy raw data to provided pointer
74 virtual void GetDataHere(void *pBuf
) const = 0;
77 // retrieve IDataObject interface (for other OLE related classes)
78 IDataObject
*GetInterface() const { return m_pIDataObject
; }
81 IDataObject
*m_pIDataObject
; // pointer to the COM interface
84 // ----------------------------------------------------------------------------
85 // wxTextDataObject is a specialization of wxDataObject for text data
86 // ----------------------------------------------------------------------------
87 class wxTextDataObject
: public wxDataObject
92 wxTextDataObject(const wxString
& strText
) : m_strText(strText
) { }
93 void Init(const wxString
& strText
) { m_strText
= strText
; }
95 // implement base class pure virtuals
96 virtual wxDataFormat
GetPreferredFormat() const
97 { return wxDataObject::Text
; }
98 virtual bool IsSupportedFormat(wxDataFormat format
) const
99 { return format
== wxDataObject::Text
|| format
== wxDataObject::Locale
; }
100 virtual uint
GetDataSize() const
101 { return m_strText
.Len() + 1; } // +1 for trailing '\0'of course
102 virtual void GetDataHere(void *pBuf
) const
103 { memcpy(pBuf
, m_strText
.c_str(), GetDataSize()); }
109 // ----------------------------------------------------------------------------
110 // @@@ TODO: wx{Bitmap|Metafile|...}DataObject
111 // ----------------------------------------------------------------------------
113 #endif //_OLEDATAOBJ_H