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