]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/enhmeta.h
Some BC++ 5.4 fixes
[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 license
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_MSW_ENHMETA_H_
13 #define _WX_MSW_ENHMETA_H_
14
15 #ifdef __GNUG__
16 #pragma interface "enhmeta.h"
17 #endif
18
19 #include "wx/dc.h"
20
21 #if wxUSE_DRAG_AND_DROP
22 #include "wx/dataobj.h"
23 #endif
24
25 // ----------------------------------------------------------------------------
26 // wxEnhMetaFile: encapsulation of Win32 HENHMETAFILE
27 // ----------------------------------------------------------------------------
28
29 class WXDLLEXPORT wxEnhMetaFile : public wxObject
30 {
31 public:
32 wxEnhMetaFile(const wxString& file = wxEmptyString) : m_filename(file)
33 { Init(); }
34 wxEnhMetaFile(const wxEnhMetaFile& metafile)
35 { Init(); Assign(metafile); }
36 wxEnhMetaFile& operator=(const wxEnhMetaFile& metafile)
37 { Free(); Assign(metafile); return *this; }
38
39 virtual ~wxEnhMetaFile()
40 { Free(); }
41
42 // display the picture stored in the metafile on the given DC
43 bool Play(wxDC *dc, wxRect *rectBound = (wxRect *)NULL);
44
45 // accessors
46 bool Ok() const { return m_hMF != 0; }
47
48 wxSize GetSize() const;
49 int GetWidth() const { return GetSize().x; }
50 int GetHeight() const { return GetSize().y; }
51
52 const wxString& GetFileName() const { return m_filename; }
53
54 // implementation
55 WXHANDLE GetHENHMETAFILE() const { return m_hMF; }
56 void SetHENHMETAFILE(WXHANDLE hMF) { Free(); m_hMF = hMF; }
57
58 protected:
59 void Init() { m_hMF = 0; }
60 void Free();
61 void Assign(const wxEnhMetaFile& mf);
62
63 private:
64 wxString m_filename;
65 WXHANDLE m_hMF;
66
67 DECLARE_DYNAMIC_CLASS(wxEnhMetaFile)
68 };
69
70 // ----------------------------------------------------------------------------
71 // wxEnhMetaFileDC: allows to create a wxEnhMetaFile
72 // ----------------------------------------------------------------------------
73
74 class WXDLLEXPORT wxEnhMetaFileDC : public wxDC
75 {
76 public:
77 // the ctor parameters specify the filename (empty for memory metafiles),
78 // the metafile picture size and the optional description/comment
79 wxEnhMetaFileDC(const wxString& filename = wxEmptyString,
80 int width = 0, int height = 0,
81 const wxString& description = wxEmptyString);
82
83 virtual ~wxEnhMetaFileDC();
84
85 // obtain a pointer to the new metafile (caller should delete it)
86 wxEnhMetaFile *Close();
87
88 private:
89 DECLARE_DYNAMIC_CLASS(wxEnhMetaFileDC)
90 };
91
92 // ----------------------------------------------------------------------------
93 // wxEnhMetaFileDataObject is a specialization of wxDataObject for enh metafile
94 // ----------------------------------------------------------------------------
95
96 #if wxUSE_DRAG_AND_DROP
97
98 // notice that we want to support both CF_METAFILEPICT and CF_ENHMETAFILE and
99 // so we derive from and not from wxDataObjectSimple
100 class WXDLLEXPORT wxEnhMetaFileDataObject : public wxDataObject
101 {
102 public:
103 // ctors
104 wxEnhMetaFileDataObject() { }
105 wxEnhMetaFileDataObject(const wxEnhMetaFile& metafile)
106 : m_metafile(metafile) { }
107
108 // virtual functions which you may override if you want to provide data on
109 // demand only - otherwise, the trivial default versions will be used
110 virtual void SetMetafile(const wxEnhMetaFile& metafile)
111 { m_metafile = metafile; }
112 virtual wxEnhMetaFile GetMetafile() const
113 { return m_metafile; }
114
115 // implement base class pure virtuals
116 virtual wxDataFormat GetPreferredFormat(Direction dir) const;
117 virtual size_t GetFormatCount(Direction dir) const;
118 virtual void GetAllFormats(wxDataFormat *formats, Direction dir) const;
119 virtual size_t GetDataSize(const wxDataFormat& format) const;
120 virtual bool GetDataHere(const wxDataFormat& format, void *buf) const;
121 virtual bool SetData(const wxDataFormat& format, size_t len,
122 const void *buf);
123
124 protected:
125 wxEnhMetaFile m_metafile;
126 };
127
128 #endif // wxUSE_DRAG_AND_DROP
129
130 #endif // _WX_MSW_ENHMETA_H_