1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/metafile.h
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
9 // Copyright: (c) Stefan Csomor
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
14 #ifndef _WX_METAFIILE_H_
15 #define _WX_METAFIILE_H_
18 #include "wx/gdiobj.h"
21 #include "wx/dataobj.h"
24 #include "wx/osx/dcclient.h"
27 * Metafile and metafile device context classes
31 #define wxMetaFile wxMetafile
32 #define wxMetaFileDC wxMetafileDC
34 class WXDLLIMPEXP_FWD_CORE wxMetafile
;
35 class wxMetafileRefData
;
37 #define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
39 class WXDLLIMPEXP_CORE wxMetafile
: public wxGDIObject
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
);
51 wxSize
GetSize() const;
52 int GetWidth() const { return GetSize().x
; }
53 int GetHeight() const { return GetSize().y
; }
56 WXHMETAFILE
GetHMETAFILE() const ;
57 void SetHMETAFILE(WXHMETAFILE mf
) ;
59 virtual wxGDIRefData
*CreateGDIRefData() const;
60 virtual wxGDIRefData
*CloneGDIRefData(const wxGDIRefData
*data
) const;
62 DECLARE_DYNAMIC_CLASS(wxMetafile
)
66 class WXDLLIMPEXP_CORE wxMetafileDCImpl
: public wxGCDCImpl
69 wxMetafileDCImpl( wxDC
*owner
,
70 const wxString
& filename
,
71 int width
, int height
,
72 const wxString
& description
);
74 virtual ~wxMetafileDCImpl();
76 // Should be called at end of drawing
77 virtual wxMetafile
*Close();
80 wxMetafile
*GetMetaFile(void) const { return m_metaFile
; }
81 void SetMetaFile(wxMetafile
*mf
) { m_metaFile
= mf
; }
84 virtual void DoGetSize(int *width
, int *height
) const;
86 wxMetafile
* m_metaFile
;
89 DECLARE_CLASS(wxMetafileDCImpl
)
90 wxDECLARE_NO_COPY_CLASS(wxMetafileDCImpl
);
93 class WXDLLIMPEXP_CORE wxMetafileDC
: public wxDC
96 // the ctor parameters specify the filename (empty for memory metafiles),
97 // the metafile picture size and the optional description/comment
98 wxMetafileDC( const wxString
& filename
= wxEmptyString
,
99 int width
= 0, int height
= 0,
100 const wxString
& description
= wxEmptyString
) :
101 wxDC( new wxMetafileDCImpl( this, filename
, width
, height
, description
) )
104 wxMetafile
*GetMetafile() const
105 { return ((wxMetafileDCImpl
*)m_pimpl
)->GetMetaFile(); }
108 { return ((wxMetafileDCImpl
*)m_pimpl
)->Close(); }
111 DECLARE_CLASS(wxMetafileDC
)
112 wxDECLARE_NO_COPY_CLASS(wxMetafileDC
);
117 * Pass filename of existing non-placeable metafile, and bounding box.
118 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
119 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
123 // No origin or extent
124 #define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
125 bool WXDLLIMPEXP_CORE
wxMakeMetafilePlaceable(const wxString
& filename
, float scale
= 1.0);
127 // Optional origin and extent
128 bool WXDLLIMPEXP_CORE
wxMakeMetaFilePlaceable(const wxString
& filename
, int x1
, int y1
, int x2
, int y2
, float scale
= 1.0, bool useOriginAndExtent
= true);
130 // ----------------------------------------------------------------------------
131 // wxMetafileDataObject is a specialization of wxDataObject for metafile data
132 // ----------------------------------------------------------------------------
135 class WXDLLIMPEXP_CORE wxMetafileDataObject
: public wxDataObjectSimple
139 wxMetafileDataObject()
140 : wxDataObjectSimple(wxDF_METAFILE
) { }
141 wxMetafileDataObject(const wxMetafile
& metafile
)
142 : wxDataObjectSimple(wxDF_METAFILE
), m_metafile(metafile
) { }
144 // virtual functions which you may override if you want to provide data on
145 // demand only - otherwise, the trivial default versions will be used
146 virtual void SetMetafile(const wxMetafile
& metafile
)
147 { m_metafile
= metafile
; }
148 virtual wxMetafile
GetMetafile() const
149 { return m_metafile
; }
151 // implement base class pure virtuals
152 virtual size_t GetDataSize() const;
153 virtual bool GetDataHere(void *buf
) const;
154 virtual bool SetData(size_t len
, const void *buf
);
156 virtual size_t GetDataSize(const wxDataFormat
& WXUNUSED(format
)) const
157 { return GetDataSize(); }
158 virtual bool GetDataHere(const wxDataFormat
& WXUNUSED(format
),
160 { return GetDataHere(buf
); }
161 virtual bool SetData(const wxDataFormat
& WXUNUSED(format
),
162 size_t len
, const void *buf
)
163 { return SetData(len
, buf
); }
165 wxMetafile m_metafile
;