]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/ole/dataobj.h
The new wxRect doesn't compile so I #if 0ed it
[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>
bbcdf8bc 9// Licence: wxWindows licence
1737035f
VZ
10///////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_OLEDATAOBJ_H
13#define _WX_OLEDATAOBJ_H
1737035f
VZ
14
15// ----------------------------------------------------------------------------
16// forward declarations
17// ----------------------------------------------------------------------------
18struct IDataObject;
19
20// ----------------------------------------------------------------------------
21// wxDataObject is a "smart" and polymorphic piece of data.
22//
3f480da3
VZ
23// TODO 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)
1737035f
VZ
26// ----------------------------------------------------------------------------
27
8853b9a8 28class WXDLLEXPORT wxDataObject
1737035f
VZ
29{
30public:
40e1a9c0
JS
31 // function to return symbolic name of clipboard format (debug messages)
32 static const char *GetFormatName(wxDataFormat format);
1737035f
VZ
33
34 // ctor & dtor
35 wxDataObject();
36 ~wxDataObject();
37
38 // pure virtuals to override
39 // get the best suited format for our data
40 virtual wxDataFormat GetPreferredFormat() const = 0;
41 // decide if we support this format (should be one of values of
3f480da3 42 // wxDataFormatId enumerations or a user-defined format)
1737035f
VZ
43 virtual bool IsSupportedFormat(wxDataFormat format) const = 0;
44 // get the (total) size of data
3cda6353 45 virtual size_t GetDataSize() const = 0;
1737035f
VZ
46 // copy raw data to provided pointer
47 virtual void GetDataHere(void *pBuf) const = 0;
48
49 // accessors
50 // retrieve IDataObject interface (for other OLE related classes)
51 IDataObject *GetInterface() const { return m_pIDataObject; }
52
06e43511
JS
53 ////// wxGTK compatibility: hopefully to become the preferred API.
54 virtual wxDataFormat GetFormat() const { return GetPreferredFormat(); }
55
1737035f
VZ
56private:
57 IDataObject *m_pIDataObject; // pointer to the COM interface
58};
59
60// ----------------------------------------------------------------------------
61// wxTextDataObject is a specialization of wxDataObject for text data
62// ----------------------------------------------------------------------------
8853b9a8 63class WXDLLEXPORT wxTextDataObject : public wxDataObject
1737035f
VZ
64{
65public:
66 // ctors
26f86486 67 wxTextDataObject() { }
1737035f
VZ
68 wxTextDataObject(const wxString& strText) : m_strText(strText) { }
69 void Init(const wxString& strText) { m_strText = strText; }
70
71 // implement base class pure virtuals
72 virtual wxDataFormat GetPreferredFormat() const
3f480da3 73 { return wxDF_TEXT; }
1737035f 74 virtual bool IsSupportedFormat(wxDataFormat format) const
3f480da3 75 { return format == wxDF_TEXT || format == wxDF_LOCALE; }
3cda6353 76 virtual size_t GetDataSize() const
1737035f
VZ
77 { return m_strText.Len() + 1; } // +1 for trailing '\0'of course
78 virtual void GetDataHere(void *pBuf) const
79 { memcpy(pBuf, m_strText.c_str(), GetDataSize()); }
80
06e43511
JS
81 ////// wxGTK compatibility: hopefully to become the preferred API.
82 void SetText(const wxString& strText) { m_strText = strText; }
83 wxString GetText() const { return m_strText; }
84 virtual wxDataFormat GetFormat() const { return wxDF_TEXT; }
85
1737035f
VZ
86private:
87 wxString m_strText;
88};
89
90// ----------------------------------------------------------------------------
91// @@@ TODO: wx{Bitmap|Metafile|...}DataObject
92// ----------------------------------------------------------------------------
93
06e43511
JS
94// ----------------------------------------------------------------------------
95// wxBitmapDataObject is a specialization of wxDataObject for bitmap data
96// ----------------------------------------------------------------------------
97
98// TODO: implement OLE side of things. At present, it's just for clipboard
99// use.
100class WXDLLEXPORT wxBitmapDataObject : public wxDataObject
101{
102public:
103 // ctors
104 wxBitmapDataObject() {};
105 wxBitmapDataObject(const wxBitmap& bitmap): m_bitmap(bitmap) {}
106 void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; }
107 wxBitmap GetBitmap() const { return m_bitmap; }
108
109 virtual wxDataFormat GetFormat() const { return wxDF_BITMAP; }
110
06e43511
JS
111 // implement base class pure virtuals
112 virtual wxDataFormat GetPreferredFormat() const
3f480da3 113 { return wxDF_BITMAP; }
06e43511 114 virtual bool IsSupportedFormat(wxDataFormat format) const
3f480da3 115 { return format == wxDF_BITMAP; }
06e43511 116 virtual size_t GetDataSize() const
41618278 117 { wxASSERT(false); return 0; } // BEMIMP
06e43511 118 virtual void GetDataHere(void *pBuf) const
41618278 119 { wxASSERT(false); } // BEMIMP
06e43511
JS
120
121private:
122 wxBitmap m_bitmap;
123};
124
125// ----------------------------------------------------------------------------
126// wxMetaFileDataObject: see metafile.h is a specialization of wxDataObject for bitmap data
127// ----------------------------------------------------------------------------
128
657865d2 129// TODO: wxFileDataObject.
2845ddc2 130
bbcdf8bc 131#endif //_WX_OLEDATAOBJ_H
06e43511 132