]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/ole/dataobj.h
wxDocManager gets the only view if none other specified as the current view;
[wxWidgets.git] / include / wx / msw / ole / dataobj.h
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 // ----------------------------------------------------------------------------
18 struct 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
28 class wxDataObject
29 {
30 public:
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 // function to return symbolic name of clipboard format (debug messages)
55 static const char *GetFormatName(wxDataFormat format);
56
57 // ctor & dtor
58 wxDataObject();
59 ~wxDataObject();
60
61 // pure virtuals to override
62 // get the best suited format for our data
63 virtual wxDataFormat GetPreferredFormat() const = 0;
64 // decide if we support this format (should be one of values of
65 // StdFormat enumerations or a user-defined format)
66 virtual bool IsSupportedFormat(wxDataFormat format) const = 0;
67 // get the (total) size of data
68 virtual uint GetDataSize() const = 0;
69 // copy raw data to provided pointer
70 virtual void GetDataHere(void *pBuf) const = 0;
71
72 // accessors
73 // retrieve IDataObject interface (for other OLE related classes)
74 IDataObject *GetInterface() const { return m_pIDataObject; }
75
76 private:
77 IDataObject *m_pIDataObject; // pointer to the COM interface
78 };
79
80 // ----------------------------------------------------------------------------
81 // wxTextDataObject is a specialization of wxDataObject for text data
82 // ----------------------------------------------------------------------------
83 class wxTextDataObject : public wxDataObject
84 {
85 public:
86 // ctors
87 wxTextDataObject();
88 wxTextDataObject(const wxString& strText) : m_strText(strText) { }
89 void Init(const wxString& strText) { m_strText = strText; }
90
91 // implement base class pure virtuals
92 virtual wxDataFormat GetPreferredFormat() const
93 { return wxDataObject::Text; }
94 virtual bool IsSupportedFormat(wxDataFormat format) const
95 { return format == wxDataObject::Text || format == wxDataObject::Locale; }
96 virtual uint GetDataSize() const
97 { return m_strText.Len() + 1; } // +1 for trailing '\0'of course
98 virtual void GetDataHere(void *pBuf) const
99 { memcpy(pBuf, m_strText.c_str(), GetDataSize()); }
100
101 private:
102 wxString m_strText;
103 };
104
105 // ----------------------------------------------------------------------------
106 // @@@ TODO: wx{Bitmap|Metafile|...}DataObject
107 // ----------------------------------------------------------------------------
108
109 #endif //_OLEDATAOBJ_H