]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/enhmeta.h
handle fatal exceptions in the other threads (based on patch 1459813 by Carl-Friedric...
[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
17 #if wxUSE_DRAG_AND_DROP
18 #include "wx/dataobj.h"
19 #endif
20
21 // ----------------------------------------------------------------------------
22 // wxEnhMetaFile: encapsulation of Win32 HENHMETAFILE
23 // ----------------------------------------------------------------------------
24
25 class WXDLLEXPORT wxEnhMetaFile : public wxObject
26 {
27 public:
28 wxEnhMetaFile(const wxString& file = wxEmptyString) : m_filename(file)
29 { Init(); }
30 wxEnhMetaFile(const wxEnhMetaFile& metafile) : wxObject()
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
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
55 // implementation
56 WXHANDLE GetHENHMETAFILE() const { return m_hMF; }
57 void SetHENHMETAFILE(WXHANDLE hMF) { Free(); m_hMF = hMF; }
58
59 protected:
60 void Init();
61 void Free();
62 void Assign(const wxEnhMetaFile& mf);
63
64 private:
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
75 class WXDLLEXPORT wxEnhMetaFileDC : public wxDC
76 {
77 public:
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
89 protected:
90 virtual void DoGetSize(int *width, int *height) const;
91
92 private:
93 // size passed to ctor and returned by DoGetSize()
94 int m_width,
95 m_height;
96
97 DECLARE_DYNAMIC_CLASS_NO_COPY(wxEnhMetaFileDC)
98 };
99
100 #if wxUSE_DRAG_AND_DROP
101
102 // ----------------------------------------------------------------------------
103 // wxEnhMetaFileDataObject is a specialization of wxDataObject for enh metafile
104 // ----------------------------------------------------------------------------
105
106 // notice that we want to support both CF_METAFILEPICT and CF_ENHMETAFILE and
107 // so we derive from wxDataObject and not from wxDataObjectSimple
108 class WXDLLEXPORT wxEnhMetaFileDataObject : public wxDataObject
109 {
110 public:
111 // ctors
112 wxEnhMetaFileDataObject() { }
113 wxEnhMetaFileDataObject(const wxEnhMetaFile& metafile)
114 : m_metafile(metafile) { }
115
116 // virtual functions which you may override if you want to provide data on
117 // demand only - otherwise, the trivial default versions will be used
118 virtual void SetMetafile(const wxEnhMetaFile& metafile)
119 { m_metafile = metafile; }
120 virtual wxEnhMetaFile GetMetafile() const
121 { return m_metafile; }
122
123 // implement base class pure virtuals
124 virtual wxDataFormat GetPreferredFormat(Direction dir) const;
125 virtual size_t GetFormatCount(Direction dir) const;
126 virtual void GetAllFormats(wxDataFormat *formats, Direction dir) const;
127 virtual size_t GetDataSize(const wxDataFormat& format) const;
128 virtual bool GetDataHere(const wxDataFormat& format, void *buf) const;
129 virtual bool SetData(const wxDataFormat& format, size_t len,
130 const void *buf);
131
132 protected:
133 wxEnhMetaFile m_metafile;
134
135 DECLARE_NO_COPY_CLASS(wxEnhMetaFileDataObject)
136 };
137
138
139 // ----------------------------------------------------------------------------
140 // wxEnhMetaFileSimpleDataObject does derive from wxDataObjectSimple which
141 // makes it more convenient to use (it can be used with wxDataObjectComposite)
142 // at the price of not supoprting any more CF_METAFILEPICT but only
143 // CF_ENHMETAFILE
144 // ----------------------------------------------------------------------------
145
146 class WXDLLEXPORT wxEnhMetaFileSimpleDataObject : public wxDataObjectSimple
147 {
148 public:
149 // ctors
150 wxEnhMetaFileSimpleDataObject() : wxDataObjectSimple(wxDF_ENHMETAFILE) { }
151 wxEnhMetaFileSimpleDataObject(const wxEnhMetaFile& metafile)
152 : wxDataObjectSimple(wxDF_ENHMETAFILE), m_metafile(metafile) { }
153
154 // virtual functions which you may override if you want to provide data on
155 // demand only - otherwise, the trivial default versions will be used
156 virtual void SetEnhMetafile(const wxEnhMetaFile& metafile)
157 { m_metafile = metafile; }
158 virtual wxEnhMetaFile GetEnhMetafile() const
159 { return m_metafile; }
160
161 // implement base class pure virtuals
162 virtual size_t GetDataSize() const;
163 virtual bool GetDataHere(void *buf) const;
164 virtual bool SetData(size_t len, const void *buf);
165
166 virtual size_t GetDataSize(const wxDataFormat& WXUNUSED(format)) const
167 { return GetDataSize(); }
168 virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format),
169 void *buf) const
170 { return GetDataHere(buf); }
171 virtual bool SetData(const wxDataFormat& WXUNUSED(format),
172 size_t len, const void *buf)
173 { return SetData(len, buf); }
174
175 protected:
176 wxEnhMetaFile m_metafile;
177
178 DECLARE_NO_COPY_CLASS(wxEnhMetaFileSimpleDataObject)
179 };
180
181 #endif // wxUSE_DRAG_AND_DROP
182
183 #endif // _WX_MSW_ENHMETA_H_