dataobj2.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/cocoa/dataobj2.h
  3. // Purpose: declaration of standard wxDataObjectSimple-derived classes
  4. // Author: David Elliott <dfe@cox.net>
  5. // Modified by:
  6. // Created: 2003/07/23
  7. // Copyright: (c) 2003 David Elliott
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef __WX_COCOA_DATAOBJ2_H__
  11. #define __WX_COCOA_DATAOBJ2_H__
  12. //=========================================================================
  13. // wxBitmapDataObject is a specialization of wxDataObject for bitmaps
  14. //=========================================================================
  15. class WXDLLIMPEXP_CORE wxBitmapDataObject : public wxBitmapDataObjectBase
  16. {
  17. public:
  18. // ctors
  19. wxBitmapDataObject();
  20. wxBitmapDataObject(const wxBitmap& bitmap);
  21. // destr
  22. virtual ~wxBitmapDataObject();
  23. // override base class virtual to update PNG data too
  24. virtual void SetBitmap(const wxBitmap& bitmap);
  25. // implement base class pure virtuals
  26. // ----------------------------------
  27. virtual size_t GetDataSize() const { return m_pngSize; }
  28. virtual bool GetDataHere(void *buf) const;
  29. virtual bool SetData(size_t len, const void *buf);
  30. protected:
  31. void Init() { m_pngData = NULL; m_pngSize = 0; }
  32. void Clear() { free(m_pngData); }
  33. void ClearAll() { Clear(); Init(); }
  34. size_t m_pngSize;
  35. void *m_pngData;
  36. void DoConvertToPng();
  37. private:
  38. // virtual function hiding supression
  39. size_t GetDataSize(const wxDataFormat& format) const
  40. { return(wxDataObjectSimple::GetDataSize(format)); }
  41. bool GetDataHere(const wxDataFormat& format, void* pBuf) const
  42. { return(wxDataObjectSimple::GetDataHere(format, pBuf)); }
  43. bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf)
  44. { return(wxDataObjectSimple::SetData(format, nLen, pBuf)); }
  45. };
  46. //=========================================================================
  47. // wxFileDataObject is a specialization of wxDataObject for file names
  48. //=========================================================================
  49. class WXDLLIMPEXP_CORE wxFileDataObject : public wxFileDataObjectBase
  50. {
  51. public:
  52. // implement base class pure virtuals
  53. // ----------------------------------
  54. void AddFile( const wxString &filename );
  55. virtual size_t GetDataSize() const;
  56. virtual bool GetDataHere(void *buf) const;
  57. virtual bool SetData(size_t len, const void *buf);
  58. private:
  59. // virtual function hiding supression
  60. size_t GetDataSize(const wxDataFormat& format) const
  61. { return(wxDataObjectSimple::GetDataSize(format)); }
  62. bool GetDataHere(const wxDataFormat& format, void* pBuf) const
  63. { return(wxDataObjectSimple::GetDataHere(format, pBuf)); }
  64. bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf)
  65. { return(wxDataObjectSimple::SetData(format, nLen, pBuf)); }
  66. };
  67. #endif //__WX_COCOA_DATAOBJ2_H__