]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/enhmeta.h
Compile in IFF stuff.
[wxWidgets.git] / include / wx / msw / enhmeta.h
CommitLineData
d9317fd4
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/msw/enhmeta.h
3// Purpose: wxEnhMetaFile class for Win32
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 13.01.00
7// RCS-ID: $Id$
8// Copyright: (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9// Licence: wxWindows license
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_MSW_ENHMETA_H_
13#define _WX_MSW_ENHMETA_H_
14
15#ifdef __GNUG__
16 #pragma interface "enhmeta.h"
17#endif
18
19#include "wx/dc.h"
20
21#if wxUSE_DRAG_AND_DROP
22 #include "wx/dataobj.h"
23#endif
24
25// ----------------------------------------------------------------------------
26// wxEnhMetaFile: encapsulation of Win32 HENHMETAFILE
27// ----------------------------------------------------------------------------
28
29class WXDLLEXPORT wxEnhMetaFile : public wxObject
30{
31public:
32 wxEnhMetaFile(const wxString& file = wxEmptyString) : m_filename(file)
33 { Init(); }
34 wxEnhMetaFile(const wxEnhMetaFile& metafile)
35 { Init(); Assign(metafile); }
36 wxEnhMetaFile& operator=(const wxEnhMetaFile& metafile)
37 { Free(); Assign(metafile); return *this; }
38
39 virtual ~wxEnhMetaFile()
40 { Free(); }
41
42 // display the picture stored in the metafile on the given DC
43 bool Play(wxDC *dc, wxRect *rectBound = (wxRect *)NULL);
44
45 // accessors
46 bool Ok() const { return m_hMF != 0; }
47
48 wxSize GetSize() const;
49 int GetWidth() const { return GetSize().x; }
50 int GetHeight() const { return GetSize().y; }
51
52 const wxString& GetFileName() const { return m_filename; }
53
bfbd6dc1
VZ
54 // copy the metafile to the clipboard: the width and height parameters are
55 // for backwards compatibility (with wxMetaFile) only, they are ignored by
56 // this method
57 bool SetClipboard(int width = 0, int height = 0);
58
d9317fd4
VZ
59 // implementation
60 WXHANDLE GetHENHMETAFILE() const { return m_hMF; }
61 void SetHENHMETAFILE(WXHANDLE hMF) { Free(); m_hMF = hMF; }
62
63protected:
64 void Init() { m_hMF = 0; }
65 void Free();
66 void Assign(const wxEnhMetaFile& mf);
67
68private:
69 wxString m_filename;
70 WXHANDLE m_hMF;
71
72 DECLARE_DYNAMIC_CLASS(wxEnhMetaFile)
73};
74
75// ----------------------------------------------------------------------------
76// wxEnhMetaFileDC: allows to create a wxEnhMetaFile
77// ----------------------------------------------------------------------------
78
79class WXDLLEXPORT wxEnhMetaFileDC : public wxDC
80{
81public:
82 // the ctor parameters specify the filename (empty for memory metafiles),
83 // the metafile picture size and the optional description/comment
84 wxEnhMetaFileDC(const wxString& filename = wxEmptyString,
85 int width = 0, int height = 0,
86 const wxString& description = wxEmptyString);
87
88 virtual ~wxEnhMetaFileDC();
89
90 // obtain a pointer to the new metafile (caller should delete it)
91 wxEnhMetaFile *Close();
92
93private:
94 DECLARE_DYNAMIC_CLASS(wxEnhMetaFileDC)
95};
96
7ba4fbeb
VZ
97#if wxUSE_DRAG_AND_DROP
98
d9317fd4
VZ
99// ----------------------------------------------------------------------------
100// wxEnhMetaFileDataObject is a specialization of wxDataObject for enh metafile
101// ----------------------------------------------------------------------------
102
d9317fd4 103// notice that we want to support both CF_METAFILEPICT and CF_ENHMETAFILE and
bfbd6dc1 104// so we derive from wxDataObject and not from wxDataObjectSimple
d9317fd4
VZ
105class WXDLLEXPORT wxEnhMetaFileDataObject : public wxDataObject
106{
107public:
108 // ctors
109 wxEnhMetaFileDataObject() { }
110 wxEnhMetaFileDataObject(const wxEnhMetaFile& metafile)
111 : m_metafile(metafile) { }
112
113 // virtual functions which you may override if you want to provide data on
114 // demand only - otherwise, the trivial default versions will be used
115 virtual void SetMetafile(const wxEnhMetaFile& metafile)
116 { m_metafile = metafile; }
117 virtual wxEnhMetaFile GetMetafile() const
118 { return m_metafile; }
119
120 // implement base class pure virtuals
121 virtual wxDataFormat GetPreferredFormat(Direction dir) const;
122 virtual size_t GetFormatCount(Direction dir) const;
123 virtual void GetAllFormats(wxDataFormat *formats, Direction dir) const;
124 virtual size_t GetDataSize(const wxDataFormat& format) const;
125 virtual bool GetDataHere(const wxDataFormat& format, void *buf) const;
126 virtual bool SetData(const wxDataFormat& format, size_t len,
127 const void *buf);
128
129protected:
130 wxEnhMetaFile m_metafile;
131};
132
7ba4fbeb
VZ
133
134// ----------------------------------------------------------------------------
135// wxEnhMetaFileSimpleDataObject does derive from wxDataObjectSimple which
136// makes it more convenient to use (it can be used with wxDataObjectComposite)
137// at the price of not supoprting any more CF_METAFILEPICT but only
138// CF_ENHMETAFILE
139// ----------------------------------------------------------------------------
140
141class WXDLLEXPORT wxEnhMetaFileSimpleDataObject : public wxDataObjectSimple
142{
143public:
144 // ctors
145 wxEnhMetaFileSimpleDataObject() : wxDataObjectSimple(wxDF_ENHMETAFILE) { }
146 wxEnhMetaFileSimpleDataObject(const wxEnhMetaFile& metafile)
147 : wxDataObjectSimple(wxDF_ENHMETAFILE), m_metafile(metafile) { }
148
149 // virtual functions which you may override if you want to provide data on
150 // demand only - otherwise, the trivial default versions will be used
151 virtual void SetEnhMetafile(const wxEnhMetaFile& metafile)
152 { m_metafile = metafile; }
153 virtual wxEnhMetaFile GetEnhMetafile() const
154 { return m_metafile; }
155
156 // implement base class pure virtuals
157 virtual size_t GetDataSize() const;
158 virtual bool GetDataHere(void *buf) const;
159 virtual bool SetData(size_t len, const void *buf);
160
161protected:
162 wxEnhMetaFile m_metafile;
163};
164
d9317fd4
VZ
165#endif // wxUSE_DRAG_AND_DROP
166
167#endif // _WX_MSW_ENHMETA_H_