]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/metafile.h
temporarily reverted binary backwards incompatible DoCreate to XmDoCreateTLW renaming
[wxWidgets.git] / include / wx / os2 / metafile.h
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: David Webster
7 // Modified by:
8 // Created: 10/10/99
9 // RCS-ID: $Id$
10 // Copyright: (c) David Webster
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_DRAG_AND_DROP
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
35 class WXDLLEXPORT wxMetafileRefData: public wxGDIRefData
36 {
37 friend class WXDLLEXPORT wxMetafile;
38 public:
39 wxMetafileRefData(void);
40 ~wxMetafileRefData(void);
41
42 public:
43 WXHANDLE m_metafile;
44 int m_windowsMappingMode;
45 };
46
47 #define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
48
49 class WXDLLEXPORT wxMetafile: public wxGDIObject
50 {
51 DECLARE_DYNAMIC_CLASS(wxMetafile)
52 public:
53 // Copy constructor
54 inline wxMetafile(const wxMetafile& metafile)
55 { Ref(metafile); }
56
57 wxMetafile(const wxString& file = wxEmptyString);
58 ~wxMetafile(void);
59
60 // After this is called, the metafile cannot be used for anything
61 // since it is now owned by the clipboard.
62 virtual bool SetClipboard(int width = 0, int height = 0);
63
64 virtual bool Play(wxDC *dc);
65 inline bool Ok(void) const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); };
66
67 // Implementation
68 inline WXHANDLE GetHMETAFILE(void) { return M_METAFILEDATA->m_metafile; }
69 void SetHMETAFILE(WXHANDLE mf) ;
70 inline int GetWindowsMappingMode(void) { return M_METAFILEDATA->m_windowsMappingMode; }
71 void SetWindowsMappingMode(int mm);
72
73 // Operators
74 inline wxMetafile& operator = (const wxMetafile& metafile)
75 { if (*this == metafile) return (*this); Ref(metafile); return *this; }
76 inline bool operator== (const wxMetafile& metafile) const
77 { return m_refData == metafile.m_refData; }
78 inline bool operator!= (const wxMetafile& metafile) const
79 { return m_refData != metafile.m_refData; }
80 };
81
82 class WXDLLEXPORT wxMetafileDC: public wxDC
83 {
84 DECLARE_DYNAMIC_CLASS(wxMetafileDC)
85
86 public:
87 // Don't supply origin and extent
88 // Supply them to wxMakeMetaFilePlaceable instead.
89 wxMetafileDC(const wxString& file = wxEmptyString);
90
91 // Supply origin and extent (recommended).
92 // Then don't need to supply them to wxMakeMetaFilePlaceable.
93 wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg);
94
95 ~wxMetafileDC(void);
96
97 // Should be called at end of drawing
98 virtual wxMetafile *Close(void);
99 virtual void SetMapMode(int mode);
100 virtual void GetTextExtent(const wxString& string, long *x, long *y,
101 long *descent = NULL, long *externalLeading = NULL,
102 wxFont *theFont = NULL, bool use16bit = false) const;
103
104 // Implementation
105 inline wxMetafile *GetMetaFile(void) const { return m_metaFile; }
106 inline void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
107 inline int GetWindowsMappingMode(void) const { return m_windowsMappingMode; }
108 inline void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; }
109
110 protected:
111 int m_windowsMappingMode;
112 wxMetafile* m_metaFile;
113
114 private:
115 #ifndef __WATCOMC__
116 // function hiding warning supression
117 // still required ??
118 inline virtual void GetTextExtent( const wxString& string
119 ,long* width
120 ,long* height
121 ,long* descent = NULL
122 ,long* externalLeading = NULL
123 ,wxFont* theFont = NULL
124 ) const
125 { GetTextExtent( string, width, height, descent, externalLeading, theFont, false);};
126 #endif
127 };
128
129 /*
130 * Pass filename of existing non-placeable metafile, and bounding box.
131 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
132 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
133 *
134 */
135
136 // No origin or extent
137 #define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
138 bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
139
140 // Optional origin and extent
141 bool WXDLLEXPORT wxMakeMetaFilePlaceable( const wxString& filename
142 ,int x1
143 ,int y1
144 ,int x2
145 ,int y2
146 ,float scale = 1.0
147 ,bool useOriginAndExtent = true
148 );
149
150 // ----------------------------------------------------------------------------
151 // wxMetafileDataObject is a specialization of wxDataObject for metafile data
152 // ----------------------------------------------------------------------------
153
154 // TODO: implement OLE side of things. At present, it's just for clipboard
155 // use.
156
157 #if wxUSE_DRAG_AND_DROP
158 class WXDLLEXPORT wxMetafileDataObject : public wxDataObject
159 {
160 public:
161 // ctors
162 wxMetafileDataObject() { m_width = 0; m_height = 0; };
163 wxMetafileDataObject(const wxMetafile& metafile, int width = 0,int height = 0)
164 :m_metafile(metafile)
165 ,m_width(width)
166 ,m_height(height) { }
167
168 void SetMetafile(const wxMetafile& metafile, int w = 0, int h = 0)
169 { m_metafile = metafile; m_width = w; m_height = h; }
170 wxMetafile GetMetafile() const { return m_metafile; }
171 int GetWidth() const { return m_width; }
172 int GetHeight() const { return m_height; }
173
174 virtual wxDataFormat GetFormat() const { return wxDF_METAFILE; }
175
176 /* ??
177 // implement base class pure virtuals
178 virtual wxDataFormat GetPreferredFormat() const
179 { return (wxDataFormat) wxDataObject::Text; }
180 virtual bool IsSupportedFormat(wxDataFormat format) const
181 { return format == wxDataObject::Text || format == wxDataObject::Locale; }
182 virtual size_t GetDataSize() const
183 { return m_strText.Len() + 1; } // +1 for trailing '\0'of course
184 virtual void GetDataHere(void *pBuf) const
185 { memcpy(pBuf, m_strText.c_str(), GetDataSize()); }
186 */
187
188 private:
189 wxMetafile m_metafile;
190 int m_width;
191 int m_height;
192 };
193 #endif
194
195 #endif
196 // _WX_METAFIILE_H_