]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/metafile.h
Better compatibility between wxRichTextCtrl and wxTextCtrlBase
[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
65571936 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_METAFIILE_H_
13#define _WX_METAFIILE_H_
2bda0e17 14
2bda0e17 15#include "wx/dc.h"
06e43511
JS
16#include "wx/gdiobj.h"
17
18#if wxUSE_DRAG_AND_DROP
265b0c07 19 #include "wx/dataobj.h"
06e43511 20#endif
2bda0e17 21
265b0c07
VZ
22// ----------------------------------------------------------------------------
23// Metafile and metafile device context classes
24// ----------------------------------------------------------------------------
06e43511
JS
25
26class WXDLLEXPORT wxMetafile;
27
28class WXDLLEXPORT wxMetafileRefData: public wxGDIRefData
2bda0e17 29{
06e43511
JS
30 friend class WXDLLEXPORT wxMetafile;
31public:
265b0c07 32 wxMetafileRefData();
d3c7fc99 33 virtual ~wxMetafileRefData();
06e43511
JS
34
35public:
36 WXHANDLE m_metafile;
37 int m_windowsMappingMode;
265b0c07 38 int m_width, m_height;
06e43511
JS
39};
40
41#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
42
43class WXDLLEXPORT wxMetafile: public wxGDIObject
44{
265b0c07
VZ
45public:
46 wxMetafile(const wxString& file = wxEmptyString);
265b0c07
VZ
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 (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); };
55
56 // set/get the size of metafile for clipboard operations
d9317fd4 57 wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); }
265b0c07
VZ
58 int GetWidth() const { return M_METAFILEDATA->m_width; }
59 int GetHeight() const { return M_METAFILEDATA->m_height; }
60
61 void SetWidth(int width) { M_METAFILEDATA->m_width = width; }
62 void SetHeight(int height) { M_METAFILEDATA->m_height = height; }
63
64 // Implementation
65 WXHANDLE GetHMETAFILE() const { return M_METAFILEDATA->m_metafile; }
66 void SetHMETAFILE(WXHANDLE mf) ;
67 int GetWindowsMappingMode() const { return M_METAFILEDATA->m_windowsMappingMode; }
68 void SetWindowsMappingMode(int mm);
69
70 // Operators
265b0c07
VZ
71 bool operator==(const wxMetafile& metafile) const
72 { return m_refData == metafile.m_refData; }
73 bool operator!=(const wxMetafile& metafile) const
74 { return m_refData != metafile.m_refData; }
2bda0e17 75
265b0c07
VZ
76private:
77 DECLARE_DYNAMIC_CLASS(wxMetafile)
2bda0e17
KB
78};
79
06e43511 80class WXDLLEXPORT wxMetafileDC: public wxDC
2bda0e17 81{
265b0c07
VZ
82public:
83 // Don't supply origin and extent
84 // Supply them to wxMakeMetaFilePlaceable instead.
d9317fd4 85 wxMetafileDC(const wxString& file = wxEmptyString);
2bda0e17 86
265b0c07
VZ
87 // Supply origin and extent (recommended).
88 // Then don't need to supply them to wxMakeMetaFilePlaceable.
89 wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg);
2bda0e17 90
265b0c07 91 virtual ~wxMetafileDC();
2bda0e17 92
265b0c07
VZ
93 // Should be called at end of drawing
94 virtual wxMetafile *Close();
95 virtual void SetMapMode(int mode);
96 virtual void GetTextExtent(const wxString& string, long *x, long *y,
97 long *descent = NULL, long *externalLeading = NULL,
598ddd96 98 wxFont *theFont = NULL, bool use16bit = false) const;
2bda0e17 99
265b0c07
VZ
100 // Implementation
101 wxMetafile *GetMetaFile() const { return m_metaFile; }
102 void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
103 int GetWindowsMappingMode() const { return m_windowsMappingMode; }
104 void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; }
2bda0e17
KB
105
106protected:
024026be
VZ
107 virtual void DoGetSize(int *width, int *height) const;
108
265b0c07
VZ
109 int m_windowsMappingMode;
110 wxMetafile* m_metaFile;
111
112private:
113 DECLARE_DYNAMIC_CLASS(wxMetafileDC)
2bda0e17
KB
114};
115
116/*
117 * Pass filename of existing non-placeable metafile, and bounding box.
118 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
e3065973 119 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
2bda0e17
KB
120 *
121 */
122
123// No origin or extent
06e43511 124bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
2bda0e17
KB
125
126// Optional origin and extent
598ddd96 127bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = true);
2bda0e17 128
06e43511
JS
129// ----------------------------------------------------------------------------
130// wxMetafileDataObject is a specialization of wxDataObject for metafile data
131// ----------------------------------------------------------------------------
132
06e43511 133#if wxUSE_DRAG_AND_DROP
265b0c07
VZ
134
135class WXDLLEXPORT wxMetafileDataObject : public wxDataObjectSimple
06e43511
JS
136{
137public:
265b0c07
VZ
138 // ctors
139 wxMetafileDataObject() : wxDataObjectSimple(wxDF_METAFILE)
140 { }
141 wxMetafileDataObject(const wxMetafile& metafile)
142 : wxDataObjectSimple(wxDF_METAFILE), m_metafile(metafile) { }
143
144 // virtual functions which you may override if you want to provide data on
145 // demand only - otherwise, the trivial default versions will be used
146 virtual void SetMetafile(const wxMetafile& metafile)
147 { m_metafile = metafile; }
148 virtual wxMetafile GetMetafile() const
149 { return m_metafile; }
150
151 // implement base class pure virtuals
152 virtual size_t GetDataSize() const;
153 virtual bool GetDataHere(void *buf) const;
154 virtual bool SetData(size_t len, const void *buf);
06e43511 155
265b0c07
VZ
156protected:
157 wxMetafile m_metafile;
06e43511 158};
265b0c07
VZ
159
160#endif // wxUSE_DRAG_AND_DROP
06e43511 161
2bda0e17 162#endif
bbcdf8bc 163 // _WX_METAFIILE_H_
2845ddc2 164