]>
Commit | Line | Data |
---|---|---|
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 WXDLLEXPORT wxDataFormat | |
20 | { | |
21 | public: | |
22 | // the clipboard formats under Win32 are WORDs | |
23 | typedef unsigned short NativeFormat; | |
24 | ||
25 | wxDataFormat(NativeFormat format = wxDF_INVALID) { m_format = format; } | |
26 | wxDataFormat(const wxChar *format) { SetId(format); } | |
27 | ||
28 | wxDataFormat& operator=(NativeFormat format) | |
29 | { m_format = format; return *this; } | |
30 | wxDataFormat& operator=(const wxDataFormat& format) | |
31 | { m_format = format.m_format; return *this; } | |
32 | ||
33 | // default copy ctor/assignment operators ok | |
34 | ||
35 | // comparison (must have both versions) | |
36 | bool operator==(wxDataFormatId format) const | |
37 | { return m_format == (NativeFormat)format; } | |
38 | bool operator!=(wxDataFormatId format) const | |
39 | { return m_format != (NativeFormat)format; } | |
40 | bool operator==(const wxDataFormat& format) const | |
41 | { return m_format == format.m_format; } | |
42 | bool operator!=(const wxDataFormat& format) const | |
43 | { return m_format != format.m_format; } | |
44 | ||
45 | // explicit and implicit conversions to NativeFormat which is one of | |
46 | // standard data types (implicit conversion is useful for preserving the | |
47 | // compatibility with old code) | |
48 | NativeFormat GetFormatId() const { return m_format; } | |
49 | operator NativeFormat() const { return m_format; } | |
50 | ||
51 | // this works with standard as well as custom ids | |
52 | void SetType(NativeFormat format) { m_format = format; } | |
53 | NativeFormat GetType() const { return m_format; } | |
54 | ||
55 | // string ids are used for custom types - this SetId() must be used for | |
56 | // application-specific formats | |
57 | wxString GetId() const; | |
58 | void SetId(const wxChar *format); | |
59 | ||
60 | // returns TRUE if the format is one of those defined in wxDataFormatId | |
61 | bool IsStandard() const { return m_format > 0 && m_format < wxDF_MAX; } | |
62 | ||
63 | private: | |
64 | NativeFormat m_format; | |
65 | }; | |
66 | ||
67 | #endif // _WX_MSW_OLE_DATAFORM_H | |
68 |