]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/metafile.h
implement wxLIST_AUTOSIZE support in wxMac's wxListCtrl
[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
888dde65
RR
25#include "wx/mac/carbon/dcclient.h"
26
8cf73271
SC
27/*
28 * Metafile and metafile device context classes
29 *
30 */
31
32#define wxMetaFile wxMetafile
33#define wxMetaFileDC wxMetafileDC
34
b5dbe15d 35class WXDLLIMPEXP_FWD_CORE wxMetafile;
71cc158e 36class wxMetafileRefData ;
8cf73271
SC
37
38#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
39
53a2db12 40class WXDLLIMPEXP_CORE wxMetafile : public wxGDIObject
8cf73271 41{
8cf73271 42public:
8cf73271 43 wxMetafile(const wxString& file = wxEmptyString);
d3c7fc99 44 virtual ~wxMetafile(void);
8cf73271
SC
45
46 // After this is called, the metafile cannot be used for anything
47 // since it is now owned by the clipboard.
48 virtual bool SetClipboard(int width = 0, int height = 0);
49
50 virtual bool Play(wxDC *dc);
8cf73271
SC
51
52 wxSize GetSize() const;
53 int GetWidth() const { return GetSize().x; }
54 int GetHeight() const { return GetSize().y; }
55
56 // Implementation
71cc158e 57 WXHMETAFILE GetHMETAFILE() const ;
8cf73271 58 void SetHMETAFILE(WXHMETAFILE mf) ;
11556386 59#ifndef __LP64__
ebf2a1ec
SC
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) ;
11556386 64#endif
8f884a0d
VZ
65
66protected:
67 virtual wxGDIRefData *CreateGDIRefData() const;
68 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
69
70 DECLARE_DYNAMIC_CLASS(wxMetafile)
8cf73271
SC
71};
72
8cf73271 73
53a2db12 74class WXDLLIMPEXP_CORE wxMetafileDCImpl: public wxGCDCImpl
888dde65
RR
75{
76public:
77 wxMetafileDCImpl( wxDC *owner,
78 const wxString& filename,
79 int width, int height,
80 const wxString& description );
8cf73271 81
888dde65 82 virtual ~wxMetafileDCImpl();
8cf73271 83
888dde65
RR
84 // Should be called at end of drawing
85 virtual wxMetafile *Close();
8cf73271 86
888dde65
RR
87 // Implementation
88 wxMetafile *GetMetaFile(void) const { return m_metaFile; }
89 void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
8cf73271
SC
90
91protected:
6f02a879
VZ
92 virtual void DoGetSize(int *width, int *height) const;
93
888dde65 94 wxMetafile* m_metaFile;
8f884a0d 95
888dde65
RR
96private:
97 DECLARE_CLASS(wxMetafileDCImpl)
98 DECLARE_NO_COPY_CLASS(wxMetafileDCImpl)
8cf73271
SC
99};
100
53a2db12 101class WXDLLIMPEXP_CORE wxMetafileDC: public wxDC
888dde65
RR
102{
103 public:
104 // the ctor parameters specify the filename (empty for memory metafiles),
105 // the metafile picture size and the optional description/comment
106 wxMetafileDC( const wxString& filename = wxEmptyString,
107 int width = 0, int height = 0,
b2da749f
RR
108 const wxString& description = wxEmptyString ) :
109 wxDC( new wxMetafileDCImpl( this, filename, width, height, description) )
110 { }
8f884a0d
VZ
111
112 wxMetafile *GetMetafile() const
888dde65 113 { return ((wxMetafileDCImpl*)m_pimpl)->GetMetaFile(); }
8f884a0d 114
888dde65
RR
115 wxMetafile *Close()
116 { return ((wxMetafileDCImpl*)m_pimpl)->Close(); }
8f884a0d 117
888dde65
RR
118private:
119 DECLARE_CLASS(wxMetafileDC)
120 DECLARE_NO_COPY_CLASS(wxMetafileDC)
121};
8f884a0d
VZ
122
123
8cf73271
SC
124/*
125 * Pass filename of existing non-placeable metafile, and bounding box.
126 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
127 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
128 *
129 */
130
131// No origin or extent
132#define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
53a2db12 133bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
8cf73271
SC
134
135// Optional origin and extent
53a2db12 136bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = TRUE);
8cf73271
SC
137
138// ----------------------------------------------------------------------------
139// wxMetafileDataObject is a specialization of wxDataObject for metafile data
140// ----------------------------------------------------------------------------
141
142#if wxUSE_DATAOBJ
53a2db12 143class WXDLLIMPEXP_CORE wxMetafileDataObject : public wxDataObjectSimple
8cf73271
SC
144{
145public:
146 // ctors
8f884a0d 147 wxMetafileDataObject()
8cf73271
SC
148 : wxDataObjectSimple(wxDF_METAFILE) { };
149 wxMetafileDataObject(const wxMetafile& metafile)
150 : wxDataObjectSimple(wxDF_METAFILE), m_metafile(metafile) { }
151
152 // virtual functions which you may override if you want to provide data on
153 // demand only - otherwise, the trivial default versions will be used
154 virtual void SetMetafile(const wxMetafile& metafile)
155 { m_metafile = metafile; }
156 virtual wxMetafile GetMetafile() const
157 { return m_metafile; }
158
159 // implement base class pure virtuals
160 virtual size_t GetDataSize() const;
161 virtual bool GetDataHere(void *buf) const;
162 virtual bool SetData(size_t len, const void *buf);
163
164 virtual size_t GetDataSize(const wxDataFormat& WXUNUSED(format)) const
165 { return GetDataSize(); }
166 virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format),
167 void *buf) const
168 { return GetDataHere(buf); }
169 virtual bool SetData(const wxDataFormat& WXUNUSED(format),
170 size_t len, const void *buf)
171 { return SetData(len, buf); }
172protected:
173 wxMetafile m_metafile;
174};
175#endif
176
8cf73271
SC
177#endif
178 // _WX_METAFIILE_H_