1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk1/dataform.h
3 // Purpose: declaration of the wxDataFormat class
4 // Author: Vadim Zeitlin
6 // Created: 19.10.99 (extracted from gtk/dataobj.h)
7 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_GTK_DATAFORM_H
12 #define _WX_GTK_DATAFORM_H
14 class WXDLLIMPEXP_CORE wxDataFormat
17 // the clipboard formats under GDK are GdkAtoms
18 typedef GdkAtom NativeFormat
;
21 wxDataFormat( wxDataFormatId type
);
22 wxDataFormat( NativeFormat format
);
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
); }
32 wxDataFormat
& operator=(const wxDataFormat
& format
)
33 { m_type
= format
.m_type
; m_format
= format
.m_format
; return *this; }
34 wxDataFormat
& operator=(NativeFormat format
)
35 { SetId(format
); return *this; }
37 // comparison (must have both versions)
38 bool operator==(NativeFormat format
) const
39 { return m_format
== (NativeFormat
)format
; }
40 bool operator!=(NativeFormat format
) const
41 { return m_format
!= (NativeFormat
)format
; }
42 bool operator==(wxDataFormatId format
) const
43 { return m_type
== (wxDataFormatId
)format
; }
44 bool operator!=(wxDataFormatId format
) const
45 { return m_type
!= (wxDataFormatId
)format
; }
47 // explicit and implicit conversions to NativeFormat which is one of
48 // standard data types (implicit conversion is useful for preserving the
49 // compatibility with old code)
50 NativeFormat
GetFormatId() const { return m_format
; }
51 operator NativeFormat() const { return m_format
; }
53 void SetId( NativeFormat format
);
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 wxString
& id
);
61 wxDataFormatId
GetType() const;
62 void SetType( wxDataFormatId type
);
65 // common part of ctors from format name
66 void InitFromString(const wxString
& id
);
68 wxDataFormatId m_type
;
69 NativeFormat m_format
;
71 void PrepareFormats();
74 #endif // _WX_GTK_DATAFORM_H