]> git.saurik.com Git - wxWidgets.git/blob - include/wx/palmos/metafile.h
great copy ctor/assignment operators cleanup by Paul Cornett (patch 1307665)
[wxWidgets.git] / include / wx / palmos / metafile.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/palmos/metafile.h
3 // Purpose: wxMetaFile, wxMetaFileDC and wxMetaFileDataObject classes
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by:
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne
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
26 class WXDLLEXPORT wxMetafile;
27
28 class WXDLLEXPORT wxMetafileRefData: public wxGDIRefData
29 {
30 friend class WXDLLEXPORT wxMetafile;
31 public:
32 wxMetafileRefData();
33 ~wxMetafileRefData();
34
35 public:
36 WXHANDLE m_metafile;
37 int m_windowsMappingMode;
38 int m_width, m_height;
39 };
40
41 #define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
42
43 class WXDLLEXPORT wxMetafile: public wxGDIObject
44 {
45 public:
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 (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); };
55
56 // set/get the size of metafile for clipboard operations
57 wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); }
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
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; }
75
76 private:
77 DECLARE_DYNAMIC_CLASS(wxMetafile)
78 };
79
80 class WXDLLEXPORT wxMetafileDC: public wxDC
81 {
82 public:
83 // Don't supply origin and extent
84 // Supply them to wxMakeMetaFilePlaceable instead.
85 wxMetafileDC(const wxString& file = wxEmptyString);
86
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);
90
91 virtual ~wxMetafileDC();
92
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,
98 wxFont *theFont = NULL, bool use16bit = FALSE) const;
99
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; }
105
106 protected:
107 int m_windowsMappingMode;
108 wxMetafile* m_metaFile;
109
110 private:
111 DECLARE_DYNAMIC_CLASS(wxMetafileDC)
112 };
113
114 /*
115 * Pass filename of existing non-placeable metafile, and bounding box.
116 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
117 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
118 *
119 */
120
121 // No origin or extent
122 bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
123
124 // Optional origin and extent
125 bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = TRUE);
126
127 // ----------------------------------------------------------------------------
128 // wxMetafileDataObject is a specialization of wxDataObject for metafile data
129 // ----------------------------------------------------------------------------
130
131 #if wxUSE_DRAG_AND_DROP
132
133 class WXDLLEXPORT wxMetafileDataObject : public wxDataObjectSimple
134 {
135 public:
136 // ctors
137 wxMetafileDataObject() : wxDataObjectSimple(wxDF_METAFILE)
138 { }
139 wxMetafileDataObject(const wxMetafile& metafile)
140 : wxDataObjectSimple(wxDF_METAFILE), m_metafile(metafile) { }
141
142 // virtual functions which you may override if you want to provide data on
143 // demand only - otherwise, the trivial default versions will be used
144 virtual void SetMetafile(const wxMetafile& metafile)
145 { m_metafile = metafile; }
146 virtual wxMetafile GetMetafile() const
147 { return m_metafile; }
148
149 // implement base class pure virtuals
150 virtual size_t GetDataSize() const;
151 virtual bool GetDataHere(void *buf) const;
152 virtual bool SetData(size_t len, const void *buf);
153
154 protected:
155 wxMetafile m_metafile;
156 };
157
158 #endif // wxUSE_DRAG_AND_DROP
159
160 #endif
161 // _WX_METAFIILE_H_
162