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