]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/enhmeta.h
Implement monitoring of file descriptors in wxMotif event loop.
[wxWidgets.git] / include / wx / msw / enhmeta.h
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 licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_MSW_ENHMETA_H_
13 #define _WX_MSW_ENHMETA_H_
14
15 #include "wx/dc.h"
16 #include "wx/gdiobj.h"
17
18 #if wxUSE_DRAG_AND_DROP
19 #include "wx/dataobj.h"
20 #endif
21
22 // ----------------------------------------------------------------------------
23 // wxEnhMetaFile: encapsulation of Win32 HENHMETAFILE
24 // ----------------------------------------------------------------------------
25
26 class WXDLLIMPEXP_CORE wxEnhMetaFile : public wxGDIObject
27 {
28 public:
29 wxEnhMetaFile(const wxString& file = wxEmptyString) : m_filename(file)
30 { Init(); }
31 wxEnhMetaFile(const wxEnhMetaFile& metafile) : wxGDIObject()
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 = NULL);
41
42 // accessors
43 virtual bool IsOk() const { return m_hMF != 0; }
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
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
56 // implementation
57 WXHANDLE GetHENHMETAFILE() const { return m_hMF; }
58 void SetHENHMETAFILE(WXHANDLE hMF) { Free(); m_hMF = hMF; }
59
60 protected:
61 void Init();
62 void Free();
63 void Assign(const wxEnhMetaFile& mf);
64
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
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 WXDLLIMPEXP_CORE 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
90 // as above, but takes reference DC as first argument to take resolution,
91 // size, font metrics etc. from
92 wxEXPLICIT
93 wxEnhMetaFileDC(const wxDC& referenceDC,
94 const wxString& filename = wxEmptyString,
95 int width = 0, int height = 0,
96 const wxString& description = wxEmptyString);
97
98 // obtain a pointer to the new metafile (caller should delete it)
99 wxEnhMetaFile *Close();
100
101 private:
102 DECLARE_DYNAMIC_CLASS_NO_COPY(wxEnhMetaFileDC)
103 };
104
105 #if wxUSE_DRAG_AND_DROP
106
107 // ----------------------------------------------------------------------------
108 // wxEnhMetaFileDataObject is a specialization of wxDataObject for enh metafile
109 // ----------------------------------------------------------------------------
110
111 // notice that we want to support both CF_METAFILEPICT and CF_ENHMETAFILE and
112 // so we derive from wxDataObject and not from wxDataObjectSimple
113 class WXDLLIMPEXP_CORE wxEnhMetaFileDataObject : public wxDataObject
114 {
115 public:
116 // ctors
117 wxEnhMetaFileDataObject() { }
118 wxEnhMetaFileDataObject(const wxEnhMetaFile& metafile)
119 : m_metafile(metafile) { }
120
121 // virtual functions which you may override if you want to provide data on
122 // demand only - otherwise, the trivial default versions will be used
123 virtual void SetMetafile(const wxEnhMetaFile& metafile)
124 { m_metafile = metafile; }
125 virtual wxEnhMetaFile GetMetafile() const
126 { return m_metafile; }
127
128 // implement base class pure virtuals
129 virtual wxDataFormat GetPreferredFormat(Direction dir) const;
130 virtual size_t GetFormatCount(Direction dir) const;
131 virtual void GetAllFormats(wxDataFormat *formats, Direction dir) const;
132 virtual size_t GetDataSize(const wxDataFormat& format) const;
133 virtual bool GetDataHere(const wxDataFormat& format, void *buf) const;
134 virtual bool SetData(const wxDataFormat& format, size_t len,
135 const void *buf);
136
137 protected:
138 wxEnhMetaFile m_metafile;
139
140 wxDECLARE_NO_COPY_CLASS(wxEnhMetaFileDataObject);
141 };
142
143
144 // ----------------------------------------------------------------------------
145 // wxEnhMetaFileSimpleDataObject does derive from wxDataObjectSimple which
146 // makes it more convenient to use (it can be used with wxDataObjectComposite)
147 // at the price of not supoprting any more CF_METAFILEPICT but only
148 // CF_ENHMETAFILE
149 // ----------------------------------------------------------------------------
150
151 class WXDLLIMPEXP_CORE wxEnhMetaFileSimpleDataObject : public wxDataObjectSimple
152 {
153 public:
154 // ctors
155 wxEnhMetaFileSimpleDataObject() : wxDataObjectSimple(wxDF_ENHMETAFILE) { }
156 wxEnhMetaFileSimpleDataObject(const wxEnhMetaFile& metafile)
157 : wxDataObjectSimple(wxDF_ENHMETAFILE), m_metafile(metafile) { }
158
159 // virtual functions which you may override if you want to provide data on
160 // demand only - otherwise, the trivial default versions will be used
161 virtual void SetEnhMetafile(const wxEnhMetaFile& metafile)
162 { m_metafile = metafile; }
163 virtual wxEnhMetaFile GetEnhMetafile() const
164 { return m_metafile; }
165
166 // implement base class pure virtuals
167 virtual size_t GetDataSize() const;
168 virtual bool GetDataHere(void *buf) const;
169 virtual bool SetData(size_t len, const void *buf);
170
171 virtual size_t GetDataSize(const wxDataFormat& WXUNUSED(format)) const
172 { return GetDataSize(); }
173 virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format),
174 void *buf) const
175 { return GetDataHere(buf); }
176 virtual bool SetData(const wxDataFormat& WXUNUSED(format),
177 size_t len, const void *buf)
178 { return SetData(len, buf); }
179
180 protected:
181 wxEnhMetaFile m_metafile;
182
183 wxDECLARE_NO_COPY_CLASS(wxEnhMetaFileSimpleDataObject);
184 };
185
186 #endif // wxUSE_DRAG_AND_DROP
187
188 #endif // _WX_MSW_ENHMETA_H_