]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
265b0c07 VZ |
2 | // Name: wx/msw/metafile.h |
3 | // Purpose: wxMetaFile, wxMetaFileDC and wxMetaFileDataObject classes | |
2bda0e17 | 4 | // Author: Julian Smart |
265b0c07 | 5 | // Modified by: VZ 07.01.00: implemented wxMetaFileDataObject |
2bda0e17 | 6 | // Created: 01/02/97 |
bbcdf8bc | 7 | // Copyright: (c) Julian Smart |
65571936 | 8 | // Licence: wxWindows licence |
2bda0e17 KB |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
bbcdf8bc JS |
11 | #ifndef _WX_METAFIILE_H_ |
12 | #define _WX_METAFIILE_H_ | |
2bda0e17 | 13 | |
2bda0e17 | 14 | #include "wx/dc.h" |
06e43511 JS |
15 | #include "wx/gdiobj.h" |
16 | ||
17 | #if wxUSE_DRAG_AND_DROP | |
265b0c07 | 18 | #include "wx/dataobj.h" |
06e43511 | 19 | #endif |
2bda0e17 | 20 | |
265b0c07 VZ |
21 | // ---------------------------------------------------------------------------- |
22 | // Metafile and metafile device context classes | |
23 | // ---------------------------------------------------------------------------- | |
06e43511 | 24 | |
b5dbe15d | 25 | class WXDLLIMPEXP_FWD_CORE wxMetafile; |
06e43511 | 26 | |
53a2db12 | 27 | class WXDLLIMPEXP_CORE wxMetafileRefData: public wxGDIRefData |
2bda0e17 | 28 | { |
06e43511 | 29 | public: |
265b0c07 | 30 | wxMetafileRefData(); |
d3c7fc99 | 31 | virtual ~wxMetafileRefData(); |
06e43511 | 32 | |
8f884a0d VZ |
33 | virtual bool IsOk() const { return m_metafile != 0; } |
34 | ||
06e43511 JS |
35 | public: |
36 | WXHANDLE m_metafile; | |
37 | int m_windowsMappingMode; | |
265b0c07 | 38 | int m_width, m_height; |
8f884a0d VZ |
39 | |
40 | friend class WXDLLIMPEXP_FWD_CORE wxMetafile; | |
06e43511 JS |
41 | }; |
42 | ||
43 | #define M_METAFILEDATA ((wxMetafileRefData *)m_refData) | |
44 | ||
53a2db12 | 45 | class WXDLLIMPEXP_CORE wxMetafile: public wxGDIObject |
06e43511 | 46 | { |
265b0c07 VZ |
47 | public: |
48 | wxMetafile(const wxString& file = wxEmptyString); | |
265b0c07 VZ |
49 | virtual ~wxMetafile(); |
50 | ||
51 | // After this is called, the metafile cannot be used for anything | |
52 | // since it is now owned by the clipboard. | |
53 | virtual bool SetClipboard(int width = 0, int height = 0); | |
54 | ||
55 | virtual bool Play(wxDC *dc); | |
265b0c07 VZ |
56 | |
57 | // set/get the size of metafile for clipboard operations | |
d9317fd4 | 58 | wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); } |
265b0c07 VZ |
59 | int GetWidth() const { return M_METAFILEDATA->m_width; } |
60 | int GetHeight() const { return M_METAFILEDATA->m_height; } | |
61 | ||
62 | void SetWidth(int width) { M_METAFILEDATA->m_width = width; } | |
63 | void SetHeight(int height) { M_METAFILEDATA->m_height = height; } | |
64 | ||
65 | // Implementation | |
66 | WXHANDLE GetHMETAFILE() const { return M_METAFILEDATA->m_metafile; } | |
67 | void SetHMETAFILE(WXHANDLE mf) ; | |
68 | int GetWindowsMappingMode() const { return M_METAFILEDATA->m_windowsMappingMode; } | |
69 | void SetWindowsMappingMode(int mm); | |
70 | ||
d2ce59e9 SN |
71 | protected: |
72 | virtual wxGDIRefData *CreateGDIRefData() const; | |
73 | virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; | |
74 | ||
265b0c07 VZ |
75 | private: |
76 | DECLARE_DYNAMIC_CLASS(wxMetafile) | |
2bda0e17 KB |
77 | }; |
78 | ||
53a2db12 | 79 | class WXDLLIMPEXP_CORE wxMetafileDCImpl: public wxMSWDCImpl |
2bda0e17 | 80 | { |
265b0c07 | 81 | public: |
d2ce59e9 SN |
82 | wxMetafileDCImpl(wxDC *owner, const wxString& file = wxEmptyString); |
83 | wxMetafileDCImpl(wxDC *owner, const wxString& file, | |
84 | int xext, int yext, int xorg, int yorg); | |
888dde65 | 85 | virtual ~wxMetafileDCImpl(); |
2bda0e17 | 86 | |
265b0c07 | 87 | virtual wxMetafile *Close(); |
89efaf2b | 88 | virtual void SetMapMode(wxMappingMode mode); |
d1ae2638 VZ |
89 | virtual void DoGetTextExtent(const wxString& string, |
90 | wxCoord *x, wxCoord *y, | |
91 | wxCoord *descent = NULL, | |
92 | wxCoord *externalLeading = NULL, | |
93 | const wxFont *theFont = NULL) const; | |
2bda0e17 | 94 | |
265b0c07 VZ |
95 | // Implementation |
96 | wxMetafile *GetMetaFile() const { return m_metaFile; } | |
97 | void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; } | |
98 | int GetWindowsMappingMode() const { return m_windowsMappingMode; } | |
99 | void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; } | |
2bda0e17 KB |
100 | |
101 | protected: | |
024026be VZ |
102 | virtual void DoGetSize(int *width, int *height) const; |
103 | ||
265b0c07 VZ |
104 | int m_windowsMappingMode; |
105 | wxMetafile* m_metaFile; | |
106 | ||
107 | private: | |
888dde65 | 108 | DECLARE_CLASS(wxMetafileDCImpl) |
c0c133e1 | 109 | wxDECLARE_NO_COPY_CLASS(wxMetafileDCImpl); |
2bda0e17 KB |
110 | }; |
111 | ||
53a2db12 | 112 | class WXDLLIMPEXP_CORE wxMetafileDC: public wxDC |
888dde65 RR |
113 | { |
114 | public: | |
115 | // Don't supply origin and extent | |
116 | // Supply them to wxMakeMetaFilePlaceable instead. | |
d2ce59e9 SN |
117 | wxMetafileDC(const wxString& file) |
118 | : wxDC(new wxMetafileDCImpl( this, file )) | |
119 | { } | |
888dde65 RR |
120 | |
121 | // Supply origin and extent (recommended). | |
122 | // Then don't need to supply them to wxMakeMetaFilePlaceable. | |
123 | wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg) | |
d2ce59e9 SN |
124 | : wxDC(new wxMetafileDCImpl( this, file, xext, yext, xorg, yorg )) |
125 | { } | |
888dde65 | 126 | |
89efaf2b | 127 | wxMetafile *GetMetafile() const |
888dde65 | 128 | { return ((wxMetafileDCImpl*)m_pimpl)->GetMetaFile(); } |
89efaf2b | 129 | |
888dde65 RR |
130 | wxMetafile *Close() |
131 | { return ((wxMetafileDCImpl*)m_pimpl)->Close(); } | |
132 | ||
133 | private: | |
134 | DECLARE_CLASS(wxMetafileDC) | |
c0c133e1 | 135 | wxDECLARE_NO_COPY_CLASS(wxMetafileDC); |
888dde65 RR |
136 | }; |
137 | ||
138 | ||
139 | ||
140 | ||
2bda0e17 KB |
141 | /* |
142 | * Pass filename of existing non-placeable metafile, and bounding box. | |
143 | * Adds a placeable metafile header, sets the mapping mode to anisotropic, | |
e3065973 | 144 | * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. |
2bda0e17 KB |
145 | * |
146 | */ | |
147 | ||
148 | // No origin or extent | |
53a2db12 | 149 | bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0); |
2bda0e17 KB |
150 | |
151 | // Optional origin and extent | |
53a2db12 | 152 | bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = true); |
2bda0e17 | 153 | |
06e43511 JS |
154 | // ---------------------------------------------------------------------------- |
155 | // wxMetafileDataObject is a specialization of wxDataObject for metafile data | |
156 | // ---------------------------------------------------------------------------- | |
157 | ||
06e43511 | 158 | #if wxUSE_DRAG_AND_DROP |
265b0c07 | 159 | |
53a2db12 | 160 | class WXDLLIMPEXP_CORE wxMetafileDataObject : public wxDataObjectSimple |
06e43511 JS |
161 | { |
162 | public: | |
265b0c07 VZ |
163 | // ctors |
164 | wxMetafileDataObject() : wxDataObjectSimple(wxDF_METAFILE) | |
165 | { } | |
166 | wxMetafileDataObject(const wxMetafile& metafile) | |
167 | : wxDataObjectSimple(wxDF_METAFILE), m_metafile(metafile) { } | |
168 | ||
169 | // virtual functions which you may override if you want to provide data on | |
170 | // demand only - otherwise, the trivial default versions will be used | |
171 | virtual void SetMetafile(const wxMetafile& metafile) | |
172 | { m_metafile = metafile; } | |
173 | virtual wxMetafile GetMetafile() const | |
174 | { return m_metafile; } | |
175 | ||
176 | // implement base class pure virtuals | |
177 | virtual size_t GetDataSize() const; | |
178 | virtual bool GetDataHere(void *buf) const; | |
179 | virtual bool SetData(size_t len, const void *buf); | |
06e43511 | 180 | |
265b0c07 VZ |
181 | protected: |
182 | wxMetafile m_metafile; | |
06e43511 | 183 | }; |
265b0c07 VZ |
184 | |
185 | #endif // wxUSE_DRAG_AND_DROP | |
06e43511 | 186 | |
2bda0e17 | 187 | #endif |
bbcdf8bc | 188 | // _WX_METAFIILE_H_ |
2845ddc2 | 189 |