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