1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/enhmeta.h
3 // Purpose: wxEnhMetaFile class for Win32
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_MSW_ENHMETA_H_
13 #define _WX_MSW_ENHMETA_H_
16 #pragma interface "enhmeta.h"
21 #if wxUSE_DRAG_AND_DROP
22 #include "wx/dataobj.h"
25 // ----------------------------------------------------------------------------
26 // wxEnhMetaFile: encapsulation of Win32 HENHMETAFILE
27 // ----------------------------------------------------------------------------
29 class WXDLLEXPORT wxEnhMetaFile
: public wxObject
32 wxEnhMetaFile(const wxString
& file
= wxEmptyString
) : m_filename(file
)
34 wxEnhMetaFile(const wxEnhMetaFile
& metafile
)
35 { Init(); Assign(metafile
); }
36 wxEnhMetaFile
& operator=(const wxEnhMetaFile
& metafile
)
37 { Free(); Assign(metafile
); return *this; }
39 virtual ~wxEnhMetaFile()
42 // display the picture stored in the metafile on the given DC
43 bool Play(wxDC
*dc
, wxRect
*rectBound
= (wxRect
*)NULL
);
46 bool Ok() const { return m_hMF
!= 0; }
48 wxSize
GetSize() const;
49 int GetWidth() const { return GetSize().x
; }
50 int GetHeight() const { return GetSize().y
; }
52 const wxString
& GetFileName() const { return m_filename
; }
55 WXHANDLE
GetHENHMETAFILE() const { return m_hMF
; }
56 void SetHENHMETAFILE(WXHANDLE hMF
) { Free(); m_hMF
= hMF
; }
59 void Init() { m_hMF
= 0; }
61 void Assign(const wxEnhMetaFile
& mf
);
67 DECLARE_DYNAMIC_CLASS(wxEnhMetaFile
)
70 // ----------------------------------------------------------------------------
71 // wxEnhMetaFileDC: allows to create a wxEnhMetaFile
72 // ----------------------------------------------------------------------------
74 class WXDLLEXPORT wxEnhMetaFileDC
: public wxDC
77 // the ctor parameters specify the filename (empty for memory metafiles),
78 // the metafile picture size and the optional description/comment
79 wxEnhMetaFileDC(const wxString
& filename
= wxEmptyString
,
80 int width
= 0, int height
= 0,
81 const wxString
& description
= wxEmptyString
);
83 virtual ~wxEnhMetaFileDC();
85 // obtain a pointer to the new metafile (caller should delete it)
86 wxEnhMetaFile
*Close();
89 DECLARE_DYNAMIC_CLASS(wxEnhMetaFileDC
)
92 // ----------------------------------------------------------------------------
93 // wxEnhMetaFileDataObject is a specialization of wxDataObject for enh metafile
94 // ----------------------------------------------------------------------------
96 #if wxUSE_DRAG_AND_DROP
98 // notice that we want to support both CF_METAFILEPICT and CF_ENHMETAFILE and
99 // so we derive from and not from wxDataObjectSimple
100 class WXDLLEXPORT wxEnhMetaFileDataObject
: public wxDataObject
104 wxEnhMetaFileDataObject() { }
105 wxEnhMetaFileDataObject(const wxEnhMetaFile
& metafile
)
106 : m_metafile(metafile
) { }
108 // virtual functions which you may override if you want to provide data on
109 // demand only - otherwise, the trivial default versions will be used
110 virtual void SetMetafile(const wxEnhMetaFile
& metafile
)
111 { m_metafile
= metafile
; }
112 virtual wxEnhMetaFile
GetMetafile() const
113 { return m_metafile
; }
115 // implement base class pure virtuals
116 virtual wxDataFormat
GetPreferredFormat(Direction dir
) const;
117 virtual size_t GetFormatCount(Direction dir
) const;
118 virtual void GetAllFormats(wxDataFormat
*formats
, Direction dir
) const;
119 virtual size_t GetDataSize(const wxDataFormat
& format
) const;
120 virtual bool GetDataHere(const wxDataFormat
& format
, void *buf
) const;
121 virtual bool SetData(const wxDataFormat
& format
, size_t len
,
125 wxEnhMetaFile m_metafile
;
128 #endif // wxUSE_DRAG_AND_DROP
130 #endif // _WX_MSW_ENHMETA_H_