]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/metafile.h
Define SQLUINTEGER
[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:
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; }
0e320a79
DW
80};
81
75f11ad7 82class WXDLLEXPORT wxMetafileDC: public wxDC
0e320a79 83{
c40158e4 84 DECLARE_DYNAMIC_CLASS(wxMetafileDC)
0e320a79 85
c40158e4
WS
86public:
87 // Don't supply origin and extent
88 // Supply them to wxMakeMetaFilePlaceable instead.
89 wxMetafileDC(const wxString& file = wxEmptyString);
0e320a79 90
c40158e4
WS
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);
0e320a79 94
c40158e4 95 ~wxMetafileDC(void);
0e320a79 96
c40158e4
WS
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;
0e320a79 103
c40158e4
WS
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; }
0e320a79
DW
109
110protected:
c40158e4
WS
111 int m_windowsMappingMode;
112 wxMetafile* m_metaFile;
75f11ad7
DW
113
114private:
c40158e4
WS
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
0e320a79
DW
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
75f11ad7
DW
137#define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
138bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
0e320a79
DW
139
140// Optional origin and extent
c40158e4
WS
141bool 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 );
0e320a79 149
75f11ad7
DW
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
158class WXDLLEXPORT wxMetafileDataObject : public wxDataObject
159{
160public:
c40158e4
WS
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) { }
75f11ad7 167
c40158e4
WS
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; }
75f11ad7 173
c40158e4 174 virtual wxDataFormat GetFormat() const { return wxDF_METAFILE; }
75f11ad7
DW
175
176/* ??
c40158e4
WS
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()); }
75f11ad7
DW
186*/
187
188private:
c40158e4
WS
189 wxMetafile m_metafile;
190 int m_width;
191 int m_height;
75f11ad7
DW
192};
193#endif
194
0e320a79
DW
195#endif
196 // _WX_METAFIILE_H_