]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/metafile.h
Some but not all compile fixes for typetest (VC++ 1.5); added datetime.cpp
[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
VZ
30// ----------------------------------------------------------------------------
31// Metafile and metafile device context classes
32// ----------------------------------------------------------------------------
06e43511
JS
33
34class WXDLLEXPORT wxMetafile;
35
36class WXDLLEXPORT wxMetafileRefData: public wxGDIRefData
2bda0e17 37{
06e43511
JS
38 friend class WXDLLEXPORT wxMetafile;
39public:
265b0c07
VZ
40 wxMetafileRefData();
41 ~wxMetafileRefData();
06e43511
JS
42
43public:
44 WXHANDLE m_metafile;
45 int m_windowsMappingMode;
265b0c07 46 int m_width, m_height;
06e43511
JS
47};
48
49#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
50
51class WXDLLEXPORT wxMetafile: public wxGDIObject
52{
265b0c07
VZ
53public:
54 wxMetafile(const wxString& file = wxEmptyString);
55 wxMetafile(const wxMetafile& metafile) { Ref(metafile); }
56 virtual ~wxMetafile();
57
58 // After this is called, the metafile cannot be used for anything
59 // since it is now owned by the clipboard.
60 virtual bool SetClipboard(int width = 0, int height = 0);
61
62 virtual bool Play(wxDC *dc);
63 bool Ok() const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); };
64
65 // set/get the size of metafile for clipboard operations
d9317fd4 66 wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); }
265b0c07
VZ
67 int GetWidth() const { return M_METAFILEDATA->m_width; }
68 int GetHeight() const { return M_METAFILEDATA->m_height; }
69
70 void SetWidth(int width) { M_METAFILEDATA->m_width = width; }
71 void SetHeight(int height) { M_METAFILEDATA->m_height = height; }
72
73 // Implementation
74 WXHANDLE GetHMETAFILE() const { return M_METAFILEDATA->m_metafile; }
75 void SetHMETAFILE(WXHANDLE mf) ;
76 int GetWindowsMappingMode() const { return M_METAFILEDATA->m_windowsMappingMode; }
77 void SetWindowsMappingMode(int mm);
78
79 // Operators
80 wxMetafile& operator=(const wxMetafile& metafile)
81 { if (*this != metafile) Ref(metafile); return *this; }
82 bool operator==(const wxMetafile& metafile) const
83 { return m_refData == metafile.m_refData; }
84 bool operator!=(const wxMetafile& metafile) const
85 { return m_refData != metafile.m_refData; }
2bda0e17 86
265b0c07
VZ
87private:
88 DECLARE_DYNAMIC_CLASS(wxMetafile)
2bda0e17
KB
89};
90
06e43511 91class WXDLLEXPORT wxMetafileDC: public wxDC
2bda0e17 92{
265b0c07
VZ
93public:
94 // Don't supply origin and extent
95 // Supply them to wxMakeMetaFilePlaceable instead.
d9317fd4 96 wxMetafileDC(const wxString& file = wxEmptyString);
2bda0e17 97
265b0c07
VZ
98 // Supply origin and extent (recommended).
99 // Then don't need to supply them to wxMakeMetaFilePlaceable.
100 wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg);
2bda0e17 101
265b0c07 102 virtual ~wxMetafileDC();
2bda0e17 103
265b0c07
VZ
104 // Should be called at end of drawing
105 virtual wxMetafile *Close();
106 virtual void SetMapMode(int mode);
107 virtual void GetTextExtent(const wxString& string, long *x, long *y,
108 long *descent = NULL, long *externalLeading = NULL,
109 wxFont *theFont = NULL, bool use16bit = FALSE) const;
2bda0e17 110
265b0c07
VZ
111 // Implementation
112 wxMetafile *GetMetaFile() const { return m_metaFile; }
113 void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
114 int GetWindowsMappingMode() const { return m_windowsMappingMode; }
115 void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; }
2bda0e17
KB
116
117protected:
265b0c07
VZ
118 int m_windowsMappingMode;
119 wxMetafile* m_metaFile;
120
121private:
122 DECLARE_DYNAMIC_CLASS(wxMetafileDC)
2bda0e17
KB
123};
124
125/*
126 * Pass filename of existing non-placeable metafile, and bounding box.
127 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
e3065973 128 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
2bda0e17
KB
129 *
130 */
131
132// No origin or extent
06e43511 133bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
2bda0e17
KB
134
135// Optional origin and extent
136bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = TRUE);
137
06e43511
JS
138// ----------------------------------------------------------------------------
139// wxMetafileDataObject is a specialization of wxDataObject for metafile data
140// ----------------------------------------------------------------------------
141
06e43511 142#if wxUSE_DRAG_AND_DROP
265b0c07
VZ
143
144class WXDLLEXPORT wxMetafileDataObject : public wxDataObjectSimple
06e43511
JS
145{
146public:
265b0c07
VZ
147 // ctors
148 wxMetafileDataObject() : wxDataObjectSimple(wxDF_METAFILE)
149 { }
150 wxMetafileDataObject(const wxMetafile& metafile)
151 : wxDataObjectSimple(wxDF_METAFILE), m_metafile(metafile) { }
152
153 // virtual functions which you may override if you want to provide data on
154 // demand only - otherwise, the trivial default versions will be used
155 virtual void SetMetafile(const wxMetafile& metafile)
156 { m_metafile = metafile; }
157 virtual wxMetafile GetMetafile() const
158 { return m_metafile; }
159
160 // implement base class pure virtuals
161 virtual size_t GetDataSize() const;
162 virtual bool GetDataHere(void *buf) const;
163 virtual bool SetData(size_t len, const void *buf);
06e43511 164
265b0c07
VZ
165protected:
166 wxMetafile m_metafile;
06e43511 167};
265b0c07
VZ
168
169#endif // wxUSE_DRAG_AND_DROP
06e43511 170
47d67540 171#endif // wxUSE_METAFILE
2bda0e17 172#endif
bbcdf8bc 173 // _WX_METAFIILE_H_
2845ddc2 174