]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/msw/metafile.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / msw / metafile.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/msw/metafile.h
3// Purpose: wxMetaFile, wxMetaFileDC and wxMetaFileDataObject classes
4// Author: Julian Smart
5// Modified by: VZ 07.01.00: implemented wxMetaFileDataObject
6// Created: 01/02/97
7// Copyright: (c) Julian Smart
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_METAFIILE_H_
12#define _WX_METAFIILE_H_
13
14#include "wx/dc.h"
15#include "wx/gdiobj.h"
16
17#if wxUSE_DRAG_AND_DROP
18 #include "wx/dataobj.h"
19#endif
20
21// ----------------------------------------------------------------------------
22// Metafile and metafile device context classes
23// ----------------------------------------------------------------------------
24
25class WXDLLIMPEXP_FWD_CORE wxMetafile;
26
27class WXDLLIMPEXP_CORE wxMetafileRefData: public wxGDIRefData
28{
29public:
30 wxMetafileRefData();
31 virtual ~wxMetafileRefData();
32
33 virtual bool IsOk() const { return m_metafile != 0; }
34
35public:
36 WXHANDLE m_metafile;
37 int m_windowsMappingMode;
38 int m_width, m_height;
39
40 friend class WXDLLIMPEXP_FWD_CORE wxMetafile;
41};
42
43#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
44
45class WXDLLIMPEXP_CORE wxMetafile: public wxGDIObject
46{
47public:
48 wxMetafile(const wxString& file = wxEmptyString);
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);
56
57 // set/get the size of metafile for clipboard operations
58 wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); }
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
71protected:
72 virtual wxGDIRefData *CreateGDIRefData() const;
73 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
74
75private:
76 DECLARE_DYNAMIC_CLASS(wxMetafile)
77};
78
79class WXDLLIMPEXP_CORE wxMetafileDCImpl: public wxMSWDCImpl
80{
81public:
82 wxMetafileDCImpl(wxDC *owner, const wxString& file = wxEmptyString);
83 wxMetafileDCImpl(wxDC *owner, const wxString& file,
84 int xext, int yext, int xorg, int yorg);
85 virtual ~wxMetafileDCImpl();
86
87 virtual wxMetafile *Close();
88 virtual void SetMapMode(wxMappingMode mode);
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;
94
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; }
100
101protected:
102 virtual void DoGetSize(int *width, int *height) const;
103
104 int m_windowsMappingMode;
105 wxMetafile* m_metaFile;
106
107private:
108 DECLARE_CLASS(wxMetafileDCImpl)
109 wxDECLARE_NO_COPY_CLASS(wxMetafileDCImpl);
110};
111
112class WXDLLIMPEXP_CORE wxMetafileDC: public wxDC
113{
114public:
115 // Don't supply origin and extent
116 // Supply them to wxMakeMetaFilePlaceable instead.
117 wxMetafileDC(const wxString& file)
118 : wxDC(new wxMetafileDCImpl( this, file ))
119 { }
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)
124 : wxDC(new wxMetafileDCImpl( this, file, xext, yext, xorg, yorg ))
125 { }
126
127 wxMetafile *GetMetafile() const
128 { return ((wxMetafileDCImpl*)m_pimpl)->GetMetaFile(); }
129
130 wxMetafile *Close()
131 { return ((wxMetafileDCImpl*)m_pimpl)->Close(); }
132
133private:
134 DECLARE_CLASS(wxMetafileDC)
135 wxDECLARE_NO_COPY_CLASS(wxMetafileDC);
136};
137
138
139
140
141/*
142 * Pass filename of existing non-placeable metafile, and bounding box.
143 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
144 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
145 *
146 */
147
148// No origin or extent
149bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
150
151// Optional origin and extent
152bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = true);
153
154// ----------------------------------------------------------------------------
155// wxMetafileDataObject is a specialization of wxDataObject for metafile data
156// ----------------------------------------------------------------------------
157
158#if wxUSE_DRAG_AND_DROP
159
160class WXDLLIMPEXP_CORE wxMetafileDataObject : public wxDataObjectSimple
161{
162public:
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);
180
181protected:
182 wxMetafile m_metafile;
183};
184
185#endif // wxUSE_DRAG_AND_DROP
186
187#endif
188 // _WX_METAFIILE_H_
189