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