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