]>
Commit | Line | Data |
---|---|---|
ffecfa5a JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/palmos/metafile.h | |
3 | // Purpose: wxMetaFile, wxMetaFileDC and wxMetaFileDataObject classes | |
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_METAFIILE_H_ | |
13 | #define _WX_METAFIILE_H_ | |
14 | ||
ffecfa5a JS |
15 | #include "wx/dc.h" |
16 | #include "wx/gdiobj.h" | |
17 | ||
18 | #if wxUSE_DRAG_AND_DROP | |
19 | #include "wx/dataobj.h" | |
20 | #endif | |
21 | ||
22 | // ---------------------------------------------------------------------------- | |
23 | // Metafile and metafile device context classes | |
24 | // ---------------------------------------------------------------------------- | |
25 | ||
b5dbe15d | 26 | class WXDLLIMPEXP_FWD_CORE wxMetafile; |
ffecfa5a JS |
27 | |
28 | class WXDLLEXPORT wxMetafileRefData: public wxGDIRefData | |
29 | { | |
b5dbe15d | 30 | friend class WXDLLIMPEXP_FWD_CORE wxMetafile; |
ffecfa5a JS |
31 | public: |
32 | wxMetafileRefData(); | |
d3c7fc99 | 33 | virtual ~wxMetafileRefData(); |
ffecfa5a JS |
34 | |
35 | public: | |
36 | WXHANDLE m_metafile; | |
37 | int m_windowsMappingMode; | |
38 | int m_width, m_height; | |
39 | }; | |
40 | ||
41 | #define M_METAFILEDATA ((wxMetafileRefData *)m_refData) | |
42 | ||
43 | class WXDLLEXPORT wxMetafile: public wxGDIObject | |
44 | { | |
45 | public: | |
46 | wxMetafile(const wxString& file = wxEmptyString); | |
ffecfa5a JS |
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)); }; | |
ffecfa5a JS |
56 | |
57 | // set/get the size of metafile for clipboard operations | |
58 | wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); } | |
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 | ||
ffecfa5a JS |
71 | private: |
72 | DECLARE_DYNAMIC_CLASS(wxMetafile) | |
73 | }; | |
74 | ||
75 | class WXDLLEXPORT wxMetafileDC: public wxDC | |
76 | { | |
77 | public: | |
78 | // Don't supply origin and extent | |
79 | // Supply them to wxMakeMetaFilePlaceable instead. | |
80 | wxMetafileDC(const wxString& file = wxEmptyString); | |
81 | ||
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); | |
85 | ||
86 | virtual ~wxMetafileDC(); | |
87 | ||
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; |
ffecfa5a JS |
94 | |
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; } | |
100 | ||
101 | protected: | |
102 | int m_windowsMappingMode; | |
103 | wxMetafile* m_metaFile; | |
104 | ||
105 | private: | |
106 | DECLARE_DYNAMIC_CLASS(wxMetafileDC) | |
107 | }; | |
108 | ||
109 | /* | |
110 | * Pass filename of existing non-placeable metafile, and bounding box. | |
111 | * Adds a placeable metafile header, sets the mapping mode to anisotropic, | |
112 | * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. | |
113 | * | |
114 | */ | |
115 | ||
116 | // No origin or extent | |
117 | bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0); | |
118 | ||
119 | // Optional origin and extent | |
120 | bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = TRUE); | |
121 | ||
122 | // ---------------------------------------------------------------------------- | |
123 | // wxMetafileDataObject is a specialization of wxDataObject for metafile data | |
124 | // ---------------------------------------------------------------------------- | |
125 | ||
126 | #if wxUSE_DRAG_AND_DROP | |
127 | ||
128 | class WXDLLEXPORT wxMetafileDataObject : public wxDataObjectSimple | |
129 | { | |
130 | public: | |
131 | // ctors | |
132 | wxMetafileDataObject() : wxDataObjectSimple(wxDF_METAFILE) | |
133 | { } | |
134 | wxMetafileDataObject(const wxMetafile& metafile) | |
135 | : wxDataObjectSimple(wxDF_METAFILE), m_metafile(metafile) { } | |
136 | ||
137 | // virtual functions which you may override if you want to provide data on | |
138 | // demand only - otherwise, the trivial default versions will be used | |
139 | virtual void SetMetafile(const wxMetafile& metafile) | |
140 | { m_metafile = metafile; } | |
141 | virtual wxMetafile GetMetafile() const | |
142 | { return m_metafile; } | |
143 | ||
144 | // implement base class pure virtuals | |
145 | virtual size_t GetDataSize() const; | |
146 | virtual bool GetDataHere(void *buf) const; | |
147 | virtual bool SetData(size_t len, const void *buf); | |
148 | ||
149 | protected: | |
150 | wxMetafile m_metafile; | |
151 | }; | |
152 | ||
153 | #endif // wxUSE_DRAG_AND_DROP | |
154 | ||
ffecfa5a JS |
155 | #endif |
156 | // _WX_METAFIILE_H_ | |
157 |