]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
265b0c07 VZ |
2 | // Name: wx/msw/metafile.h |
3 | // Purpose: wxMetaFile, wxMetaFileDC and wxMetaFileDataObject classes | |
2bda0e17 | 4 | // Author: Julian Smart |
265b0c07 | 5 | // Modified by: VZ 07.01.00: implemented wxMetaFileDataObject |
2bda0e17 KB |
6 | // Created: 01/02/97 |
7 | // RCS-ID: $Id$ | |
bbcdf8bc | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_METAFIILE_H_ |
13 | #define _WX_METAFIILE_H_ | |
2bda0e17 | 14 | |
2bda0e17 | 15 | #include "wx/dc.h" |
06e43511 JS |
16 | #include "wx/gdiobj.h" |
17 | ||
18 | #if wxUSE_DRAG_AND_DROP | |
265b0c07 | 19 | #include "wx/dataobj.h" |
06e43511 | 20 | #endif |
2bda0e17 | 21 | |
265b0c07 VZ |
22 | // ---------------------------------------------------------------------------- |
23 | // Metafile and metafile device context classes | |
24 | // ---------------------------------------------------------------------------- | |
06e43511 JS |
25 | |
26 | class WXDLLEXPORT wxMetafile; | |
27 | ||
28 | class WXDLLEXPORT wxMetafileRefData: public wxGDIRefData | |
2bda0e17 | 29 | { |
06e43511 JS |
30 | friend class WXDLLEXPORT wxMetafile; |
31 | public: | |
265b0c07 | 32 | wxMetafileRefData(); |
d3c7fc99 | 33 | virtual ~wxMetafileRefData(); |
06e43511 JS |
34 | |
35 | public: | |
36 | WXHANDLE m_metafile; | |
37 | int m_windowsMappingMode; | |
265b0c07 | 38 | int m_width, m_height; |
06e43511 JS |
39 | }; |
40 | ||
41 | #define M_METAFILEDATA ((wxMetafileRefData *)m_refData) | |
42 | ||
43 | class WXDLLEXPORT wxMetafile: public wxGDIObject | |
44 | { | |
265b0c07 VZ |
45 | public: |
46 | wxMetafile(const wxString& file = wxEmptyString); | |
265b0c07 VZ |
47 | virtual ~wxMetafile(); |
48 | ||
49 | // After this is called, the metafile cannot be used for anything | |
50 | // since it is now owned by the clipboard. | |
51 | virtual bool SetClipboard(int width = 0, int height = 0); | |
52 | ||
53 | virtual bool Play(wxDC *dc); | |
b7cacb43 VZ |
54 | bool Ok() const { return IsOk(); } |
55 | bool IsOk() const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); }; | |
265b0c07 VZ |
56 | |
57 | // set/get the size of metafile for clipboard operations | |
d9317fd4 | 58 | wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); } |
265b0c07 VZ |
59 | int GetWidth() const { return M_METAFILEDATA->m_width; } |
60 | int GetHeight() const { return M_METAFILEDATA->m_height; } | |
61 | ||
62 | void SetWidth(int width) { M_METAFILEDATA->m_width = width; } | |
63 | void SetHeight(int height) { M_METAFILEDATA->m_height = height; } | |
64 | ||
65 | // Implementation | |
66 | WXHANDLE GetHMETAFILE() const { return M_METAFILEDATA->m_metafile; } | |
67 | void SetHMETAFILE(WXHANDLE mf) ; | |
68 | int GetWindowsMappingMode() const { return M_METAFILEDATA->m_windowsMappingMode; } | |
69 | void SetWindowsMappingMode(int mm); | |
70 | ||
265b0c07 VZ |
71 | private: |
72 | DECLARE_DYNAMIC_CLASS(wxMetafile) | |
2bda0e17 KB |
73 | }; |
74 | ||
06e43511 | 75 | class WXDLLEXPORT wxMetafileDC: public wxDC |
2bda0e17 | 76 | { |
265b0c07 VZ |
77 | public: |
78 | // Don't supply origin and extent | |
79 | // Supply them to wxMakeMetaFilePlaceable instead. | |
d9317fd4 | 80 | wxMetafileDC(const wxString& file = wxEmptyString); |
2bda0e17 | 81 | |
265b0c07 VZ |
82 | // Supply origin and extent (recommended). |
83 | // Then don't need to supply them to wxMakeMetaFilePlaceable. | |
84 | wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg); | |
2bda0e17 | 85 | |
265b0c07 | 86 | virtual ~wxMetafileDC(); |
2bda0e17 | 87 | |
265b0c07 VZ |
88 | // Should be called at end of drawing |
89 | virtual wxMetafile *Close(); | |
90 | virtual void SetMapMode(int mode); | |
91 | virtual void GetTextExtent(const wxString& string, long *x, long *y, | |
92 | long *descent = NULL, long *externalLeading = NULL, | |
c94f845b | 93 | const wxFont *theFont = NULL, bool use16bit = false) const; |
2bda0e17 | 94 | |
265b0c07 VZ |
95 | // Implementation |
96 | wxMetafile *GetMetaFile() const { return m_metaFile; } | |
97 | void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; } | |
98 | int GetWindowsMappingMode() const { return m_windowsMappingMode; } | |
99 | void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; } | |
2bda0e17 KB |
100 | |
101 | protected: | |
024026be VZ |
102 | virtual void DoGetSize(int *width, int *height) const; |
103 | ||
265b0c07 VZ |
104 | int m_windowsMappingMode; |
105 | wxMetafile* m_metaFile; | |
106 | ||
107 | private: | |
108 | DECLARE_DYNAMIC_CLASS(wxMetafileDC) | |
2bda0e17 KB |
109 | }; |
110 | ||
111 | /* | |
112 | * Pass filename of existing non-placeable metafile, and bounding box. | |
113 | * Adds a placeable metafile header, sets the mapping mode to anisotropic, | |
e3065973 | 114 | * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. |
2bda0e17 KB |
115 | * |
116 | */ | |
117 | ||
118 | // No origin or extent | |
06e43511 | 119 | bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0); |
2bda0e17 KB |
120 | |
121 | // Optional origin and extent | |
598ddd96 | 122 | bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = true); |
2bda0e17 | 123 | |
06e43511 JS |
124 | // ---------------------------------------------------------------------------- |
125 | // wxMetafileDataObject is a specialization of wxDataObject for metafile data | |
126 | // ---------------------------------------------------------------------------- | |
127 | ||
06e43511 | 128 | #if wxUSE_DRAG_AND_DROP |
265b0c07 VZ |
129 | |
130 | class WXDLLEXPORT wxMetafileDataObject : public wxDataObjectSimple | |
06e43511 JS |
131 | { |
132 | public: | |
265b0c07 VZ |
133 | // ctors |
134 | wxMetafileDataObject() : wxDataObjectSimple(wxDF_METAFILE) | |
135 | { } | |
136 | wxMetafileDataObject(const wxMetafile& metafile) | |
137 | : wxDataObjectSimple(wxDF_METAFILE), m_metafile(metafile) { } | |
138 | ||
139 | // virtual functions which you may override if you want to provide data on | |
140 | // demand only - otherwise, the trivial default versions will be used | |
141 | virtual void SetMetafile(const wxMetafile& metafile) | |
142 | { m_metafile = metafile; } | |
143 | virtual wxMetafile GetMetafile() const | |
144 | { return m_metafile; } | |
145 | ||
146 | // implement base class pure virtuals | |
147 | virtual size_t GetDataSize() const; | |
148 | virtual bool GetDataHere(void *buf) const; | |
149 | virtual bool SetData(size_t len, const void *buf); | |
06e43511 | 150 | |
265b0c07 VZ |
151 | protected: |
152 | wxMetafile m_metafile; | |
06e43511 | 153 | }; |
265b0c07 VZ |
154 | |
155 | #endif // wxUSE_DRAG_AND_DROP | |
06e43511 | 156 | |
2bda0e17 | 157 | #endif |
bbcdf8bc | 158 | // _WX_METAFIILE_H_ |
2845ddc2 | 159 |