]>
Commit | Line | Data |
---|---|---|
ffecfa5a JS |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/palmos/enhmeta.h | |
4055ed82 | 3 | // Purpose: wxEnhMetaFile class for PalmOS |
e1d63b79 | 4 | // Author: William Osborne - minimal working wxPalmOS port |
ffecfa5a JS |
5 | // Modified by: |
6 | // Created: 10/13/04 | |
e1d63b79 | 7 | // RCS-ID: $Id$ |
ffecfa5a JS |
8 | // Copyright: (c) William Osborne |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_PALMOS_ENHMETA_H_ | |
13 | #define _WX_PALMOS_ENHMETA_H_ | |
14 | ||
ffecfa5a | 15 | #include "wx/dc.h" |
8f884a0d | 16 | #include "wx/gdiobj.h" |
ffecfa5a JS |
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 |
ffecfa5a JS |
27 | { |
28 | public: | |
29 | wxEnhMetaFile(const wxString& file = wxEmptyString) : m_filename(file) | |
30 | { Init(); } | |
31 | wxEnhMetaFile(const wxEnhMetaFile& metafile) | |
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; } |
ffecfa5a JS |
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() { m_hMF = 0; } | |
62 | void Free(); | |
63 | void Assign(const wxEnhMetaFile& mf); | |
64 | ||
65 | private: | |
66 | wxString m_filename; | |
67 | WXHANDLE m_hMF; | |
68 | ||
69 | DECLARE_DYNAMIC_CLASS(wxEnhMetaFile) | |
70 | }; | |
71 | ||
72 | // ---------------------------------------------------------------------------- | |
73 | // wxEnhMetaFileDC: allows to create a wxEnhMetaFile | |
74 | // ---------------------------------------------------------------------------- | |
75 | ||
76 | class WXDLLEXPORT wxEnhMetaFileDC : public wxDC | |
77 | { | |
78 | public: | |
79 | // the ctor parameters specify the filename (empty for memory metafiles), | |
80 | // the metafile picture size and the optional description/comment | |
81 | wxEnhMetaFileDC(const wxString& filename = wxEmptyString, | |
82 | int width = 0, int height = 0, | |
83 | const wxString& description = wxEmptyString); | |
84 | ||
85 | virtual ~wxEnhMetaFileDC(); | |
86 | ||
87 | // obtain a pointer to the new metafile (caller should delete it) | |
88 | wxEnhMetaFile *Close(); | |
89 | ||
90 | private: | |
91 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxEnhMetaFileDC) | |
92 | }; | |
93 | ||
94 | #if wxUSE_DRAG_AND_DROP | |
95 | ||
96 | // ---------------------------------------------------------------------------- | |
97 | // wxEnhMetaFileDataObject is a specialization of wxDataObject for enh metafile | |
98 | // ---------------------------------------------------------------------------- | |
99 | ||
100 | // notice that we want to support both CF_METAFILEPICT and CF_ENHMETAFILE and | |
101 | // so we derive from wxDataObject and not from wxDataObjectSimple | |
102 | class WXDLLEXPORT wxEnhMetaFileDataObject : public wxDataObject | |
103 | { | |
104 | public: | |
105 | // ctors | |
106 | wxEnhMetaFileDataObject() { } | |
107 | wxEnhMetaFileDataObject(const wxEnhMetaFile& metafile) | |
108 | : m_metafile(metafile) { } | |
109 | ||
110 | // virtual functions which you may override if you want to provide data on | |
111 | // demand only - otherwise, the trivial default versions will be used | |
112 | virtual void SetMetafile(const wxEnhMetaFile& metafile) | |
113 | { m_metafile = metafile; } | |
114 | virtual wxEnhMetaFile GetMetafile() const | |
115 | { return m_metafile; } | |
116 | ||
117 | // implement base class pure virtuals | |
118 | virtual wxDataFormat GetPreferredFormat(Direction dir) const; | |
119 | virtual size_t GetFormatCount(Direction dir) const; | |
120 | virtual void GetAllFormats(wxDataFormat *formats, Direction dir) const; | |
121 | virtual size_t GetDataSize(const wxDataFormat& format) const; | |
122 | virtual bool GetDataHere(const wxDataFormat& format, void *buf) const; | |
123 | virtual bool SetData(const wxDataFormat& format, size_t len, | |
124 | const void *buf); | |
125 | ||
126 | protected: | |
127 | wxEnhMetaFile m_metafile; | |
128 | ||
129 | DECLARE_NO_COPY_CLASS(wxEnhMetaFileDataObject) | |
130 | }; | |
131 | ||
132 | ||
133 | // ---------------------------------------------------------------------------- | |
134 | // wxEnhMetaFileSimpleDataObject does derive from wxDataObjectSimple which | |
135 | // makes it more convenient to use (it can be used with wxDataObjectComposite) | |
136 | // at the price of not supoprting any more CF_METAFILEPICT but only | |
137 | // CF_ENHMETAFILE | |
138 | // ---------------------------------------------------------------------------- | |
139 | ||
140 | class WXDLLEXPORT wxEnhMetaFileSimpleDataObject : public wxDataObjectSimple | |
141 | { | |
142 | public: | |
143 | // ctors | |
144 | wxEnhMetaFileSimpleDataObject() : wxDataObjectSimple(wxDF_ENHMETAFILE) { } | |
145 | wxEnhMetaFileSimpleDataObject(const wxEnhMetaFile& metafile) | |
146 | : wxDataObjectSimple(wxDF_ENHMETAFILE), m_metafile(metafile) { } | |
147 | ||
148 | // virtual functions which you may override if you want to provide data on | |
149 | // demand only - otherwise, the trivial default versions will be used | |
150 | virtual void SetEnhMetafile(const wxEnhMetaFile& metafile) | |
151 | { m_metafile = metafile; } | |
152 | virtual wxEnhMetaFile GetEnhMetafile() const | |
153 | { return m_metafile; } | |
154 | ||
155 | // implement base class pure virtuals | |
156 | virtual size_t GetDataSize() const; | |
157 | virtual bool GetDataHere(void *buf) const; | |
158 | virtual bool SetData(size_t len, const void *buf); | |
159 | ||
160 | virtual size_t GetDataSize(const wxDataFormat& WXUNUSED(format)) const | |
161 | { return GetDataSize(); } | |
162 | virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format), | |
163 | void *buf) const | |
164 | { return GetDataHere(buf); } | |
165 | virtual bool SetData(const wxDataFormat& WXUNUSED(format), | |
166 | size_t len, const void *buf) | |
167 | { return SetData(len, buf); } | |
168 | ||
169 | protected: | |
170 | wxEnhMetaFile m_metafile; | |
171 | ||
172 | DECLARE_NO_COPY_CLASS(wxEnhMetaFileSimpleDataObject) | |
173 | }; | |
174 | ||
175 | #endif // wxUSE_DRAG_AND_DROP | |
176 | ||
177 | #endif // _WX_PALMOS_ENHMETA_H_ |