1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMetaFile, wxMetaFileDC classes.
4 // This probably should be restricted to Windows platforms,
5 // but if there is an equivalent on your platform, great.
6 // Author: Stefan Csomor
10 // Copyright: (c) Stefan Csomor
11 // Licence: wxWindows licence
12 /////////////////////////////////////////////////////////////////////////////
15 #ifndef _WX_METAFIILE_H_
16 #define _WX_METAFIILE_H_
19 #include "wx/gdiobj.h"
22 #include "wx/dataobj.h"
26 * Metafile and metafile device context classes
30 #define wxMetaFile wxMetafile
31 #define wxMetaFileDC wxMetafileDC
33 class WXDLLIMPEXP_FWD_CORE wxMetafile
;
34 class wxMetafileRefData
;
36 #define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
38 class WXDLLEXPORT wxMetafile
: public wxGDIObject
40 DECLARE_DYNAMIC_CLASS(wxMetafile
)
42 wxMetafile(const wxString
& file
= wxEmptyString
);
43 virtual ~wxMetafile(void);
45 // After this is called, the metafile cannot be used for anything
46 // since it is now owned by the clipboard.
47 virtual bool SetClipboard(int width
= 0, int height
= 0);
49 virtual bool Play(wxDC
*dc
);
50 bool Ok() const { return IsOk(); }
53 wxSize
GetSize() const;
54 int GetWidth() const { return GetSize().x
; }
55 int GetHeight() const { return GetSize().y
; }
58 WXHMETAFILE
GetHMETAFILE() const ;
59 void SetHMETAFILE(WXHMETAFILE mf
) ;
62 class WXDLLEXPORT wxMetafileDC
: public wxDC
64 DECLARE_DYNAMIC_CLASS(wxMetafileDC
)
67 // the ctor parameters specify the filename (empty for memory metafiles),
68 // the metafile picture size and the optional description/comment
69 wxMetafileDC(const wxString
& filename
= wxEmptyString
,
70 int width
= 0, int height
= 0,
71 const wxString
& description
= wxEmptyString
);
73 virtual ~wxMetafileDC(void);
75 // Should be called at end of drawing
76 virtual wxMetafile
*Close(void);
79 inline wxMetafile
*GetMetaFile(void) const { return m_metaFile
; }
80 inline void SetMetaFile(wxMetafile
*mf
) { m_metaFile
= mf
; }
83 virtual void DoGetSize(int *width
, int *height
) const;
85 wxMetafile
* m_metaFile
;
89 * Pass filename of existing non-placeable metafile, and bounding box.
90 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
91 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
95 // No origin or extent
96 #define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
97 bool WXDLLEXPORT
wxMakeMetafilePlaceable(const wxString
& filename
, float scale
= 1.0);
99 // Optional origin and extent
100 bool WXDLLEXPORT
wxMakeMetaFilePlaceable(const wxString
& filename
, int x1
, int y1
, int x2
, int y2
, float scale
= 1.0, bool useOriginAndExtent
= TRUE
);
102 // ----------------------------------------------------------------------------
103 // wxMetafileDataObject is a specialization of wxDataObject for metafile data
104 // ----------------------------------------------------------------------------
107 class WXDLLEXPORT wxMetafileDataObject
: public wxDataObjectSimple
111 wxMetafileDataObject()
112 : wxDataObjectSimple(wxDF_METAFILE
) { };
113 wxMetafileDataObject(const wxMetafile
& metafile
)
114 : wxDataObjectSimple(wxDF_METAFILE
), m_metafile(metafile
) { }
116 // virtual functions which you may override if you want to provide data on
117 // demand only - otherwise, the trivial default versions will be used
118 virtual void SetMetafile(const wxMetafile
& metafile
)
119 { m_metafile
= metafile
; }
120 virtual wxMetafile
GetMetafile() const
121 { return m_metafile
; }
123 // implement base class pure virtuals
124 virtual size_t GetDataSize() const;
125 virtual bool GetDataHere(void *buf
) const;
126 virtual bool SetData(size_t len
, const void *buf
);
128 virtual size_t GetDataSize(const wxDataFormat
& WXUNUSED(format
)) const
129 { return GetDataSize(); }
130 virtual bool GetDataHere(const wxDataFormat
& WXUNUSED(format
),
132 { return GetDataHere(buf
); }
133 virtual bool SetData(const wxDataFormat
& WXUNUSED(format
),
134 size_t len
, const void *buf
)
135 { return SetData(len
, buf
); }
137 wxMetafile m_metafile
;