]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/ole/dataobj.h
Updates from Chris Breeze
[wxWidgets.git] / include / wx / msw / ole / dataobj.h
CommitLineData
1737035f
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: ole/dataobj.h
3// Purpose: declaration of the wxDataObject class
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 10.05.98
7// RCS-ID: $Id$
8// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9// Licence: wxWindows license
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _OLEDATAOBJ_H
13#define _OLEDATAOBJ_H
14
15// ----------------------------------------------------------------------------
16// forward declarations
17// ----------------------------------------------------------------------------
18struct IDataObject;
19
20// ----------------------------------------------------------------------------
21// wxDataObject is a "smart" and polymorphic piece of data.
22//
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// ----------------------------------------------------------------------------
27
28class wxDataObject
29{
30public:
31 // all data formats (values are the same as in windows.h, do not change!)
32 enum StdFormat
33 {
34 Invalid,
35 Text,
36 Bitmap,
37 MetafilePict,
38 Sylk,
39 Dif,
40 Tiff,
41 OemText,
42 Dib,
43 Palette,
44 Pendata,
45 Riff,
46 Wave,
47 UnicodeText,
48 EnhMetafile,
49 Hdrop,
50 Locale,
51 Max
52 };
53
54 #ifdef __DEBUG__
55 // function to return symbolic name of clipboard format (debug messages)
56 static const char *GetFormatName(wxDataFormat format);
57 #endif
58
59 // ctor & dtor
60 wxDataObject();
61 ~wxDataObject();
62
63 // pure virtuals to override
64 // get the best suited format for our data
65 virtual wxDataFormat GetPreferredFormat() const = 0;
66 // decide if we support this format (should be one of values of
67 // StdFormat enumerations or a user-defined format)
68 virtual bool IsSupportedFormat(wxDataFormat format) const = 0;
69 // get the (total) size of data
70 virtual uint GetDataSize() const = 0;
71 // copy raw data to provided pointer
72 virtual void GetDataHere(void *pBuf) const = 0;
73
74 // accessors
75 // retrieve IDataObject interface (for other OLE related classes)
76 IDataObject *GetInterface() const { return m_pIDataObject; }
77
78private:
79 IDataObject *m_pIDataObject; // pointer to the COM interface
80};
81
82// ----------------------------------------------------------------------------
83// wxTextDataObject is a specialization of wxDataObject for text data
84// ----------------------------------------------------------------------------
85class wxTextDataObject : public wxDataObject
86{
87public:
88 // ctors
89 wxTextDataObject();
90 wxTextDataObject(const wxString& strText) : m_strText(strText) { }
91 void Init(const wxString& strText) { m_strText = strText; }
92
93 // implement base class pure virtuals
94 virtual wxDataFormat GetPreferredFormat() const
95 { return wxDataObject::Text; }
96 virtual bool IsSupportedFormat(wxDataFormat format) const
97 { return format == wxDataObject::Text || format == wxDataObject::Locale; }
98 virtual uint GetDataSize() const
99 { return m_strText.Len() + 1; } // +1 for trailing '\0'of course
100 virtual void GetDataHere(void *pBuf) const
101 { memcpy(pBuf, m_strText.c_str(), GetDataSize()); }
102
103private:
104 wxString m_strText;
105};
106
107// ----------------------------------------------------------------------------
108// @@@ TODO: wx{Bitmap|Metafile|...}DataObject
109// ----------------------------------------------------------------------------
110
111#endif //_OLEDATAOBJ_H