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