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