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