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