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