]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/ole/dataform.h
allow passing temporary functors to Bind() too (closes #10653)
[wxWidgets.git] / include / wx / msw / ole / dataform.h
CommitLineData
e1ee679c
VZ
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>
65571936 9// Licence: wxWindows licence
e1ee679c
VZ
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
53a2db12 19class WXDLLIMPEXP_CORE wxDataFormat
e1ee679c
VZ
20{
21public:
33ac7e6f 22 // the clipboard formats under Win32 are WORD's
3922ecc9 23 typedef unsigned short NativeFormat;
e1ee679c
VZ
24
25 wxDataFormat(NativeFormat format = wxDF_INVALID) { m_format = format; }
aad27874
VZ
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
a1eb65c2 30 wxDataFormat(const wxString& format) { SetId(format); }
aad27874
VZ
31 wxDataFormat(const char *format) { SetId(format); }
32 wxDataFormat(const wchar_t *format) { SetId(format); }
33 wxDataFormat(const wxCStrData& format) { SetId(format); }
e1ee679c
VZ
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
3922ecc9
VZ
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; }
e1ee679c
VZ
61
62 // string ids are used for custom types - this SetId() must be used for
63 // application-specific formats
64 wxString GetId() const;
a1eb65c2 65 void SetId(const wxString& format);
e1ee679c 66
0a0e6a5b 67 // returns true if the format is one of those defined in wxDataFormatId
478d4ab7 68 bool IsStandard() const { return m_format > 0 && m_format < wxDF_PRIVATE; }
e1ee679c 69
3922ecc9 70private:
e1ee679c
VZ
71 NativeFormat m_format;
72};
73
74#endif // _WX_MSW_OLE_DATAFORM_H
75