]>
Commit | Line | Data |
---|---|---|
e1ee679c | 1 | /////////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: wx/gtk/dataform.h |
e1ee679c VZ |
3 | // Purpose: declaration of the wxDataFormat class |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 19.10.99 (extracted from gtk/dataobj.h) | |
e1ee679c | 7 | // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> |
65571936 | 8 | // Licence: wxWindows licence |
e1ee679c VZ |
9 | /////////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | #ifndef _WX_GTK_DATAFORM_H | |
12 | #define _WX_GTK_DATAFORM_H | |
13 | ||
20123d49 | 14 | class WXDLLIMPEXP_CORE wxDataFormat |
e1ee679c VZ |
15 | { |
16 | public: | |
17 | // the clipboard formats under GDK are GdkAtoms | |
18 | typedef GdkAtom NativeFormat; | |
19 | ||
20 | wxDataFormat(); | |
21 | wxDataFormat( wxDataFormatId type ); | |
e1ee679c VZ |
22 | wxDataFormat( NativeFormat format ); |
23 | ||
45344b38 VZ |
24 | // we have to provide all the overloads to allow using strings instead of |
25 | // data formats (as a lot of existing code does) | |
26 | wxDataFormat( const wxString& id ) { InitFromString(id); } | |
27 | wxDataFormat( const char *id ) { InitFromString(id); } | |
28 | wxDataFormat( const wchar_t *id ) { InitFromString(id); } | |
29 | wxDataFormat( const wxCStrData& id ) { InitFromString(id); } | |
30 | ||
bf3dab48 | 31 | wxDataFormat& operator=(const wxDataFormat& format) |
162e998c PC |
32 | { |
33 | if (&format != this) | |
34 | { | |
35 | m_type = format.m_type; | |
36 | m_format = format.m_format; | |
37 | } | |
38 | return *this; | |
39 | } | |
e1ee679c VZ |
40 | wxDataFormat& operator=(NativeFormat format) |
41 | { SetId(format); return *this; } | |
42 | ||
43 | // comparison (must have both versions) | |
44 | bool operator==(NativeFormat format) const | |
45 | { return m_format == (NativeFormat)format; } | |
46 | bool operator!=(NativeFormat format) const | |
47 | { return m_format != (NativeFormat)format; } | |
e5d6aa22 RR |
48 | bool operator==(wxDataFormatId format) const |
49 | { return m_type == (wxDataFormatId)format; } | |
50 | bool operator!=(wxDataFormatId format) const | |
51 | { return m_type != (wxDataFormatId)format; } | |
e1ee679c VZ |
52 | |
53 | // explicit and implicit conversions to NativeFormat which is one of | |
54 | // standard data types (implicit conversion is useful for preserving the | |
55 | // compatibility with old code) | |
56 | NativeFormat GetFormatId() const { return m_format; } | |
57 | operator NativeFormat() const { return m_format; } | |
58 | ||
59 | void SetId( NativeFormat format ); | |
60 | ||
61 | // string ids are used for custom types - this SetId() must be used for | |
62 | // application-specific formats | |
63 | wxString GetId() const; | |
a1eb65c2 | 64 | void SetId( const wxString& id ); |
e1ee679c VZ |
65 | |
66 | // implementation | |
67 | wxDataFormatId GetType() const; | |
085078a1 | 68 | void SetType( wxDataFormatId type ); |
e1ee679c VZ |
69 | |
70 | private: | |
45344b38 VZ |
71 | // common part of ctors from format name |
72 | void InitFromString(const wxString& id); | |
73 | ||
e1ee679c VZ |
74 | wxDataFormatId m_type; |
75 | NativeFormat m_format; | |
76 | ||
77 | void PrepareFormats(); | |
e1ee679c VZ |
78 | }; |
79 | ||
80 | #endif // _WX_GTK_DATAFORM_H |