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