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