]> git.saurik.com Git - wxWidgets.git/blame - include/wx/osx/metafile.h
Add wxDateTime::DiffAsDateSpan().
[wxWidgets.git] / include / wx / osx / metafile.h
CommitLineData
6762286d 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: wx/osx/metafile.h
6762286d
SC
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
11// Licence: wxWindows licence
12/////////////////////////////////////////////////////////////////////////////
13
14
15#ifndef _WX_METAFIILE_H_
16#define _WX_METAFIILE_H_
17
18#include "wx/dc.h"
19#include "wx/gdiobj.h"
20
21#if wxUSE_DATAOBJ
22#include "wx/dataobj.h"
5c6eb3a8 23#endif
6762286d 24
7a03aebc 25#include "wx/osx/dcclient.h"
6762286d
SC
26
27/*
28 * Metafile and metafile device context classes
29 *
30 */
31
32#define wxMetaFile wxMetafile
33#define wxMetaFileDC wxMetafileDC
34
35class WXDLLIMPEXP_FWD_CORE wxMetafile;
36class wxMetafileRefData ;
37
38#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
39
40class WXDLLIMPEXP_CORE wxMetafile : public wxGDIObject
41{
42public:
43 wxMetafile(const wxString& file = wxEmptyString);
44 virtual ~wxMetafile(void);
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);
51
52 wxSize GetSize() const;
53 int GetWidth() const { return GetSize().x; }
54 int GetHeight() const { return GetSize().y; }
55
56 // Implementation
57 WXHMETAFILE GetHMETAFILE() const ;
58 void SetHMETAFILE(WXHMETAFILE mf) ;
6762286d
SC
59protected:
60 virtual wxGDIRefData *CreateGDIRefData() const;
61 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
62
63 DECLARE_DYNAMIC_CLASS(wxMetafile)
64};
65
66
67class WXDLLIMPEXP_CORE wxMetafileDCImpl: public wxGCDCImpl
68{
69public:
70 wxMetafileDCImpl( wxDC *owner,
71 const wxString& filename,
72 int width, int height,
73 const wxString& description );
74
75 virtual ~wxMetafileDCImpl();
76
77 // Should be called at end of drawing
78 virtual wxMetafile *Close();
79
80 // Implementation
81 wxMetafile *GetMetaFile(void) const { return m_metaFile; }
82 void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
83
84protected:
85 virtual void DoGetSize(int *width, int *height) const;
86
87 wxMetafile* m_metaFile;
88
89private:
90 DECLARE_CLASS(wxMetafileDCImpl)
c0c133e1 91 wxDECLARE_NO_COPY_CLASS(wxMetafileDCImpl);
6762286d
SC
92};
93
94class WXDLLIMPEXP_CORE wxMetafileDC: public wxDC
95{
96 public:
97 // the ctor parameters specify the filename (empty for memory metafiles),
98 // the metafile picture size and the optional description/comment
99 wxMetafileDC( const wxString& filename = wxEmptyString,
100 int width = 0, int height = 0,
101 const wxString& description = wxEmptyString ) :
102 wxDC( new wxMetafileDCImpl( this, filename, width, height, description) )
103 { }
104
105 wxMetafile *GetMetafile() const
106 { return ((wxMetafileDCImpl*)m_pimpl)->GetMetaFile(); }
107
108 wxMetafile *Close()
109 { return ((wxMetafileDCImpl*)m_pimpl)->Close(); }
110
111private:
112 DECLARE_CLASS(wxMetafileDC)
c0c133e1 113 wxDECLARE_NO_COPY_CLASS(wxMetafileDC);
6762286d
SC
114};
115
116
117/*
118 * Pass filename of existing non-placeable metafile, and bounding box.
119 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
120 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
121 *
122 */
123
124// No origin or extent
125#define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
126bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
127
128// Optional origin and extent
8e6efd1f 129bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = true);
6762286d
SC
130
131// ----------------------------------------------------------------------------
132// wxMetafileDataObject is a specialization of wxDataObject for metafile data
133// ----------------------------------------------------------------------------
134
135#if wxUSE_DATAOBJ
136class WXDLLIMPEXP_CORE wxMetafileDataObject : public wxDataObjectSimple
137{
138public:
139 // ctors
140 wxMetafileDataObject()
6dd0883d 141 : wxDataObjectSimple(wxDF_METAFILE) { }
6762286d
SC
142 wxMetafileDataObject(const wxMetafile& metafile)
143 : wxDataObjectSimple(wxDF_METAFILE), m_metafile(metafile) { }
144
145 // virtual functions which you may override if you want to provide data on
146 // demand only - otherwise, the trivial default versions will be used
147 virtual void SetMetafile(const wxMetafile& metafile)
148 { m_metafile = metafile; }
149 virtual wxMetafile GetMetafile() const
150 { return m_metafile; }
151
152 // implement base class pure virtuals
153 virtual size_t GetDataSize() const;
154 virtual bool GetDataHere(void *buf) const;
155 virtual bool SetData(size_t len, const void *buf);
156
157 virtual size_t GetDataSize(const wxDataFormat& WXUNUSED(format)) const
158 { return GetDataSize(); }
159 virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format),
160 void *buf) const
161 { return GetDataHere(buf); }
162 virtual bool SetData(const wxDataFormat& WXUNUSED(format),
163 size_t len, const void *buf)
164 { return SetData(len, buf); }
165protected:
166 wxMetafile m_metafile;
167};
168#endif
169
170#endif
171 // _WX_METAFIILE_H_