]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/metafile.h
Applied notebook font patch.
[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.
a31a5f85 6// Author: Stefan Csomor
0dbd6262 7// Modified by:
a31a5f85 8// Created: 1998-01-01
0dbd6262 9// RCS-ID: $Id$
a31a5f85 10// Copyright: (c) Stefan Csomor
e40298d5 11// Licence: wxWindows licence
0dbd6262
SC
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
0b140baa 22#if wxUSE_DATAOBJ
5fde6fcc 23#include "wx/dataobj.h"
519cb848 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:
5273bf2f 44 WXHMETAFILE m_metafile;
519cb848
SC
45};
46
47#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
48
49class WXDLLEXPORT wxMetafile: public wxGDIObject
0dbd6262 50{
35c40e78
SC
51 DECLARE_DYNAMIC_CLASS(wxMetafile)
52public:
53 // Copy constructor
54 wxMetafile(const wxMetafile& metafile)
7ee31b00 55 : wxGDIObject()
35c40e78 56 { Ref(metafile); }
519cb848 57
35c40e78
SC
58 wxMetafile(const wxString& file = wxEmptyString);
59 ~wxMetafile(void);
0dbd6262 60
35c40e78
SC
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);
0dbd6262 64
35c40e78
SC
65 virtual bool Play(wxDC *dc);
66 inline bool Ok(void) const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); };
519cb848 67
35c40e78
SC
68 wxSize GetSize() const;
69 int GetWidth() const { return GetSize().x; }
70 int GetHeight() const { return GetSize().y; }
0dbd6262 71
35c40e78
SC
72 // Implementation
73 inline WXHMETAFILE GetHMETAFILE() const { return M_METAFILEDATA->m_metafile; }
74 void SetHMETAFILE(WXHMETAFILE mf) ;
75
76 // Operators
77 inline wxMetafile& operator = (const wxMetafile& metafile) { if (*this == metafile) return (*this); Ref(metafile); return *this; }
78 inline bool operator == (const wxMetafile& metafile) { return m_refData == metafile.m_refData; }
79 inline bool operator != (const wxMetafile& metafile) { return m_refData != metafile.m_refData; }
0dbd6262
SC
80
81protected:
0dbd6262
SC
82};
83
519cb848 84class WXDLLEXPORT wxMetafileDC: public wxDC
0dbd6262 85{
519cb848 86 DECLARE_DYNAMIC_CLASS(wxMetafileDC)
0dbd6262
SC
87
88 public:
35c40e78
SC
89 // the ctor parameters specify the filename (empty for memory metafiles),
90 // the metafile picture size and the optional description/comment
91 wxMetafileDC(const wxString& filename = wxEmptyString,
92 int width = 0, int height = 0,
93 const wxString& description = wxEmptyString);
0dbd6262 94
519cb848 95 ~wxMetafileDC(void);
0dbd6262
SC
96
97 // Should be called at end of drawing
519cb848 98 virtual wxMetafile *Close(void);
35c40e78 99 virtual void DoGetSize(int *width, int *height) const ;
0dbd6262
SC
100
101 // Implementation
519cb848
SC
102 inline wxMetafile *GetMetaFile(void) const { return m_metaFile; }
103 inline void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
0dbd6262
SC
104
105protected:
519cb848 106 wxMetafile* m_metaFile;
0dbd6262
SC
107};
108
109/*
110 * Pass filename of existing non-placeable metafile, and bounding box.
111 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
e3065973 112 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
0dbd6262
SC
113 *
114 */
115
116// No origin or extent
519cb848
SC
117#define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
118bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
0dbd6262
SC
119
120// Optional origin and extent
121bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = TRUE);
122
519cb848
SC
123// ----------------------------------------------------------------------------
124// wxMetafileDataObject is a specialization of wxDataObject for metafile data
125// ----------------------------------------------------------------------------
126
662899dd 127#if wxUSE_DATAOBJ
8400ad1e 128class WXDLLEXPORT wxMetafileDataObject : public wxDataObjectSimple
519cb848
SC
129{
130public:
131 // ctors
8400ad1e
SC
132 wxMetafileDataObject()
133 : wxDataObjectSimple(wxDF_METAFILE) { };
134 wxMetafileDataObject(const wxMetafile& metafile)
135 : wxDataObjectSimple(wxDF_METAFILE), m_metafile(metafile) { }
136
137 // virtual functions which you may override if you want to provide data on
138 // demand only - otherwise, the trivial default versions will be used
139 virtual void SetMetafile(const wxMetafile& metafile)
140 { m_metafile = metafile; }
141 virtual wxMetafile GetMetafile() const
142 { return m_metafile; }
143
144 // implement base class pure virtuals
145 virtual size_t GetDataSize() const;
146 virtual bool GetDataHere(void *buf) const;
147 virtual bool SetData(size_t len, const void *buf);
148
35c40e78
SC
149 virtual size_t GetDataSize(const wxDataFormat& WXUNUSED(format)) const
150 { return GetDataSize(); }
151 virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format),
152 void *buf) const
153 { return GetDataHere(buf); }
154 virtual bool SetData(const wxDataFormat& WXUNUSED(format),
155 size_t len, const void *buf)
156 { return SetData(len, buf); }
8400ad1e 157protected:
519cb848 158 wxMetafile m_metafile;
519cb848
SC
159};
160#endif
161
162#endif // wxUSE_METAFILE
163
164
0dbd6262
SC
165#endif
166 // _WX_METAFIILE_H_