]> git.saurik.com Git - wxWidgets.git/blame - include/wx/palmos/metafile.h
Make Smartphone buildable with current flags.
[wxWidgets.git] / include / wx / palmos / metafile.h
CommitLineData
ffecfa5a
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/palmos/metafile.h
3// Purpose: wxMetaFile, wxMetaFileDC and wxMetaFileDataObject classes
e1d63b79 4// Author: William Osborne - minimal working wxPalmOS port
ffecfa5a
JS
5// Modified by:
6// Created: 10/13/04
e1d63b79 7// RCS-ID: $Id$
ffecfa5a
JS
8// Copyright: (c) William Osborne
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_METAFIILE_H_
13#define _WX_METAFIILE_H_
14
15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "metafile.h"
17#endif
18
19#include "wx/setup.h"
20
21#if wxUSE_METAFILE
22
23#include "wx/dc.h"
24#include "wx/gdiobj.h"
25
26#if wxUSE_DRAG_AND_DROP
27 #include "wx/dataobj.h"
28#endif
29
30// ----------------------------------------------------------------------------
31// Metafile and metafile device context classes
32// ----------------------------------------------------------------------------
33
34class WXDLLEXPORT wxMetafile;
35
36class WXDLLEXPORT wxMetafileRefData: public wxGDIRefData
37{
38 friend class WXDLLEXPORT wxMetafile;
39public:
40 wxMetafileRefData();
41 ~wxMetafileRefData();
42
43public:
44 WXHANDLE m_metafile;
45 int m_windowsMappingMode;
46 int m_width, m_height;
47};
48
49#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
50
51class WXDLLEXPORT wxMetafile: public wxGDIObject
52{
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
66 wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); }
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; }
86
87private:
88 DECLARE_DYNAMIC_CLASS(wxMetafile)
89};
90
91class WXDLLEXPORT wxMetafileDC: public wxDC
92{
93public:
94 // Don't supply origin and extent
95 // Supply them to wxMakeMetaFilePlaceable instead.
96 wxMetafileDC(const wxString& file = wxEmptyString);
97
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);
101
102 virtual ~wxMetafileDC();
103
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;
110
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; }
116
117protected:
118 int m_windowsMappingMode;
119 wxMetafile* m_metaFile;
120
121private:
122 DECLARE_DYNAMIC_CLASS(wxMetafileDC)
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,
128 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
129 *
130 */
131
132// No origin or extent
133bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
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
138// ----------------------------------------------------------------------------
139// wxMetafileDataObject is a specialization of wxDataObject for metafile data
140// ----------------------------------------------------------------------------
141
142#if wxUSE_DRAG_AND_DROP
143
144class WXDLLEXPORT wxMetafileDataObject : public wxDataObjectSimple
145{
146public:
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);
164
165protected:
166 wxMetafile m_metafile;
167};
168
169#endif // wxUSE_DRAG_AND_DROP
170
171#endif // wxUSE_METAFILE
172#endif
173 // _WX_METAFIILE_H_
174