dataform.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/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. // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_GTK_DATAFORM_H
  11. #define _WX_GTK_DATAFORM_H
  12. class WXDLLIMPEXP_CORE wxDataFormat
  13. {
  14. public:
  15. // the clipboard formats under GDK are GdkAtoms
  16. typedef GdkAtom NativeFormat;
  17. wxDataFormat();
  18. wxDataFormat( wxDataFormatId type );
  19. wxDataFormat( NativeFormat format );
  20. // we have to provide all the overloads to allow using strings instead of
  21. // data formats (as a lot of existing code does)
  22. wxDataFormat( const wxString& id ) { InitFromString(id); }
  23. wxDataFormat( const char *id ) { InitFromString(id); }
  24. wxDataFormat( const wchar_t *id ) { InitFromString(id); }
  25. wxDataFormat( const wxCStrData& id ) { InitFromString(id); }
  26. wxDataFormat& operator=(const wxDataFormat& format)
  27. {
  28. if (&format != this)
  29. {
  30. m_type = format.m_type;
  31. m_format = format.m_format;
  32. }
  33. return *this;
  34. }
  35. wxDataFormat& operator=(NativeFormat format)
  36. { 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; }
  46. // explicit and implicit conversions to NativeFormat which is one of
  47. // standard data types (implicit conversion is useful for preserving the
  48. // compatibility with old code)
  49. NativeFormat GetFormatId() const { return m_format; }
  50. operator NativeFormat() const { return m_format; }
  51. void SetId( NativeFormat format );
  52. // string ids are used for custom types - this SetId() must be used for
  53. // application-specific formats
  54. wxString GetId() const;
  55. void SetId( const wxString& id );
  56. // implementation
  57. wxDataFormatId GetType() const;
  58. void SetType( wxDataFormatId type );
  59. private:
  60. // common part of ctors from format name
  61. void InitFromString(const wxString& id);
  62. wxDataFormatId m_type;
  63. NativeFormat m_format;
  64. void PrepareFormats();
  65. };
  66. #endif // _WX_GTK_DATAFORM_H