]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/os2/metafile.h
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / include / wx / os2 / metafile.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/os2/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// Copyright: (c) David Webster
10// Licence: wxWindows licence
11/////////////////////////////////////////////////////////////////////////////
12
13
14#ifndef _WX_METAFIILE_H_
15#define _WX_METAFIILE_H_
16
17#include "wx/dc.h"
18#include "wx/gdiobj.h"
19#include "wx/os2/dc.h"
20
21#if wxUSE_DRAG_AND_DROP
22#include "wx/dataobj.h"
23#endif
24
25/*
26 * Metafile and metafile device context classes
27 *
28 */
29
30#define wxMetaFile wxMetafile
31#define wxMetaFileDC wxMetafileDC
32
33class WXDLLIMPEXP_FWD_CORE wxMetafile;
34
35class WXDLLIMPEXP_CORE wxMetafileRefData: public wxGDIRefData
36{
37 friend class WXDLLIMPEXP_FWD_CORE wxMetafile;
38public:
39 wxMetafileRefData(void);
40 virtual ~wxMetafileRefData(void);
41
42 virtual bool IsOk() const { return m_metafile != 0; }
43
44public:
45 WXHANDLE m_metafile;
46 int m_windowsMappingMode;
47};
48
49#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
50
51class WXDLLIMPEXP_CORE wxMetafile: public wxGDIObject
52{
53 DECLARE_DYNAMIC_CLASS(wxMetafile)
54public:
55 wxMetafile(const wxString& file = wxEmptyString);
56 virtual ~wxMetafile(void);
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);
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);
69
70protected:
71 virtual wxGDIRefData *CreateGDIRefData() const;
72 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
73};
74
75class WXDLLIMPEXP_CORE wxMetafileDCImpl: public wxPMDCImpl
76{
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();
84 virtual void SetMapMode(wxMappingMode mode);
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;
102
103private:
104 DECLARE_CLASS(wxMetafileDCImpl)
105 wxDECLARE_NO_COPY_CLASS(wxMetafileDCImpl);
106};
107
108class WXDLLIMPEXP_CORE wxMetafileDC: public wxDC
109{
110public:
111 // Don't supply origin and extent
112 // Supply them to wxMakeMetaFilePlaceable instead.
113 wxMetafileDC(const wxString& file = wxEmptyString)
114 :wxDC(new wxMetafileDCImpl( this, file ))
115 { }
116
117 // Supply origin and extent (recommended).
118 // Then don't need to supply them to wxMakeMetaFilePlaceable.
119 wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg)
120 : wxDC(new wxMetafileDCImpl( this, file, xext, yext, xorg, yorg ))
121 { }
122
123 wxMetafile *GetMetafile() const
124 { return ((wxMetafileDCImpl*)m_pimpl)->GetMetaFile(); }
125
126 virtual ~wxMetafileDC(void)
127 { delete m_pimpl; }
128
129 // Should be called at end of drawing
130 virtual wxMetafile *Close(void)
131 { return ((wxMetafileDCImpl*)m_pimpl)->Close(); }
132
133 inline void SetMetaFile(wxMetafile *mf)
134 { ((wxMetafileDCImpl*)m_pimpl)->SetMetaFile(mf); }
135
136private:
137 DECLARE_CLASS(wxMetafileDC)
138 wxDECLARE_NO_COPY_CLASS(wxMetafileDC);
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
149#define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
150bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
151
152// Optional origin and extent
153bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable( const wxString& filename
154 ,int x1
155 ,int y1
156 ,int x2
157 ,int y2
158 ,float scale = 1.0
159 ,bool useOriginAndExtent = true
160 );
161
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
170class WXDLLIMPEXP_CORE wxMetafileDataObject : public wxDataObject
171{
172public:
173 // ctors
174 wxMetafileDataObject() { m_width = 0; m_height = 0; }
175 wxMetafileDataObject(const wxMetafile& metafile, int width = 0,int height = 0)
176 :m_metafile(metafile)
177 ,m_width(width)
178 ,m_height(height) { }
179
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; }
185
186 virtual wxDataFormat GetFormat() const { return wxDF_METAFILE; }
187
188/* ??
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()); }
198*/
199
200private:
201 wxMetafile m_metafile;
202 int m_width;
203 int m_height;
204};
205#endif
206
207#endif
208 // _WX_METAFIILE_H_