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