]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/metafile.h
Add wxActivateEvent::GetActivationReason().
[wxWidgets.git] / include / wx / osx / metafile.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/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: Stefan Csomor
7 // Modified by:
8 // Created: 1998-01-01
9 // Copyright: (c) Stefan Csomor
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
20 #if wxUSE_DATAOBJ
21 #include "wx/dataobj.h"
22 #endif
23
24 #include "wx/osx/dcclient.h"
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 class wxMetafileRefData ;
36
37 #define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
38
39 class WXDLLIMPEXP_CORE wxMetafile : public wxGDIObject
40 {
41 public:
42 wxMetafile(const wxString& file = wxEmptyString);
43 virtual ~wxMetafile(void);
44
45 // After this is called, the metafile cannot be used for anything
46 // since it is now owned by the clipboard.
47 virtual bool SetClipboard(int width = 0, int height = 0);
48
49 virtual bool Play(wxDC *dc);
50
51 wxSize GetSize() const;
52 int GetWidth() const { return GetSize().x; }
53 int GetHeight() const { return GetSize().y; }
54
55 // Implementation
56 WXHMETAFILE GetHMETAFILE() const ;
57 void SetHMETAFILE(WXHMETAFILE mf) ;
58 protected:
59 virtual wxGDIRefData *CreateGDIRefData() const;
60 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
61
62 DECLARE_DYNAMIC_CLASS(wxMetafile)
63 };
64
65
66 class WXDLLIMPEXP_CORE wxMetafileDCImpl: public wxGCDCImpl
67 {
68 public:
69 wxMetafileDCImpl( wxDC *owner,
70 const wxString& filename,
71 int width, int height,
72 const wxString& description );
73
74 virtual ~wxMetafileDCImpl();
75
76 // Should be called at end of drawing
77 virtual wxMetafile *Close();
78
79 // Implementation
80 wxMetafile *GetMetaFile(void) const { return m_metaFile; }
81 void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
82
83 protected:
84 virtual void DoGetSize(int *width, int *height) const;
85
86 wxMetafile* m_metaFile;
87
88 private:
89 DECLARE_CLASS(wxMetafileDCImpl)
90 wxDECLARE_NO_COPY_CLASS(wxMetafileDCImpl);
91 };
92
93 class WXDLLIMPEXP_CORE wxMetafileDC: public wxDC
94 {
95 public:
96 // the ctor parameters specify the filename (empty for memory metafiles),
97 // the metafile picture size and the optional description/comment
98 wxMetafileDC( const wxString& filename = wxEmptyString,
99 int width = 0, int height = 0,
100 const wxString& description = wxEmptyString ) :
101 wxDC( new wxMetafileDCImpl( this, filename, width, height, description) )
102 { }
103
104 wxMetafile *GetMetafile() const
105 { return ((wxMetafileDCImpl*)m_pimpl)->GetMetaFile(); }
106
107 wxMetafile *Close()
108 { return ((wxMetafileDCImpl*)m_pimpl)->Close(); }
109
110 private:
111 DECLARE_CLASS(wxMetafileDC)
112 wxDECLARE_NO_COPY_CLASS(wxMetafileDC);
113 };
114
115
116 /*
117 * Pass filename of existing non-placeable metafile, and bounding box.
118 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
119 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
120 *
121 */
122
123 // No origin or extent
124 #define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
125 bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
126
127 // Optional origin and extent
128 bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = true);
129
130 // ----------------------------------------------------------------------------
131 // wxMetafileDataObject is a specialization of wxDataObject for metafile data
132 // ----------------------------------------------------------------------------
133
134 #if wxUSE_DATAOBJ
135 class WXDLLIMPEXP_CORE wxMetafileDataObject : public wxDataObjectSimple
136 {
137 public:
138 // ctors
139 wxMetafileDataObject()
140 : wxDataObjectSimple(wxDF_METAFILE) { }
141 wxMetafileDataObject(const wxMetafile& metafile)
142 : wxDataObjectSimple(wxDF_METAFILE), m_metafile(metafile) { }
143
144 // virtual functions which you may override if you want to provide data on
145 // demand only - otherwise, the trivial default versions will be used
146 virtual void SetMetafile(const wxMetafile& metafile)
147 { m_metafile = metafile; }
148 virtual wxMetafile GetMetafile() const
149 { return m_metafile; }
150
151 // implement base class pure virtuals
152 virtual size_t GetDataSize() const;
153 virtual bool GetDataHere(void *buf) const;
154 virtual bool SetData(size_t len, const void *buf);
155
156 virtual size_t GetDataSize(const wxDataFormat& WXUNUSED(format)) const
157 { return GetDataSize(); }
158 virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format),
159 void *buf) const
160 { return GetDataHere(buf); }
161 virtual bool SetData(const wxDataFormat& WXUNUSED(format),
162 size_t len, const void *buf)
163 { return SetData(len, buf); }
164 protected:
165 wxMetafile m_metafile;
166 };
167 #endif
168
169 #endif
170 // _WX_METAFIILE_H_