]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/metafile.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / os2 / metafile.h
CommitLineData
0e320a79 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: wx/os2/metafile.h
0e320a79
DW
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.
75f11ad7 6// Author: David Webster
0e320a79 7// Modified by:
75f11ad7 8// Created: 10/10/99
75f11ad7 9// Copyright: (c) David Webster
65571936 10// Licence: wxWindows licence
0e320a79
DW
11/////////////////////////////////////////////////////////////////////////////
12
13
14#ifndef _WX_METAFIILE_H_
15#define _WX_METAFIILE_H_
16
a419c3b1 17#include "wx/dc.h"
75f11ad7 18#include "wx/gdiobj.h"
4b3f61d1 19#include "wx/os2/dc.h"
75f11ad7
DW
20
21#if wxUSE_DRAG_AND_DROP
22#include "wx/dataobj.h"
23#endif
0e320a79
DW
24
25/*
75f11ad7 26 * Metafile and metafile device context classes
0e320a79
DW
27 *
28 */
29
75f11ad7
DW
30#define wxMetaFile wxMetafile
31#define wxMetaFileDC wxMetafileDC
32
b5dbe15d 33class WXDLLIMPEXP_FWD_CORE wxMetafile;
75f11ad7 34
53a2db12 35class WXDLLIMPEXP_CORE wxMetafileRefData: public wxGDIRefData
75f11ad7 36{
b5dbe15d 37 friend class WXDLLIMPEXP_FWD_CORE wxMetafile;
75f11ad7
DW
38public:
39 wxMetafileRefData(void);
d3c7fc99 40 virtual ~wxMetafileRefData(void);
75f11ad7 41
8f884a0d
VZ
42 virtual bool IsOk() const { return m_metafile != 0; }
43
75f11ad7
DW
44public:
45 WXHANDLE m_metafile;
46 int m_windowsMappingMode;
47};
48
49#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
50
53a2db12 51class WXDLLIMPEXP_CORE wxMetafile: public wxGDIObject
0e320a79 52{
c40158e4
WS
53 DECLARE_DYNAMIC_CLASS(wxMetafile)
54public:
c40158e4 55 wxMetafile(const wxString& file = wxEmptyString);
d3c7fc99 56 virtual ~wxMetafile(void);
c40158e4
WS
57
58 // After this is called, the metafile cannot be used for anything
59 // since it is now owned by the clipboard.
60 virtual bool SetClipboard(int width = 0, int height = 0);
61
62 virtual bool Play(wxDC *dc);
c40158e4
WS
63
64 // Implementation
65 inline WXHANDLE GetHMETAFILE(void) { return M_METAFILEDATA->m_metafile; }
66 void SetHMETAFILE(WXHANDLE mf) ;
67 inline int GetWindowsMappingMode(void) { return M_METAFILEDATA->m_windowsMappingMode; }
68 void SetWindowsMappingMode(int mm);
4b3f61d1
SN
69
70protected:
71 virtual wxGDIRefData *CreateGDIRefData() const;
72 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
0e320a79
DW
73};
74
53a2db12 75class WXDLLIMPEXP_CORE wxMetafileDCImpl: public wxPMDCImpl
0e320a79 76{
4b3f61d1
SN
77public:
78 wxMetafileDCImpl(wxDC *owner, const wxString& file = wxEmptyString);
79 wxMetafileDCImpl(wxDC *owner, const wxString& file,
80 int xext, int yext, int xorg, int yorg);
81 virtual ~wxMetafileDCImpl();
82
83 virtual wxMetafile *Close();
89efaf2b 84 virtual void SetMapMode(wxMappingMode mode);
4b3f61d1
SN
85 virtual void DoGetTextExtent(const wxString& string,
86 wxCoord *x, wxCoord *y,
87 wxCoord *descent = NULL,
88 wxCoord *externalLeading = NULL,
89 const wxFont *theFont = NULL) const;
90
91 // Implementation
92 wxMetafile *GetMetaFile() const { return m_metaFile; }
93 void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
94 int GetWindowsMappingMode() const { return m_windowsMappingMode; }
95 void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; }
96
97protected:
98 virtual void DoGetSize(int *width, int *height) const;
99
100 int m_windowsMappingMode;
101 wxMetafile* m_metaFile;
0e320a79 102
4b3f61d1
SN
103private:
104 DECLARE_CLASS(wxMetafileDCImpl)
c0c133e1 105 wxDECLARE_NO_COPY_CLASS(wxMetafileDCImpl);
4b3f61d1
SN
106};
107
53a2db12 108class WXDLLIMPEXP_CORE wxMetafileDC: public wxDC
4b3f61d1 109{
c40158e4
WS
110public:
111 // Don't supply origin and extent
112 // Supply them to wxMakeMetaFilePlaceable instead.
4b3f61d1
SN
113 wxMetafileDC(const wxString& file = wxEmptyString)
114 :wxDC(new wxMetafileDCImpl( this, file ))
115 { }
0e320a79 116
c40158e4
WS
117 // Supply origin and extent (recommended).
118 // Then don't need to supply them to wxMakeMetaFilePlaceable.
4b3f61d1 119 wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg)
2c6dbc21 120 : wxDC(new wxMetafileDCImpl( this, file, xext, yext, xorg, yorg ))
4b3f61d1 121 { }
0e320a79 122
2c6dbc21 123 wxMetafile *GetMetafile() const
4b3f61d1 124 { return ((wxMetafileDCImpl*)m_pimpl)->GetMetaFile(); }
0e320a79 125
4b3f61d1
SN
126 virtual ~wxMetafileDC(void)
127 { delete m_pimpl; }
0e320a79 128
4b3f61d1
SN
129 // Should be called at end of drawing
130 virtual wxMetafile *Close(void)
131 { return ((wxMetafileDCImpl*)m_pimpl)->Close(); }
0e320a79 132
4b3f61d1
SN
133 inline void SetMetaFile(wxMetafile *mf)
134 { ((wxMetafileDCImpl*)m_pimpl)->SetMetaFile(mf); }
75f11ad7
DW
135
136private:
4b3f61d1 137 DECLARE_CLASS(wxMetafileDC)
c0c133e1 138 wxDECLARE_NO_COPY_CLASS(wxMetafileDC);
0e320a79
DW
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
75f11ad7 149#define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
53a2db12 150bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
0e320a79
DW
151
152// Optional origin and extent
53a2db12 153bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable( const wxString& filename
c40158e4
WS
154 ,int x1
155 ,int y1
156 ,int x2
157 ,int y2
158 ,float scale = 1.0
159 ,bool useOriginAndExtent = true
160 );
0e320a79 161
75f11ad7
DW
162// ----------------------------------------------------------------------------
163// wxMetafileDataObject is a specialization of wxDataObject for metafile data
164// ----------------------------------------------------------------------------
165
166// TODO: implement OLE side of things. At present, it's just for clipboard
167// use.
168
169#if wxUSE_DRAG_AND_DROP
53a2db12 170class WXDLLIMPEXP_CORE wxMetafileDataObject : public wxDataObject
75f11ad7
DW
171{
172public:
c40158e4 173 // ctors
6dd0883d 174 wxMetafileDataObject() { m_width = 0; m_height = 0; }
c40158e4
WS
175 wxMetafileDataObject(const wxMetafile& metafile, int width = 0,int height = 0)
176 :m_metafile(metafile)
177 ,m_width(width)
178 ,m_height(height) { }
75f11ad7 179
c40158e4
WS
180 void SetMetafile(const wxMetafile& metafile, int w = 0, int h = 0)
181 { m_metafile = metafile; m_width = w; m_height = h; }
182 wxMetafile GetMetafile() const { return m_metafile; }
183 int GetWidth() const { return m_width; }
184 int GetHeight() const { return m_height; }
75f11ad7 185
c40158e4 186 virtual wxDataFormat GetFormat() const { return wxDF_METAFILE; }
75f11ad7
DW
187
188/* ??
c40158e4
WS
189 // implement base class pure virtuals
190 virtual wxDataFormat GetPreferredFormat() const
191 { return (wxDataFormat) wxDataObject::Text; }
192 virtual bool IsSupportedFormat(wxDataFormat format) const
193 { return format == wxDataObject::Text || format == wxDataObject::Locale; }
194 virtual size_t GetDataSize() const
195 { return m_strText.Len() + 1; } // +1 for trailing '\0'of course
196 virtual void GetDataHere(void *pBuf) const
197 { memcpy(pBuf, m_strText.c_str(), GetDataSize()); }
75f11ad7
DW
198*/
199
200private:
c40158e4
WS
201 wxMetafile m_metafile;
202 int m_width;
203 int m_height;
75f11ad7
DW
204};
205#endif
206
0e320a79
DW
207#endif
208 // _WX_METAFIILE_H_