]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: metafile.h | |
3 | // Purpose: wxMetaFile, wxMetaFileDC classes. | |
4 | // This probably should be restricted to Windows platforms, | |
5 | // but if there is an equivalent on your platform, great. | |
6 | // Author: Stefan Csomor | |
7 | // Modified by: | |
8 | // Created: 1998-01-01 | |
9 | // RCS-ID: $Id$ | |
10 | // Copyright: (c) Stefan Csomor | |
11 | // Licence: wxWindows licence | |
12 | ///////////////////////////////////////////////////////////////////////////// | |
13 | ||
14 | ||
15 | #ifndef _WX_METAFIILE_H_ | |
16 | #define _WX_METAFIILE_H_ | |
17 | ||
18 | #include "wx/dc.h" | |
19 | #include "wx/gdiobj.h" | |
20 | ||
21 | #if wxUSE_DATAOBJ | |
22 | #include "wx/dataobj.h" | |
23 | #endif | |
24 | ||
25 | /* | |
26 | * Metafile and metafile device context classes | |
27 | * | |
28 | */ | |
29 | ||
30 | #define wxMetaFile wxMetafile | |
31 | #define wxMetaFileDC wxMetafileDC | |
32 | ||
33 | class WXDLLEXPORT wxMetafile; | |
34 | class wxMetafileRefData ; | |
35 | ||
36 | #define M_METAFILEDATA ((wxMetafileRefData *)m_refData) | |
37 | ||
38 | class WXDLLEXPORT wxMetafile: public wxGDIObject | |
39 | { | |
40 | DECLARE_DYNAMIC_CLASS(wxMetafile) | |
41 | public: | |
42 | wxMetafile(const wxString& file = wxEmptyString); | |
43 | ~wxMetafile(void); | |
44 | ||
45 | // After this is called, the metafile cannot be used for anything | |
46 | // since it is now owned by the clipboard. | |
47 | virtual bool SetClipboard(int width = 0, int height = 0); | |
48 | ||
49 | virtual bool Play(wxDC *dc); | |
50 | bool Ok() const ; | |
51 | ||
52 | wxSize GetSize() const; | |
53 | int GetWidth() const { return GetSize().x; } | |
54 | int GetHeight() const { return GetSize().y; } | |
55 | ||
56 | // Implementation | |
57 | WXHMETAFILE GetHMETAFILE() const ; | |
58 | void SetHMETAFILE(WXHMETAFILE mf) ; | |
59 | ||
60 | // Operators | |
61 | inline bool operator == (const wxMetafile& metafile) const { return m_refData == metafile.m_refData; } | |
62 | inline bool operator != (const wxMetafile& metafile) const { return m_refData != metafile.m_refData; } | |
63 | ||
64 | protected: | |
65 | }; | |
66 | ||
67 | class WXDLLEXPORT wxMetafileDC: public wxDC | |
68 | { | |
69 | DECLARE_DYNAMIC_CLASS(wxMetafileDC) | |
70 | ||
71 | public: | |
72 | // the ctor parameters specify the filename (empty for memory metafiles), | |
73 | // the metafile picture size and the optional description/comment | |
74 | wxMetafileDC(const wxString& filename = wxEmptyString, | |
75 | int width = 0, int height = 0, | |
76 | const wxString& description = wxEmptyString); | |
77 | ||
78 | ~wxMetafileDC(void); | |
79 | ||
80 | // Should be called at end of drawing | |
81 | virtual wxMetafile *Close(void); | |
82 | ||
83 | // Implementation | |
84 | inline wxMetafile *GetMetaFile(void) const { return m_metaFile; } | |
85 | inline void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; } | |
86 | ||
87 | protected: | |
88 | virtual void DoGetSize(int *width, int *height) const; | |
89 | ||
90 | wxMetafile* m_metaFile; | |
91 | }; | |
92 | ||
93 | /* | |
94 | * Pass filename of existing non-placeable metafile, and bounding box. | |
95 | * Adds a placeable metafile header, sets the mapping mode to anisotropic, | |
96 | * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. | |
97 | * | |
98 | */ | |
99 | ||
100 | // No origin or extent | |
101 | #define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable | |
102 | bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0); | |
103 | ||
104 | // Optional origin and extent | |
105 | bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = TRUE); | |
106 | ||
107 | // ---------------------------------------------------------------------------- | |
108 | // wxMetafileDataObject is a specialization of wxDataObject for metafile data | |
109 | // ---------------------------------------------------------------------------- | |
110 | ||
111 | #if wxUSE_DATAOBJ | |
112 | class WXDLLEXPORT wxMetafileDataObject : public wxDataObjectSimple | |
113 | { | |
114 | public: | |
115 | // ctors | |
116 | wxMetafileDataObject() | |
117 | : wxDataObjectSimple(wxDF_METAFILE) { }; | |
118 | wxMetafileDataObject(const wxMetafile& metafile) | |
119 | : wxDataObjectSimple(wxDF_METAFILE), 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 wxMetafile& metafile) | |
124 | { m_metafile = metafile; } | |
125 | virtual wxMetafile GetMetafile() const | |
126 | { return m_metafile; } | |
127 | ||
128 | // implement base class pure virtuals | |
129 | virtual size_t GetDataSize() const; | |
130 | virtual bool GetDataHere(void *buf) const; | |
131 | virtual bool SetData(size_t len, const void *buf); | |
132 | ||
133 | virtual size_t GetDataSize(const wxDataFormat& WXUNUSED(format)) const | |
134 | { return GetDataSize(); } | |
135 | virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format), | |
136 | void *buf) const | |
137 | { return GetDataHere(buf); } | |
138 | virtual bool SetData(const wxDataFormat& WXUNUSED(format), | |
139 | size_t len, const void *buf) | |
140 | { return SetData(len, buf); } | |
141 | protected: | |
142 | wxMetafile m_metafile; | |
143 | }; | |
144 | #endif | |
145 | ||
146 | #endif | |
147 | // _WX_METAFIILE_H_ |