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
) ;
60 // Since the native metafile format is PDF for Quartz
61 // we need a call that allows setting PICT content for
62 // backwards compatibility
63 void SetPICT(void* pictHandle
) ;
66 class WXDLLEXPORT wxMetafileDC
: public wxDC
68 DECLARE_DYNAMIC_CLASS(wxMetafileDC
)
71 // the ctor parameters specify the filename (empty for memory metafiles),
72 // the metafile picture size and the optional description/comment
73 wxMetafileDC(const wxString
& filename
= wxEmptyString
,
74 int width
= 0, int height
= 0,
75 const wxString
& description
= wxEmptyString
);
77 virtual ~wxMetafileDC(void);
79 // Should be called at end of drawing
80 virtual wxMetafile
*Close(void);
83 inline wxMetafile
*GetMetaFile(void) const { return m_metaFile
; }
84 inline void SetMetaFile(wxMetafile
*mf
) { m_metaFile
= mf
; }
87 virtual void DoGetSize(int *width
, int *height
) const;
89 wxMetafile
* m_metaFile
;
93 * Pass filename of existing non-placeable metafile, and bounding box.
94 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
95 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
99 // No origin or extent
100 #define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
101 bool WXDLLEXPORT
wxMakeMetafilePlaceable(const wxString
& filename
, float scale
= 1.0);
103 // Optional origin and extent
104 bool WXDLLEXPORT
wxMakeMetaFilePlaceable(const wxString
& filename
, int x1
, int y1
, int x2
, int y2
, float scale
= 1.0, bool useOriginAndExtent
= TRUE
);
106 // ----------------------------------------------------------------------------
107 // wxMetafileDataObject is a specialization of wxDataObject for metafile data
108 // ----------------------------------------------------------------------------
111 class WXDLLEXPORT wxMetafileDataObject
: public wxDataObjectSimple
115 wxMetafileDataObject()
116 : wxDataObjectSimple(wxDF_METAFILE
) { };
117 wxMetafileDataObject(const wxMetafile
& metafile
)
118 : wxDataObjectSimple(wxDF_METAFILE
), m_metafile(metafile
) { }
120 // virtual functions which you may override if you want to provide data on
121 // demand only - otherwise, the trivial default versions will be used
122 virtual void SetMetafile(const wxMetafile
& metafile
)
123 { m_metafile
= metafile
; }
124 virtual wxMetafile
GetMetafile() const
125 { return m_metafile
; }
127 // implement base class pure virtuals
128 virtual size_t GetDataSize() const;
129 virtual bool GetDataHere(void *buf
) const;
130 virtual bool SetData(size_t len
, const void *buf
);
132 virtual size_t GetDataSize(const wxDataFormat
& WXUNUSED(format
)) const
133 { return GetDataSize(); }
134 virtual bool GetDataHere(const wxDataFormat
& WXUNUSED(format
),
136 { return GetDataHere(buf
); }
137 virtual bool SetData(const wxDataFormat
& WXUNUSED(format
),
138 size_t len
, const void *buf
)
139 { return SetData(len
, buf
); }
141 wxMetafile m_metafile
;