]> git.saurik.com Git - wxWidgets.git/blob - include/wx/palmos/metafile.h
don't get margin to non NULL values in default ctor, this is inconsistent as default...
[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 wxMetafile(const wxMetafile& metafile) { Ref(metafile); }
48 virtual ~wxMetafile();
49
50 // After this is called, the metafile cannot be used for anything
51 // since it is now owned by the clipboard.
52 virtual bool SetClipboard(int width = 0, int height = 0);
53
54 virtual bool Play(wxDC *dc);
55 bool Ok() 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
71 // Operators
72 wxMetafile& operator=(const wxMetafile& metafile)
73 { if (*this != metafile) Ref(metafile); return *this; }
74 bool operator==(const wxMetafile& metafile) const
75 { return m_refData == metafile.m_refData; }
76 bool operator!=(const wxMetafile& metafile) const
77 { return m_refData != metafile.m_refData; }
78
79 private:
80 DECLARE_DYNAMIC_CLASS(wxMetafile)
81 };
82
83 class WXDLLEXPORT wxMetafileDC: public wxDC
84 {
85 public:
86 // Don't supply origin and extent
87 // Supply them to wxMakeMetaFilePlaceable instead.
88 wxMetafileDC(const wxString& file = wxEmptyString);
89
90 // Supply origin and extent (recommended).
91 // Then don't need to supply them to wxMakeMetaFilePlaceable.
92 wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg);
93
94 virtual ~wxMetafileDC();
95
96 // Should be called at end of drawing
97 virtual wxMetafile *Close();
98 virtual void SetMapMode(int mode);
99 virtual void GetTextExtent(const wxString& string, long *x, long *y,
100 long *descent = NULL, long *externalLeading = NULL,
101 wxFont *theFont = NULL, bool use16bit = FALSE) const;
102
103 // Implementation
104 wxMetafile *GetMetaFile() const { return m_metaFile; }
105 void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
106 int GetWindowsMappingMode() const { return m_windowsMappingMode; }
107 void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; }
108
109 protected:
110 int m_windowsMappingMode;
111 wxMetafile* m_metaFile;
112
113 private:
114 DECLARE_DYNAMIC_CLASS(wxMetafileDC)
115 };
116
117 /*
118 * Pass filename of existing non-placeable metafile, and bounding box.
119 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
120 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
121 *
122 */
123
124 // No origin or extent
125 bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
126
127 // Optional origin and extent
128 bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = TRUE);
129
130 // ----------------------------------------------------------------------------
131 // wxMetafileDataObject is a specialization of wxDataObject for metafile data
132 // ----------------------------------------------------------------------------
133
134 #if wxUSE_DRAG_AND_DROP
135
136 class WXDLLEXPORT wxMetafileDataObject : public wxDataObjectSimple
137 {
138 public:
139 // ctors
140 wxMetafileDataObject() : wxDataObjectSimple(wxDF_METAFILE)
141 { }
142 wxMetafileDataObject(const wxMetafile& metafile)
143 : wxDataObjectSimple(wxDF_METAFILE), m_metafile(metafile) { }
144
145 // virtual functions which you may override if you want to provide data on
146 // demand only - otherwise, the trivial default versions will be used
147 virtual void SetMetafile(const wxMetafile& metafile)
148 { m_metafile = metafile; }
149 virtual wxMetafile GetMetafile() const
150 { return m_metafile; }
151
152 // implement base class pure virtuals
153 virtual size_t GetDataSize() const;
154 virtual bool GetDataHere(void *buf) const;
155 virtual bool SetData(size_t len, const void *buf);
156
157 protected:
158 wxMetafile m_metafile;
159 };
160
161 #endif // wxUSE_DRAG_AND_DROP
162
163 #endif
164 // _WX_METAFIILE_H_
165