]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/ole/dataform.h
supporting a null cgimage so that we don't get exceptions, only an wxbitmap that...
[wxWidgets.git] / include / wx / msw / ole / dataform.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: msw/ole/dataform.h
3 // Purpose: declaration of the wxDataFormat class
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 19.10.99 (extracted from msw/ole/dataobj.h)
7 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_MSW_OLE_DATAFORM_H
13 #define _WX_MSW_OLE_DATAFORM_H
14
15 // ----------------------------------------------------------------------------
16 // wxDataFormat identifies the single format of data
17 // ----------------------------------------------------------------------------
18
19 class WXDLLIMPEXP_CORE wxDataFormat
20 {
21 public:
22 // the clipboard formats under Win32 are WORD's
23 typedef unsigned short NativeFormat;
24
25 wxDataFormat(NativeFormat format = wxDF_INVALID) { m_format = format; }
26
27 // we need constructors from all string types as implicit conversions to
28 // wxString don't apply when we already rely on implicit conversion of a,
29 // for example, "char *" string to wxDataFormat, and existing code does it
30 wxDataFormat(const wxString& format) { SetId(format); }
31 wxDataFormat(const char *format) { SetId(format); }
32 wxDataFormat(const wchar_t *format) { SetId(format); }
33 wxDataFormat(const wxCStrData& format) { SetId(format); }
34
35 wxDataFormat& operator=(NativeFormat format)
36 { m_format = format; return *this; }
37 wxDataFormat& operator=(const wxDataFormat& format)
38 { m_format = format.m_format; return *this; }
39
40 // default copy ctor/assignment operators ok
41
42 // comparison (must have both versions)
43 bool operator==(wxDataFormatId format) const
44 { return m_format == (NativeFormat)format; }
45 bool operator!=(wxDataFormatId format) const
46 { return m_format != (NativeFormat)format; }
47 bool operator==(const wxDataFormat& format) const
48 { return m_format == format.m_format; }
49 bool operator!=(const wxDataFormat& format) const
50 { return m_format != format.m_format; }
51
52 // explicit and implicit conversions to NativeFormat which is one of
53 // standard data types (implicit conversion is useful for preserving the
54 // compatibility with old code)
55 NativeFormat GetFormatId() const { return m_format; }
56 operator NativeFormat() const { return m_format; }
57
58 // this works with standard as well as custom ids
59 void SetType(NativeFormat format) { m_format = format; }
60 NativeFormat GetType() const { return m_format; }
61
62 // string ids are used for custom types - this SetId() must be used for
63 // application-specific formats
64 wxString GetId() const;
65 void SetId(const wxString& format);
66
67 // returns true if the format is one of those defined in wxDataFormatId
68 bool IsStandard() const { return m_format > 0 && m_format < wxDF_PRIVATE; }
69
70 private:
71 NativeFormat m_format;
72 };
73
74 #endif // _WX_MSW_OLE_DATAFORM_H
75