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