]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/msw/metafile.h
check that the version of __sync_sub_and_fetch that returns a value is supported...
[wxWidgets.git] / include / wx / msw / metafile.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/msw/metafile.h
3// Purpose: wxMetaFile, wxMetaFileDC and wxMetaFileDataObject classes
4// Author: Julian Smart
5// Modified by: VZ 07.01.00: implemented wxMetaFileDataObject
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_METAFIILE_H_
13#define _WX_METAFIILE_H_
14
15#include "wx/dc.h"
16#include "wx/gdiobj.h"
17
18#if wxUSE_DRAG_AND_DROP
19 #include "wx/dataobj.h"
20#endif
21
22// ----------------------------------------------------------------------------
23// Metafile and metafile device context classes
24// ----------------------------------------------------------------------------
25
26class WXDLLIMPEXP_FWD_CORE wxMetafile;
27
28class WXDLLEXPORT wxMetafileRefData: public wxGDIRefData
29{
30 friend class WXDLLIMPEXP_FWD_CORE wxMetafile;
31public:
32 wxMetafileRefData();
33 virtual ~wxMetafileRefData();
34
35public:
36 WXHANDLE m_metafile;
37 int m_windowsMappingMode;
38 int m_width, m_height;
39};
40
41#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
42
43class WXDLLEXPORT wxMetafile: public wxGDIObject
44{
45public:
46 wxMetafile(const wxString& file = wxEmptyString);
47 virtual ~wxMetafile();
48
49 // After this is called, the metafile cannot be used for anything
50 // since it is now owned by the clipboard.
51 virtual bool SetClipboard(int width = 0, int height = 0);
52
53 virtual bool Play(wxDC *dc);
54 bool Ok() const { return IsOk(); }
55 bool IsOk() const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); };
56
57 // set/get the size of metafile for clipboard operations
58 wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); }
59 int GetWidth() const { return M_METAFILEDATA->m_width; }
60 int GetHeight() const { return M_METAFILEDATA->m_height; }
61
62 void SetWidth(int width) { M_METAFILEDATA->m_width = width; }
63 void SetHeight(int height) { M_METAFILEDATA->m_height = height; }
64
65 // Implementation
66 WXHANDLE GetHMETAFILE() const { return M_METAFILEDATA->m_metafile; }
67 void SetHMETAFILE(WXHANDLE mf) ;
68 int GetWindowsMappingMode() const { return M_METAFILEDATA->m_windowsMappingMode; }
69 void SetWindowsMappingMode(int mm);
70
71private:
72 DECLARE_DYNAMIC_CLASS(wxMetafile)
73};
74
75class WXDLLEXPORT wxMetafileDCImpl: public wxMSWDCImpl
76{
77public:
78 wxMetafileDCImpl(const wxString& file = wxEmptyString);
79 wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg);
80 virtual ~wxMetafileDCImpl();
81
82 virtual wxMetafile *Close();
83 virtual void SetMapMode(int mode);
84 virtual void DoGetTextExtent(const wxString& string,
85 wxCoord *x, wxCoord *y,
86 wxCoord *descent = NULL,
87 wxCoord *externalLeading = NULL,
88 const wxFont *theFont = NULL) const;
89
90 // Implementation
91 wxMetafile *GetMetaFile() const { return m_metaFile; }
92 void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
93 int GetWindowsMappingMode() const { return m_windowsMappingMode; }
94 void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; }
95
96protected:
97 virtual void DoGetSize(int *width, int *height) const;
98
99 int m_windowsMappingMode;
100 wxMetafile* m_metaFile;
101
102private:
103 DECLARE_CLASS(wxMetafileDCImpl)
104 DECLARE_NO_COPY_CLASS(wxMetafileDCImpl)
105};
106
107class WXDLLEXPORT wxMetafileDC: public wxDC
108{
109public:
110 // Don't supply origin and extent
111 // Supply them to wxMakeMetaFilePlaceable instead.
112 wxMetafileDC(const wxString& file);
113 { m_pimpl = new wxMetafileDCImpl( this, file ); }
114
115 // Supply origin and extent (recommended).
116 // Then don't need to supply them to wxMakeMetaFilePlaceable.
117 wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg)
118 { m_pimpl = new wxMetafileDCImpl( this, file, xext, yext, xorg, yorg ); }
119
120 wxMetafile *GetMetafile() const
121 { return ((wxMetafileDCImpl*)m_pimpl)->GetMetaFile(); }
122
123 wxMetafile *Close()
124 { return ((wxMetafileDCImpl*)m_pimpl)->Close(); }
125
126private:
127 DECLARE_CLASS(wxMetafileDC)
128 DECLARE_NO_COPY_CLASS(wxMetafileDC)
129};
130
131
132
133
134/*
135 * Pass filename of existing non-placeable metafile, and bounding box.
136 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
137 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
138 *
139 */
140
141// No origin or extent
142bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
143
144// Optional origin and extent
145bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = true);
146
147// ----------------------------------------------------------------------------
148// wxMetafileDataObject is a specialization of wxDataObject for metafile data
149// ----------------------------------------------------------------------------
150
151#if wxUSE_DRAG_AND_DROP
152
153class WXDLLEXPORT wxMetafileDataObject : public wxDataObjectSimple
154{
155public:
156 // ctors
157 wxMetafileDataObject() : wxDataObjectSimple(wxDF_METAFILE)
158 { }
159 wxMetafileDataObject(const wxMetafile& metafile)
160 : wxDataObjectSimple(wxDF_METAFILE), m_metafile(metafile) { }
161
162 // virtual functions which you may override if you want to provide data on
163 // demand only - otherwise, the trivial default versions will be used
164 virtual void SetMetafile(const wxMetafile& metafile)
165 { m_metafile = metafile; }
166 virtual wxMetafile GetMetafile() const
167 { return m_metafile; }
168
169 // implement base class pure virtuals
170 virtual size_t GetDataSize() const;
171 virtual bool GetDataHere(void *buf) const;
172 virtual bool SetData(size_t len, const void *buf);
173
174protected:
175 wxMetafile m_metafile;
176};
177
178#endif // wxUSE_DRAG_AND_DROP
179
180#endif
181 // _WX_METAFIILE_H_
182