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