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.
10 // Copyright: (c) AUTHOR
11 // Licence: wxWindows licence
12 /////////////////////////////////////////////////////////////////////////////
15 #ifndef _WX_METAFIILE_H_
16 #define _WX_METAFIILE_H_
20 #include "wx/gdiobj.h"
23 #include "wx/dataobj.h"
27 * Metafile and metafile device context classes
31 #define wxMetaFile wxMetafile
32 #define wxMetaFileDC wxMetafileDC
34 class WXDLLEXPORT wxMetafile
;
36 class WXDLLEXPORT wxMetafileRefData
: public wxGDIRefData
38 friend class WXDLLEXPORT wxMetafile
;
40 wxMetafileRefData(void);
41 ~wxMetafileRefData(void);
44 WXHMETAFILE m_metafile
;
47 #define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
49 class WXDLLEXPORT wxMetafile
: public wxGDIObject
51 DECLARE_DYNAMIC_CLASS(wxMetafile
)
54 inline wxMetafile(const wxMetafile
& metafile
)
57 wxMetafile(const wxString
& file
= "");
60 // After this is called, the metafile cannot be used for anything
61 // since it is now owned by the clipboard.
62 virtual bool SetClipboard(int width
= 0, int height
= 0);
64 virtual bool Play(wxDC
*dc
);
65 inline bool Ok(void) const { return (M_METAFILEDATA
&& (M_METAFILEDATA
->m_metafile
!= 0)); };
68 inline WXHMETAFILE
GetHMETAFILE(void) { return M_METAFILEDATA
->m_metafile
; }
69 void SetHMETAFILE(WXHMETAFILE mf
) ;
72 inline wxMetafile
& operator = (const wxMetafile
& metafile
) { if (*this == metafile
) return (*this); Ref(metafile
); return *this; }
73 inline bool operator == (const wxMetafile
& metafile
) { return m_refData
== metafile
.m_refData
; }
74 inline bool operator != (const wxMetafile
& metafile
) { return m_refData
!= metafile
.m_refData
; }
79 class WXDLLEXPORT wxMetafileDC
: public wxDC
81 DECLARE_DYNAMIC_CLASS(wxMetafileDC
)
84 // Don't supply origin and extent
85 // Supply them to wxMakeMetaFilePlaceable instead.
86 wxMetafileDC(const wxString
& file
= "");
88 // Supply origin and extent (recommended).
89 // Then don't need to supply them to wxMakeMetaFilePlaceable.
90 wxMetafileDC(const wxString
& file
, int xext
, int yext
, int xorg
, int yorg
);
94 // Should be called at end of drawing
95 virtual wxMetafile
*Close(void);
98 inline wxMetafile
*GetMetaFile(void) const { return m_metaFile
; }
99 inline void SetMetaFile(wxMetafile
*mf
) { m_metaFile
= mf
; }
102 wxMetafile
* m_metaFile
;
106 * Pass filename of existing non-placeable metafile, and bounding box.
107 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
108 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
112 // No origin or extent
113 #define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
114 bool WXDLLEXPORT
wxMakeMetafilePlaceable(const wxString
& filename
, float scale
= 1.0);
116 // Optional origin and extent
117 bool WXDLLEXPORT
wxMakeMetaFilePlaceable(const wxString
& filename
, int x1
, int y1
, int x2
, int y2
, float scale
= 1.0, bool useOriginAndExtent
= TRUE
);
119 // ----------------------------------------------------------------------------
120 // wxMetafileDataObject is a specialization of wxDataObject for metafile data
121 // ----------------------------------------------------------------------------
124 class WXDLLEXPORT wxMetafileDataObject
: public wxDataObjectSimple
128 wxMetafileDataObject()
129 : wxDataObjectSimple(wxDF_METAFILE
) { };
130 wxMetafileDataObject(const wxMetafile
& metafile
)
131 : wxDataObjectSimple(wxDF_METAFILE
), m_metafile(metafile
) { }
133 // virtual functions which you may override if you want to provide data on
134 // demand only - otherwise, the trivial default versions will be used
135 virtual void SetMetafile(const wxMetafile
& metafile
)
136 { m_metafile
= metafile
; }
137 virtual wxMetafile
GetMetafile() const
138 { return m_metafile
; }
140 // implement base class pure virtuals
141 virtual size_t GetDataSize() const;
142 virtual bool GetDataHere(void *buf
) const;
143 virtual bool SetData(size_t len
, const void *buf
);
146 wxMetafile m_metafile
;
150 #endif // wxUSE_METAFILE