]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/metafile.h
wxChar -> char
[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 /*
26 * Metafile and metafile device context classes
27 *
28 */
29
30 #define wxMetaFile wxMetafile
31 #define wxMetaFileDC wxMetafileDC
32
33 class WXDLLIMPEXP_FWD_CORE wxMetafile;
34 class wxMetafileRefData ;
35
36 #define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
37
38 class WXDLLEXPORT wxMetafile: public wxGDIObject
39 {
40 DECLARE_DYNAMIC_CLASS(wxMetafile)
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 bool Ok() const { return IsOk(); }
51 bool IsOk() const ;
52
53 wxSize GetSize() const;
54 int GetWidth() const { return GetSize().x; }
55 int GetHeight() const { return GetSize().y; }
56
57 // Implementation
58 WXHMETAFILE GetHMETAFILE() const ;
59 void SetHMETAFILE(WXHMETAFILE mf) ;
60 // Since the native metafile format is PDF for Quartz
61 // we need a call that allows setting PICT content for
62 // backwards compatibility
63 void SetPICT(void* pictHandle) ;
64 };
65
66 class WXDLLEXPORT wxMetafileDC: public wxDC
67 {
68 DECLARE_DYNAMIC_CLASS(wxMetafileDC)
69
70 public:
71 // the ctor parameters specify the filename (empty for memory metafiles),
72 // the metafile picture size and the optional description/comment
73 wxMetafileDC(const wxString& filename = wxEmptyString,
74 int width = 0, int height = 0,
75 const wxString& description = wxEmptyString);
76
77 virtual ~wxMetafileDC(void);
78
79 // Should be called at end of drawing
80 virtual wxMetafile *Close(void);
81
82 // Implementation
83 inline wxMetafile *GetMetaFile(void) const { return m_metaFile; }
84 inline void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
85
86 protected:
87 virtual void DoGetSize(int *width, int *height) const;
88
89 wxMetafile* m_metaFile;
90 };
91
92 /*
93 * Pass filename of existing non-placeable metafile, and bounding box.
94 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
95 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
96 *
97 */
98
99 // No origin or extent
100 #define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
101 bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
102
103 // Optional origin and extent
104 bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = TRUE);
105
106 // ----------------------------------------------------------------------------
107 // wxMetafileDataObject is a specialization of wxDataObject for metafile data
108 // ----------------------------------------------------------------------------
109
110 #if wxUSE_DATAOBJ
111 class WXDLLEXPORT wxMetafileDataObject : public wxDataObjectSimple
112 {
113 public:
114 // ctors
115 wxMetafileDataObject()
116 : wxDataObjectSimple(wxDF_METAFILE) { };
117 wxMetafileDataObject(const wxMetafile& metafile)
118 : wxDataObjectSimple(wxDF_METAFILE), m_metafile(metafile) { }
119
120 // virtual functions which you may override if you want to provide data on
121 // demand only - otherwise, the trivial default versions will be used
122 virtual void SetMetafile(const wxMetafile& metafile)
123 { m_metafile = metafile; }
124 virtual wxMetafile GetMetafile() const
125 { return m_metafile; }
126
127 // implement base class pure virtuals
128 virtual size_t GetDataSize() const;
129 virtual bool GetDataHere(void *buf) const;
130 virtual bool SetData(size_t len, const void *buf);
131
132 virtual size_t GetDataSize(const wxDataFormat& WXUNUSED(format)) const
133 { return GetDataSize(); }
134 virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format),
135 void *buf) const
136 { return GetDataHere(buf); }
137 virtual bool SetData(const wxDataFormat& WXUNUSED(format),
138 size_t len, const void *buf)
139 { return SetData(len, buf); }
140 protected:
141 wxMetafile m_metafile;
142 };
143 #endif
144
145 #endif
146 // _WX_METAFIILE_H_