1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: msw/ole/dataform.h
3 // Purpose: declaration of the wxDataFormat class
4 // Author: Vadim Zeitlin
6 // Created: 19.10.99 (extracted from msw/ole/dataobj.h)
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_MSW_OLE_DATAFORM_H
13 #define _WX_MSW_OLE_DATAFORM_H
15 // ----------------------------------------------------------------------------
16 // wxDataFormat identifies the single format of data
17 // ----------------------------------------------------------------------------
19 class WXDLLIMPEXP_CORE wxDataFormat
22 // the clipboard formats under Win32 are WORD's
23 typedef unsigned short NativeFormat
;
25 wxDataFormat(NativeFormat format
= wxDF_INVALID
) { m_format
= format
; }
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
); }
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; }
40 // default copy ctor/assignment operators ok
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
; }
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
; }
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
; }
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
);
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
; }
71 NativeFormat m_format
;
74 #endif // _WX_MSW_OLE_DATAFORM_H