]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/enhmeta.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[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
d9317fd4 7// Copyright: (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
65571936 8// Licence: wxWindows licence
d9317fd4
VZ
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_MSW_ENHMETA_H_
12#define _WX_MSW_ENHMETA_H_
13
d9317fd4 14#include "wx/dc.h"
8f884a0d 15#include "wx/gdiobj.h"
d9317fd4
VZ
16
17#if wxUSE_DRAG_AND_DROP
18 #include "wx/dataobj.h"
19#endif
20
21// ----------------------------------------------------------------------------
22// wxEnhMetaFile: encapsulation of Win32 HENHMETAFILE
23// ----------------------------------------------------------------------------
24
53a2db12 25class WXDLLIMPEXP_CORE wxEnhMetaFile : public wxGDIObject
d9317fd4
VZ
26{
27public:
28 wxEnhMetaFile(const wxString& file = wxEmptyString) : m_filename(file)
29 { Init(); }
8f884a0d 30 wxEnhMetaFile(const wxEnhMetaFile& metafile) : wxGDIObject()
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
d3b9f782 39 bool Play(wxDC *dc, wxRect *rectBound = NULL);
d9317fd4
VZ
40
41 // accessors
8f884a0d 42 virtual bool IsOk() const { return m_hMF != 0; }
d9317fd4
VZ
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
8f884a0d
VZ
64 // we don't use these functions (but probably should) but have to implement
65 // them as they're pure virtual in the base class
66 virtual wxGDIRefData *CreateGDIRefData() const;
67 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
68
d9317fd4
VZ
69private:
70 wxString m_filename;
71 WXHANDLE m_hMF;
72
73 DECLARE_DYNAMIC_CLASS(wxEnhMetaFile)
74};
75
76// ----------------------------------------------------------------------------
77// wxEnhMetaFileDC: allows to create a wxEnhMetaFile
78// ----------------------------------------------------------------------------
79
53a2db12 80class WXDLLIMPEXP_CORE wxEnhMetaFileDC : public wxDC
d9317fd4
VZ
81{
82public:
83 // the ctor parameters specify the filename (empty for memory metafiles),
84 // the metafile picture size and the optional description/comment
85 wxEnhMetaFileDC(const wxString& filename = wxEmptyString,
86 int width = 0, int height = 0,
87 const wxString& description = wxEmptyString);
88
cc344571
VS
89 // as above, but takes reference DC as first argument to take resolution,
90 // size, font metrics etc. from
fb4faeb5 91 wxEXPLICIT
cc344571
VS
92 wxEnhMetaFileDC(const wxDC& referenceDC,
93 const wxString& filename = wxEmptyString,
94 int width = 0, int height = 0,
95 const wxString& description = wxEmptyString);
96
0273787a
VZ
97 // obtain a pointer to the new metafile (caller should delete it)
98 wxEnhMetaFile *Close();
99
100private:
2eb10e2a 101 DECLARE_DYNAMIC_CLASS_NO_COPY(wxEnhMetaFileDC)
d9317fd4
VZ
102};
103
7ba4fbeb
VZ
104#if wxUSE_DRAG_AND_DROP
105
d9317fd4
VZ
106// ----------------------------------------------------------------------------
107// wxEnhMetaFileDataObject is a specialization of wxDataObject for enh metafile
108// ----------------------------------------------------------------------------
109
d9317fd4 110// notice that we want to support both CF_METAFILEPICT and CF_ENHMETAFILE and
bfbd6dc1 111// so we derive from wxDataObject and not from wxDataObjectSimple
53a2db12 112class WXDLLIMPEXP_CORE wxEnhMetaFileDataObject : public wxDataObject
d9317fd4
VZ
113{
114public:
115 // ctors
116 wxEnhMetaFileDataObject() { }
117 wxEnhMetaFileDataObject(const wxEnhMetaFile& metafile)
118 : m_metafile(metafile) { }
119
120 // virtual functions which you may override if you want to provide data on
121 // demand only - otherwise, the trivial default versions will be used
122 virtual void SetMetafile(const wxEnhMetaFile& metafile)
123 { m_metafile = metafile; }
124 virtual wxEnhMetaFile GetMetafile() const
125 { return m_metafile; }
126
127 // implement base class pure virtuals
128 virtual wxDataFormat GetPreferredFormat(Direction dir) const;
129 virtual size_t GetFormatCount(Direction dir) const;
130 virtual void GetAllFormats(wxDataFormat *formats, Direction dir) const;
131 virtual size_t GetDataSize(const wxDataFormat& format) const;
132 virtual bool GetDataHere(const wxDataFormat& format, void *buf) const;
133 virtual bool SetData(const wxDataFormat& format, size_t len,
134 const void *buf);
135
136protected:
137 wxEnhMetaFile m_metafile;
2eb10e2a 138
c0c133e1 139 wxDECLARE_NO_COPY_CLASS(wxEnhMetaFileDataObject);
d9317fd4
VZ
140};
141
7ba4fbeb
VZ
142
143// ----------------------------------------------------------------------------
144// wxEnhMetaFileSimpleDataObject does derive from wxDataObjectSimple which
145// makes it more convenient to use (it can be used with wxDataObjectComposite)
146// at the price of not supoprting any more CF_METAFILEPICT but only
147// CF_ENHMETAFILE
148// ----------------------------------------------------------------------------
149
53a2db12 150class WXDLLIMPEXP_CORE wxEnhMetaFileSimpleDataObject : public wxDataObjectSimple
7ba4fbeb
VZ
151{
152public:
153 // ctors
154 wxEnhMetaFileSimpleDataObject() : wxDataObjectSimple(wxDF_ENHMETAFILE) { }
155 wxEnhMetaFileSimpleDataObject(const wxEnhMetaFile& metafile)
156 : wxDataObjectSimple(wxDF_ENHMETAFILE), m_metafile(metafile) { }
157
158 // virtual functions which you may override if you want to provide data on
159 // demand only - otherwise, the trivial default versions will be used
160 virtual void SetEnhMetafile(const wxEnhMetaFile& metafile)
161 { m_metafile = metafile; }
162 virtual wxEnhMetaFile GetEnhMetafile() const
163 { return m_metafile; }
164
165 // implement base class pure virtuals
166 virtual size_t GetDataSize() const;
167 virtual bool GetDataHere(void *buf) const;
168 virtual bool SetData(size_t len, const void *buf);
169
0e4acbd4
JS
170 virtual size_t GetDataSize(const wxDataFormat& WXUNUSED(format)) const
171 { return GetDataSize(); }
172 virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format),
173 void *buf) const
174 { return GetDataHere(buf); }
175 virtual bool SetData(const wxDataFormat& WXUNUSED(format),
176 size_t len, const void *buf)
177 { return SetData(len, buf); }
178
7ba4fbeb
VZ
179protected:
180 wxEnhMetaFile m_metafile;
2eb10e2a 181
c0c133e1 182 wxDECLARE_NO_COPY_CLASS(wxEnhMetaFileSimpleDataObject);
7ba4fbeb
VZ
183};
184
d9317fd4
VZ
185#endif // wxUSE_DRAG_AND_DROP
186
187#endif // _WX_MSW_ENHMETA_H_