dataform.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/gtk1/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. { m_type = format.m_type; m_format = format.m_format; return *this; }
  28. wxDataFormat& operator=(NativeFormat format)
  29. { SetId(format); return *this; }
  30. // comparison (must have both versions)
  31. bool operator==(NativeFormat format) const
  32. { return m_format == (NativeFormat)format; }
  33. bool operator!=(NativeFormat format) const
  34. { return m_format != (NativeFormat)format; }
  35. bool operator==(wxDataFormatId format) const
  36. { return m_type == (wxDataFormatId)format; }
  37. bool operator!=(wxDataFormatId format) const
  38. { return m_type != (wxDataFormatId)format; }
  39. // explicit and implicit conversions to NativeFormat which is one of
  40. // standard data types (implicit conversion is useful for preserving the
  41. // compatibility with old code)
  42. NativeFormat GetFormatId() const { return m_format; }
  43. operator NativeFormat() const { return m_format; }
  44. void SetId( NativeFormat format );
  45. // string ids are used for custom types - this SetId() must be used for
  46. // application-specific formats
  47. wxString GetId() const;
  48. void SetId( const wxString& id );
  49. // implementation
  50. wxDataFormatId GetType() const;
  51. void SetType( wxDataFormatId type );
  52. private:
  53. // common part of ctors from format name
  54. void InitFromString(const wxString& id);
  55. wxDataFormatId m_type;
  56. NativeFormat m_format;
  57. void PrepareFormats();
  58. };
  59. #endif // _WX_GTK_DATAFORM_H