]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/metafile.h
Removed unnecessary code from utilsunx.cpp
[wxWidgets.git] / include / wx / mac / metafile.h
CommitLineData
0dbd6262
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: AUTHOR
7// Modified by:
8// Created: ??/??/98
9// RCS-ID: $Id$
10// Copyright: (c) AUTHOR
11// Licence: wxWindows licence
12/////////////////////////////////////////////////////////////////////////////
13
14
15#ifndef _WX_METAFIILE_H_
16#define _WX_METAFIILE_H_
17
519cb848
SC
18#if wxUSE_METAFILE
19#include "wx/dc.h"
20#include "wx/gdiobj.h"
0dbd6262 21
519cb848
SC
22#if wxUSE_DRAG_AND_DROP
23#include "wx/dataobj.h" wx/defs.h
24#endif
0dbd6262
SC
25
26/*
519cb848 27 * Metafile and metafile device context classes
0dbd6262
SC
28 *
29 */
30
519cb848
SC
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 PicHandle m_metafile;
45};
46
47#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
48
49class WXDLLEXPORT wxMetafile: public wxGDIObject
0dbd6262 50{
519cb848 51 DECLARE_DYNAMIC_CLASS(wxMetafile)
0dbd6262 52 public:
519cb848
SC
53 // Copy constructor
54 inline wxMetafile(const wxMetafile& metafile)
55 { Ref(metafile); }
56
57 wxMetafile(const wxString& file = "");
58 ~wxMetafile(void);
0dbd6262
SC
59
60 // After this is called, the metafile cannot be used for anything
61 // since it is now owned by the clipboard.
62 virtual bool SetClipboard(int width = 0, int height = 0);
63
64 virtual bool Play(wxDC *dc);
519cb848
SC
65 inline bool Ok(void) const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); };
66
67 // Implementation
68 inline PicHandle GetHMETAFILE(void) { return M_METAFILEDATA->m_metafile; }
69 void SetHMETAFILE(PicHandle mf) ;
0dbd6262 70
519cb848
SC
71 // Operators
72 inline wxMetafile& operator = (const wxMetafile& metafile) { if (*this == metafile) return (*this); Ref(metafile); return *this; }
73 inline bool operator == (const wxMetafile& metafile) { return m_refData == metafile.m_refData; }
74 inline bool operator != (const wxMetafile& metafile) { return m_refData != metafile.m_refData; }
0dbd6262
SC
75
76protected:
0dbd6262
SC
77};
78
519cb848 79class WXDLLEXPORT wxMetafileDC: public wxDC
0dbd6262 80{
519cb848 81 DECLARE_DYNAMIC_CLASS(wxMetafileDC)
0dbd6262
SC
82
83 public:
84 // Don't supply origin and extent
85 // Supply them to wxMakeMetaFilePlaceable instead.
519cb848 86 wxMetafileDC(const wxString& file = "");
0dbd6262
SC
87
88 // Supply origin and extent (recommended).
89 // Then don't need to supply them to wxMakeMetaFilePlaceable.
519cb848 90 wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg);
0dbd6262 91
519cb848 92 ~wxMetafileDC(void);
0dbd6262
SC
93
94 // Should be called at end of drawing
519cb848 95 virtual wxMetafile *Close(void);
0dbd6262
SC
96
97 // Implementation
519cb848
SC
98 inline wxMetafile *GetMetaFile(void) const { return m_metaFile; }
99 inline void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
0dbd6262
SC
100
101protected:
519cb848 102 wxMetafile* m_metaFile;
0dbd6262
SC
103};
104
105/*
106 * Pass filename of existing non-placeable metafile, and bounding box.
107 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
e3065973 108 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
0dbd6262
SC
109 *
110 */
111
112// No origin or extent
519cb848
SC
113#define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
114bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
0dbd6262
SC
115
116// Optional origin and extent
117bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = TRUE);
118
519cb848
SC
119// ----------------------------------------------------------------------------
120// wxMetafileDataObject is a specialization of wxDataObject for metafile data
121// ----------------------------------------------------------------------------
122
123// TODO: implement OLE side of things. At present, it's just for clipboard
124// use.
125
126#if wxUSE_DRAG_AND_DROP
127class WXDLLEXPORT wxMetafileDataObject : public wxDataObject
128{
129public:
130 // ctors
131 wxMetafileDataObject() { m_width = 0; m_height = 0; };
132 wxMetafileDataObject(const wxMetafile& metafile, int width = 0, int height = 0):
133 m_metafile(metafile), m_width(width), m_height(height) { }
134
135 void SetMetafile(const wxMetafile& metafile, int w = 0, int h = 0)
136 { m_metafile = metafile; m_width = w; m_height = h; }
137 wxMetafile GetMetafile() const { return m_metafile; }
138 int GetWidth() const { return m_width; }
139 int GetHeight() const { return m_height; }
140
141 virtual wxDataFormat GetFormat() const { return wxDF_METAFILE; }
142
143/* ??
144 // implement base class pure virtuals
145 virtual wxDataFormat GetPreferredFormat() const
146 { return (wxDataFormat) wxDataObject::Text; }
147 virtual bool IsSupportedFormat(wxDataFormat format) const
148 { return format == wxDataObject::Text || format == wxDataObject::Locale; }
149 virtual size_t GetDataSize() const
150 { return m_strText.Len() + 1; } // +1 for trailing '\0'of course
151 virtual void GetDataHere(void *pBuf) const
152 { memcpy(pBuf, m_strText.c_str(), GetDataSize()); }
153*/
154
155private:
156 wxMetafile m_metafile;
157 int m_width;
158 int m_height;
159};
160#endif
161
162#endif // wxUSE_METAFILE
163
164
0dbd6262
SC
165#endif
166 // _WX_METAFIILE_H_